diff options
author | t3sserakt <t3ss@posteo.de> | 2021-01-25 15:47:10 +0100 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-01-25 15:47:10 +0100 |
commit | ac71165822501c42b00980db2fb7f5e2144f3d20 (patch) | |
tree | cb62e4f7af0f91bdcf50c69bfc0bb901d3059358 /src/transport/test_communicator_basic.c | |
parent | 438aca2f666f0e0648f389774adee01c131da25c (diff) | |
download | gnunet-ac71165822501c42b00980db2fb7f5e2144f3d20.tar.gz gnunet-ac71165822501c42b00980db2fb7f5e2144f3d20.zip |
- fixed bug in tcp com challenge logic. added test case for bidirectional test.
Diffstat (limited to 'src/transport/test_communicator_basic.c')
-rw-r--r-- | src/transport/test_communicator_basic.c | 570 |
1 files changed, 351 insertions, 219 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index 0250de474..ffc21e47a 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | #define NUM_PEERS 2 | 43 | #define NUM_PEERS 2 |
44 | 44 | ||
45 | static struct GNUNET_SCHEDULER_Task *to_task; | 45 | static struct GNUNET_SCHEDULER_Task *to_task[NUM_PEERS]; |
46 | 46 | ||
47 | static int queue_est = GNUNET_NO; | 47 | static int queue_est = GNUNET_NO; |
48 | 48 | ||
@@ -59,27 +59,29 @@ static struct GNUNET_STATISTICS_Handle *stats[NUM_PEERS]; | |||
59 | 59 | ||
60 | static char *cfg_peers_name[NUM_PEERS]; | 60 | static char *cfg_peers_name[NUM_PEERS]; |
61 | 61 | ||
62 | static int finished[NUM_PEERS]; | ||
63 | |||
62 | static int ret; | 64 | static int ret; |
63 | 65 | ||
64 | static int bidirect = GNUNET_NO; | 66 | static int bidirect = GNUNET_NO; |
65 | 67 | ||
66 | static size_t long_message_size; | 68 | static size_t long_message_size; |
67 | 69 | ||
68 | static struct GNUNET_TIME_Absolute start_short; | 70 | static struct GNUNET_TIME_Absolute start_short[NUM_PEERS]; |
69 | 71 | ||
70 | static struct GNUNET_TIME_Absolute start_long; | 72 | static struct GNUNET_TIME_Absolute start_long[NUM_PEERS]; |
71 | 73 | ||
72 | static struct GNUNET_TIME_Absolute timeout; | 74 | static struct GNUNET_TIME_Absolute timeout[NUM_PEERS]; |
73 | 75 | ||
74 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc; | 76 | // static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc; |
75 | 77 | ||
76 | static char *communicator_name; | 78 | static char *communicator_name; |
77 | 79 | ||
78 | static char *test_name; | 80 | static char *test_name; |
79 | 81 | ||
80 | static struct GNUNET_STATISTICS_GetHandle *box_stats; | 82 | static struct GNUNET_STATISTICS_GetHandle *box_stats[NUM_PEERS]; |
81 | 83 | ||
82 | static struct GNUNET_STATISTICS_GetHandle *rekey_stats; | 84 | static struct GNUNET_STATISTICS_GetHandle *rekey_stats[NUM_PEERS]; |
83 | 85 | ||
84 | #define TEST_SECTION "test-setup" | 86 | #define TEST_SECTION "test-setup" |
85 | 87 | ||
@@ -97,7 +99,7 @@ static struct GNUNET_STATISTICS_GetHandle *rekey_stats; | |||
97 | 99 | ||
98 | #define PEER_B 1 | 100 | #define PEER_B 1 |
99 | 101 | ||
100 | static unsigned int iterations_left = TOTAL_ITERATIONS; | 102 | static unsigned int iterations_left[NUM_PEERS]; |
101 | 103 | ||
102 | #define TIMEOUT_MULTIPLIER 1 | 104 | #define TIMEOUT_MULTIPLIER 1 |
103 | 105 | ||
@@ -118,11 +120,11 @@ enum TestPhase | |||
118 | TP_SIZE_CHECK | 120 | TP_SIZE_CHECK |
119 | }; | 121 | }; |
120 | 122 | ||
121 | static unsigned int phase_short; | 123 | static unsigned int phase_short[NUM_PEERS]; |
122 | 124 | ||
123 | static unsigned int phase_long; | 125 | static unsigned int phase_long[NUM_PEERS]; |
124 | 126 | ||
125 | static unsigned int phase_size; | 127 | static unsigned int phase_size[NUM_PEERS]; |
126 | 128 | ||
127 | static long long unsigned int allowed_packet_loss_short; | 129 | static long long unsigned int allowed_packet_loss_short; |
128 | 130 | ||
@@ -140,26 +142,23 @@ static struct GNUNET_TIME_Relative delay_short; | |||
140 | 142 | ||
141 | static struct GNUNET_TIME_Relative delay_long; | 143 | static struct GNUNET_TIME_Relative delay_long; |
142 | 144 | ||
143 | static size_t num_sent_short = 0; | 145 | static size_t num_sent_short[NUM_PEERS]; |
144 | |||
145 | static size_t num_sent_long = 0; | ||
146 | |||
147 | static size_t num_sent_size = 0; | ||
148 | 146 | ||
149 | static uint32_t ack = 0; | 147 | static size_t num_sent_long[NUM_PEERS]; |
150 | 148 | ||
151 | static enum TestPhase phase; | 149 | static size_t num_sent_size[NUM_PEERS]; |
152 | 150 | ||
153 | static size_t num_received_short = 0; | 151 | static uint32_t ack[NUM_PEERS]; |
154 | 152 | ||
155 | static size_t num_received_long = 0; | 153 | static enum TestPhase phase[NUM_PEERS]; |
156 | 154 | ||
157 | static size_t num_received_size = 0; | 155 | static size_t num_received_short[NUM_PEERS]; |
158 | 156 | ||
159 | static uint64_t avg_latency = 0; | 157 | static size_t num_received_long[NUM_PEERS]; |
160 | 158 | ||
161 | static struct GNUNET_TIME_Relative duration; | 159 | static size_t num_received_size[NUM_PEERS]; |
162 | 160 | ||
161 | static uint64_t avg_latency[NUM_PEERS]; | ||
163 | 162 | ||
164 | static void | 163 | static void |
165 | communicator_available_cb ( | 164 | communicator_available_cb ( |
@@ -284,43 +283,87 @@ make_payload (size_t payload_size) | |||
284 | return payload; | 283 | return payload; |
285 | } | 284 | } |
286 | 285 | ||
286 | static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | ||
287 | get_tc_h (unsigned int peer_nr) | ||
288 | { | ||
289 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
290 | "Got peer %u\n", | ||
291 | peer_nr); | ||
292 | |||
293 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
294 | "Handle %p peer 0\n", | ||
295 | tc_hs[0]); | ||
296 | |||
297 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
298 | "Handle %p peer 1\n", | ||
299 | tc_hs[1]); | ||
300 | |||
301 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
302 | "Handle %p get\n", | ||
303 | tc_hs[peer_nr]); | ||
304 | |||
305 | return tc_hs[peer_nr]; | ||
306 | } | ||
307 | |||
308 | |||
309 | static unsigned int | ||
310 | get_peer_nr_from_tc (struct | ||
311 | GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | ||
312 | { | ||
313 | if (tc_h == get_tc_h (0)) | ||
314 | return PEER_A; | ||
315 | else | ||
316 | return PEER_B; | ||
317 | } | ||
318 | |||
319 | static unsigned int | ||
320 | get_peer_nr (void *cls, unsigned int get_the_other_one) | ||
321 | { | ||
322 | if (0 == strcmp ((char*) cls, cfg_peers_name[0])) | ||
323 | return get_the_other_one ? PEER_B : PEER_A; | ||
324 | else | ||
325 | return get_the_other_one ? PEER_A : PEER_B; | ||
326 | } | ||
287 | 327 | ||
288 | static void | 328 | static void |
289 | latency_timeout (void *cls) | 329 | latency_timeout (void *cls) |
290 | { | 330 | { |
291 | 331 | ||
332 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
333 | unsigned int peer_nr; | ||
292 | size_t num_sent = 0; | 334 | size_t num_sent = 0; |
293 | size_t num_received = 0; | 335 | size_t num_received = 0; |
294 | 336 | ||
295 | to_task = NULL; | 337 | peer_nr = get_peer_nr_from_tc (tc_h); |
296 | if (GNUNET_TIME_absolute_get_remaining (timeout).rel_value_us > 0) | 338 | to_task[peer_nr] = NULL; |
339 | if (GNUNET_TIME_absolute_get_remaining (timeout[peer_nr]).rel_value_us > 0) | ||
297 | { | 340 | { |
298 | to_task = GNUNET_SCHEDULER_add_at (timeout, | 341 | to_task[peer_nr] = GNUNET_SCHEDULER_add_at (timeout[peer_nr], |
299 | &latency_timeout, | 342 | &latency_timeout, |
300 | NULL); | 343 | cls); |
301 | return; | 344 | return; |
302 | } | 345 | } |
303 | switch (phase) | 346 | switch (phase[peer_nr]) |
304 | { | 347 | { |
305 | case TP_INIT: | 348 | case TP_INIT: |
306 | GNUNET_assert (0); | 349 | GNUNET_assert (0); |
307 | break; | 350 | break; |
308 | case TP_BURST_SHORT: | 351 | case TP_BURST_SHORT: |
309 | num_sent = num_sent_short; | 352 | num_sent = num_sent_short[peer_nr]; |
310 | num_received = num_received_short; | 353 | num_received = num_received_short[peer_nr]; |
311 | break; | 354 | break; |
312 | case TP_BURST_LONG: | 355 | case TP_BURST_LONG: |
313 | num_sent = num_sent_long; | 356 | num_sent = num_sent_long[peer_nr]; |
314 | num_received = num_received_long; | 357 | num_received = num_received_long[peer_nr]; |
315 | break; | 358 | break; |
316 | case TP_SIZE_CHECK: | 359 | case TP_SIZE_CHECK: |
317 | num_sent = num_sent_size; | 360 | num_sent = num_sent_size[peer_nr]; |
318 | num_received = num_received_size; | 361 | num_received = num_received_size[peer_nr]; |
319 | break; | 362 | break; |
320 | } | 363 | } |
321 | LOG (GNUNET_ERROR_TYPE_ERROR, | 364 | LOG (GNUNET_ERROR_TYPE_ERROR, |
322 | "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n", | 365 | "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n", |
323 | phase, num_sent, num_received); | 366 | phase[peer_nr], num_sent, num_received); |
324 | ret = 2; | 367 | ret = 2; |
325 | GNUNET_SCHEDULER_shutdown (); | 368 | GNUNET_SCHEDULER_shutdown (); |
326 | } | 369 | } |
@@ -328,31 +371,36 @@ latency_timeout (void *cls) | |||
328 | static void | 371 | static void |
329 | size_test (void *cls) | 372 | size_test (void *cls) |
330 | { | 373 | { |
374 | unsigned int peer_nr; | ||
331 | char *payload; | 375 | char *payload; |
332 | size_t max_size = 64000; | 376 | size_t max_size = 64000; |
377 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
333 | 378 | ||
379 | peer_nr = get_peer_nr_from_tc (tc_h); | ||
334 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 380 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
335 | "size_test_cb %u\n", | 381 | "size_test_cb %u\n", |
336 | (unsigned int) num_sent_size); | 382 | (unsigned int) num_sent_size[peer_nr]); |
337 | GNUNET_assert (TP_SIZE_CHECK == phase); | 383 | GNUNET_assert (TP_SIZE_CHECK == phase[peer_nr]); |
338 | if (LONG_MESSAGE_SIZE != long_message_size) | 384 | if (LONG_MESSAGE_SIZE != long_message_size) |
339 | max_size = long_message_size; | 385 | max_size = long_message_size; |
340 | if (ack + 10 > max_size) | 386 | if (ack[peer_nr] + 10 > max_size) |
341 | return; /* Leave some room for our protocol, so not 2^16 exactly */ | 387 | return; /* Leave some room for our protocol, so not 2^16 exactly */ |
342 | ack += 10; | 388 | ack[peer_nr] += 10; |
343 | payload = make_payload (ack); | 389 | payload = make_payload (ack[peer_nr]); |
344 | num_sent_size++; | 390 | num_sent_size[peer_nr]++; |
345 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 391 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, |
346 | (ack < max_size) | 392 | (ack[peer_nr] < |
393 | max_size) | ||
347 | ? &size_test | 394 | ? &size_test |
348 | : NULL, | 395 | : NULL, |
349 | NULL, | 396 | cls, |
350 | payload, | 397 | payload, |
351 | ack); | 398 | ack[peer_nr]); |
352 | GNUNET_free (payload); | 399 | GNUNET_free (payload); |
353 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( | 400 | timeout[peer_nr] = GNUNET_TIME_relative_to_absolute ( |
354 | GNUNET_TIME_UNIT_SECONDS, | 401 | GNUNET_TIME_relative_multiply ( |
355 | TIMEOUT_MULTIPLIER)); | 402 | GNUNET_TIME_UNIT_SECONDS, |
403 | TIMEOUT_MULTIPLIER)); | ||
356 | } | 404 | } |
357 | 405 | ||
358 | 406 | ||
@@ -362,24 +410,28 @@ long_test (void *cls); | |||
362 | static void | 410 | static void |
363 | long_test_cb (void *cls) | 411 | long_test_cb (void *cls) |
364 | { | 412 | { |
413 | unsigned int peer_nr; | ||
365 | char *payload; | 414 | char *payload; |
415 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
416 | |||
417 | peer_nr = get_peer_nr_from_tc (tc_h); | ||
366 | 418 | ||
367 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 419 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
368 | "long_test_cb %u/%u\n", | 420 | "long_test_cb %u/%u\n", |
369 | (unsigned int) num_sent_long, | 421 | (unsigned int) num_sent_long[peer_nr], |
370 | (unsigned int) num_received_long); | 422 | (unsigned int) num_received_long[peer_nr]); |
371 | payload = make_payload (long_message_size); | 423 | payload = make_payload (long_message_size); |
372 | num_sent_long++; | 424 | num_sent_long[peer_nr]++; |
373 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 425 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, |
374 | (burst_packets_long == | 426 | (burst_packets_long == |
375 | num_sent_long) | 427 | num_sent_long[peer_nr]) |
376 | ? NULL | 428 | ? NULL |
377 | : &long_test, | 429 | : &long_test, |
378 | NULL, | 430 | cls, |
379 | payload, | 431 | payload, |
380 | long_message_size); | 432 | long_message_size); |
381 | GNUNET_free (payload); | 433 | GNUNET_free (payload); |
382 | timeout = GNUNET_TIME_relative_to_absolute ( | 434 | timeout[peer_nr] = GNUNET_TIME_relative_to_absolute ( |
383 | GNUNET_TIME_relative_multiply ( | 435 | GNUNET_TIME_relative_multiply ( |
384 | GNUNET_TIME_UNIT_SECONDS, | 436 | GNUNET_TIME_UNIT_SECONDS, |
385 | TIMEOUT_MULTIPLIER)); | 437 | TIMEOUT_MULTIPLIER)); |
@@ -391,7 +443,7 @@ long_test (void *cls) | |||
391 | { | 443 | { |
392 | GNUNET_SCHEDULER_add_delayed (delay_long, | 444 | GNUNET_SCHEDULER_add_delayed (delay_long, |
393 | &long_test_cb, | 445 | &long_test_cb, |
394 | NULL); | 446 | cls); |
395 | } | 447 | } |
396 | 448 | ||
397 | 449 | ||
@@ -402,26 +454,33 @@ short_test (void *cls); | |||
402 | static void | 454 | static void |
403 | short_test_cb (void *cls) | 455 | short_test_cb (void *cls) |
404 | { | 456 | { |
457 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
458 | unsigned int peer_nr; | ||
405 | char *payload; | 459 | char *payload; |
406 | 460 | ||
461 | peer_nr = get_peer_nr_from_tc (tc_h); | ||
462 | |||
407 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 463 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
408 | "short_test_cb %u/%u\n", | 464 | "short_test_cb %u/%u for peer %u and handle %p\n", |
409 | (unsigned int) num_sent_short, | 465 | (unsigned int) num_sent_short[peer_nr], |
410 | (unsigned int) num_received_short); | 466 | (unsigned int) num_received_short[peer_nr], |
467 | peer_nr, | ||
468 | tc_h); | ||
411 | payload = make_payload (SHORT_MESSAGE_SIZE); | 469 | payload = make_payload (SHORT_MESSAGE_SIZE); |
412 | num_sent_short++; | 470 | num_sent_short[peer_nr]++; |
413 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 471 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_h, |
414 | (burst_packets_short == | 472 | (burst_packets_short == |
415 | num_sent_short) | 473 | num_sent_short[peer_nr]) |
416 | ? NULL | 474 | ? NULL |
417 | : &short_test, | 475 | : &short_test, |
418 | NULL, | 476 | cls, |
419 | payload, | 477 | payload, |
420 | SHORT_MESSAGE_SIZE); | 478 | SHORT_MESSAGE_SIZE); |
421 | GNUNET_free (payload); | 479 | GNUNET_free (payload); |
422 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( | 480 | timeout[peer_nr] = GNUNET_TIME_relative_to_absolute ( |
423 | GNUNET_TIME_UNIT_SECONDS, | 481 | GNUNET_TIME_relative_multiply ( |
424 | TIMEOUT_MULTIPLIER)); | 482 | GNUNET_TIME_UNIT_SECONDS, |
483 | TIMEOUT_MULTIPLIER)); | ||
425 | } | 484 | } |
426 | 485 | ||
427 | 486 | ||
@@ -430,7 +489,7 @@ short_test (void *cls) | |||
430 | { | 489 | { |
431 | GNUNET_SCHEDULER_add_delayed (delay_short, | 490 | GNUNET_SCHEDULER_add_delayed (delay_short, |
432 | &short_test_cb, | 491 | &short_test_cb, |
433 | NULL); | 492 | cls); |
434 | } | 493 | } |
435 | 494 | ||
436 | 495 | ||
@@ -462,9 +521,14 @@ short_test (void *cls) | |||
462 | static void | 521 | static void |
463 | process_statistics_box_done (void *cls, int success) | 522 | process_statistics_box_done (void *cls, int success) |
464 | { | 523 | { |
465 | if (NULL != box_stats) | 524 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
466 | box_stats = NULL; | 525 | unsigned int peer_nr; |
467 | if (NULL == rekey_stats) | 526 | |
527 | peer_nr = get_peer_nr_from_tc (tc_h); | ||
528 | |||
529 | if (NULL != box_stats[peer_nr]) | ||
530 | box_stats[peer_nr] = NULL; | ||
531 | if (NULL == rekey_stats[peer_nr]) | ||
468 | { | 532 | { |
469 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 533 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
470 | "Finished\n"); | 534 | "Finished\n"); |
@@ -476,9 +540,14 @@ process_statistics_box_done (void *cls, int success) | |||
476 | static void | 540 | static void |
477 | process_statistics_rekey_done (void *cls, int success) | 541 | process_statistics_rekey_done (void *cls, int success) |
478 | { | 542 | { |
479 | if (NULL != rekey_stats) | 543 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
480 | rekey_stats = NULL; | 544 | unsigned int peer_nr; |
481 | if (NULL == box_stats) | 545 | |
546 | peer_nr = get_peer_nr_from_tc (tc_h); | ||
547 | |||
548 | if (NULL != rekey_stats[peer_nr]) | ||
549 | rekey_stats[peer_nr] = NULL; | ||
550 | if (NULL == box_stats[peer_nr]) | ||
482 | { | 551 | { |
483 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 552 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
484 | "Finished\n"); | 553 | "Finished\n"); |
@@ -533,24 +602,37 @@ process_statistics (void *cls, | |||
533 | } | 602 | } |
534 | 603 | ||
535 | static void | 604 | static void |
536 | choose_phase () | 605 | choose_phase (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) |
537 | { | 606 | { |
538 | if (GNUNET_YES == phase_short) | 607 | unsigned int peer_nr; |
608 | |||
609 | peer_nr = get_peer_nr_from_tc (tc_h); | ||
610 | |||
611 | if (GNUNET_YES == phase_short[peer_nr]) | ||
539 | { | 612 | { |
540 | phase = TP_BURST_SHORT; | 613 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
541 | start_short = GNUNET_TIME_absolute_get (); | 614 | "Choose phase short with peer %u and Handle %p\n", |
542 | short_test (NULL); | 615 | peer_nr, |
616 | tc_h); | ||
617 | phase[peer_nr] = TP_BURST_SHORT; | ||
618 | start_short[peer_nr] = GNUNET_TIME_absolute_get (); | ||
619 | short_test (tc_h); | ||
543 | } | 620 | } |
544 | else if (GNUNET_YES == phase_long) | 621 | else if (GNUNET_YES == phase_long[peer_nr]) |
545 | { | 622 | { |
546 | phase = TP_BURST_LONG; | 623 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
547 | start_long = GNUNET_TIME_absolute_get (); | 624 | "Choose phase long with peer %u\n", |
548 | long_test (NULL); | 625 | peer_nr); |
626 | phase[peer_nr] = TP_BURST_LONG; | ||
627 | start_long[peer_nr] = GNUNET_TIME_absolute_get (); | ||
628 | long_test (tc_h); | ||
549 | } | 629 | } |
550 | else if (GNUNET_YES == phase_size) | 630 | else if (GNUNET_YES == phase_size[peer_nr]) |
551 | { | 631 | { |
552 | phase = TP_SIZE_CHECK; | 632 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
553 | size_test (NULL); | 633 | "Choose phase size\n"); |
634 | phase[peer_nr] = TP_SIZE_CHECK; | ||
635 | size_test (tc_h); | ||
554 | } | 636 | } |
555 | else | 637 | else |
556 | { | 638 | { |
@@ -560,28 +642,33 @@ choose_phase () | |||
560 | "backchannel", | 642 | "backchannel", |
561 | test_name))) ) | 643 | test_name))) ) |
562 | { | 644 | { |
563 | if (NULL != box_stats) | 645 | if (NULL != box_stats[peer_nr]) |
564 | GNUNET_STATISTICS_get_cancel (box_stats); | 646 | GNUNET_STATISTICS_get_cancel (box_stats[peer_nr]); |
565 | box_stats = GNUNET_STATISTICS_get (stats[1], | 647 | box_stats[peer_nr] = GNUNET_STATISTICS_get (stats[1], |
566 | "C-UDP", | 648 | "C-UDP", |
567 | "# messages decrypted with BOX", | 649 | "# messages decrypted with BOX", |
568 | process_statistics_box_done, | 650 | process_statistics_box_done, |
569 | &process_statistics, | 651 | &process_statistics, |
570 | NULL); | 652 | tc_h); |
571 | if (NULL != rekey_stats) | 653 | if (NULL != rekey_stats[peer_nr]) |
572 | GNUNET_STATISTICS_get_cancel (rekey_stats); | 654 | GNUNET_STATISTICS_get_cancel (rekey_stats[peer_nr]); |
573 | rekey_stats = GNUNET_STATISTICS_get (stats[0], | 655 | rekey_stats[peer_nr] = GNUNET_STATISTICS_get (stats[0], |
574 | "C-UDP", | 656 | "C-UDP", |
575 | "# rekeying successful", | 657 | "# rekeying successful", |
576 | process_statistics_rekey_done, | 658 | process_statistics_rekey_done, |
577 | &process_statistics, | 659 | &process_statistics, |
578 | NULL); | 660 | tc_h); |
579 | } | 661 | } |
580 | else | 662 | else |
581 | { | 663 | { |
582 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 664 | if (((PEER_A == peer_nr) && finished[PEER_B]) || ((PEER_B == peer_nr) && |
583 | "Finished\n"); | 665 | finished[PEER_A])) |
584 | GNUNET_SCHEDULER_shutdown (); | 666 | { |
667 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
668 | "Finished\n"); | ||
669 | GNUNET_SCHEDULER_shutdown (); | ||
670 | } | ||
671 | finished[peer_nr] = GNUNET_YES; | ||
585 | } | 672 | } |
586 | } | 673 | } |
587 | } | 674 | } |
@@ -604,37 +691,54 @@ add_queue_cb (void *cls, | |||
604 | tc_queue, | 691 | tc_queue, |
605 | size_t mtu) | 692 | size_t mtu) |
606 | { | 693 | { |
607 | if (TP_INIT != phase) | 694 | |
608 | return; | 695 | unsigned int peer_nr; |
609 | if (0 != strcmp ((char*) cls, cfg_peers_name[0])) | 696 | |
697 | peer_nr = get_peer_nr (cls, GNUNET_NO); | ||
698 | |||
699 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
700 | "Handle %p add %u %u\n", | ||
701 | tc_h, | ||
702 | peer_nr, | ||
703 | get_peer_nr_from_tc (tc_h)); | ||
704 | |||
705 | if ((GNUNET_NO == bidirect)&&(0 != strcmp ((char*) cls, cfg_peers_name[0]))) | ||
706 | { | ||
707 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
708 | "Queue available at receiving peer\n"); | ||
610 | return; // TODO? | 709 | return; // TODO? |
710 | } | ||
711 | else if (TP_INIT != phase[peer_nr]) | ||
712 | return; | ||
611 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 713 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
612 | "Queue established, starting test...\n"); | 714 | "Queue established, starting test...\n"); |
613 | // start_short = GNUNET_TIME_absolute_get (); | 715 | // start_short = GNUNET_TIME_absolute_get (); |
614 | my_tc = tc_h; | 716 | // my_tc = tc_h; |
615 | if (0 != mtu) /* Message header overhead */ | 717 | if (0 != mtu) /* Message header overhead */ |
616 | long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) | 718 | long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) |
617 | - sizeof(struct GNUNET_MessageHeader); | 719 | - sizeof(struct GNUNET_MessageHeader); |
618 | else | 720 | else |
619 | long_message_size = LONG_MESSAGE_SIZE; | 721 | long_message_size = LONG_MESSAGE_SIZE; |
620 | // phase = TP_BURST_SHORT; | 722 | // phase = TP_BURST_SHORT; |
621 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( | 723 | timeout[peer_nr] = GNUNET_TIME_relative_to_absolute ( |
622 | GNUNET_TIME_UNIT_SECONDS, | 724 | GNUNET_TIME_relative_multiply ( |
623 | TIMEOUT_MULTIPLIER)); | 725 | GNUNET_TIME_UNIT_SECONDS, |
624 | GNUNET_assert (NULL == to_task); | 726 | TIMEOUT_MULTIPLIER)); |
625 | to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( | 727 | GNUNET_assert (NULL == to_task[peer_nr]); |
626 | GNUNET_TIME_UNIT_SECONDS, | 728 | to_task[peer_nr] = GNUNET_SCHEDULER_add_delayed ( |
627 | TIMEOUT_MULTIPLIER), | 729 | GNUNET_TIME_relative_multiply ( |
628 | &latency_timeout, | 730 | GNUNET_TIME_UNIT_SECONDS, |
629 | NULL); | 731 | TIMEOUT_MULTIPLIER), |
732 | &latency_timeout, | ||
733 | tc_h); | ||
630 | // prepare_test (NULL); | 734 | // prepare_test (NULL); |
631 | // short_test (NULL); | 735 | // short_test (NULL); |
632 | choose_phase (); | 736 | choose_phase (tc_h); |
633 | } | 737 | } |
634 | 738 | ||
635 | 739 | ||
636 | static void | 740 | static void |
637 | update_avg_latency (const char*payload) | 741 | update_avg_latency (const char *payload, unsigned int peer_nr) |
638 | { | 742 | { |
639 | struct GNUNET_TIME_AbsoluteNBO *ts_n; | 743 | struct GNUNET_TIME_AbsoluteNBO *ts_n; |
640 | struct GNUNET_TIME_Absolute ts; | 744 | struct GNUNET_TIME_Absolute ts; |
@@ -645,31 +749,33 @@ update_avg_latency (const char*payload) | |||
645 | ts = GNUNET_TIME_absolute_ntoh (*ts_n); | 749 | ts = GNUNET_TIME_absolute_ntoh (*ts_n); |
646 | latency = GNUNET_TIME_absolute_get_duration (ts); | 750 | latency = GNUNET_TIME_absolute_get_duration (ts); |
647 | 751 | ||
648 | switch (phase) | 752 | switch (phase[peer_nr]) |
649 | { | 753 | { |
650 | case TP_INIT: | 754 | case TP_INIT: |
651 | GNUNET_assert (0); | 755 | GNUNET_assert (0); |
652 | break; | 756 | break; |
653 | case TP_BURST_SHORT: | 757 | case TP_BURST_SHORT: |
654 | num_received = num_received_short; | 758 | num_received = num_received_short[peer_nr]; |
655 | break; | 759 | break; |
656 | case TP_BURST_LONG: | 760 | case TP_BURST_LONG: |
657 | num_received = num_received_long; | 761 | num_received = num_received_long[peer_nr]; |
658 | break; | 762 | break; |
659 | case TP_SIZE_CHECK: | 763 | case TP_SIZE_CHECK: |
660 | num_received = num_received_size; | 764 | num_received = num_received_size[peer_nr]; |
661 | break; | 765 | break; |
662 | } | 766 | } |
663 | if (1 >= num_received) | 767 | if (1 >= num_received) |
664 | avg_latency = latency.rel_value_us; | 768 | avg_latency[peer_nr] = latency.rel_value_us; |
665 | else | 769 | else |
666 | avg_latency = ((avg_latency * (num_received - 1)) + latency.rel_value_us) | 770 | avg_latency[peer_nr] = ((avg_latency[peer_nr] * (num_received - 1)) |
667 | / num_received; | 771 | + latency.rel_value_us) |
772 | / num_received; | ||
668 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 773 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
669 | "Latency of received packet: %s with avg latency %lu\n", | 774 | "Latency of received packet by peer %u: %s with avg latency %lu\n", |
775 | peer_nr, | ||
670 | GNUNET_STRINGS_relative_time_to_string (latency, | 776 | GNUNET_STRINGS_relative_time_to_string (latency, |
671 | GNUNET_YES), | 777 | GNUNET_YES), |
672 | avg_latency); | 778 | avg_latency[peer_nr]); |
673 | } | 779 | } |
674 | 780 | ||
675 | 781 | ||
@@ -679,25 +785,31 @@ static void | |||
679 | load_phase_config () | 785 | load_phase_config () |
680 | { | 786 | { |
681 | 787 | ||
682 | phase_short = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0], | 788 | phase_short[0] = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0], |
683 | TEST_SECTION, | 789 | TEST_SECTION, |
684 | "PHASE_SHORT"); | 790 | "PHASE_SHORT"); |
685 | if (GNUNET_SYSERR == phase_short) | 791 | if (GNUNET_SYSERR == phase_short[0]) |
686 | phase_short = GNUNET_YES; | 792 | phase_short[0] = GNUNET_YES; |
687 | 793 | ||
688 | phase_long = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0], | 794 | phase_short[1] = phase_short[0]; |
689 | TEST_SECTION, | ||
690 | "PHASE_LONG"); | ||
691 | 795 | ||
692 | if (GNUNET_SYSERR == phase_long) | 796 | phase_long[0] = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0], |
693 | phase_long = GNUNET_YES; | 797 | TEST_SECTION, |
798 | "PHASE_LONG"); | ||
694 | 799 | ||
695 | phase_size = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0], | 800 | if (GNUNET_SYSERR == phase_long[0]) |
696 | TEST_SECTION, | 801 | phase_long[0] = GNUNET_YES; |
697 | "PHASE_SIZE"); | ||
698 | 802 | ||
699 | if (GNUNET_SYSERR == phase_size) | 803 | phase_long[1] = phase_long[0]; |
700 | phase_size = GNUNET_YES; | 804 | |
805 | phase_size[0] = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0], | ||
806 | TEST_SECTION, | ||
807 | "PHASE_SIZE"); | ||
808 | |||
809 | if (GNUNET_SYSERR == phase_size[0]) | ||
810 | phase_size[0] = GNUNET_YES; | ||
811 | |||
812 | phase_size[1] = phase_size[0]; | ||
701 | } | 813 | } |
702 | 814 | ||
703 | /** | 815 | /** |
@@ -716,18 +828,24 @@ incoming_message_cb ( | |||
716 | const char *payload, | 828 | const char *payload, |
717 | size_t payload_len) | 829 | size_t payload_len) |
718 | { | 830 | { |
719 | if (0 != strcmp ((char*) cls, | 831 | unsigned int peer_nr; |
720 | cfg_peers_name[NUM_PEERS - 1])) | 832 | static struct GNUNET_TIME_Relative duration; |
833 | |||
834 | peer_nr = get_peer_nr (cls, GNUNET_YES); | ||
835 | |||
836 | if ((GNUNET_NO == bidirect)&&(0 != strcmp ((char*) cls, | ||
837 | cfg_peers_name[NUM_PEERS - 1]))) | ||
721 | { | 838 | { |
722 | LOG (GNUNET_ERROR_TYPE_WARNING, | 839 | LOG (GNUNET_ERROR_TYPE_WARNING, |
723 | "unexpected receiver...\n"); | 840 | "unexpected receiver...\n"); |
724 | return; | 841 | return; |
725 | } | 842 | } |
726 | /* Reset timeout */ | 843 | /* Reset timeout */ |
727 | timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( | 844 | timeout[peer_nr] = GNUNET_TIME_relative_to_absolute ( |
728 | GNUNET_TIME_UNIT_SECONDS, | 845 | GNUNET_TIME_relative_multiply ( |
729 | TIMEOUT_MULTIPLIER)); | 846 | GNUNET_TIME_UNIT_SECONDS, |
730 | switch (phase) | 847 | TIMEOUT_MULTIPLIER)); |
848 | switch (phase[peer_nr]) | ||
731 | { | 849 | { |
732 | case TP_INIT: | 850 | case TP_INIT: |
733 | GNUNET_break (0); | 851 | GNUNET_break (0); |
@@ -735,34 +853,37 @@ incoming_message_cb ( | |||
735 | case TP_BURST_SHORT: | 853 | case TP_BURST_SHORT: |
736 | { | 854 | { |
737 | GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); | 855 | GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); |
738 | num_received_short++; | 856 | num_received_short[peer_nr]++; |
739 | duration = GNUNET_TIME_absolute_get_duration (start_short); | 857 | duration = GNUNET_TIME_absolute_get_duration (start_short[peer_nr]); |
740 | update_avg_latency (payload); | 858 | update_avg_latency (payload, peer_nr); |
741 | if ((num_sent_short == burst_packets_short) && (num_received_short > | 859 | if ((num_sent_short[peer_nr] == burst_packets_short) && |
742 | burst_packets_short / 100 | 860 | (num_received_short[peer_nr] > |
743 | * | 861 | burst_packets_short |
744 | allowed_packet_loss_short) ) | 862 | / 100 |
863 | * | ||
864 | allowed_packet_loss_short) ) | ||
745 | { | 865 | { |
746 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 866 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
747 | "Short size packet test done.\n"); | 867 | "Short size packet test for peer %u done.\n", |
868 | peer_nr); | ||
748 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( | 869 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( |
749 | (SHORT_MESSAGE_SIZE * num_received_short * 1000 * 1000) | 870 | (SHORT_MESSAGE_SIZE * num_received_short[peer_nr] * 1000 * 1000) |
750 | / duration.rel_value_us); | 871 | / duration.rel_value_us); |
751 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 872 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
752 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 873 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
753 | (unsigned long) num_received_short, | 874 | (unsigned long) num_received_short[peer_nr], |
754 | (unsigned long) num_sent_short, | 875 | (unsigned long) num_sent_short[peer_nr], |
755 | (unsigned long long) duration.rel_value_us, | 876 | (unsigned long long) duration.rel_value_us, |
756 | goodput, | 877 | goodput, |
757 | (unsigned long long) avg_latency); | 878 | (unsigned long long) avg_latency[peer_nr]); |
758 | GNUNET_free (goodput); | 879 | GNUNET_free (goodput); |
759 | // start_long = GNUNET_TIME_absolute_get (); | 880 | // start_long = GNUNET_TIME_absolute_get (); |
760 | // phase = TP_BURST_LONG; | 881 | // phase = TP_BURST_LONG; |
761 | // num_sent_short = 0; | 882 | // num_sent_short = 0; |
762 | avg_latency = 0; | 883 | avg_latency[peer_nr] = 0; |
763 | // num_received = 0; | 884 | // num_received = 0; |
764 | phase_short = GNUNET_NO; | 885 | phase_short[peer_nr] = GNUNET_NO; |
765 | choose_phase (); | 886 | choose_phase (get_tc_h (peer_nr)); |
766 | // long_test (NULL); | 887 | // long_test (NULL); |
767 | } | 888 | } |
768 | break; | 889 | break; |
@@ -775,37 +896,40 @@ incoming_message_cb ( | |||
775 | "Ignoring packet with wrong length\n"); | 896 | "Ignoring packet with wrong length\n"); |
776 | return; // Ignore | 897 | return; // Ignore |
777 | } | 898 | } |
778 | num_received_long++; | 899 | num_received_long[peer_nr]++; |
779 | duration = GNUNET_TIME_absolute_get_duration (start_long); | 900 | duration = GNUNET_TIME_absolute_get_duration (start_long[peer_nr]); |
780 | update_avg_latency (payload); | 901 | update_avg_latency (payload, peer_nr); |
781 | if ((num_sent_long == burst_packets_long) && (num_received_long > | 902 | if ((num_sent_long[peer_nr] == burst_packets_long) && |
782 | burst_packets_long | 903 | (num_received_long[peer_nr] > |
783 | / 100 | 904 | burst_packets_long |
784 | * allowed_packet_loss_short) ) | 905 | / 100 |
906 | * | ||
907 | allowed_packet_loss_short) ) | ||
785 | { | 908 | { |
786 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 909 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
787 | "Long size packet test done.\n"); | 910 | "Long size packet test for peer %u done.\n", |
911 | peer_nr); | ||
788 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( | 912 | char *goodput = GNUNET_STRINGS_byte_size_fancy ( |
789 | (long_message_size * num_received_long * 1000 * 1000) | 913 | (long_message_size * num_received_long[peer_nr] * 1000 * 1000) |
790 | / duration. | 914 | / duration. |
791 | rel_value_us); | 915 | rel_value_us); |
792 | 916 | ||
793 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 917 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
794 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", | 918 | "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", |
795 | (unsigned long) num_received_long, | 919 | (unsigned long) num_received_long[peer_nr], |
796 | (unsigned long) num_sent_long, | 920 | (unsigned long) num_sent_long[peer_nr], |
797 | (unsigned long long) duration.rel_value_us, | 921 | (unsigned long long) duration.rel_value_us, |
798 | goodput, | 922 | goodput, |
799 | (unsigned long long) avg_latency); | 923 | (unsigned long long) avg_latency[peer_nr]); |
800 | GNUNET_free (goodput); | 924 | GNUNET_free (goodput); |
801 | ack = 0; | 925 | ack[peer_nr] = 0; |
802 | // phase = TP_SIZE_CHECK; | 926 | // phase = TP_SIZE_CHECK; |
803 | // num_received = 0; | 927 | // num_received = 0; |
804 | // num_sent_long = 0; | 928 | // num_sent_long = 0; |
805 | avg_latency = 0; | 929 | avg_latency[peer_nr] = 0; |
806 | // size_test (NULL); | 930 | // size_test (NULL); |
807 | phase_long = GNUNET_NO; | 931 | phase_long[peer_nr] = GNUNET_NO; |
808 | choose_phase (); | 932 | choose_phase (get_tc_h (peer_nr)); |
809 | } | 933 | } |
810 | break; | 934 | break; |
811 | } | 935 | } |
@@ -813,39 +937,44 @@ incoming_message_cb ( | |||
813 | { | 937 | { |
814 | size_t max_size = 64000; | 938 | size_t max_size = 64000; |
815 | 939 | ||
816 | GNUNET_assert (TP_SIZE_CHECK == phase); | 940 | GNUNET_assert (TP_SIZE_CHECK == phase[peer_nr]); |
817 | if (LONG_MESSAGE_SIZE != long_message_size) | 941 | if (LONG_MESSAGE_SIZE != long_message_size) |
818 | max_size = long_message_size; | 942 | max_size = long_message_size; |
819 | num_received_size++; | 943 | num_received_size[peer_nr]++; |
820 | update_avg_latency (payload); | 944 | update_avg_latency (payload, peer_nr); |
821 | if (num_received_size >= (max_size) / 10) | 945 | if ((GNUNET_YES == phase_size[peer_nr]) && (num_received_size[peer_nr] >= |
946 | (max_size) / 10) ) | ||
822 | { | 947 | { |
823 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 948 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
824 | "Size packet test done.\n"); | 949 | "Size packet test for peer %u done.\n", |
950 | peer_nr); | ||
825 | LOG (GNUNET_ERROR_TYPE_MESSAGE, | 951 | LOG (GNUNET_ERROR_TYPE_MESSAGE, |
826 | "%lu/%lu packets -- avg latency: %llu us\n", | 952 | "%lu/%lu packets -- avg latency: %llu us\n", |
827 | (unsigned long) num_received_size, | 953 | (unsigned long) num_received_size[peer_nr], |
828 | (unsigned long) num_sent_size, | 954 | (unsigned long) num_sent_size[peer_nr], |
829 | (unsigned long long) avg_latency); | 955 | (unsigned long long) avg_latency[peer_nr]); |
830 | num_received_size = 0; | 956 | iterations_left[peer_nr]--; |
831 | num_sent_size = 0; | 957 | phase_size[peer_nr] = GNUNET_NO; |
832 | avg_latency = 0; | 958 | if (0 != iterations_left[peer_nr]) |
833 | iterations_left--; | ||
834 | if (0 != iterations_left) | ||
835 | { | 959 | { |
836 | // start_short = GNUNET_TIME_absolute_get (); | 960 | // start_short = GNUNET_TIME_absolute_get (); |
837 | // phase = TP_BURST_SHORT; | 961 | // phase = TP_BURST_SHORT; |
838 | num_sent_short = 0; | 962 | num_received_size[peer_nr] = 0; |
839 | num_sent_long = 0; | 963 | num_sent_size[peer_nr] = 0; |
840 | num_received_short = 0; | 964 | avg_latency[peer_nr] = 0; |
841 | num_received_long = 0; | 965 | num_sent_short[peer_nr] = 0; |
966 | num_sent_long[peer_nr] = 0; | ||
967 | num_received_short[peer_nr] = 0; | ||
968 | num_received_long[peer_nr] = 0; | ||
842 | // short_test (NULL); | 969 | // short_test (NULL); |
843 | load_phase_config (); | 970 | if (((PEER_A == peer_nr) && finished[PEER_B]) || ((PEER_B == |
844 | choose_phase (); | 971 | peer_nr) && |
845 | break; | 972 | finished[PEER_A])) |
973 | { | ||
974 | load_phase_config (); | ||
975 | } | ||
846 | } | 976 | } |
847 | phase_size = GNUNET_NO; | 977 | choose_phase (get_tc_h (peer_nr)); |
848 | choose_phase (); | ||
849 | } | 978 | } |
850 | break; | 979 | break; |
851 | } | 980 | } |
@@ -859,23 +988,23 @@ do_shutdown (void *cls) | |||
859 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 988 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
860 | "shuting down test.\n"); | 989 | "shuting down test.\n"); |
861 | 990 | ||
862 | if (NULL != box_stats) | ||
863 | { | ||
864 | GNUNET_STATISTICS_get_cancel (box_stats); | ||
865 | box_stats = NULL; | ||
866 | } | ||
867 | if (NULL != rekey_stats) | ||
868 | { | ||
869 | GNUNET_STATISTICS_get_cancel (rekey_stats); | ||
870 | rekey_stats = NULL; | ||
871 | } | ||
872 | if (NULL != to_task) | ||
873 | { | ||
874 | GNUNET_SCHEDULER_cancel (to_task); | ||
875 | to_task = NULL; | ||
876 | } | ||
877 | for (unsigned int i = 0; i < NUM_PEERS; i++) | 991 | for (unsigned int i = 0; i < NUM_PEERS; i++) |
878 | { | 992 | { |
993 | if (NULL != box_stats[i]) | ||
994 | { | ||
995 | GNUNET_STATISTICS_get_cancel (box_stats[i]); | ||
996 | box_stats[i] = NULL; | ||
997 | } | ||
998 | if (NULL != rekey_stats[i]) | ||
999 | { | ||
1000 | GNUNET_STATISTICS_get_cancel (rekey_stats[i]); | ||
1001 | rekey_stats[i] = NULL; | ||
1002 | } | ||
1003 | if (NULL != to_task[i]) | ||
1004 | { | ||
1005 | GNUNET_SCHEDULER_cancel (to_task[i]); | ||
1006 | to_task[i] = NULL; | ||
1007 | } | ||
879 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (tc_hs[i]); | 1008 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop (tc_hs[i]); |
880 | GNUNET_STATISTICS_destroy (stats[i], GNUNET_NO); | 1009 | GNUNET_STATISTICS_destroy (stats[i], GNUNET_NO); |
881 | } | 1010 | } |
@@ -935,7 +1064,10 @@ main (int argc, | |||
935 | char *test_mode; | 1064 | char *test_mode; |
936 | char *cfg_peer; | 1065 | char *cfg_peer; |
937 | 1066 | ||
938 | phase = TP_INIT; | 1067 | iterations_left[0] = TOTAL_ITERATIONS; |
1068 | iterations_left[1] = TOTAL_ITERATIONS; | ||
1069 | phase[0] = TP_INIT; | ||
1070 | phase[1] = TP_INIT; | ||
939 | ret = 1; | 1071 | ret = 1; |
940 | test_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 1072 | test_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); |
941 | communicator_name = strchr (test_name, '-'); | 1073 | communicator_name = strchr (test_name, '-'); |