aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-12-25 19:39:20 +0900
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-12-25 19:39:20 +0900
commitfd8f467fe5488f969012ec6098523c5aaa8bcc43 (patch)
treef95f12b0bd5f6db4b4aa80f2b0a5d7ac3c031042
parentd0f2906ee9d65568ae9c859680706cf7b0bdaf0c (diff)
downloadgnunet-fd8f467fe5488f969012ec6098523c5aaa8bcc43.tar.gz
gnunet-fd8f467fe5488f969012ec6098523c5aaa8bcc43.zip
better test for comms
-rw-r--r--src/transport/test_communicator_basic.c170
-rw-r--r--src/transport/test_communicator_unix_peer1.conf4
-rw-r--r--src/transport/test_communicator_unix_peer2.conf4
-rw-r--r--src/transport/test_transport_defaults.conf2
4 files changed, 119 insertions, 61 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index ef91e133d..7ae50be05 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -41,6 +41,10 @@
41 41
42#define NUM_PEERS 2 42#define NUM_PEERS 2
43 43
44static struct GNUNET_SCHEDULER_Task *to_task;
45
46static int queue_est = GNUNET_NO;
47
44static struct GNUNET_PeerIdentity peer_id[NUM_PEERS]; 48static struct GNUNET_PeerIdentity peer_id[NUM_PEERS];
45 49
46static char *communicator_binary; 50static char *communicator_binary;
@@ -124,12 +128,16 @@ add_address_cb (void *cls,
124 aid, 128 aid,
125 nt); 129 nt);
126 // addresses[1] = GNUNET_strdup (address); 130 // addresses[1] = GNUNET_strdup (address);
127 if (0 == strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) 131 if ((0 == strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) &&
132 (GNUNET_NO == queue_est))
133 {
134 queue_est = GNUNET_YES;
128 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0], 135 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0],
129 &peer_id[ 136 &peer_id[
130 NUM_PEERS 137 NUM_PEERS
131 - 1], 138 - 1],
132 address); 139 address);
140 }
133} 141}
134 142
135 143
@@ -176,6 +184,18 @@ make_payload (size_t payload_size)
176 184
177 185
178static void 186static void
187latency_timeout (void *cls)
188{
189 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
190 "Latency too high. Test failed. (Phase: %d. Received: %lu\n",
191 phase, num_received);
192 ret = 2;
193 to_task = NULL;
194 GNUNET_SCHEDULER_shutdown ();
195}
196
197
198static void
179size_test (void *cls) 199size_test (void *cls)
180{ 200{
181 char *payload; 201 char *payload;
@@ -190,24 +210,13 @@ size_test (void *cls)
190 GNUNET_free (payload); 210 GNUNET_free (payload);
191 ack += 5; 211 ack += 5;
192 num_sent++; 212 num_sent++;
213 if (NULL == to_task)
214 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
215 &latency_timeout,
216 NULL);
193 if (ack < 64000) 217 if (ack < 64000)
194 GNUNET_SCHEDULER_add_now (&size_test, NULL); 218 GNUNET_SCHEDULER_add_now (&size_test, NULL);
195 else
196 GNUNET_SCHEDULER_add_delayed (SHORT_BURST_WINDOW,
197 &size_test, NULL);
198 return;
199 } 219 }
200 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
201 "Size packet test done.\n");
202 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
203 "%lu/%lu packets -- avg latency: %lu us\n",
204 num_received,
205 num_sent,
206 avg_latency);
207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
208 "Finished\n");
209 GNUNET_SCHEDULER_shutdown ();
210 // Finished!
211} 220}
212 221
213 222
@@ -223,27 +232,17 @@ long_test (void *cls)
223 LONG_MESSAGE_SIZE); 232 LONG_MESSAGE_SIZE);
224 num_sent++; 233 num_sent++;
225 GNUNET_free (payload); 234 GNUNET_free (payload);
226 if (num_sent < BURST_PACKETS) 235 if (NULL == to_task)
227 GNUNET_SCHEDULER_add_now (&long_test, NULL); 236 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
228 if (num_sent == BURST_PACKETS) 237 &latency_timeout,
229 GNUNET_SCHEDULER_add_delayed (LONG_BURST_WINDOW, 238 NULL);
230 &long_test, NULL); 239
240 GNUNET_SCHEDULER_add_now (&long_test, NULL);
241 //if (num_sent == BURST_PACKETS)
242 // GNUNET_SCHEDULER_add_delayed (LONG_BURST_WINDOW,
243 // &long_test, NULL);
231 return; 244 return;
232 } 245 }
233 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
234 "Long size packet test done.\n");
235 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
236 "%lu/%lu packets in %lu us (%lu kb/s) -- avg latency: %lu us\n",
237 num_received,
238 num_sent,
239 duration.rel_value_us,
240 (LONG_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
241 avg_latency);
242 ack = 10;
243 num_received = 0;
244 num_sent = 0;
245 avg_latency = 0;
246 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &size_test, NULL);
247} 246}
248 247
249 248
@@ -251,7 +250,7 @@ static void
251short_test (void *cls) 250short_test (void *cls)
252{ 251{
253 char *payload; 252 char *payload;
254 while (num_sent < BURST_PACKETS) 253 if (num_sent < BURST_PACKETS)
255 { 254 {
256 payload = make_payload (SHORT_MESSAGE_SIZE); 255 payload = make_payload (SHORT_MESSAGE_SIZE);
257 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 256 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
@@ -259,33 +258,23 @@ short_test (void *cls)
259 SHORT_MESSAGE_SIZE); 258 SHORT_MESSAGE_SIZE);
260 num_sent++; 259 num_sent++;
261 GNUNET_free (payload); 260 GNUNET_free (payload);
262 //if (num_sent < BURST_PACKETS) 261 if (NULL == to_task)
263 // GNUNET_SCHEDULER_add_now (&short_test, NULL); 262 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
264 if (num_sent == BURST_PACKETS) 263 &latency_timeout,
264 NULL);
265
266 GNUNET_SCHEDULER_add_now (&short_test, NULL);
267 /*if (num_sent == BURST_PACKETS)
265 { 268 {
266 GNUNET_SCHEDULER_add_delayed (SHORT_BURST_WINDOW, 269 GNUNET_SCHEDULER_add_delayed (SHORT_BURST_WINDOW,
267 &short_test, NULL); 270 &short_test, NULL);
268 return; 271 return;
269 } 272 }*/
270 } 273 }
271 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
272 "Short size packet test done.\n");
273 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
274 "%lu/%lu packets in %lu us (%lu kb/s) -- avg latency: %lu us\n",
275 num_received,
276 num_sent,
277 duration.rel_value_us,
278 (SHORT_MESSAGE_SIZE * num_received) / (duration.rel_value_us / 1000),
279 avg_latency);
280 start_long = GNUNET_TIME_absolute_get ();
281 phase = BURST_LONG;
282 num_sent = 0;
283 avg_latency = 0;
284 num_received = 0;
285 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &long_test, NULL);
286} 274}
287 275
288 276
277
289/** 278/**
290 * @brief Handle opening of queue 279 * @brief Handle opening of queue
291 * 280 *
@@ -361,6 +350,28 @@ incoming_message_cb (void *cls,
361 num_received++; 350 num_received++;
362 duration = GNUNET_TIME_absolute_get_duration (start_short); 351 duration = GNUNET_TIME_absolute_get_duration (start_short);
363 update_avg_latency (payload); 352 update_avg_latency (payload);
353 if (num_received == BURST_PACKETS)
354 {
355 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
356 "Short size packet test done.\n");
357 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
358 "%lu/%lu packets in %llu us (%llu kb/s) -- avg latency: %llu us\n",
359 num_received,
360 num_sent,
361 duration.rel_value_us,
362 (SHORT_MESSAGE_SIZE * num_received) / (duration.rel_value_us
363 / 1000),
364 avg_latency);
365 start_long = GNUNET_TIME_absolute_get ();
366 phase = BURST_LONG;
367 num_sent = 0;
368 avg_latency = 0;
369 num_received = 0;
370 GNUNET_SCHEDULER_cancel (to_task);
371 to_task = NULL;
372 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &long_test, NULL);
373 }
374
364 } 375 }
365 else if (phase == BURST_LONG) 376 else if (phase == BURST_LONG)
366 { 377 {
@@ -373,11 +384,58 @@ incoming_message_cb (void *cls,
373 num_received++; 384 num_received++;
374 duration = GNUNET_TIME_absolute_get_duration (start_long); 385 duration = GNUNET_TIME_absolute_get_duration (start_long);
375 update_avg_latency (payload); 386 update_avg_latency (payload);
387 if (num_received == BURST_PACKETS)
388 {
389 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
390 "Long size packet test done.\n");
391 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
392 "%lu/%lu packets in %llu us (%llu kb/s) -- avg latency: %llu us\n",
393 num_received,
394 num_sent,
395 duration.rel_value_us,
396 (LONG_MESSAGE_SIZE * num_received) / (duration.rel_value_us
397 / 1000),
398 avg_latency);
399 ack = 10;
400 phase = SIZE_CHECK;
401 num_received = 0;
402 num_sent = 0;
403 avg_latency = 0;
404 GNUNET_SCHEDULER_cancel (to_task);
405 to_task = NULL;
406 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &size_test, NULL);
407
408 }
376 } 409 }
377 else // if (phase == SIZE_CHECK) { 410 else // if (phase == SIZE_CHECK) {
378 { 411 {
379 num_received++; 412 num_received++;
380 update_avg_latency (payload); 413 update_avg_latency (payload);
414 if (num_received >= (64000 - 10) / 5)
415 {
416 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
417 "Size packet test done.\n");
418 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
419 "%lu/%lu packets -- avg latency: %llu us\n",
420 num_received,
421 num_sent,
422 avg_latency);
423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
424 "Finished\n");
425 GNUNET_SCHEDULER_cancel (to_task);
426 to_task = NULL;
427 GNUNET_SCHEDULER_shutdown ();
428 // Finished!
429 // }
430 }
431 }
432 // Reset timeout
433 if (to_task != NULL)
434 {
435 GNUNET_SCHEDULER_cancel (to_task);
436 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
437 &latency_timeout,
438 NULL);
381 } 439 }
382} 440}
383 441
@@ -404,7 +462,7 @@ run (void *cls)
404 &queue_create_reply_cb, 462 &queue_create_reply_cb,
405 &add_queue_cb, 463 &add_queue_cb,
406 &incoming_message_cb, 464 &incoming_message_cb,
407 cfg_peers_name[i]); /* cls */ 465 cfg_peers_name[i]); /* cls */
408 } 466 }
409} 467}
410 468
diff --git a/src/transport/test_communicator_unix_peer1.conf b/src/transport/test_communicator_unix_peer1.conf
index 411b7f587..d50588007 100644
--- a/src/transport/test_communicator_unix_peer1.conf
+++ b/src/transport/test_communicator_unix_peer1.conf
@@ -17,11 +17,11 @@ PORT = 60000
17UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock 17UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
18 18
19[nat] 19[nat]
20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/communicator-unix-1/nat.sock
21ENABLE_IPSCAN = YES 21ENABLE_IPSCAN = YES
22 22
23[communicator-unix] 23[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock 24UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock
25 25
26[communicator-tcp] 26[communicator-tcp]
27BINDTO = 60002 27BINDTO = 60002
diff --git a/src/transport/test_communicator_unix_peer2.conf b/src/transport/test_communicator_unix_peer2.conf
index d06ef0d1e..fe27ef1a6 100644
--- a/src/transport/test_communicator_unix_peer2.conf
+++ b/src/transport/test_communicator_unix_peer2.conf
@@ -18,10 +18,10 @@ PORT = 60001
18UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock 18UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
19 19
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/communicator-unix-2/nat.sock
22 22
23[communicator-unix] 23[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock 24UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock
25 25
26[communicator-tcp] 26[communicator-tcp]
27BINDTO = 60003 27BINDTO = 60003
diff --git a/src/transport/test_transport_defaults.conf b/src/transport/test_transport_defaults.conf
index 3f38eeab7..3aed73f0c 100644
--- a/src/transport/test_transport_defaults.conf
+++ b/src/transport/test_transport_defaults.conf
@@ -1,7 +1,7 @@
1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf 1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2 2
3[PATHS] 3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/test-transport-api/ 4GNUNET_TEST_HOME = $GNUNET_TMP/test-tng/
5 5
6[transport-tcp] 6[transport-tcp]
7TIMEOUT = 300 s 7TIMEOUT = 300 s