[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32177 - in gnunet/src/ats-tests: . experiments
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32177 - in gnunet/src/ats-tests: . experiments |
Date: |
Mon, 3 Feb 2014 23:31:19 +0100 |
Author: wachs
Date: 2014-02-03 23:31:19 +0100 (Mon, 03 Feb 2014)
New Revision: 32177
Modified:
gnunet/src/ats-tests/ats-testing-experiment.c
gnunet/src/ats-tests/ats-testing.h
gnunet/src/ats-tests/experiments/test.exp
gnunet/src/ats-tests/gnunet-ats-sim.c
Log:
enforcing preferences
Modified: gnunet/src/ats-tests/ats-testing-experiment.c
===================================================================
--- gnunet/src/ats-tests/ats-testing-experiment.c 2014-02-03 22:28:01 UTC
(rev 32176)
+++ gnunet/src/ats-tests/ats-testing-experiment.c 2014-02-03 22:31:19 UTC
(rev 32177)
@@ -35,8 +35,10 @@
return "START_SEND";
case STOP_SEND:
return "STOP_SEND";
- case SET_PREFERENCE:
- return "SET_PREFERENCE";
+ case START_PREFERENCE:
+ return "START_PREFERENCE";
+ case STOP_PREFERENCE:
+ return "STOP_PREFERENCE";
default:
break;
}
@@ -93,6 +95,7 @@
char *op_name;
char *op;
char *type;
+ char *pref;
int op_counter = 0;
fprintf (stderr, "Parsing episode %u\n",cur->id);
GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
@@ -117,10 +120,14 @@
{
o->type = STOP_SEND;
}
- else if (0 == strcmp (op, "set_preference"))
+ else if (0 == strcmp (op, "start_preference"))
{
- o->type = SET_PREFERENCE;
+ o->type = START_PREFERENCE;
}
+ else if (0 == strcmp (op, "stop_preference"))
+ {
+ o->type = STOP_PREFERENCE;
+ }
else
{
fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
@@ -176,7 +183,7 @@
GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
sec_name, op_name, &type)) &&
- (STOP_SEND != o->type))
+ ((STOP_SEND != o->type) || (STOP_PREFERENCE != o->type)))
{
/* Load arguments for set_rate, start_send, set_preference */
if (0 == strcmp (type, "constant"))
@@ -247,6 +254,55 @@
o->period = cur->duration;
}
GNUNET_free (op_name);
+
+ if (START_PREFERENCE == o->type)
+ {
+ /* Get frequency */
+ GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
+ sec_name, op_name, &o->frequency))
+ {
+ fprintf (stderr, "Missing frequency in operation %u `%s' in
episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free (type);
+ GNUNET_free (op_name);
+ GNUNET_free (op);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free (op_name);
+
+ /* Get preference */
+ GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
+ sec_name, op_name, &pref))
+ {
+ fprintf (stderr, "Missing preference in operation %u `%s' in
episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free (type);
+ GNUNET_free (op_name);
+ GNUNET_free (op);
+ GNUNET_free_non_null (pref);
+ return GNUNET_SYSERR;
+ }
+
+ if (0 == strcmp(pref, "bandwidth"))
+ o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
+ else if (0 == strcmp(pref, "latency"))
+ o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
+ else
+ {
+ fprintf (stderr, "Invalid preference in operation %u `%s' in
episode %u\n",
+ op_counter, op, cur->id);
+ GNUNET_free (type);
+ GNUNET_free (op_name);
+ GNUNET_free (op);
+ GNUNET_free (pref);
+ GNUNET_free_non_null (pref);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free (pref);
+ GNUNET_free (op_name);
+ }
}
/* Safety checks */
@@ -261,11 +317,15 @@
fprintf (stderr, "Selected max rate and base rate cannot be used for
desired traffic form!\n");
}
- fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] ==
%s, %llu -> %llu in %s\n",
+ if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
+ fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] ==
%s, %llu -> %llu in %s\n",
op_counter, cur->id, print_op (o->type), o->src_id,
o->dest_id, (NULL != type) ? type : "",
o->base_rate, o->max_rate,
GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
+ else
+ fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
+ op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
GNUNET_free_non_null (type);
GNUNET_free (op);
@@ -396,7 +456,8 @@
if (NULL != p->tg)
{
- fprintf (stderr, "Stopping traffic between master %llu slave
%llu\n",op->src_id, op->dest_id);
+ fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
+ op->src_id, op->dest_id);
GNUNET_ATS_TEST_generate_traffic_stop(p->tg);
p->tg = NULL;
}
@@ -404,11 +465,62 @@
static void
-enforce_set_preference (struct GNUNET_ATS_TEST_Operation *op)
+enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
{
- GNUNET_break (0);
+ struct BenchmarkPeer *peer;
+ struct BenchmarkPartner *partner;
+
+ peer = GNUNET_ATS_TEST_get_peer (op->src_id);
+ if (NULL == peer)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
+ if (NULL == partner)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+
+ if (NULL != partner->pg)
+ {
+ fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
+ op->src_id, op->dest_id);
+ GNUNET_ATS_TEST_generate_preferences_stop(partner->pg);
+ partner->pg = NULL;
+ }
+
+ partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner,
+ op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency,
+ op->pref_type);
}
+static void
+enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
+{
+ struct BenchmarkPartner *p;
+ p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
+ if (NULL == p)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+
+ if (NULL != p->pg)
+ {
+ fprintf (stderr, "Stopping preference between master %llu slave %llu\n",
+ op->src_id, op->dest_id);
+ GNUNET_ATS_TEST_generate_preferences_stop (p->pg);
+ p->pg = NULL;
+ }
+}
+
static void enforce_episode (struct Episode *ep)
{
struct GNUNET_ATS_TEST_Operation *cur;
@@ -424,9 +536,12 @@
case STOP_SEND:
enforce_stop_send (cur);
break;
- case SET_PREFERENCE:
- enforce_set_preference (cur);
+ case START_PREFERENCE:
+ enforce_start_preference (cur);
break;
+ case STOP_PREFERENCE:
+ enforce_stop_preference (cur);
+ break;
default:
break;
}
Modified: gnunet/src/ats-tests/ats-testing.h
===================================================================
--- gnunet/src/ats-tests/ats-testing.h 2014-02-03 22:28:01 UTC (rev 32176)
+++ gnunet/src/ats-tests/ats-testing.h 2014-02-03 22:31:19 UTC (rev 32177)
@@ -462,7 +462,8 @@
{
START_SEND,
STOP_SEND,
- SET_PREFERENCE
+ START_PREFERENCE,
+ STOP_PREFERENCE
};
struct Episode;
@@ -489,9 +490,11 @@
long long unsigned int base_rate;
long long unsigned int max_rate;
struct GNUNET_TIME_Relative period;
+ struct GNUNET_TIME_Relative frequency;
enum OperationType type;
enum GeneratorType tg_type;
+ enum GNUNET_ATS_PreferenceKind pref_type;
};
struct Episode
Modified: gnunet/src/ats-tests/experiments/test.exp
===================================================================
--- gnunet/src/ats-tests/experiments/test.exp 2014-02-03 22:28:01 UTC (rev
32176)
+++ gnunet/src/ats-tests/experiments/test.exp 2014-02-03 22:31:19 UTC (rev
32177)
@@ -2,12 +2,12 @@
name = test
masters = 1
slaves = 2
- max_duration = 10 s
+ max_duration = 15 s
log_freq = 100 ms
cfg_file = gnunet_ats_sim_default.conf
[episode-0]
-# operations = set_rate, start_send, stop_send, set_preference
+# operations = start_send, stop_send, start_preference, stop_preference
duration = 10 s
op-0-operation = start_send
op-0-src = 0
@@ -23,3 +23,33 @@
op-1-period = 5 s
op-1-base-rate= 10000
op-1-max-rate = 15000
+
+op-2-operation = start_preference
+op-2-src = 0
+op-2-dest = 0
+op-2-type = constant
+op-2-period = 5 s
+op-2-base-rate= 10
+op-2-max-rate = 5
+op-2-pref = latency
+op-2-frequency = 2 s
+
+op-3-operation = start_preference
+op-3-src = 0
+op-3-dest = 1
+op-3-type = linear
+op-3-period = 5 s
+op-3-base-rate= 40
+op-3-max-rate = 50
+op-3-pref = bandwidth
+op-3-frequency = 750 ms
+
+[episode-1]
+duration = 5 s
+op-0-operation = stop_preference
+op-0-src = 0
+op-0-dest = 0
+
+op-1-operation = stop_preference
+op-1-src = 0
+op-1-dest = 1
Modified: gnunet/src/ats-tests/gnunet-ats-sim.c
===================================================================
--- gnunet/src/ats-tests/gnunet-ats-sim.c 2014-02-03 22:28:01 UTC (rev
32176)
+++ gnunet/src/ats-tests/gnunet-ats-sim.c 2014-02-03 22:31:19 UTC (rev
32177)
@@ -257,12 +257,13 @@
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250),
GNUNET_ATS_PREFERENCE_BANDWIDTH);
*/
+ /*
GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0],
GNUNET_ATS_TEST_TG_SINUS, 10, 5,
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250),
GNUNET_ATS_PREFERENCE_BANDWIDTH);
-
+*/
#if 0
int c_m;
int c_s;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32177 - in gnunet/src/ats-tests: . experiments,
gnunet <=