aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-06 09:53:12 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-06 09:53:12 +0100
commit90499cabec25be14fb96bb3d62b791c5bf3470c2 (patch)
tree53d00bd5b89793d6ffe3ed80cec7db2e39a340d8 /src
parentcff7a2fe5f78561bb091a96d776cc6e59fed016b (diff)
parent438aca2f666f0e0648f389774adee01c131da25c (diff)
downloadgnunet-90499cabec25be14fb96bb3d62b791c5bf3470c2.tar.gz
gnunet-90499cabec25be14fb96bb3d62b791c5bf3470c2.zip
Merge branch 'master' of git+ssh://gnunet.org/gnunet
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-communicator-tcp.c111
-rw-r--r--src/transport/test_communicator_basic.c456
-rw-r--r--src/transport/test_communicator_tcp_basic_peer1.conf7
-rw-r--r--src/transport/test_communicator_tcp_basic_peer2.conf2
-rw-r--r--src/transport/test_communicator_tcp_rekey_peer2.conf2
-rw-r--r--src/transport/transport-testing-communicator.c1
6 files changed, 388 insertions, 191 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 59f42496a..0c79fc1b4 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -541,6 +541,11 @@ struct Queue
541 enum GNUNET_NetworkType nt; 541 enum GNUNET_NetworkType nt;
542 542
543 /** 543 /**
544 * The connection status of this queue.
545 */
546 enum GNUNET_TRANSPORT_ConnectionStatus cs;
547
548 /**
544 * Is MQ awaiting a #GNUNET_MQ_impl_send_continue() call? 549 * Is MQ awaiting a #GNUNET_MQ_impl_send_continue() call?
545 */ 550 */
546 int mq_awaits_continue; 551 int mq_awaits_continue;
@@ -828,7 +833,8 @@ int addrs_lens;
828/** 833/**
829 * Size of data received without KX challenge played back. 834 * Size of data received without KX challenge played back.
830 */ 835 */
831size_t unverified_size; 836// TODO remove?
837// size_t unverified_size;
832 838
833/** 839/**
834 * Database for peer's HELLOs. 840 * Database for peer's HELLOs.
@@ -1434,6 +1440,9 @@ try_handle_plaintext (struct Queue *queue)
1434 struct TcpHandshakeAckSignature thas; 1440 struct TcpHandshakeAckSignature thas;
1435 const struct ChallengeNonceP challenge = queue->challenge; 1441 const struct ChallengeNonceP challenge = queue->challenge;
1436 1442
1443 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1444 "try handle plaintext!\n");
1445
1437 if ((sizeof(*hdr) > queue->pread_off)) 1446 if ((sizeof(*hdr) > queue->pread_off))
1438 { 1447 {
1439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1441,16 +1450,16 @@ try_handle_plaintext (struct Queue *queue)
1441 return 0; /* not even a header */ 1450 return 0; /* not even a header */
1442 } 1451 }
1443 1452
1444 if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) 1453 /* if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) */
1445 { 1454 /* { */
1446 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1455 /* GNUNET_log (GNUNET_ERROR_TYPE_ERROR, */
1447 "Already received data of size %lu bigger than KX size %lu!\n", 1456 /* "Already received data of size %lu bigger than KX size %lu!\n", */
1448 unverified_size, 1457 /* unverified_size, */
1449 INITIAL_CORE_KX_SIZE); 1458 /* INITIAL_CORE_KX_SIZE); */
1450 GNUNET_break_op (0); 1459 /* GNUNET_break_op (0); */
1451 queue_finish (queue); 1460 /* queue_finish (queue); */
1452 return 0; 1461 /* return 0; */
1453 } 1462 /* } */
1454 1463
1455 type = ntohs (hdr->type); 1464 type = ntohs (hdr->type);
1456 switch (type) 1465 switch (type)
@@ -1513,7 +1522,41 @@ try_handle_plaintext (struct Queue *queue)
1513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1522 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1514 "Handling plaintext, ack processed!"); 1523 "Handling plaintext, ack processed!");
1515 1524
1516 unverified_size = -1; 1525 // unverified_size = -1;
1526
1527 /* char *foreign_addr; */
1528
1529 /* switch (queue->address->sa_family) */
1530 /* { */
1531 /* case AF_INET: */
1532 /* GNUNET_asprintf (&foreign_addr, */
1533 /* "%s-%s", */
1534 /* COMMUNICATOR_ADDRESS_PREFIX, */
1535 /* GNUNET_a2s (queue->address, queue->address_len)); */
1536 /* break; */
1537
1538 /* case AF_INET6: */
1539 /* GNUNET_asprintf (&foreign_addr, */
1540 /* "%s-%s", */
1541 /* COMMUNICATOR_ADDRESS_PREFIX, */
1542 /* GNUNET_a2s (queue->address, queue->address_len)); */
1543 /* break; */
1544
1545 /* default: */
1546 /* GNUNET_assert (0); */
1547 /* } */
1548
1549 /* queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch, */
1550 /* &queue->target, */
1551 /* foreign_addr, */
1552 /* 0 /\* no MTU *\/, */
1553 /* GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, */
1554 /* 0, /\* Priority *\/ */
1555 /* queue->nt, */
1556 /* queue->cs, */
1557 /* queue->mq); */
1558
1559 /* GNUNET_free (foreign_addr); */
1517 1560
1518 size = ntohs (hdr->size); 1561 size = ntohs (hdr->size);
1519 break; 1562 break;
@@ -1590,8 +1633,8 @@ try_handle_plaintext (struct Queue *queue)
1590 return 0; 1633 return 0;
1591 } 1634 }
1592 GNUNET_assert (0 != size); 1635 GNUNET_assert (0 != size);
1593 if (-1 != unverified_size) 1636 /* if (-1 != unverified_size) */
1594 unverified_size += size; 1637 /* unverified_size += size; */
1595 return size; 1638 return size;
1596} 1639}
1597 1640
@@ -2139,11 +2182,12 @@ queue_write (void *cls)
2139 queue->cwrite_off += queue->pwrite_off; 2182 queue->cwrite_off += queue->pwrite_off;
2140 queue->pwrite_off = 0; 2183 queue->pwrite_off = 0;
2141 } 2184 }
2142 if ((-1 != unverified_size)&& ((0 == queue->pwrite_off) && 2185 // if ((-1 != unverified_size)&& ((0 == queue->pwrite_off) &&
2143 ((0 == queue->rekey_left_bytes) || 2186 if (((0 == queue->pwrite_off) &&
2144 (0 == 2187 ((0 == queue->rekey_left_bytes) ||
2145 GNUNET_TIME_absolute_get_remaining ( 2188 (0 ==
2146 queue->rekey_time).rel_value_us)))) 2189 GNUNET_TIME_absolute_get_remaining (
2190 queue->rekey_time).rel_value_us))))
2147 { 2191 {
2148 inject_rekey (queue); 2192 inject_rekey (queue);
2149 } 2193 }
@@ -2282,7 +2326,7 @@ mq_error (void *cls, enum GNUNET_MQ_Error error)
2282 * @param queue queue to boot 2326 * @param queue queue to boot
2283 */ 2327 */
2284static void 2328static void
2285boot_queue (struct Queue *queue, enum GNUNET_TRANSPORT_ConnectionStatus cs) 2329boot_queue (struct Queue *queue)
2286{ 2330{
2287 queue->nt = 2331 queue->nt =
2288 GNUNET_NT_scanner_get_type (is, queue->address, queue->address_len); 2332 GNUNET_NT_scanner_get_type (is, queue->address, queue->address_len);
@@ -2333,7 +2377,7 @@ boot_queue (struct Queue *queue, enum GNUNET_TRANSPORT_ConnectionStatus cs)
2333 GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, 2377 GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED,
2334 0, /* Priority */ 2378 0, /* Priority */
2335 queue->nt, 2379 queue->nt,
2336 cs, 2380 queue->cs,
2337 queue->mq); 2381 queue->mq);
2338 GNUNET_free (foreign_addr); 2382 GNUNET_free (foreign_addr);
2339 } 2383 }
@@ -2557,7 +2601,7 @@ free_proto_queue (struct ProtoQueue *pq)
2557 * @param queue The queue context. 2601 * @param queue The queue context.
2558 */ 2602 */
2559static void 2603static void
2560send_challenge (struct TCPConfirmation tc, struct Queue *queue) 2604send_challenge (struct ChallengeNonceP challenge, struct Queue *queue)
2561{ 2605{
2562 struct TCPConfirmationAck tca; 2606 struct TCPConfirmationAck tca;
2563 struct TcpHandshakeAckSignature thas; 2607 struct TcpHandshakeAckSignature thas;
@@ -2569,7 +2613,7 @@ send_challenge (struct TCPConfirmation tc, struct Queue *queue)
2569 tca.header.type = ntohs ( 2613 tca.header.type = ntohs (
2570 GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK); 2614 GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK);
2571 tca.header.size = ntohs (sizeof(tca)); 2615 tca.header.size = ntohs (sizeof(tca));
2572 tca.challenge = tc.challenge; 2616 tca.challenge = challenge;
2573 tca.sender = my_identity; 2617 tca.sender = my_identity;
2574 tca.monotonic_time = 2618 tca.monotonic_time =
2575 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); 2619 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg));
@@ -2665,7 +2709,8 @@ proto_read_kx (void *cls)
2665 "start kx proto\n"); 2709 "start kx proto\n");
2666 2710
2667 start_initial_kx_out (queue); 2711 start_initial_kx_out (queue);
2668 boot_queue (queue, GNUNET_TRANSPORT_CS_INBOUND); 2712 queue->cs = GNUNET_TRANSPORT_CS_INBOUND;
2713 boot_queue (queue);
2669 queue->read_task = 2714 queue->read_task =
2670 GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2715 GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2671 queue->sock, 2716 queue->sock,
@@ -2676,7 +2721,8 @@ proto_read_kx (void *cls)
2676 queue->sock, 2721 queue->sock,
2677 &queue_write, 2722 &queue_write,
2678 queue); 2723 queue);
2679 send_challenge (tc, queue); 2724 // TODO To early! Move it somewhere else.
2725 // send_challenge (tc, queue);
2680 2726
2681 GNUNET_CONTAINER_DLL_remove (proto_head, proto_tail, pq); 2727 GNUNET_CONTAINER_DLL_remove (proto_head, proto_tail, pq);
2682 GNUNET_free (pq); 2728 GNUNET_free (pq);
@@ -2762,7 +2808,9 @@ queue_read_kx (void *cls)
2762 rcvd = GNUNET_NETWORK_socket_recv (queue->sock, 2808 rcvd = GNUNET_NETWORK_socket_recv (queue->sock,
2763 &queue->cread_buf[queue->cread_off], 2809 &queue->cread_buf[queue->cread_off],
2764 BUF_SIZE - queue->cread_off); 2810 BUF_SIZE - queue->cread_off);
2765 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %lu bytes for KX\n", rcvd); 2811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2812 "Received %lu bytes for KX\n",
2813 rcvd);
2766 if (-1 == rcvd) 2814 if (-1 == rcvd)
2767 { 2815 {
2768 if ((EAGAIN != errno) && (EINTR != errno)) 2816 if ((EAGAIN != errno) && (EINTR != errno))
@@ -2804,14 +2852,20 @@ queue_read_kx (void *cls)
2804 queue_destroy (queue); 2852 queue_destroy (queue);
2805 return; 2853 return;
2806 } 2854 }
2807 send_challenge (tc, queue); 2855 send_challenge (tc.challenge, queue);
2808 /* update queue timeout */ 2856 /* update queue timeout */
2809 reschedule_queue_timeout (queue); 2857 reschedule_queue_timeout (queue);
2810 /* prepare to continue with regular read task immediately */ 2858 /* prepare to continue with regular read task immediately */
2811 memmove (queue->cread_buf, 2859 memmove (queue->cread_buf,
2812 &queue->cread_buf[INITIAL_KX_SIZE], 2860 &queue->cread_buf[INITIAL_KX_SIZE],
2813 queue->cread_off - (INITIAL_KX_SIZE)); 2861 queue->cread_off - (INITIAL_KX_SIZE));
2862 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2863 "cread_off is %lu bytes before adjusting\n",
2864 queue->cread_off);
2814 queue->cread_off -= INITIAL_KX_SIZE; 2865 queue->cread_off -= INITIAL_KX_SIZE;
2866 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2867 "cread_off set to %lu bytes\n",
2868 queue->cread_off);
2815 if (0 < queue->cread_off) 2869 if (0 < queue->cread_off)
2816 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue); 2870 queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue);
2817} 2871}
@@ -2893,7 +2947,8 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2893 queue->address = in; 2947 queue->address = in;
2894 queue->address_len = in_len; 2948 queue->address_len = in_len;
2895 queue->sock = sock; 2949 queue->sock = sock;
2896 boot_queue (queue, GNUNET_TRANSPORT_CS_OUTBOUND); 2950 queue->cs = GNUNET_TRANSPORT_CS_OUTBOUND;
2951 boot_queue (queue);
2897 // queue->mq_awaits_continue = GNUNET_YES; 2952 // queue->mq_awaits_continue = GNUNET_YES;
2898 queue->read_task = 2953 queue->read_task =
2899 GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2954 GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index ea1a7b1fb..0250de474 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -61,6 +61,8 @@ static char *cfg_peers_name[NUM_PEERS];
61 61
62static int ret; 62static int ret;
63 63
64static int bidirect = GNUNET_NO;
65
64static size_t long_message_size; 66static size_t long_message_size;
65 67
66static struct GNUNET_TIME_Absolute start_short; 68static struct GNUNET_TIME_Absolute start_short;
@@ -71,16 +73,22 @@ static struct GNUNET_TIME_Absolute timeout;
71 73
72static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc; 74static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
73 75
76static char *communicator_name;
77
74static char *test_name; 78static char *test_name;
75 79
76static struct GNUNET_STATISTICS_GetHandle *box_stats; 80static struct GNUNET_STATISTICS_GetHandle *box_stats;
77 81
78static struct GNUNET_STATISTICS_GetHandle *rekey_stats; 82static struct GNUNET_STATISTICS_GetHandle *rekey_stats;
79 83
84#define TEST_SECTION "test-setup"
85
80#define SHORT_MESSAGE_SIZE 128 86#define SHORT_MESSAGE_SIZE 128
81 87
82#define LONG_MESSAGE_SIZE 32000 /* FIXME */ 88#define LONG_MESSAGE_SIZE 32000 /* FIXME */
83 89
90#define ALLOWED_PACKET_LOSS 91
91
84#define BURST_PACKETS 5000 92#define BURST_PACKETS 5000
85 93
86#define TOTAL_ITERATIONS 1 94#define TOTAL_ITERATIONS 1
@@ -110,6 +118,27 @@ enum TestPhase
110 TP_SIZE_CHECK 118 TP_SIZE_CHECK
111}; 119};
112 120
121static unsigned int phase_short;
122
123static unsigned int phase_long;
124
125static unsigned int phase_size;
126
127static long long unsigned int allowed_packet_loss_short;
128
129static long long unsigned int allowed_packet_loss_long;
130
131static long long unsigned int burst_packets_short;
132
133static long long unsigned int burst_packets_long;
134
135static long long unsigned int delay_long_value;
136
137static long long unsigned int delay_short_value;
138
139static struct GNUNET_TIME_Relative delay_short;
140
141static struct GNUNET_TIME_Relative delay_long;
113 142
114static size_t num_sent_short = 0; 143static size_t num_sent_short = 0;
115 144
@@ -296,10 +325,6 @@ latency_timeout (void *cls)
296 GNUNET_SCHEDULER_shutdown (); 325 GNUNET_SCHEDULER_shutdown ();
297} 326}
298 327
299
300/*static void
301 size_test (void *cls);*/
302
303static void 328static void
304size_test (void *cls) 329size_test (void *cls)
305{ 330{
@@ -345,15 +370,14 @@ long_test_cb (void *cls)
345 (unsigned int) num_received_long); 370 (unsigned int) num_received_long);
346 payload = make_payload (long_message_size); 371 payload = make_payload (long_message_size);
347 num_sent_long++; 372 num_sent_long++;
348 GNUNET_TRANSPORT_TESTING_transport_communicator_send ( 373 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
349 my_tc, 374 (burst_packets_long ==
350 ((BURST_PACKETS * 0.91 == num_received_long) || 375 num_sent_long)
351 (BURST_PACKETS == num_sent_long)) 376 ? NULL
352 ? NULL 377 : &long_test,
353 : &long_test, 378 NULL,
354 NULL, 379 payload,
355 payload, 380 long_message_size);
356 long_message_size);
357 GNUNET_free (payload); 381 GNUNET_free (payload);
358 timeout = GNUNET_TIME_relative_to_absolute ( 382 timeout = GNUNET_TIME_relative_to_absolute (
359 GNUNET_TIME_relative_multiply ( 383 GNUNET_TIME_relative_multiply (
@@ -365,10 +389,7 @@ long_test_cb (void *cls)
365static void 389static void
366long_test (void *cls) 390long_test (void *cls)
367{ 391{
368 /*LOG (GNUNET_ERROR_TYPE_DEBUG, 392 GNUNET_SCHEDULER_add_delayed (delay_long,
369 "long_test %u\n",
370 num_sent_long);*/
371 GNUNET_SCHEDULER_add_delayed (DELAY,
372 &long_test_cb, 393 &long_test_cb,
373 NULL); 394 NULL);
374} 395}
@@ -389,15 +410,14 @@ short_test_cb (void *cls)
389 (unsigned int) num_received_short); 410 (unsigned int) num_received_short);
390 payload = make_payload (SHORT_MESSAGE_SIZE); 411 payload = make_payload (SHORT_MESSAGE_SIZE);
391 num_sent_short++; 412 num_sent_short++;
392 GNUNET_TRANSPORT_TESTING_transport_communicator_send ( 413 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
393 my_tc, 414 (burst_packets_short ==
394 ( (BURST_PACKETS * 0.91 == num_received_short) || 415 num_sent_short)
395 (BURST_PACKETS == num_sent_short) ) 416 ? NULL
396 ? NULL 417 : &short_test,
397 : &short_test, 418 NULL,
398 NULL, 419 payload,
399 payload, 420 SHORT_MESSAGE_SIZE);
400 SHORT_MESSAGE_SIZE);
401 GNUNET_free (payload); 421 GNUNET_free (payload);
402 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( 422 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
403 GNUNET_TIME_UNIT_SECONDS, 423 GNUNET_TIME_UNIT_SECONDS,
@@ -408,40 +428,164 @@ short_test_cb (void *cls)
408static void 428static void
409short_test (void *cls) 429short_test (void *cls)
410{ 430{
411 GNUNET_SCHEDULER_add_delayed (DELAY, 431 GNUNET_SCHEDULER_add_delayed (delay_short,
412 &short_test_cb, 432 &short_test_cb,
413 NULL); 433 NULL);
414} 434}
415 435
416 436
417static int test_prepared = GNUNET_NO; 437/* static int test_prepared = GNUNET_NO; */
438
439/* This helps establishing the backchannel */
440/* static void */
441/* prepare_test (void *cls) */
442/* { */
443/* char *payload; */
444
445/* if (GNUNET_YES == test_prepared) */
446/* { */
447/* GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, */
448/* &short_test, */
449/* NULL); */
450/* return; */
451/* } */
452/* test_prepared = GNUNET_YES; */
453/* payload = make_payload (SHORT_MESSAGE_SIZE); */
454/* GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, */
455/* &prepare_test, */
456/* NULL, */
457/* payload, */
458/* SHORT_MESSAGE_SIZE); */
459/* GNUNET_free (payload); */
460/* } */
418 461
419/**
420 * This helps establishing the backchannel
421 */
422static void 462static void
423prepare_test (void *cls) 463process_statistics_box_done (void *cls, int success)
424{ 464{
425 char *payload; 465 if (NULL != box_stats)
466 box_stats = NULL;
467 if (NULL == rekey_stats)
468 {
469 LOG (GNUNET_ERROR_TYPE_DEBUG,
470 "Finished\n");
471 GNUNET_SCHEDULER_shutdown ();
472 }
473}
474
426 475
427 if (GNUNET_YES == test_prepared) 476static void
477process_statistics_rekey_done (void *cls, int success)
478{
479 if (NULL != rekey_stats)
480 rekey_stats = NULL;
481 if (NULL == box_stats)
428 { 482 {
429 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 483 LOG (GNUNET_ERROR_TYPE_DEBUG,
430 &short_test, 484 "Finished\n");
431 NULL); 485 GNUNET_SCHEDULER_shutdown ();
432 return;
433 } 486 }
434 test_prepared = GNUNET_YES;
435 payload = make_payload (SHORT_MESSAGE_SIZE);
436 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
437 &prepare_test,
438 NULL,
439 payload,
440 SHORT_MESSAGE_SIZE);
441 GNUNET_free (payload);
442} 487}
443 488
444 489
490static int
491process_statistics (void *cls,
492 const char *subsystem,
493 const char *name,
494 uint64_t value,
495 int is_persistent)
496{
497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
498 "Statistic: Name %s and value %lu\n",
499 name,
500 value);
501 if ((0 == strcmp ("rekey", test_name)) && (0 == strcmp (
502 "# rekeying successful",
503 name)) && (0 == value))
504 {
505 ret = 2;
506 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
507 "No successful rekeying!\n");
508 GNUNET_SCHEDULER_shutdown ();
509 }
510 if ((0 == strcmp ("backchannel", test_name)) &&
511 (0 == strcmp (
512 "# messages decrypted with BOX",
513 name))
514 && (9000 > value))
515 {
516 ret = 2;
517 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
518 "Not enough BOX messages!\n");
519 GNUNET_SCHEDULER_shutdown ();
520 }
521 if ((0 == strcmp ("rekey", test_name)) &&
522 (0 == strcmp (
523 "# messages decrypted with BOX",
524 name))
525 && (6000 > value))
526 {
527 ret = 2;
528 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
529 "Not enough BOX messages!\n");
530 GNUNET_SCHEDULER_shutdown ();
531 }
532 return GNUNET_OK;
533}
534
535static void
536choose_phase ()
537{
538 if (GNUNET_YES == phase_short)
539 {
540 phase = TP_BURST_SHORT;
541 start_short = GNUNET_TIME_absolute_get ();
542 short_test (NULL);
543 }
544 else if (GNUNET_YES == phase_long)
545 {
546 phase = TP_BURST_LONG;
547 start_long = GNUNET_TIME_absolute_get ();
548 long_test (NULL);
549 }
550 else if (GNUNET_YES == phase_size)
551 {
552 phase = TP_SIZE_CHECK;
553 size_test (NULL);
554 }
555 else
556 {
557 if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
558 test_name))
559 ||(0 == strcmp (
560 "backchannel",
561 test_name))) )
562 {
563 if (NULL != box_stats)
564 GNUNET_STATISTICS_get_cancel (box_stats);
565 box_stats = GNUNET_STATISTICS_get (stats[1],
566 "C-UDP",
567 "# messages decrypted with BOX",
568 process_statistics_box_done,
569 &process_statistics,
570 NULL);
571 if (NULL != rekey_stats)
572 GNUNET_STATISTICS_get_cancel (rekey_stats);
573 rekey_stats = GNUNET_STATISTICS_get (stats[0],
574 "C-UDP",
575 "# rekeying successful",
576 process_statistics_rekey_done,
577 &process_statistics,
578 NULL);
579 }
580 else
581 {
582 LOG (GNUNET_ERROR_TYPE_DEBUG,
583 "Finished\n");
584 GNUNET_SCHEDULER_shutdown ();
585 }
586 }
587}
588
445/** 589/**
446 * @brief Handle opening of queue 590 * @brief Handle opening of queue
447 * 591 *
@@ -466,14 +610,14 @@ add_queue_cb (void *cls,
466 return; // TODO? 610 return; // TODO?
467 LOG (GNUNET_ERROR_TYPE_DEBUG, 611 LOG (GNUNET_ERROR_TYPE_DEBUG,
468 "Queue established, starting test...\n"); 612 "Queue established, starting test...\n");
469 start_short = GNUNET_TIME_absolute_get (); 613 // start_short = GNUNET_TIME_absolute_get ();
470 my_tc = tc_h; 614 my_tc = tc_h;
471 if (0 != mtu) /* Message header overhead */ 615 if (0 != mtu) /* Message header overhead */
472 long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) 616 long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo)
473 - sizeof(struct GNUNET_MessageHeader); 617 - sizeof(struct GNUNET_MessageHeader);
474 else 618 else
475 long_message_size = LONG_MESSAGE_SIZE; 619 long_message_size = LONG_MESSAGE_SIZE;
476 phase = TP_BURST_SHORT; 620 // phase = TP_BURST_SHORT;
477 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply ( 621 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
478 GNUNET_TIME_UNIT_SECONDS, 622 GNUNET_TIME_UNIT_SECONDS,
479 TIMEOUT_MULTIPLIER)); 623 TIMEOUT_MULTIPLIER));
@@ -484,7 +628,8 @@ add_queue_cb (void *cls,
484 &latency_timeout, 628 &latency_timeout,
485 NULL); 629 NULL);
486 // prepare_test (NULL); 630 // prepare_test (NULL);
487 short_test (NULL); 631 // short_test (NULL);
632 choose_phase ();
488} 633}
489 634
490 635
@@ -499,10 +644,7 @@ update_avg_latency (const char*payload)
499 ts_n = (struct GNUNET_TIME_AbsoluteNBO *) payload; 644 ts_n = (struct GNUNET_TIME_AbsoluteNBO *) payload;
500 ts = GNUNET_TIME_absolute_ntoh (*ts_n); 645 ts = GNUNET_TIME_absolute_ntoh (*ts_n);
501 latency = GNUNET_TIME_absolute_get_duration (ts); 646 latency = GNUNET_TIME_absolute_get_duration (ts);
502 LOG (GNUNET_ERROR_TYPE_DEBUG, 647
503 "Latency of received packet: %s\n",
504 GNUNET_STRINGS_relative_time_to_string (latency,
505 GNUNET_YES));
506 switch (phase) 648 switch (phase)
507 { 649 {
508 case TP_INIT: 650 case TP_INIT:
@@ -523,83 +665,40 @@ update_avg_latency (const char*payload)
523 else 665 else
524 avg_latency = ((avg_latency * (num_received - 1)) + latency.rel_value_us) 666 avg_latency = ((avg_latency * (num_received - 1)) + latency.rel_value_us)
525 / num_received; 667 / num_received;
526 668 LOG (GNUNET_ERROR_TYPE_DEBUG,
669 "Latency of received packet: %s with avg latency %lu\n",
670 GNUNET_STRINGS_relative_time_to_string (latency,
671 GNUNET_YES),
672 avg_latency);
527} 673}
528 674
529 675
530static void
531process_statistics_box_done (void *cls, int success)
532{
533 if (NULL != box_stats)
534 box_stats = NULL;
535 if (NULL == rekey_stats)
536 {
537 LOG (GNUNET_ERROR_TYPE_DEBUG,
538 "Finished\n");
539 GNUNET_SCHEDULER_shutdown ();
540 }
541}
542 676
543 677
544static void 678static void
545process_statistics_rekey_done (void *cls, int success) 679load_phase_config ()
546{ 680{
547 if (NULL != rekey_stats)
548 rekey_stats = NULL;
549 if (NULL == box_stats)
550 {
551 LOG (GNUNET_ERROR_TYPE_DEBUG,
552 "Finished\n");
553 GNUNET_SCHEDULER_shutdown ();
554 }
555}
556 681
682 phase_short = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
683 TEST_SECTION,
684 "PHASE_SHORT");
685 if (GNUNET_SYSERR == phase_short)
686 phase_short = GNUNET_YES;
557 687
558static int 688 phase_long = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
559process_statistics (void *cls, 689 TEST_SECTION,
560 const char *subsystem, 690 "PHASE_LONG");
561 const char *name, 691
562 uint64_t value, 692 if (GNUNET_SYSERR == phase_long)
563 int is_persistent) 693 phase_long = GNUNET_YES;
564{
565 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
566 "Statistic: Name %s and value %lu\n",
567 name,
568 value);
569 if ((0 == strcmp ("rekey", test_name)) && (0 == strcmp (
570 "# rekeying successful",
571 name)) && (0 == value))
572 {
573 ret = 2;
574 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
575 "No successful rekeying!\n");
576 GNUNET_SCHEDULER_shutdown ();
577 }
578 if ((0 == strcmp ("backchannel", test_name)) &&
579 (0 == strcmp (
580 "# messages decrypted with BOX",
581 name))
582 && (9000 > value))
583 {
584 ret = 2;
585 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
586 "Not enough BOX messages!\n");
587 GNUNET_SCHEDULER_shutdown ();
588 }
589 if ((0 == strcmp ("rekey", test_name)) &&
590 (0 == strcmp (
591 "# messages decrypted with BOX",
592 name))
593 && (6000 > value))
594 {
595 ret = 2;
596 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
597 "Not enough BOX messages!\n");
598 GNUNET_SCHEDULER_shutdown ();
599 }
600 return GNUNET_OK;
601}
602 694
695 phase_size = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
696 TEST_SECTION,
697 "PHASE_SIZE");
698
699 if (GNUNET_SYSERR == phase_size)
700 phase_size = GNUNET_YES;
701}
603 702
604/** 703/**
605 * @brief Handle an incoming message 704 * @brief Handle an incoming message
@@ -639,7 +738,10 @@ incoming_message_cb (
639 num_received_short++; 738 num_received_short++;
640 duration = GNUNET_TIME_absolute_get_duration (start_short); 739 duration = GNUNET_TIME_absolute_get_duration (start_short);
641 update_avg_latency (payload); 740 update_avg_latency (payload);
642 if (num_received_short == BURST_PACKETS * 0.91) 741 if ((num_sent_short == burst_packets_short) && (num_received_short >
742 burst_packets_short / 100
743 *
744 allowed_packet_loss_short) )
643 { 745 {
644 LOG (GNUNET_ERROR_TYPE_MESSAGE, 746 LOG (GNUNET_ERROR_TYPE_MESSAGE,
645 "Short size packet test done.\n"); 747 "Short size packet test done.\n");
@@ -654,12 +756,14 @@ incoming_message_cb (
654 goodput, 756 goodput,
655 (unsigned long long) avg_latency); 757 (unsigned long long) avg_latency);
656 GNUNET_free (goodput); 758 GNUNET_free (goodput);
657 start_long = GNUNET_TIME_absolute_get (); 759 // start_long = GNUNET_TIME_absolute_get ();
658 phase = TP_BURST_LONG; 760 // phase = TP_BURST_LONG;
659 // num_sent_short = 0; 761 // num_sent_short = 0;
660 avg_latency = 0; 762 avg_latency = 0;
661 // num_received = 0; 763 // num_received = 0;
662 long_test (NULL); 764 phase_short = GNUNET_NO;
765 choose_phase ();
766 // long_test (NULL);
663 } 767 }
664 break; 768 break;
665 } 769 }
@@ -674,7 +778,10 @@ incoming_message_cb (
674 num_received_long++; 778 num_received_long++;
675 duration = GNUNET_TIME_absolute_get_duration (start_long); 779 duration = GNUNET_TIME_absolute_get_duration (start_long);
676 update_avg_latency (payload); 780 update_avg_latency (payload);
677 if (num_received_long == BURST_PACKETS * 0.91) 781 if ((num_sent_long == burst_packets_long) && (num_received_long >
782 burst_packets_long
783 / 100
784 * allowed_packet_loss_short) )
678 { 785 {
679 LOG (GNUNET_ERROR_TYPE_MESSAGE, 786 LOG (GNUNET_ERROR_TYPE_MESSAGE,
680 "Long size packet test done.\n"); 787 "Long size packet test done.\n");
@@ -692,11 +799,13 @@ incoming_message_cb (
692 (unsigned long long) avg_latency); 799 (unsigned long long) avg_latency);
693 GNUNET_free (goodput); 800 GNUNET_free (goodput);
694 ack = 0; 801 ack = 0;
695 phase = TP_SIZE_CHECK; 802 // phase = TP_SIZE_CHECK;
696 // num_received = 0; 803 // num_received = 0;
697 // num_sent_long = 0; 804 // num_sent_long = 0;
698 avg_latency = 0; 805 avg_latency = 0;
699 size_test (NULL); 806 // size_test (NULL);
807 phase_long = GNUNET_NO;
808 choose_phase ();
700 } 809 }
701 break; 810 break;
702 } 811 }
@@ -724,41 +833,19 @@ incoming_message_cb (
724 iterations_left--; 833 iterations_left--;
725 if (0 != iterations_left) 834 if (0 != iterations_left)
726 { 835 {
727 start_short = GNUNET_TIME_absolute_get (); 836 // start_short = GNUNET_TIME_absolute_get ();
728 phase = TP_BURST_SHORT; 837 // phase = TP_BURST_SHORT;
729 num_sent_short = 0; 838 num_sent_short = 0;
730 num_sent_long = 0; 839 num_sent_long = 0;
731 num_received_short = 0; 840 num_received_short = 0;
732 num_received_long = 0; 841 num_received_long = 0;
733 short_test (NULL); 842 // short_test (NULL);
843 load_phase_config ();
844 choose_phase ();
734 break; 845 break;
735 } 846 }
736 if ( (0 == strcmp ("rekey", test_name)) || 847 phase_size = GNUNET_NO;
737 (0 == strcmp ("backchannel", test_name)) ) 848 choose_phase ();
738 {
739 if (NULL != box_stats)
740 GNUNET_STATISTICS_get_cancel (box_stats);
741 box_stats = GNUNET_STATISTICS_get (stats[1],
742 "C-UDP",
743 "# messages decrypted with BOX",
744 process_statistics_box_done,
745 &process_statistics,
746 NULL);
747 if (NULL != rekey_stats)
748 GNUNET_STATISTICS_get_cancel (rekey_stats);
749 rekey_stats = GNUNET_STATISTICS_get (stats[0],
750 "C-UDP",
751 "# rekeying successful",
752 process_statistics_rekey_done,
753 &process_statistics,
754 NULL);
755 }
756 else
757 {
758 LOG (GNUNET_ERROR_TYPE_DEBUG,
759 "Finished\n");
760 GNUNET_SCHEDULER_shutdown ();
761 }
762 } 849 }
763 break; 850 break;
764 } 851 }
@@ -795,6 +882,7 @@ do_shutdown (void *cls)
795} 882}
796 883
797 884
885
798/** 886/**
799 * @brief Main function called by the scheduler 887 * @brief Main function called by the scheduler
800 * 888 *
@@ -821,24 +909,29 @@ run (void *cls)
821 &handle_backchannel_cb, 909 &handle_backchannel_cb,
822 cfg_peers_name[i]); /* cls */ 910 cfg_peers_name[i]); /* cls */
823 911
824 if ((0 == strcmp ("rekey", test_name)) || (0 == strcmp ("backchannel", 912 if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
825 test_name)) ) 913 test_name))||
914 (0 == strcmp (
915 "backchannel",
916 test_name))) )
826 { 917 {
827 stats[i] = GNUNET_STATISTICS_create ("C-UDP", 918 stats[i] = GNUNET_STATISTICS_create ("C-UDP",
828 cfg_peers[i]); 919 cfg_peers[i]);
829 } 920 }
921 else if ((0 == strcmp ("bidirect", test_name)))
922 {
923 bidirect = GNUNET_YES;
924 }
830 } 925 }
831 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 926 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
832 NULL); 927 NULL);
833} 928}
834 929
835
836int 930int
837main (int argc, 931main (int argc,
838 char *const *argv) 932 char *const *argv)
839{ 933{
840 struct GNUNET_CRYPTO_EddsaPrivateKey *private_key; 934 struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
841 char *communicator_name;
842 char *test_mode; 935 char *test_mode;
843 char *cfg_peer; 936 char *cfg_peer;
844 937
@@ -911,6 +1004,49 @@ main (int argc,
911 i, 1004 i,
912 GNUNET_i2s_full (&peer_id[i])); 1005 GNUNET_i2s_full (&peer_id[i]));
913 } 1006 }
1007 if (GNUNET_OK !=
1008 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1009 TEST_SECTION,
1010 "ALLOWED_PACKET_LOSS_SHORT",
1011 &allowed_packet_loss_short))
1012 allowed_packet_loss_short = ALLOWED_PACKET_LOSS;
1013 if (GNUNET_OK !=
1014 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1015 TEST_SECTION,
1016 "ALLOWED_PACKET_LOSS_LONG",
1017 &allowed_packet_loss_long))
1018 allowed_packet_loss_long = ALLOWED_PACKET_LOSS;
1019 if (GNUNET_OK !=
1020 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1021 TEST_SECTION,
1022 "BURST_PACKETS_SHORT",
1023 &burst_packets_short))
1024 burst_packets_short = BURST_PACKETS;
1025 if (GNUNET_OK !=
1026 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1027 TEST_SECTION,
1028 "BURST_ÜACKETS_LONG",
1029 &burst_packets_long))
1030 burst_packets_long = BURST_PACKETS;
1031 if (GNUNET_OK !=
1032 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1033 TEST_SECTION,
1034 "DELAY_SHORT",
1035 &delay_short_value))
1036 delay_short = DELAY;
1037 else
1038 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,
1039 delay_short_value);
1040 if (GNUNET_OK !=
1041 GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
1042 TEST_SECTION,
1043 "DELAY_SHORT",
1044 &delay_long_value))
1045 delay_long = DELAY;
1046 else
1047 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,
1048 delay_long_value);
1049 load_phase_config ();
914 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n"); 1050 LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n");
915 LOG (GNUNET_ERROR_TYPE_DEBUG, 1051 LOG (GNUNET_ERROR_TYPE_DEBUG,
916 "argv[0]: %s\n", 1052 "argv[0]: %s\n",
diff --git a/src/transport/test_communicator_tcp_basic_peer1.conf b/src/transport/test_communicator_tcp_basic_peer1.conf
index 2411f485b..dbc227ac6 100644
--- a/src/transport/test_communicator_tcp_basic_peer1.conf
+++ b/src/transport/test_communicator_tcp_basic_peer1.conf
@@ -1,5 +1,10 @@
1@INLINE@ test_transport_defaults.conf 1@INLINE@ test_transport_defaults.conf
2 2
3[test-setup]
4#PHASE_LONG=NO
5#PHASE_SIZE=NO
6#BURST_PACKETS_SHORT=1
7
3[PATHS] 8[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/ 9GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/
5 10
@@ -33,7 +38,7 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
33#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args 38#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
34#PREFIX = valgrind --leak-check=full --track-origins=yes 39#PREFIX = valgrind --leak-check=full --track-origins=yes
35BINDTO = 60002 40BINDTO = 60002
36DISABLE_V6 = NO 41DISABLE_V6 = YES
37 42
38[communicator-udp] 43[communicator-udp]
39BINDTO = 60002 44BINDTO = 60002
diff --git a/src/transport/test_communicator_tcp_basic_peer2.conf b/src/transport/test_communicator_tcp_basic_peer2.conf
index 8005718bf..b73157f0d 100644
--- a/src/transport/test_communicator_tcp_basic_peer2.conf
+++ b/src/transport/test_communicator_tcp_basic_peer2.conf
@@ -34,7 +34,7 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
34#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args 34#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
35#PREFIX = valgrind --leak-check=full --track-origins=yes 35#PREFIX = valgrind --leak-check=full --track-origins=yes
36BINDTO = 60003 36BINDTO = 60003
37DISABLE_V6 = NO 37DISABLE_V6 = YES
38 38
39[communicator-udp] 39[communicator-udp]
40BINDTO = 60003 40BINDTO = 60003
diff --git a/src/transport/test_communicator_tcp_rekey_peer2.conf b/src/transport/test_communicator_tcp_rekey_peer2.conf
index 1036039c4..086a996ae 100644
--- a/src/transport/test_communicator_tcp_rekey_peer2.conf
+++ b/src/transport/test_communicator_tcp_rekey_peer2.conf
@@ -38,7 +38,7 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
38#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args 38#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
39#PREFIX = valgrind --leak-check=full --track-origins=yes 39#PREFIX = valgrind --leak-check=full --track-origins=yes
40BINDTO = 60003 40BINDTO = 60003
41DISABLE_V6 = NO 41DISABLE_V6 = YES
42REKEY_INTERVAL = 100ms 42REKEY_INTERVAL = 100ms
43 43
44[communicator-udp] 44[communicator-udp]
diff --git a/src/transport/transport-testing-communicator.c b/src/transport/transport-testing-communicator.c
index 56240864c..de356fb9c 100644
--- a/src/transport/transport-testing-communicator.c
+++ b/src/transport/transport-testing-communicator.c
@@ -317,6 +317,7 @@ handle_add_address (void *cls,
317 client->tc; 317 client->tc;
318 uint16_t size; 318 uint16_t size;
319 size = ntohs (msg->header.size) - sizeof(*msg); 319 size = ntohs (msg->header.size) - sizeof(*msg);
320 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
320 if (0 == size) 321 if (0 == size)
321 return; /* receive-only communicator */ 322 return; /* receive-only communicator */
322 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size); 323 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);