diff options
Diffstat (limited to 'src/core/test_core_quota_compliance.c')
-rw-r--r-- | src/core/test_core_quota_compliance.c | 106 |
1 files changed, 51 insertions, 55 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 5a3e3dc14..9d231c4e0 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -191,8 +191,7 @@ static int | |||
191 | inbound_notify (void *cls, | 191 | inbound_notify (void *cls, |
192 | const struct GNUNET_PeerIdentity *other, | 192 | const struct GNUNET_PeerIdentity *other, |
193 | const struct GNUNET_MessageHeader *message, | 193 | const struct GNUNET_MessageHeader *message, |
194 | struct GNUNET_TIME_Relative latency, | 194 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
195 | uint32_t distance) | ||
196 | { | 195 | { |
197 | total_bytes_recv += ntohs (message->size); | 196 | total_bytes_recv += ntohs (message->size); |
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -207,8 +206,7 @@ static int | |||
207 | outbound_notify (void *cls, | 206 | outbound_notify (void *cls, |
208 | const struct GNUNET_PeerIdentity *other, | 207 | const struct GNUNET_PeerIdentity *other, |
209 | const struct GNUNET_MessageHeader *message, | 208 | const struct GNUNET_MessageHeader *message, |
210 | struct GNUNET_TIME_Relative latency, | 209 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
211 | uint32_t distance) | ||
212 | { | 210 | { |
213 | #if DEBUG_CONNECTIONS | 211 | #if DEBUG_CONNECTIONS |
214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -238,38 +236,37 @@ static void | |||
238 | measurement_end (void *cls, | 236 | measurement_end (void *cls, |
239 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 237 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
240 | { | 238 | { |
241 | struct GNUNET_TIME_Relative duration; | 239 | struct GNUNET_TIME_Relative duration; |
242 | 240 | ||
243 | measure_task = GNUNET_SCHEDULER_NO_TASK; | 241 | measure_task = GNUNET_SCHEDULER_NO_TASK; |
244 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 242 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
245 | return; | 243 | return; |
246 | 244 | ||
247 | if (err_task != GNUNET_SCHEDULER_NO_TASK) | 245 | if (err_task != GNUNET_SCHEDULER_NO_TASK) |
248 | GNUNET_SCHEDULER_cancel (err_task); | 246 | GNUNET_SCHEDULER_cancel (err_task); |
249 | if (send_task != GNUNET_SCHEDULER_NO_TASK) | 247 | if (send_task != GNUNET_SCHEDULER_NO_TASK) |
250 | GNUNET_SCHEDULER_cancel (send_task); | 248 | GNUNET_SCHEDULER_cancel (send_task); |
251 | 249 | ||
252 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); | 250 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); |
253 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); | 251 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); |
254 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); | 252 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); |
255 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); | 253 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); |
256 | 254 | ||
257 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); | 255 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); |
258 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); | 256 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); |
259 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); | 257 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); |
260 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); | 258 | GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); |
261 | measurement_running = GNUNET_NO; | 259 | measurement_running = GNUNET_NO; |
262 | duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); | 260 | duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); |
263 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 261 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
264 | "\nQuota compliance: \n"\ | 262 | "\nQuota compliance: \n" \ |
265 | "Receive rate: %10llu kB/s\n" | 263 | "Receive rate: %10llu kB/s\n" |
266 | "Send rate : %10llu kB/s\n"\ | 264 | "Send rate : %10llu kB/s\n" \ |
267 | "Quota : %10llu kB/s\n", | 265 | "Quota : %10llu kB/s\n", |
268 | (total_bytes_recv/(duration.rel_value / 1000)/1024), | 266 | (total_bytes_recv/(duration.rel_value / 1000)/1024), |
269 | (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); | 267 | (total_bytes_sent/(duration.rel_value / 1000)/1024), |
270 | 268 | current_quota_p1_in/1024); | |
271 | 269 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | |
272 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | ||
273 | } | 270 | } |
274 | 271 | ||
275 | static size_t | 272 | static size_t |
@@ -279,17 +276,19 @@ static void | |||
279 | send_tsk (void *cls, | 276 | send_tsk (void *cls, |
280 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 277 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
281 | { | 278 | { |
282 | send_task = GNUNET_SCHEDULER_NO_TASK; | 279 | send_task = GNUNET_SCHEDULER_NO_TASK; |
283 | 280 | ||
284 | ch = GNUNET_CORE_notify_transmit_ready (p1.ch, | 281 | ch = GNUNET_CORE_notify_transmit_ready (p1.ch, |
285 | 0, | 282 | 0, |
286 | FAST_TIMEOUT, | 283 | FAST_TIMEOUT, |
287 | &p2.id, | 284 | &p2.id, |
288 | sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE, | 285 | sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE, |
289 | &transmit_ready, &p1); | 286 | &transmit_ready, &p1); |
290 | } | 287 | } |
291 | 288 | ||
292 | static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | 289 | |
290 | static void | ||
291 | measure (unsigned long long quota_p1, unsigned long long quota_p2) | ||
293 | { | 292 | { |
294 | #if VERBOSE | 293 | #if VERBOSE |
295 | if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES)) | 294 | if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES)) |
@@ -316,11 +315,11 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | |||
316 | total_bytes = 0; | 315 | total_bytes = 0; |
317 | total_bytes_sent = 0; | 316 | total_bytes_sent = 0; |
318 | ch = GNUNET_CORE_notify_transmit_ready (p1.ch, | 317 | ch = GNUNET_CORE_notify_transmit_ready (p1.ch, |
319 | 0, | 318 | 0, |
320 | TIMEOUT, | 319 | TIMEOUT, |
321 | &p2.id, | 320 | &p2.id, |
322 | sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE, | 321 | sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE, |
323 | &transmit_ready, &p1); | 322 | &transmit_ready, &p1); |
324 | } | 323 | } |
325 | 324 | ||
326 | static int tr_n; | 325 | static int tr_n; |
@@ -330,8 +329,7 @@ static int | |||
330 | process_mtype (void *cls, | 329 | process_mtype (void *cls, |
331 | const struct GNUNET_PeerIdentity *peer, | 330 | const struct GNUNET_PeerIdentity *peer, |
332 | const struct GNUNET_MessageHeader *message, | 331 | const struct GNUNET_MessageHeader *message, |
333 | struct GNUNET_TIME_Relative latency, | 332 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
334 | uint32_t distance) | ||
335 | { | 333 | { |
336 | static int n; | 334 | static int n; |
337 | unsigned int s; | 335 | unsigned int s; |
@@ -453,7 +451,6 @@ init_notify (void *cls, | |||
453 | OKPP; | 451 | OKPP; |
454 | /* connect p2 */ | 452 | /* connect p2 */ |
455 | GNUNET_CORE_connect (p2.cfg, 1, | 453 | GNUNET_CORE_connect (p2.cfg, 1, |
456 | TIMEOUT, | ||
457 | &p2, | 454 | &p2, |
458 | &init_notify, | 455 | &init_notify, |
459 | &connect_notify, | 456 | &connect_notify, |
@@ -534,7 +531,6 @@ run (void *cls, | |||
534 | setup_peer (&p1, "test_core_quota_peer1.conf"); | 531 | setup_peer (&p1, "test_core_quota_peer1.conf"); |
535 | setup_peer (&p2, "test_core_quota_peer2.conf"); | 532 | setup_peer (&p2, "test_core_quota_peer2.conf"); |
536 | GNUNET_CORE_connect (p1.cfg, 1, | 533 | GNUNET_CORE_connect (p1.cfg, 1, |
537 | TIMEOUT, | ||
538 | &p1, | 534 | &p1, |
539 | &init_notify, | 535 | &init_notify, |
540 | &connect_notify, | 536 | &connect_notify, |
@@ -606,7 +602,7 @@ main (int argc, char *argv[]) | |||
606 | { | 602 | { |
607 | int ret; | 603 | int ret; |
608 | 604 | ||
609 | GNUNET_log_setup ("test-core-api", | 605 | GNUNET_log_setup ("test-core-quota-compliance", |
610 | #if VERBOSE | 606 | #if VERBOSE |
611 | "DEBUG", | 607 | "DEBUG", |
612 | #else | 608 | #else |