aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-10-05 17:34:44 +0000
committerBart Polot <bart@net.in.tum.de>2012-10-05 17:34:44 +0000
commitf5c1b7a3b0ef3f6390de711f19cc2eaa8f420406 (patch)
treead9cbb7f906f6bc078d63747c029ee194a7dc4ba /src
parentb112e2c6f0a0357f9fc0efaa653ecab73f546524 (diff)
downloadgnunet-f5c1b7a3b0ef3f6390de711f19cc2eaa8f420406.tar.gz
gnunet-f5c1b7a3b0ef3f6390de711f19cc2eaa8f420406.zip
- add testcases for heavy traffic leaf to root
Diffstat (limited to 'src')
-rw-r--r--src/mesh/test_mesh_small.c160
1 files changed, 94 insertions, 66 deletions
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c
index 96f448461..85e507338 100644
--- a/src/mesh/test_mesh_small.c
+++ b/src/mesh/test_mesh_small.c
@@ -75,6 +75,11 @@ struct MeshPeer
75static int test; 75static int test;
76 76
77/** 77/**
78 * String with test name
79 */
80char *test_name;
81
82/**
78 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic. 83 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
79 */ 84 */
80static int test_backwards = GNUNET_NO; 85static int test_backwards = GNUNET_NO;
@@ -232,9 +237,27 @@ static GNUNET_PEER_Id pid1;
232 237
233static struct GNUNET_TIME_Absolute start_time; 238static struct GNUNET_TIME_Absolute start_time;
234 239
235static struct GNUNET_TIME_Absolute end_time;
236 240
237static struct GNUNET_TIME_Relative total_time; 241
242static void
243show_end_data (void)
244{
245 static struct GNUNET_TIME_Absolute end_time;
246 static struct GNUNET_TIME_Relative total_time;
247
248 end_time = GNUNET_TIME_absolute_get();
249 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
250 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
251 FPRINTF (stderr, "Test time %llu ms\n",
252 (unsigned long long) total_time.rel_value);
253 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
254 4 * TOTAL_PACKETS * 1.0 / total_time.rel_value); // 4bytes * ms
255 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
256 TOTAL_PACKETS * 1000.0 / total_time.rel_value); // packets * ms
257 GAUGER ("MESH", test_name,
258 TOTAL_PACKETS * 1000.0 / total_time.rel_value,
259 "packets/s");
260}
238 261
239 262
240/** 263/**
@@ -441,73 +464,49 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
441 const struct GNUNET_ATS_Information *atsi) 464 const struct GNUNET_ATS_Information *atsi)
442{ 465{
443 long client = (long) cls; 466 long client = (long) cls;
444 long expected_client; 467 long expected_target_client;
445 struct GNUNET_MESH_Tunnel *tunnel_to_use; 468// struct GNUNET_MESH_Tunnel *tunnel_to_use;
446 struct GNUNET_PeerIdentity *dest_to_use; 469// struct GNUNET_PeerIdentity *dest_to_use;
447
448 if (GNUNET_YES == test_backwards)
449 {
450 expected_client = 1L;
451 dest_to_use = &d1->id;
452 tunnel_to_use = incoming_t;
453 }
454 else
455 {
456 expected_client = 0L;
457 dest_to_use = &d2->id;
458 tunnel_to_use = t;
459 }
460 470
471 ok++;
461 switch (client) 472 switch (client)
462 { 473 {
463 case 1L: 474 case 1L:
464 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a response!\n"); 475 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
465 ok++;
466 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); 476 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
467 peers_responded++; 477 peers_responded++;
468 data_ack++; 478 data_ack++;
469 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
470 {
471 GNUNET_SCHEDULER_cancel (disconnect_task);
472 disconnect_task =
473 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers,
474 NULL);
475 }
476 if (test == MULTICAST && peers_responded < 2) 479 if (test == MULTICAST && peers_responded < 2)
477 return GNUNET_OK; 480 return GNUNET_OK;
478 if (test == SPEED_ACK || test == SPEED)
479 {
480 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
481 " received ack %u\n", data_ack);
482 GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO,
483 GNUNET_TIME_UNIT_FOREVER_REL, sender,
484 sizeof (struct GNUNET_MessageHeader),
485 &tmt_rdy, (void *) 1L);
486 if (data_ack < TOTAL_PACKETS && test != SPEED)
487 return GNUNET_OK;
488 end_time = GNUNET_TIME_absolute_get();
489 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
490 FPRINTF (stderr, "\nTest time %llu ms\n",
491 (unsigned long long) total_time.rel_value);
492 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
493 4 * TOTAL_PACKETS * 1.0 / total_time.rel_value); // 4bytes * ms
494 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
495 TOTAL_PACKETS * 1000.0 / total_time.rel_value); // packets * ms
496 GAUGER ("MESH", "Tunnel 5 peers",
497 TOTAL_PACKETS * 1000.0 / total_time.rel_value,
498 "packets/s");
499 }
500 GNUNET_assert (tunnel == t);
501 GNUNET_MESH_tunnel_destroy (t);
502 t = NULL;
503 break; 481 break;
504 case 2L: 482 case 2L:
505 case 3L: 483 case 3L:
506 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 484 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
507 "Leaf client %u got a message.\n", 485 "Leaf client %li got a message.\n",
508 client); 486 client);
509 ok++;
510 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); 487 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
488 client = 2L;
489 break;
490 default:
491 GNUNET_assert (0);
492 break;
493 }
494
495 if (SPEED == test && GNUNET_YES == test_backwards)
496 {
497 expected_target_client = 1L;
498// dest_to_use = &d1->id;
499// tunnel_to_use = incoming_t;
500 }
501 else
502 {
503 expected_target_client = 2L;
504// dest_to_use = &d2->id;
505// tunnel_to_use = t;
506 }
507
508 if (client == expected_target_client) // Normally 2 or 3
509 {
511 if (SPEED != test || (ok_goal - 2) == ok) 510 if (SPEED != test || (ok_goal - 2) == ok)
512 { 511 {
513 GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, 512 GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO,
@@ -523,21 +522,33 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx,
523 if (data_received < TOTAL_PACKETS) 522 if (data_received < TOTAL_PACKETS)
524 return GNUNET_OK; 523 return GNUNET_OK;
525 } 524 }
526 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 525 }
526 else // Normally 1
527 {
528 if (test == SPEED_ACK || test == SPEED)
527 { 529 {
528 GNUNET_SCHEDULER_cancel (disconnect_task); 530 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
529 disconnect_task = 531 " received ack %u\n", data_ack);
530 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers, 532 GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO,
531 NULL); 533 GNUNET_TIME_UNIT_FOREVER_REL, sender,
534 sizeof (struct GNUNET_MessageHeader),
535 &tmt_rdy, (void *) 1L);
536 if (data_ack < TOTAL_PACKETS && test != SPEED)
537 return GNUNET_OK;
538 show_end_data();
532 } 539 }
533 break; 540 GNUNET_MESH_tunnel_destroy (t);
534 default: 541 t = NULL;
535 break;
536 } 542 }
537 543
538 544 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
539 545 {
540 546 GNUNET_SCHEDULER_cancel (disconnect_task);
547 disconnect_task =
548 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &disconnect_mesh_peers,
549 NULL);
550 }
551
541 return GNUNET_OK; 552 return GNUNET_OK;
542} 553}
543 554
@@ -1063,12 +1074,14 @@ main (int argc, char *argv[])
1063 { 1074 {
1064 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNICAST\n"); 1075 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNICAST\n");
1065 test = UNICAST; 1076 test = UNICAST;
1077 test_name = "unicast";
1066 ok_goal = 5; 1078 ok_goal = 5;
1067 } 1079 }
1068 else if (strstr (argv[0], "test_mesh_small_multicast") != NULL) 1080 else if (strstr (argv[0], "test_mesh_small_multicast") != NULL)
1069 { 1081 {
1070 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MULTICAST\n"); 1082 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MULTICAST\n");
1071 test = MULTICAST; 1083 test = MULTICAST;
1084 test_name = "multicast";
1072 ok_goal = 10; 1085 ok_goal = 10;
1073 } 1086 }
1074 else if (strstr (argv[0], "test_mesh_small_speed_ack") != NULL) 1087 else if (strstr (argv[0], "test_mesh_small_speed_ack") != NULL)
@@ -1084,6 +1097,7 @@ main (int argc, char *argv[])
1084 */ 1097 */
1085 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n"); 1098 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1086 test = SPEED_ACK; 1099 test = SPEED_ACK;
1100 test_name = "speed ack";
1087 ok_goal = TOTAL_PACKETS * 2 + 3; 1101 ok_goal = TOTAL_PACKETS * 2 + 3;
1088 argv2 [3] = NULL; // remove -L DEBUG 1102 argv2 [3] = NULL; // remove -L DEBUG
1089#if VERBOSE 1103#if VERBOSE
@@ -1103,11 +1117,20 @@ main (int argc, char *argv[])
1103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n"); 1117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1104 ok_goal = TOTAL_PACKETS + 4; 1118 ok_goal = TOTAL_PACKETS + 4;
1105 if (strstr (argv[0], "_min") != NULL) 1119 if (strstr (argv[0], "_min") != NULL)
1120 {
1106 test = SPEED_MIN; 1121 test = SPEED_MIN;
1122 test_name = "speed min";
1123 }
1107 else if (strstr (argv[0], "_nobuf") != NULL) 1124 else if (strstr (argv[0], "_nobuf") != NULL)
1125 {
1108 test = SPEED_NOBUF; 1126 test = SPEED_NOBUF;
1127 test_name = "speed nobuf";
1128 }
1109 else 1129 else
1130 {
1110 test = SPEED; 1131 test = SPEED;
1132 test_name = "speed";
1133 }
1111 } 1134 }
1112 else 1135 else
1113 { 1136 {
@@ -1118,8 +1141,13 @@ main (int argc, char *argv[])
1118 1141
1119 if (strstr (argv[0], "backwards") != NULL) 1142 if (strstr (argv[0], "backwards") != NULL)
1120 { 1143 {
1144 char *aux;
1145
1121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n"); 1146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1122 test_backwards = GNUNET_YES; 1147 test_backwards = GNUNET_YES;
1148 aux = malloc (32); // "leaked"
1149 sprintf (aux, "backwards %s", test_name);
1150 test_name = aux;
1123 } 1151 }
1124 1152
1125 GNUNET_PROGRAM_run (argc2, argv2, 1153 GNUNET_PROGRAM_run (argc2, argv2,