diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 08:55:04 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 08:55:04 +0000 |
commit | f65a1270609f4cc37f023a0a61788e014a7f85b0 (patch) | |
tree | c3db9477a34c7d1b8f3f1cac0e9c571f53bfb06e | |
parent | c45d65f668cf599ff9fa47a96823d18b30a2df47 (diff) | |
download | gnunet-f65a1270609f4cc37f023a0a61788e014a7f85b0.tar.gz gnunet-f65a1270609f4cc37f023a0a61788e014a7f85b0.zip |
improved episode parsing
added request support
-rw-r--r-- | src/ats/experiments/example.exp | 43 | ||||
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.c | 180 | ||||
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.h | 4 |
3 files changed, 140 insertions, 87 deletions
diff --git a/src/ats/experiments/example.exp b/src/ats/experiments/example.exp index 289a3701b..1d94c212a 100644 --- a/src/ats/experiments/example.exp +++ b/src/ats/experiments/example.exp | |||
@@ -7,7 +7,8 @@ | |||
7 | cfg_file = gnunet_ats_sim_default.conf | 7 | cfg_file = gnunet_ats_sim_default.conf |
8 | 8 | ||
9 | [episode-0] | 9 | [episode-0] |
10 | # operations = address_add, address_del, start_set_property, stop_set_property, start_set_preference, stop_preference | 10 | # operations = address_add, address_del, start_set_property, stop_set_property, |
11 | # start_set_preference, stop_preference, start_request, stop_request | ||
11 | duration = 2 s | 12 | duration = 2 s |
12 | op-0-operation = address_add | 13 | op-0-operation = address_add |
13 | op-0-address-id = 0 | 14 | op-0-address-id = 0 |
@@ -17,28 +18,31 @@ op-0-address-network = 0 | |||
17 | op-0-address = 0_0_udp | 18 | op-0-address = 0_0_udp |
18 | op-0-plugin = udp | 19 | op-0-plugin = udp |
19 | 20 | ||
20 | op-1-operation = start_set_preference | 21 | #op-1-operation = start_set_preference |
21 | op-1-address-id = 1 | 22 | #op-1-address-id = 1 |
22 | op-1-peer-id = 1 | 23 | #op-1-peer-id = 1 |
23 | # constant, linear, sinus, random | 24 | # constant, linear, sinus, random |
24 | op-1-gen-type = constant | 25 | #op-1-gen-type = constant |
25 | op-1-base-rate= 10000 | 26 | #op-1-base-rate= 10000 |
26 | op-1-max-rate = 100000 | 27 | #op-1-max-rate = 100000 |
27 | op-1-frequency = 500 ms | 28 | #op-1-frequency = 500 ms |
28 | # BANDWIDTH, LATENCY | 29 | # BANDWIDTH, LATENCY |
29 | op-1-pref = BANDWIDTH | 30 | #op-1-pref = BANDWIDTH |
30 | 31 | ||
31 | #op-2-operation = start_set_property | 32 | op-1-operation = start_set_property |
32 | #op-2-address-id = 0 | 33 | op-1-address-id = 0 |
33 | #op-2-peer-id = 0 | 34 | op-1-peer-id = 0 |
34 | # constant, linear, sinus, random | 35 | # constant, linear, sinus, random |
35 | #op-2-gen-type = linear | 36 | op-1-gen-type = random |
36 | #op-2-base-rate= 10000 | 37 | op-1-base-rate= 10000 |
37 | #op-2-max-rate = 10000 | 38 | op-1-max-rate = 100000 |
38 | #op-2-frequency = 100 ms | 39 | op-1-frequency = 100 ms |
39 | # bandwidth, latency | 40 | # bandwidth, latency |
40 | # "TERMINATOR", "UTILIZATION_UP", "UTILIZATION_DOWN", "UTILIZATION_PAYLOAD_UP", "UTILIZATION_PAYLOAD_DOWN", "NETWORK_TYPE", "DELAY", "DISTANCE", "COST_WAN", "COST_LAN", "COST_WLAN" | 41 | # "TERMINATOR", "UTILIZATION_UP", "UTILIZATION_DOWN", "UTILIZATION_PAYLOAD_UP", "UTILIZATION_PAYLOAD_DOWN", "NETWORK_TYPE", "DELAY", "DISTANCE", "COST_WAN", "COST_LAN", "COST_WLAN" |
41 | #op-2-property = UTILIZATION_UP | 42 | op-1-property = UTILIZATION_UP |
43 | |||
44 | op-2-operation = start_request | ||
45 | op-2-peer-id = 0 | ||
42 | 46 | ||
43 | [episode-1] | 47 | [episode-1] |
44 | duration = 2 s | 48 | duration = 2 s |
@@ -59,4 +63,7 @@ op-1-pref = BANDWIDTH | |||
59 | op-2-operation = stop_set_property | 63 | op-2-operation = stop_set_property |
60 | op-2-address-id = 0 | 64 | op-2-address-id = 0 |
61 | op-2-peer-id = 0 | 65 | op-2-peer-id = 0 |
62 | op-2-property = UTILIZATION_UP \ No newline at end of file | 66 | op-2-property = UTILIZATION_UP |
67 | |||
68 | op-3-operation = stop_request | ||
69 | op-3-peer-id = 0 \ No newline at end of file | ||
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index 9aa9fd093..f9598b692 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c | |||
@@ -613,9 +613,13 @@ print_op (enum OperationType op) | |||
613 | case SOLVER_OP_STOP_SET_PREFERENCE: | 613 | case SOLVER_OP_STOP_SET_PREFERENCE: |
614 | return "STOP_STOP_PREFERENCE"; | 614 | return "STOP_STOP_PREFERENCE"; |
615 | case SOLVER_OP_START_SET_PROPERTY: | 615 | case SOLVER_OP_START_SET_PROPERTY: |
616 | return "START_SET_PROPERTY"; | 616 | return "START_SET_PROPERTY"; |
617 | case SOLVER_OP_STOP_SET_PROPERTY: | 617 | case SOLVER_OP_STOP_SET_PROPERTY: |
618 | return "STOP_SET_PROPERTY"; | 618 | return "STOP_SET_PROPERTY"; |
619 | case SOLVER_OP_START_REQUEST: | ||
620 | return "START_REQUEST"; | ||
621 | case SOLVER_OP_STOP_REQUEST: | ||
622 | return "STOP_REQUEST"; | ||
619 | default: | 623 | default: |
620 | break; | 624 | break; |
621 | } | 625 | } |
@@ -1134,22 +1138,18 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, | |||
1134 | if (0 == strcmp (type, "constant")) | 1138 | if (0 == strcmp (type, "constant")) |
1135 | { | 1139 | { |
1136 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | 1140 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; |
1137 | GNUNET_break (0); | ||
1138 | } | 1141 | } |
1139 | else if (0 == strcmp (type, "linear")) | 1142 | else if (0 == strcmp (type, "linear")) |
1140 | { | 1143 | { |
1141 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | 1144 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; |
1142 | GNUNET_break (0); | ||
1143 | } | 1145 | } |
1144 | else if (0 == strcmp (type, "sinus")) | 1146 | else if (0 == strcmp (type, "sinus")) |
1145 | { | 1147 | { |
1146 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | 1148 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; |
1147 | GNUNET_break (0); | ||
1148 | } | 1149 | } |
1149 | else if (0 == strcmp (type, "random")) | 1150 | else if (0 == strcmp (type, "random")) |
1150 | { | 1151 | { |
1151 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | 1152 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; |
1152 | GNUNET_break (0); | ||
1153 | } | 1153 | } |
1154 | else | 1154 | else |
1155 | { | 1155 | { |
@@ -1313,6 +1313,54 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o, | |||
1313 | return GNUNET_OK; | 1313 | return GNUNET_OK; |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | |||
1317 | static int | ||
1318 | load_op_start_request (struct GNUNET_ATS_TEST_Operation *o, | ||
1319 | struct Episode *e, | ||
1320 | int op_counter, | ||
1321 | char *sec_name, | ||
1322 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
1323 | { | ||
1324 | char *op_name; | ||
1325 | |||
1326 | /* peer id */ | ||
1327 | GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); | ||
1328 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
1329 | sec_name, op_name, &o->peer_id)) | ||
1330 | { | ||
1331 | fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", | ||
1332 | op_counter, "START_REQUEST", op_name); | ||
1333 | GNUNET_free (op_name); | ||
1334 | return GNUNET_SYSERR; | ||
1335 | } | ||
1336 | GNUNET_free (op_name); | ||
1337 | return GNUNET_OK; | ||
1338 | } | ||
1339 | |||
1340 | static int | ||
1341 | load_op_stop_request (struct GNUNET_ATS_TEST_Operation *o, | ||
1342 | struct Episode *e, | ||
1343 | int op_counter, | ||
1344 | char *sec_name, | ||
1345 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
1346 | { | ||
1347 | char *op_name; | ||
1348 | |||
1349 | /* peer id */ | ||
1350 | GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); | ||
1351 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
1352 | sec_name, op_name, &o->peer_id)) | ||
1353 | { | ||
1354 | fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", | ||
1355 | op_counter, "STOP_REQUEST", op_name); | ||
1356 | GNUNET_free (op_name); | ||
1357 | return GNUNET_SYSERR; | ||
1358 | } | ||
1359 | GNUNET_free (op_name); | ||
1360 | return GNUNET_OK; | ||
1361 | } | ||
1362 | |||
1363 | |||
1316 | static int | 1364 | static int |
1317 | load_episode (struct Experiment *e, struct Episode *cur, | 1365 | load_episode (struct Experiment *e, struct Episode *cur, |
1318 | struct GNUNET_CONFIGURATION_Handle *cfg) | 1366 | struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -1322,6 +1370,7 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
1322 | char *op_name; | 1370 | char *op_name; |
1323 | char *op; | 1371 | char *op; |
1324 | int op_counter = 0; | 1372 | int op_counter = 0; |
1373 | int res; | ||
1325 | fprintf (stderr, "Parsing episode %u\n",cur->id); | 1374 | fprintf (stderr, "Parsing episode %u\n",cur->id); |
1326 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); | 1375 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); |
1327 | 1376 | ||
@@ -1340,93 +1389,68 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
1340 | if (0 == strcmp (op, "address_add")) | 1389 | if (0 == strcmp (op, "address_add")) |
1341 | { | 1390 | { |
1342 | o->type = SOLVER_OP_ADD_ADDRESS; | 1391 | o->type = SOLVER_OP_ADD_ADDRESS; |
1343 | if (GNUNET_SYSERR == load_op_add_address (o, cur, | 1392 | res = load_op_add_address (o, cur, |
1344 | op_counter, sec_name, cfg)) | 1393 | op_counter, sec_name, cfg); |
1345 | { | ||
1346 | GNUNET_free (o); | ||
1347 | GNUNET_free (op); | ||
1348 | GNUNET_free (op_name); | ||
1349 | GNUNET_free (sec_name); | ||
1350 | return GNUNET_SYSERR; | ||
1351 | } | ||
1352 | } | 1394 | } |
1353 | else if (0 == strcmp (op, "address_del")) | 1395 | else if (0 == strcmp (op, "address_del")) |
1354 | { | 1396 | { |
1355 | o->type = SOLVER_OP_DEL_ADDRESS; | 1397 | o->type = SOLVER_OP_DEL_ADDRESS; |
1356 | if (GNUNET_SYSERR == load_op_del_address (o, cur, | 1398 | res = load_op_del_address (o, cur, |
1357 | op_counter, sec_name, cfg)) | 1399 | op_counter, sec_name, cfg); |
1358 | { | ||
1359 | GNUNET_free (o); | ||
1360 | GNUNET_free (op); | ||
1361 | GNUNET_free (op_name); | ||
1362 | GNUNET_free (sec_name); | ||
1363 | return GNUNET_SYSERR; | ||
1364 | } | ||
1365 | } | 1400 | } |
1366 | else if (0 == strcmp (op, "start_set_property")) | 1401 | else if (0 == strcmp (op, "start_set_property")) |
1367 | { | 1402 | { |
1368 | o->type = SOLVER_OP_START_SET_PROPERTY; | 1403 | o->type = SOLVER_OP_START_SET_PROPERTY; |
1369 | if (GNUNET_SYSERR == load_op_start_set_property (o, cur, | 1404 | res = load_op_start_set_property (o, cur, |
1370 | op_counter, sec_name, cfg)) | 1405 | op_counter, sec_name, cfg); |
1371 | { | ||
1372 | GNUNET_free (o); | ||
1373 | GNUNET_free (op); | ||
1374 | GNUNET_free (op_name); | ||
1375 | GNUNET_free (sec_name); | ||
1376 | return GNUNET_SYSERR; | ||
1377 | } | ||
1378 | } | 1406 | } |
1379 | else if (0 == strcmp (op, "stop_set_property")) | 1407 | else if (0 == strcmp (op, "stop_set_property")) |
1380 | { | 1408 | { |
1381 | o->type = SOLVER_OP_STOP_SET_PROPERTY; | 1409 | o->type = SOLVER_OP_STOP_SET_PROPERTY; |
1382 | if (GNUNET_SYSERR == load_op_stop_set_property (o, cur, | 1410 | res = load_op_stop_set_property (o, cur, |
1383 | op_counter, sec_name, cfg)) | 1411 | op_counter, sec_name, cfg); |
1384 | { | ||
1385 | GNUNET_free (o); | ||
1386 | GNUNET_free (op); | ||
1387 | GNUNET_free (op_name); | ||
1388 | GNUNET_free (sec_name); | ||
1389 | return GNUNET_SYSERR; | ||
1390 | } | ||
1391 | } | 1412 | } |
1392 | else if (0 == strcmp (op, "start_set_preference")) | 1413 | else if (0 == strcmp (op, "start_set_preference")) |
1393 | { | 1414 | { |
1394 | o->type = SOLVER_OP_START_SET_PREFERENCE; | 1415 | o->type = SOLVER_OP_START_SET_PREFERENCE; |
1395 | if (GNUNET_SYSERR == load_op_start_set_preference (o, cur, | 1416 | res = load_op_start_set_preference (o, cur, |
1396 | op_counter, sec_name, cfg)) | 1417 | op_counter, sec_name, cfg); |
1397 | { | 1418 | break; |
1398 | GNUNET_free (o); | ||
1399 | GNUNET_free (op); | ||
1400 | GNUNET_free (op_name); | ||
1401 | GNUNET_free (sec_name); | ||
1402 | return GNUNET_SYSERR; | ||
1403 | } | ||
1404 | } | 1419 | } |
1405 | else if (0 == strcmp (op, "stop_set_preference")) | 1420 | else if (0 == strcmp (op, "stop_set_preference")) |
1406 | { | 1421 | { |
1407 | o->type = SOLVER_OP_STOP_SET_PREFERENCE; | 1422 | o->type = SOLVER_OP_STOP_SET_PREFERENCE; |
1408 | if (GNUNET_SYSERR == load_op_stop_set_preference (o, cur, | 1423 | res = load_op_stop_set_preference (o, cur, |
1409 | op_counter, sec_name, cfg)) | 1424 | op_counter, sec_name, cfg); |
1410 | { | 1425 | } |
1411 | GNUNET_free (o); | 1426 | else if (0 == strcmp (op, "start_request")) |
1412 | GNUNET_free (op); | 1427 | { |
1413 | GNUNET_free (op_name); | 1428 | o->type = SOLVER_OP_START_REQUEST; |
1414 | GNUNET_free (sec_name); | 1429 | res = load_op_start_request (o, cur, |
1415 | return GNUNET_SYSERR; | 1430 | op_counter, sec_name, cfg); |
1416 | } | 1431 | } |
1432 | else if (0 == strcmp (op, "stop_request")) | ||
1433 | { | ||
1434 | o->type = SOLVER_OP_STOP_REQUEST; | ||
1435 | res = load_op_stop_request(o, cur, | ||
1436 | op_counter, sec_name, cfg); | ||
1417 | } | 1437 | } |
1418 | else | 1438 | else |
1419 | { | 1439 | { |
1420 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", | 1440 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", |
1421 | op_counter, op, cur->id); | 1441 | op_counter, op, cur->id); |
1442 | res = GNUNET_SYSERR; | ||
1443 | } | ||
1444 | |||
1445 | GNUNET_free (op); | ||
1446 | GNUNET_free (op_name); | ||
1447 | |||
1448 | if (GNUNET_SYSERR == res) | ||
1449 | { | ||
1422 | GNUNET_free (o); | 1450 | GNUNET_free (o); |
1423 | GNUNET_free (op); | ||
1424 | GNUNET_free (op_name); | ||
1425 | GNUNET_free (sec_name); | 1451 | GNUNET_free (sec_name); |
1426 | return GNUNET_SYSERR; | 1452 | return GNUNET_SYSERR; |
1427 | } | 1453 | } |
1428 | GNUNET_free (op); | ||
1429 | GNUNET_free (op_name); | ||
1430 | 1454 | ||
1431 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); | 1455 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); |
1432 | op_counter++; | 1456 | op_counter++; |
@@ -1818,6 +1842,21 @@ enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) | |||
1818 | GNUNET_ATS_solver_generate_preferences_stop (pg); | 1842 | GNUNET_ATS_solver_generate_preferences_stop (pg); |
1819 | } | 1843 | } |
1820 | 1844 | ||
1845 | |||
1846 | static void | ||
1847 | enforce_start_request (struct GNUNET_ATS_TEST_Operation *op) | ||
1848 | { | ||
1849 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n", | ||
1850 | op->peer_id); | ||
1851 | } | ||
1852 | |||
1853 | static void | ||
1854 | enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op) | ||
1855 | { | ||
1856 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop requesting address for peer %u\n", | ||
1857 | op->peer_id); | ||
1858 | } | ||
1859 | |||
1821 | static void enforce_episode (struct Episode *ep) | 1860 | static void enforce_episode (struct Episode *ep) |
1822 | { | 1861 | { |
1823 | struct GNUNET_ATS_TEST_Operation *cur; | 1862 | struct GNUNET_ATS_TEST_Operation *cur; |
@@ -1854,6 +1893,16 @@ static void enforce_episode (struct Episode *ep) | |||
1854 | print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate); | 1893 | print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate); |
1855 | enforce_stop_preference (cur); | 1894 | enforce_stop_preference (cur); |
1856 | break; | 1895 | break; |
1896 | case SOLVER_OP_START_REQUEST: | ||
1897 | fprintf (stderr, "Enforcing operation: %s [%llu]\n", | ||
1898 | print_op (cur->type), cur->peer_id); | ||
1899 | enforce_start_request (cur); | ||
1900 | break; | ||
1901 | case SOLVER_OP_STOP_REQUEST: | ||
1902 | fprintf (stderr, "Enforcing operation: %s [%llu]\n", | ||
1903 | print_op (cur->type), cur->peer_id); | ||
1904 | enforce_stop_request (cur); | ||
1905 | break; | ||
1857 | default: | 1906 | default: |
1858 | break; | 1907 | break; |
1859 | } | 1908 | } |
@@ -2056,11 +2105,6 @@ GNUNET_ATS_solvers_experimentation_load (char *filename) | |||
2056 | } | 2105 | } |
2057 | 2106 | ||
2058 | /** | 2107 | /** |
2059 | * Logging | ||
2060 | */ | ||
2061 | |||
2062 | |||
2063 | /** | ||
2064 | * Solver | 2108 | * Solver |
2065 | */ | 2109 | */ |
2066 | 2110 | ||
diff --git a/src/ats/gnunet-ats-solver-eval.h b/src/ats/gnunet-ats-solver-eval.h index ca79e9602..fe63a6b58 100644 --- a/src/ats/gnunet-ats-solver-eval.h +++ b/src/ats/gnunet-ats-solver-eval.h | |||
@@ -47,7 +47,9 @@ enum OperationType | |||
47 | SOLVER_OP_START_SET_PROPERTY, | 47 | SOLVER_OP_START_SET_PROPERTY, |
48 | SOLVER_OP_STOP_SET_PROPERTY, | 48 | SOLVER_OP_STOP_SET_PROPERTY, |
49 | SOLVER_OP_START_SET_PREFERENCE, | 49 | SOLVER_OP_START_SET_PREFERENCE, |
50 | SOLVER_OP_STOP_SET_PREFERENCE | 50 | SOLVER_OP_STOP_SET_PREFERENCE, |
51 | SOLVER_OP_START_REQUEST, | ||
52 | SOLVER_OP_STOP_REQUEST, | ||
51 | }; | 53 | }; |
52 | 54 | ||
53 | struct Episode; | 55 | struct Episode; |