diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-07 18:13:06 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-07 18:13:06 +0000 |
commit | 2db5c20edc405bcaa25214be3d92cb5d1913974b (patch) | |
tree | 5cfa39d19a4fc3f4b218f543ec91726335125398 /src | |
parent | fadd7e8fcaf35436022bf5eafa35a0a5adb9776b (diff) | |
download | gnunet-2db5c20edc405bcaa25214be3d92cb5d1913974b.tar.gz gnunet-2db5c20edc405bcaa25214be3d92cb5d1913974b.zip |
preference generation implemented
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/experiments/example.exp | 16 | ||||
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.c | 290 | ||||
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.h | 244 |
3 files changed, 262 insertions, 288 deletions
diff --git a/src/ats/experiments/example.exp b/src/ats/experiments/example.exp index 708ce353e..0b1d912fe 100644 --- a/src/ats/experiments/example.exp +++ b/src/ats/experiments/example.exp | |||
@@ -18,15 +18,15 @@ op-0-address = 0_0_udp | |||
18 | op-0-plugin = udp | 18 | op-0-plugin = udp |
19 | 19 | ||
20 | op-1-operation = start_set_preference | 20 | op-1-operation = start_set_preference |
21 | op-1-address-id = 0 | 21 | op-1-address-id = 1 |
22 | op-1-peer-id = 0 | 22 | op-1-peer-id = 1 |
23 | # constant, linear, sinus, random | 23 | # constant, linear, sinus, random |
24 | op-1-gen-type = random | 24 | op-1-gen-type = random |
25 | op-1-base-rate= 10000 | 25 | op-1-base-rate= 10000 |
26 | op-1-max-rate = 10000 | 26 | op-1-max-rate = 10000 |
27 | op-1-frequency = 1 | 27 | op-1-frequency = 100 ms |
28 | # BANDWIDTH, LATENCY | 28 | # BANDWIDTH, LATENCY |
29 | op-1-pref = LATENCY | 29 | op-1-pref = BANDWIDTH |
30 | 30 | ||
31 | op-2-operation = start_set_property | 31 | op-2-operation = start_set_property |
32 | op-2-address-id = 0 | 32 | op-2-address-id = 0 |
@@ -35,7 +35,7 @@ op-2-peer-id = 0 | |||
35 | op-2-gen-type = random | 35 | op-2-gen-type = random |
36 | op-2-base-rate= 10000 | 36 | op-2-base-rate= 10000 |
37 | op-2-max-rate = 10000 | 37 | op-2-max-rate = 10000 |
38 | op-2-frequency = 1 | 38 | op-2-frequency = 10 |
39 | # bandwidth, latency | 39 | # bandwidth, latency |
40 | # "TERMINATOR", "UTILIZATION_UP", "UTILIZATION_DOWN", "UTILIZATION_PAYLOAD_UP", "UTILIZATION_PAYLOAD_DOWN", "NETWORK_TYPE", "DELAY", "DISTANCE", "COST_WAN", "COST_LAN", "COST_WLAN" | 40 | # "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 | 41 | op-2-property = UTILIZATION_UP |
@@ -52,11 +52,11 @@ op-0-address = 0_0_udp | |||
52 | op-0-plugin = udp | 52 | op-0-plugin = udp |
53 | 53 | ||
54 | op-1-operation = stop_set_preference | 54 | op-1-operation = stop_set_preference |
55 | op-1-address-id = 0 | 55 | op-1-address-id = 1 |
56 | op-1-peer-id = 0 | 56 | op-1-peer-id = 1 |
57 | op-1-pref = BANDWIDTH | 57 | op-1-pref = BANDWIDTH |
58 | 58 | ||
59 | op-2-operation = stop_set_property | 59 | op-2-operation = stop_set_property |
60 | op-2-address-id = 0 | 60 | op-2-address-id = 0 |
61 | op-2-peer-id = 0 | 61 | op-2-peer-id = 0 |
62 | #op-2-property = UTILIZATION_UP \ No newline at end of file | 62 | op-2-property = UTILIZATION_UP \ 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 e59381cdd..2edb63faf 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c | |||
@@ -61,6 +61,228 @@ static int res; | |||
61 | static void | 61 | static void |
62 | end_now (); | 62 | end_now (); |
63 | 63 | ||
64 | |||
65 | /** | ||
66 | * Preference Generators | ||
67 | */ | ||
68 | |||
69 | static struct PreferenceGenerator *pg_head; | ||
70 | static struct PreferenceGenerator *pg_tail; | ||
71 | |||
72 | static double | ||
73 | get_preference (struct PreferenceGenerator *pg) | ||
74 | { | ||
75 | struct GNUNET_TIME_Relative time_delta; | ||
76 | double delta_value; | ||
77 | double pref_value; | ||
78 | |||
79 | /* Calculate the current preference value */ | ||
80 | switch (pg->type) { | ||
81 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
82 | pref_value = pg->base_value; | ||
83 | break; | ||
84 | case GNUNET_ATS_TEST_TG_LINEAR: | ||
85 | time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); | ||
86 | /* Calculate point of time in the current period */ | ||
87 | time_delta.rel_value_us = time_delta.rel_value_us % | ||
88 | pg->duration_period.rel_value_us; | ||
89 | delta_value = ((double) time_delta.rel_value_us / | ||
90 | pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value); | ||
91 | if ((pg->max_value < pg->base_value) && | ||
92 | ((pg->max_value - pg->base_value) > pg->base_value)) | ||
93 | { | ||
94 | /* This will cause an underflow */ | ||
95 | GNUNET_break (0); | ||
96 | } | ||
97 | pref_value = pg->base_value + delta_value; | ||
98 | break; | ||
99 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
100 | delta_value = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
101 | 10000 * (pg->max_value - pg->base_value)) / 10000; | ||
102 | pref_value = pg->base_value + delta_value; | ||
103 | break; | ||
104 | case GNUNET_ATS_TEST_TG_SINUS: | ||
105 | time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); | ||
106 | /* Calculate point of time in the current period */ | ||
107 | time_delta.rel_value_us = time_delta.rel_value_us % | ||
108 | pg->duration_period.rel_value_us; | ||
109 | if ((pg->max_value - pg->base_value) > pg->base_value) | ||
110 | { | ||
111 | /* This will cause an underflow for second half of sinus period, | ||
112 | * will be detected in general when experiments are loaded */ | ||
113 | GNUNET_break (0); | ||
114 | } | ||
115 | delta_value = (pg->max_value - pg->base_value) * | ||
116 | sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) * | ||
117 | time_delta.rel_value_us); | ||
118 | pref_value = pg->base_value + delta_value; | ||
119 | break; | ||
120 | default: | ||
121 | pref_value = 0.0; | ||
122 | break; | ||
123 | } | ||
124 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n", | ||
125 | pref_value); | ||
126 | return pref_value; | ||
127 | } | ||
128 | |||
129 | |||
130 | static void | ||
131 | set_pref_task (void *cls, | ||
132 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
133 | { | ||
134 | struct PreferenceGenerator *pg = cls; | ||
135 | double pref_value; | ||
136 | pg->set_task = GNUNET_SCHEDULER_NO_TASK; | ||
137 | |||
138 | pref_value = get_preference (pg); | ||
139 | |||
140 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
141 | "Setting preference for peer [%u] address [%u] for %s to %f\n", | ||
142 | pg->peer, pg->address_id, | ||
143 | GNUNET_ATS_print_preference_type (pg->kind), pref_value); | ||
144 | |||
145 | /* set performance here! | ||
146 | GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle, | ||
147 | &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END); | ||
148 | */ | ||
149 | |||
150 | switch (pg->kind) { | ||
151 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: | ||
152 | //p->pref_bandwidth = pref_value; | ||
153 | break; | ||
154 | case GNUNET_ATS_PREFERENCE_LATENCY: | ||
155 | //p->pref_delay = pref_value; | ||
156 | break; | ||
157 | default: | ||
158 | break; | ||
159 | } | ||
160 | |||
161 | pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency, | ||
162 | set_pref_task, pg); | ||
163 | |||
164 | } | ||
165 | |||
166 | static struct PreferenceGenerator * | ||
167 | find_pref_gen (unsigned int peer, unsigned int address, | ||
168 | enum GNUNET_ATS_PreferenceKind kind) | ||
169 | { | ||
170 | struct PreferenceGenerator *cur; | ||
171 | for (cur = pg_head; NULL != cur; cur = cur->next) | ||
172 | if ((cur->peer == peer) && (cur->address_id == address) && (cur->kind == kind)) | ||
173 | return cur; | ||
174 | return NULL; | ||
175 | } | ||
176 | |||
177 | void | ||
178 | GNUNET_ATS_solver_generate_preferences_stop (struct PreferenceGenerator *pg) | ||
179 | { | ||
180 | GNUNET_CONTAINER_DLL_remove (pg_head, pg_tail, pg); | ||
181 | |||
182 | if (GNUNET_SCHEDULER_NO_TASK != pg->set_task) | ||
183 | { | ||
184 | GNUNET_SCHEDULER_cancel (pg->set_task); | ||
185 | pg->set_task = GNUNET_SCHEDULER_NO_TASK; | ||
186 | } | ||
187 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
188 | "Removing old up preference generator peer [%u] address [%u] `%s'\n", | ||
189 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(pg->kind)); | ||
190 | |||
191 | GNUNET_free (pg); | ||
192 | } | ||
193 | |||
194 | |||
195 | /** | ||
196 | * Generate between the source master and the partner and set preferences with a | ||
197 | * value depending on the generator. | ||
198 | * | ||
199 | * @param src source | ||
200 | * @param dest partner | ||
201 | * @param type type of preferences to generate | ||
202 | * @param base_rate traffic base rate to send data with | ||
203 | * @param max_rate traffic maximum rate to send data with | ||
204 | * @param period duration of a period of traffic generation (~ 1/frequency) | ||
205 | * @param duration how long to generate traffic | ||
206 | * @return the traffic generator | ||
207 | */ | ||
208 | struct PreferenceGenerator * | ||
209 | GNUNET_ATS_solver_generate_preferences_start (unsigned int peer, | ||
210 | unsigned int address_id, | ||
211 | enum GeneratorType type, | ||
212 | long int base_value, | ||
213 | long int value_rate, | ||
214 | struct GNUNET_TIME_Relative period, | ||
215 | struct GNUNET_TIME_Relative frequency, | ||
216 | enum GNUNET_ATS_PreferenceKind kind) | ||
217 | { | ||
218 | struct PreferenceGenerator *pg; | ||
219 | |||
220 | pg = GNUNET_new (struct PreferenceGenerator); | ||
221 | GNUNET_CONTAINER_DLL_insert (pg_head, pg_tail, pg); | ||
222 | pg->type = type; | ||
223 | pg->peer = peer; | ||
224 | pg->address_id = address_id; | ||
225 | pg->kind = kind; | ||
226 | pg->base_value = base_value; | ||
227 | pg->max_value = value_rate; | ||
228 | pg->duration_period = period; | ||
229 | pg->frequency = frequency; | ||
230 | pg->time_start = GNUNET_TIME_absolute_get(); | ||
231 | |||
232 | switch (type) { | ||
233 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
234 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
235 | "Setting up constant preference generator peer [%u] address [%u] `%s' max %u Bips\n", | ||
236 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | ||
237 | base_value); | ||
238 | break; | ||
239 | case GNUNET_ATS_TEST_TG_LINEAR: | ||
240 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
241 | "Setting up linear preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bips\n", | ||
242 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | ||
243 | base_value, value_rate); | ||
244 | break; | ||
245 | case GNUNET_ATS_TEST_TG_SINUS: | ||
246 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
247 | "Setting up sinus preference generator peer [%u] address [%u] `%s' baserate %u Bips, amplitude %u Bps\n", | ||
248 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | ||
249 | base_value, value_rate); | ||
250 | |||
251 | break; | ||
252 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
253 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
254 | "Setting up random preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bps\n", | ||
255 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | ||
256 | base_value, value_rate); | ||
257 | break; | ||
258 | default: | ||
259 | break; | ||
260 | } | ||
261 | |||
262 | pg->set_task = GNUNET_SCHEDULER_add_now (&set_pref_task, pg); | ||
263 | return pg; | ||
264 | } | ||
265 | |||
266 | |||
267 | |||
268 | /** | ||
269 | * Stop all preferences generators | ||
270 | */ | ||
271 | void | ||
272 | GNUNET_ATS_solver_generate_preferences_stop_all () | ||
273 | { | ||
274 | struct PreferenceGenerator *cur; | ||
275 | struct PreferenceGenerator *next; | ||
276 | next = pg_head; | ||
277 | for (cur = next; NULL != cur; cur = next) | ||
278 | { | ||
279 | next = cur->next; | ||
280 | GNUNET_ATS_solver_generate_preferences_stop(cur); | ||
281 | } | ||
282 | } | ||
283 | |||
284 | |||
285 | |||
64 | /** | 286 | /** |
65 | * Experiments | 287 | * Experiments |
66 | */ | 288 | */ |
@@ -87,7 +309,6 @@ print_op (enum OperationType op) | |||
87 | return ""; | 309 | return ""; |
88 | } | 310 | } |
89 | 311 | ||
90 | |||
91 | static struct Experiment * | 312 | static struct Experiment * |
92 | create_experiment () | 313 | create_experiment () |
93 | { | 314 | { |
@@ -1237,62 +1458,30 @@ enforce_stop_property (struct GNUNET_ATS_TEST_Operation *op) | |||
1237 | static void | 1458 | static void |
1238 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) | 1459 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) |
1239 | { | 1460 | { |
1240 | /* | 1461 | struct PreferenceGenerator *pg; |
1241 | struct BenchmarkPeer *peer; | 1462 | if (NULL != (pg = find_pref_gen (op->peer_id, op->address_id, op->pref_type))) |
1242 | struct BenchmarkPartner *partner; | ||
1243 | |||
1244 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | ||
1245 | if (NULL == peer) | ||
1246 | { | ||
1247 | GNUNET_break (0); | ||
1248 | return; | ||
1249 | } | ||
1250 | |||
1251 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
1252 | if (NULL == partner) | ||
1253 | { | 1463 | { |
1254 | GNUNET_break (0); | 1464 | GNUNET_ATS_solver_generate_preferences_stop (pg); |
1255 | return; | 1465 | GNUNET_free (pg); |
1256 | } | 1466 | } |
1257 | 1467 | ||
1258 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 1468 | GNUNET_ATS_solver_generate_preferences_start (op->peer_id, |
1259 | 1469 | op->address_id, | |
1260 | if (NULL != partner->pg) | 1470 | op->type, |
1261 | { | 1471 | op->base_rate, |
1262 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | 1472 | op->max_rate, |
1263 | op->src_id, op->dest_id); | 1473 | op->period, |
1264 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); | 1474 | op->frequency, |
1265 | partner->pg = NULL; | 1475 | op->pref_type); |
1266 | } | ||
1267 | |||
1268 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, | ||
1269 | op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency, | ||
1270 | op->pref_type); | ||
1271 | */ | ||
1272 | } | 1476 | } |
1273 | 1477 | ||
1274 | static void | 1478 | static void |
1275 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) | 1479 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) |
1276 | { | 1480 | { |
1277 | /* | 1481 | struct PreferenceGenerator *pg = find_pref_gen(op->peer_id, op->address_id, |
1278 | struct BenchmarkPartner *p; | 1482 | op->pref_type); |
1279 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 1483 | if (NULL != pg) |
1280 | if (NULL == p) | 1484 | GNUNET_ATS_solver_generate_preferences_stop (pg); |
1281 | { | ||
1282 | GNUNET_break (0); | ||
1283 | return; | ||
1284 | } | ||
1285 | |||
1286 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
1287 | |||
1288 | if (NULL != p->pg) | ||
1289 | { | ||
1290 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", | ||
1291 | op->src_id, op->dest_id); | ||
1292 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); | ||
1293 | p->pg = NULL; | ||
1294 | } | ||
1295 | */ | ||
1296 | } | 1485 | } |
1297 | 1486 | ||
1298 | static void enforce_episode (struct Episode *ep) | 1487 | static void enforce_episode (struct Episode *ep) |
@@ -1879,6 +2068,7 @@ static void | |||
1879 | done () | 2068 | done () |
1880 | { | 2069 | { |
1881 | /* Clean up experiment */ | 2070 | /* Clean up experiment */ |
2071 | GNUNET_ATS_solver_generate_preferences_stop_all (); | ||
1882 | GNUNET_ATS_solvers_experimentation_stop (e); | 2072 | GNUNET_ATS_solvers_experimentation_stop (e); |
1883 | e = NULL; | 2073 | e = NULL; |
1884 | 2074 | ||
@@ -1903,7 +2093,7 @@ experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,i | |||
1903 | // GNUNET_ATS_TEST_generate_traffic_stop_all(); | 2093 | // GNUNET_ATS_TEST_generate_traffic_stop_all(); |
1904 | 2094 | ||
1905 | /* Stop all preference generations */ | 2095 | /* Stop all preference generations */ |
1906 | // GNUNET_ATS_TEST_generate_preferences_stop_all (); | 2096 | GNUNET_ATS_solver_generate_preferences_stop_all (); |
1907 | 2097 | ||
1908 | /* | 2098 | /* |
1909 | evaluate (duration); | 2099 | evaluate (duration); |
diff --git a/src/ats/gnunet-ats-solver-eval.h b/src/ats/gnunet-ats-solver-eval.h index 9ea91cb3b..a14f1ea7f 100644 --- a/src/ats/gnunet-ats-solver-eval.h +++ b/src/ats/gnunet-ats-solver-eval.h | |||
@@ -121,245 +121,29 @@ struct Experiment | |||
121 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; | 121 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | 124 | struct PreferenceGenerator | |
125 | /** | ||
126 | * A single logging time step for a partner | ||
127 | */ | ||
128 | struct PartnerLoggingTimestep | ||
129 | { | ||
130 | /** | ||
131 | * Peer | ||
132 | */ | ||
133 | struct BenchmarkPeer *slave; | ||
134 | |||
135 | /** | ||
136 | * Total number of messages this peer has sent | ||
137 | */ | ||
138 | unsigned int total_messages_sent; | ||
139 | |||
140 | /** | ||
141 | * Total number of bytes this peer has sent | ||
142 | */ | ||
143 | unsigned int total_bytes_sent; | ||
144 | |||
145 | /** | ||
146 | * Total number of messages this peer has received | ||
147 | */ | ||
148 | unsigned int total_messages_received; | ||
149 | |||
150 | /** | ||
151 | * Total number of bytes this peer has received | ||
152 | */ | ||
153 | unsigned int total_bytes_received; | ||
154 | |||
155 | /** | ||
156 | * Total outbound throughput for master in Bytes / s | ||
157 | */ | ||
158 | unsigned int throughput_sent; | ||
159 | |||
160 | /** | ||
161 | * Total inbound throughput for master in Bytes / s | ||
162 | */ | ||
163 | unsigned int throughput_recv; | ||
164 | |||
165 | /** | ||
166 | * Accumulated RTT for all messages | ||
167 | */ | ||
168 | unsigned int total_app_rtt; | ||
169 | |||
170 | /** | ||
171 | * Current application level delay | ||
172 | */ | ||
173 | unsigned int app_rtt; | ||
174 | |||
175 | /* Current ATS properties */ | ||
176 | |||
177 | uint32_t ats_distance; | ||
178 | |||
179 | uint32_t ats_delay; | ||
180 | |||
181 | uint32_t bandwidth_in; | ||
182 | |||
183 | uint32_t bandwidth_out; | ||
184 | |||
185 | uint32_t ats_utilization_up; | ||
186 | |||
187 | uint32_t ats_utilization_down; | ||
188 | |||
189 | uint32_t ats_network_type; | ||
190 | |||
191 | uint32_t ats_cost_wan; | ||
192 | |||
193 | uint32_t ats_cost_lan; | ||
194 | |||
195 | uint32_t ats_cost_wlan; | ||
196 | |||
197 | double pref_bandwidth; | ||
198 | double pref_delay; | ||
199 | }; | ||
200 | |||
201 | |||
202 | /** | ||
203 | * A single logging time step for a peer | ||
204 | */ | ||
205 | struct PeerLoggingTimestep | ||
206 | { | ||
207 | /** | ||
208 | * Next in DLL | ||
209 | */ | ||
210 | struct PeerLoggingTimestep *next; | ||
211 | |||
212 | /** | ||
213 | * Prev in DLL | ||
214 | */ | ||
215 | struct PeerLoggingTimestep *prev; | ||
216 | |||
217 | /** | ||
218 | * Logging timestamp | ||
219 | */ | ||
220 | struct GNUNET_TIME_Absolute timestamp; | ||
221 | |||
222 | /** | ||
223 | * Total number of messages this peer has sent | ||
224 | */ | ||
225 | unsigned int total_messages_sent; | ||
226 | |||
227 | /** | ||
228 | * Total number of bytes this peer has sent | ||
229 | */ | ||
230 | unsigned int total_bytes_sent; | ||
231 | |||
232 | /** | ||
233 | * Total number of messages this peer has received | ||
234 | */ | ||
235 | unsigned int total_messages_received; | ||
236 | |||
237 | /** | ||
238 | * Total number of bytes this peer has received | ||
239 | */ | ||
240 | unsigned int total_bytes_received; | ||
241 | |||
242 | /** | ||
243 | * Total outbound throughput for master in Bytes / s | ||
244 | */ | ||
245 | unsigned int total_throughput_send; | ||
246 | |||
247 | /** | ||
248 | * Total inbound throughput for master in Bytes / s | ||
249 | */ | ||
250 | unsigned int total_throughput_recv; | ||
251 | |||
252 | /** | ||
253 | * Logs for slaves | ||
254 | */ | ||
255 | struct PartnerLoggingTimestep *slaves_log; | ||
256 | }; | ||
257 | |||
258 | /** | ||
259 | * Entry for a benchmark peer | ||
260 | */ | ||
261 | struct LoggingPeer | ||
262 | { | 125 | { |
263 | /** | 126 | struct PreferenceGenerator *prev; |
264 | * Peer | 127 | struct PreferenceGenerator *next; |
265 | */ | ||
266 | struct BenchmarkPeer *peer; | ||
267 | |||
268 | /** | ||
269 | * Start time | ||
270 | */ | ||
271 | struct GNUNET_TIME_Absolute start; | ||
272 | |||
273 | /** | ||
274 | * DLL for logging entries: head | ||
275 | */ | ||
276 | struct PeerLoggingTimestep *head; | ||
277 | 128 | ||
278 | /** | 129 | enum GeneratorType type; |
279 | * DLL for logging entries: tail | ||
280 | */ | ||
281 | struct PeerLoggingTimestep *tail; | ||
282 | }; | ||
283 | 130 | ||
131 | unsigned int peer; | ||
132 | unsigned int address_id; | ||
284 | 133 | ||
285 | struct LoggingHandle | 134 | enum GNUNET_ATS_PreferenceKind kind; |
286 | { | ||
287 | /** | ||
288 | * Logging task | ||
289 | */ | ||
290 | GNUNET_SCHEDULER_TaskIdentifier log_task; | ||
291 | 135 | ||
292 | /** | 136 | long int base_value; |
293 | * Reference to perf_ats' masters | 137 | long int max_value; |
294 | */ | 138 | struct GNUNET_TIME_Relative duration_period; |
295 | int num_masters; | ||
296 | int num_slaves; | ||
297 | int running; | ||
298 | int verbose; | ||
299 | char *name; | ||
300 | struct GNUNET_TIME_Relative frequency; | 139 | struct GNUNET_TIME_Relative frequency; |
301 | 140 | ||
302 | /** | 141 | GNUNET_SCHEDULER_TaskIdentifier set_task; |
303 | * Log structure of length num_peers | 142 | struct GNUNET_TIME_Absolute next_ping_transmission; |
304 | */ | 143 | struct GNUNET_TIME_Absolute time_start; |
305 | struct LoggingPeer *lp; | ||
306 | }; | 144 | }; |
307 | 145 | ||
308 | 146 | ||
309 | /** | ||
310 | * Start logging | ||
311 | * | ||
312 | * @param log_frequency the logging frequency | ||
313 | * @param testname the testname | ||
314 | * @param masters the master peers used for benchmarking | ||
315 | * @param num_master the number of master peers | ||
316 | * @return the logging handle or NULL on error | ||
317 | */ | ||
318 | struct LoggingHandle * | ||
319 | GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, | ||
320 | char *testname, struct BenchmarkPeer *masters, int num_masters, int num_slaves, | ||
321 | int verbose); | ||
322 | |||
323 | /** | ||
324 | * Stop logging | ||
325 | * | ||
326 | * @param l the logging handle | ||
327 | */ | ||
328 | void | ||
329 | GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l); | ||
330 | |||
331 | /** | ||
332 | * Stop logging | ||
333 | * | ||
334 | * @param l the logging handle | ||
335 | */ | ||
336 | void | ||
337 | GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l); | ||
338 | |||
339 | /** | ||
340 | * Log all data now | ||
341 | * | ||
342 | * @param l logging handle to use | ||
343 | */ | ||
344 | void | ||
345 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); | ||
346 | |||
347 | |||
348 | /** | ||
349 | * Write logging data to file | ||
350 | * | ||
351 | * @param l logging handle to use | ||
352 | * @param test_name name of the current test | ||
353 | * @param plots create gnuplots: GNUNET_YES or GNUNET_NO | ||
354 | */ | ||
355 | void | ||
356 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | ||
357 | char *test_name, int plots); | ||
358 | |||
359 | |||
360 | |||
361 | |||
362 | |||
363 | 147 | ||
364 | /* LEGACY */ | 148 | /* LEGACY */ |
365 | 149 | ||
@@ -417,7 +201,7 @@ typedef void (*GNUNET_ATS_TEST_TopologySetupDoneCallback) (void *cls, | |||
417 | */ | 201 | */ |
418 | typedef void | 202 | typedef void |
419 | (*GNUNET_ATS_TEST_LogRequest) (void *cls, | 203 | (*GNUNET_ATS_TEST_LogRequest) (void *cls, |
420 | const struct GNUNET_HELLO_Address *address, | 204 | const struct GNUNET_HELLO_Address *address_id, |
421 | int address_active, | 205 | int address_active, |
422 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 206 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
423 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 207 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |