diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 14:07:59 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 14:07:59 +0000 |
commit | 84faee523650bb8613d67f99777e990a7497bf73 (patch) | |
tree | d40b4efb0eb53b2f618787756adb84988314ab6f /src | |
parent | a5b4af52529d598adc78ae86621f8803d12eef8f (diff) | |
download | gnunet-84faee523650bb8613d67f99777e990a7497bf73.tar.gz gnunet-84faee523650bb8613d67f99777e990a7497bf73.zip |
+ setting preference
+ set preference example
+ adding client_id to suport multiple applications
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/experiments/example.exp | 10 | ||||
-rw-r--r-- | src/ats/experiments/set_preference.exp | 93 | ||||
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.c | 67 | ||||
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.h | 2 |
4 files changed, 152 insertions, 20 deletions
diff --git a/src/ats/experiments/example.exp b/src/ats/experiments/example.exp index ac7e85889..fcf5fc453 100644 --- a/src/ats/experiments/example.exp +++ b/src/ats/experiments/example.exp | |||
@@ -101,13 +101,3 @@ op-2-address-network = 0 | |||
101 | op-2-address = 1_1_test | 101 | op-2-address = 1_1_test |
102 | op-2-plugin = test | 102 | op-2-plugin = test |
103 | 103 | ||
104 | #op-1-operation = start_set_preference | ||
105 | #op-1-address-id = 1 | ||
106 | #op-1-peer-id = 1 | ||
107 | # constant, linear, sinus, random | ||
108 | #op-1-gen-type = constant | ||
109 | #op-1-base-rate= 10000 | ||
110 | #op-1-max-rate = 100000 | ||
111 | #op-1-frequency = 500 ms | ||
112 | # BANDWIDTH, LATENCY | ||
113 | #op-1-pref = BANDWIDTH \ No newline at end of file | ||
diff --git a/src/ats/experiments/set_preference.exp b/src/ats/experiments/set_preference.exp new file mode 100644 index 000000000..b49843e4b --- /dev/null +++ b/src/ats/experiments/set_preference.exp | |||
@@ -0,0 +1,93 @@ | |||
1 | # Example setting up two peers | ||
2 | |||
3 | [experiment] | ||
4 | name = test | ||
5 | max_duration = 15 s | ||
6 | log_freq = 1000 ms | ||
7 | cfg_file = experiments/gnunet_ats_sim_default.conf | ||
8 | |||
9 | |||
10 | [episode-0] | ||
11 | # Setup addresses | ||
12 | |||
13 | # operations = address_add, address_del, start_set_property, stop_set_property, | ||
14 | # start_set_preference, stop_preference, start_request, stop_request | ||
15 | duration = 5 s | ||
16 | op-0-operation = address_add | ||
17 | op-0-address-id = 0 | ||
18 | op-0-peer-id = 0 | ||
19 | op-0-address-session = 0 | ||
20 | op-0-address-network = 0 | ||
21 | op-0-address = 0_0_test | ||
22 | op-0-plugin = test | ||
23 | |||
24 | op-1-operation = address_add | ||
25 | op-1-address-id = 1 | ||
26 | op-1-peer-id = 1 | ||
27 | op-1-address-session = 0 | ||
28 | op-1-address-network = 0 | ||
29 | op-1-address = 1_1_test | ||
30 | op-1-plugin = test | ||
31 | |||
32 | op-2-operation = start_request | ||
33 | op-2-peer-id = 0 | ||
34 | |||
35 | op-3-operation = start_request | ||
36 | op-3-peer-id = 1 | ||
37 | |||
38 | [episode-1] | ||
39 | # Set delay | ||
40 | duration = 5 s | ||
41 | |||
42 | op-0-operation = start_set_preference | ||
43 | op-0-address-id = 0 | ||
44 | op-0-peer-id = 0 | ||
45 | op-0-client-id = 1 | ||
46 | # constant, linear, sinus, random | ||
47 | op-0-gen-type = constant | ||
48 | op-0-base-rate= 10000 | ||
49 | op-0-max-rate = 10000 | ||
50 | op-0-period = 1000 ms | ||
51 | op-0-frequency = 1000 ms | ||
52 | # BANDWIDTH, LATENCY | ||
53 | op-0-pref = BANDWIDTH | ||
54 | |||
55 | |||
56 | op-1-operation = start_set_preference | ||
57 | op-1-address-id = 1 | ||
58 | op-1-peer-id = 1 | ||
59 | op-1-client-id = 1 | ||
60 | # constant, linear, sinus, random | ||
61 | op-1-gen-type = linear | ||
62 | op-1-base-rate= 10000 | ||
63 | op-1-max-rate = 20000 | ||
64 | op-1-period = 1000 ms | ||
65 | op-1-frequency = 100 ms | ||
66 | # BANDWIDTH, LATENCY | ||
67 | op-1-pref = BANDWIDTH | ||
68 | |||
69 | [episode-2] | ||
70 | # Shutdown | ||
71 | duration = 2 s | ||
72 | |||
73 | op-0-operation = stop_request | ||
74 | op-0-peer-id = 0 | ||
75 | |||
76 | op-1-operation = stop_request | ||
77 | op-1-peer-id = 1 | ||
78 | |||
79 | op-2-operation = address_del | ||
80 | op-2-address-id = 0 | ||
81 | op-2-peer-id = 0 | ||
82 | op-2-address-session = 0 | ||
83 | op-2-address-network = 0 | ||
84 | op-2-address = 0_0_test | ||
85 | op-2-plugin = test | ||
86 | |||
87 | op-3-operation = address_del | ||
88 | op-3-address-id = 1 | ||
89 | op-3-peer-id = 1 | ||
90 | op-3-address-session = 0 | ||
91 | op-3-address-network = 0 | ||
92 | op-3-address = 1_1_test | ||
93 | op-3-plugin = test | ||
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index 234492962..afe65d5a1 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c | |||
@@ -296,7 +296,6 @@ set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
296 | pg->test_address->ats_addr, &atsi, 1); | 296 | pg->test_address->ats_addr, &atsi, 1); |
297 | sh->env.sf.s_bulk_stop (sh->solver); | 297 | sh->env.sf.s_bulk_stop (sh->solver); |
298 | 298 | ||
299 | |||
300 | switch (pg->ats_property) { | 299 | switch (pg->ats_property) { |
301 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: | 300 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: |
302 | //p->pref_bandwidth = pref_value; | 301 | //p->pref_bandwidth = pref_value; |
@@ -515,20 +514,29 @@ set_pref_task (void *cls, | |||
515 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 514 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
516 | { | 515 | { |
517 | struct PreferenceGenerator *pg = cls; | 516 | struct PreferenceGenerator *pg = cls; |
517 | struct TestPeer *p; | ||
518 | double pref_value; | 518 | double pref_value; |
519 | pg->set_task = GNUNET_SCHEDULER_NO_TASK; | 519 | pg->set_task = GNUNET_SCHEDULER_NO_TASK; |
520 | 520 | ||
521 | if (NULL == (p = find_peer_by_id (pg->peer))) | ||
522 | { | ||
523 | GNUNET_break (0); | ||
524 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
525 | "Setting preference for unknown peer %u\n", pg->peer); | ||
526 | return; | ||
527 | } | ||
528 | |||
521 | pref_value = get_preference (pg); | 529 | pref_value = get_preference (pg); |
522 | 530 | ||
523 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 531 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
524 | "Setting preference for peer [%u] address [%u] for %s to %f\n", | 532 | "Setting preference for peer [%u] address [%u] for client %p pref %s to %f\n", |
525 | pg->peer, pg->address_id, | 533 | pg->peer, pg->address_id, NULL + (pg->client_id), |
526 | GNUNET_ATS_print_preference_type (pg->kind), pref_value); | 534 | GNUNET_ATS_print_preference_type (pg->kind), pref_value); |
527 | 535 | ||
528 | /* set performance here! | 536 | sh->env.sf.s_bulk_start (sh->solver); |
529 | GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle, | 537 | GAS_normalization_normalize_preference (NULL + (pg->client_id), &p->peer_id, |
530 | &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END); | 538 | pg->kind, pref_value); |
531 | */ | 539 | sh->env.sf.s_bulk_stop (sh->solver); |
532 | 540 | ||
533 | switch (pg->kind) { | 541 | switch (pg->kind) { |
534 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: | 542 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: |
@@ -591,6 +599,7 @@ GNUNET_ATS_solver_generate_preferences_stop (struct PreferenceGenerator *pg) | |||
591 | struct PreferenceGenerator * | 599 | struct PreferenceGenerator * |
592 | GNUNET_ATS_solver_generate_preferences_start (unsigned int peer, | 600 | GNUNET_ATS_solver_generate_preferences_start (unsigned int peer, |
593 | unsigned int address_id, | 601 | unsigned int address_id, |
602 | unsigned int client_id, | ||
594 | enum GeneratorType type, | 603 | enum GeneratorType type, |
595 | long int base_value, | 604 | long int base_value, |
596 | long int value_rate, | 605 | long int value_rate, |
@@ -605,6 +614,7 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer, | |||
605 | pg->type = type; | 614 | pg->type = type; |
606 | pg->peer = peer; | 615 | pg->peer = peer; |
607 | pg->address_id = address_id; | 616 | pg->address_id = address_id; |
617 | pg->client_id = client_id; | ||
608 | pg->kind = kind; | 618 | pg->kind = kind; |
609 | pg->base_value = base_value; | 619 | pg->base_value = base_value; |
610 | pg->max_value = value_rate; | 620 | pg->max_value = value_rate; |
@@ -960,6 +970,18 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o, | |||
960 | } | 970 | } |
961 | GNUNET_free (op_name); | 971 | GNUNET_free (op_name); |
962 | 972 | ||
973 | /* address id */ | ||
974 | GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter); | ||
975 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
976 | sec_name, op_name, &o->client_id)) | ||
977 | { | ||
978 | fprintf (stderr, "Missing client-id in operation %u `%s' in episode `%s'\n", | ||
979 | op_counter, "START_SET_PREFERENCE", op_name); | ||
980 | GNUNET_free (op_name); | ||
981 | return GNUNET_SYSERR; | ||
982 | } | ||
983 | GNUNET_free (op_name); | ||
984 | |||
963 | /* generator */ | 985 | /* generator */ |
964 | GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter); | 986 | GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter); |
965 | if ( (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | 987 | if ( (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, |
@@ -1483,7 +1505,6 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
1483 | o->type = SOLVER_OP_START_SET_PREFERENCE; | 1505 | o->type = SOLVER_OP_START_SET_PREFERENCE; |
1484 | res = load_op_start_set_preference (o, cur, | 1506 | res = load_op_start_set_preference (o, cur, |
1485 | op_counter, sec_name, cfg); | 1507 | op_counter, sec_name, cfg); |
1486 | break; | ||
1487 | } | 1508 | } |
1488 | else if (0 == strcmp (op, "stop_set_preference")) | 1509 | else if (0 == strcmp (op, "stop_set_preference")) |
1489 | { | 1510 | { |
@@ -1733,7 +1754,7 @@ enforce_start_property (struct GNUNET_ATS_TEST_Operation *op) | |||
1733 | { | 1754 | { |
1734 | GNUNET_break (0); | 1755 | GNUNET_break (0); |
1735 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1756 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1736 | "Setting proprterty for unknown address %u\n", op->peer_id); | 1757 | "Setting property for unknown address %u\n", op->peer_id); |
1737 | return; | 1758 | return; |
1738 | } | 1759 | } |
1739 | 1760 | ||
@@ -1761,14 +1782,24 @@ static void | |||
1761 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) | 1782 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) |
1762 | { | 1783 | { |
1763 | struct PreferenceGenerator *pg; | 1784 | struct PreferenceGenerator *pg; |
1785 | struct TestPeer *p; | ||
1764 | if (NULL != (pg = find_pref_gen (op->peer_id, op->address_id, op->pref_type))) | 1786 | if (NULL != (pg = find_pref_gen (op->peer_id, op->address_id, op->pref_type))) |
1765 | { | 1787 | { |
1766 | GNUNET_ATS_solver_generate_preferences_stop (pg); | 1788 | GNUNET_ATS_solver_generate_preferences_stop (pg); |
1767 | GNUNET_free (pg); | 1789 | GNUNET_free (pg); |
1768 | } | 1790 | } |
1769 | 1791 | ||
1792 | if (NULL == (p = find_peer_by_id (op->peer_id))) | ||
1793 | { | ||
1794 | GNUNET_break (0); | ||
1795 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1796 | "Starting preference generation for unknown peer %u\n", op->peer_id); | ||
1797 | return; | ||
1798 | } | ||
1799 | |||
1770 | GNUNET_ATS_solver_generate_preferences_start (op->peer_id, | 1800 | GNUNET_ATS_solver_generate_preferences_start (op->peer_id, |
1771 | op->address_id, | 1801 | op->address_id, |
1802 | op->client_id, | ||
1772 | op->gen_type, | 1803 | op->gen_type, |
1773 | op->base_rate, | 1804 | op->base_rate, |
1774 | op->max_rate, | 1805 | op->max_rate, |
@@ -2335,6 +2366,21 @@ normalized_property_changed_cb (void *cls, struct ATS_Address *address, | |||
2335 | } | 2366 | } |
2336 | 2367 | ||
2337 | 2368 | ||
2369 | static void | ||
2370 | normalized_preference_changed_cb (void *cls, | ||
2371 | const struct GNUNET_PeerIdentity *peer, | ||
2372 | enum GNUNET_ATS_PreferenceKind kind, | ||
2373 | double pref_rel) | ||
2374 | { | ||
2375 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
2376 | "Normalized preference %s for peer `%s' changed to %.3f \n", | ||
2377 | GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer), | ||
2378 | pref_rel); | ||
2379 | |||
2380 | sh->env.sf.s_pref (sh->solver, peer, kind, pref_rel); | ||
2381 | } | ||
2382 | |||
2383 | |||
2338 | struct SolverHandle * | 2384 | struct SolverHandle * |
2339 | GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) | 2385 | GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) |
2340 | { | 2386 | { |
@@ -2374,7 +2420,8 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) | |||
2374 | 2420 | ||
2375 | 2421 | ||
2376 | /* start normalization */ | 2422 | /* start normalization */ |
2377 | GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL ); | 2423 | GAS_normalization_start (&normalized_preference_changed_cb, NULL, |
2424 | &normalized_property_changed_cb, NULL ); | ||
2378 | 2425 | ||
2379 | /* load quotas */ | 2426 | /* load quotas */ |
2380 | if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg, | 2427 | if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg, |
diff --git a/src/ats/gnunet-ats-solver-eval.h b/src/ats/gnunet-ats-solver-eval.h index fe84674ac..61e3393d7 100644 --- a/src/ats/gnunet-ats-solver-eval.h +++ b/src/ats/gnunet-ats-solver-eval.h | |||
@@ -125,6 +125,7 @@ struct GNUNET_ATS_TEST_Operation | |||
125 | 125 | ||
126 | long long unsigned int address_id; | 126 | long long unsigned int address_id; |
127 | long long unsigned int peer_id; | 127 | long long unsigned int peer_id; |
128 | long long unsigned int client_id; | ||
128 | long long unsigned int address_session; | 129 | long long unsigned int address_session; |
129 | long long unsigned int address_network; | 130 | long long unsigned int address_network; |
130 | char*address; | 131 | char*address; |
@@ -188,6 +189,7 @@ struct PreferenceGenerator | |||
188 | 189 | ||
189 | unsigned int peer; | 190 | unsigned int peer; |
190 | unsigned int address_id; | 191 | unsigned int address_id; |
192 | unsigned int client_id; | ||
191 | 193 | ||
192 | enum GNUNET_ATS_PreferenceKind kind; | 194 | enum GNUNET_ATS_PreferenceKind kind; |
193 | 195 | ||