diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-07-24 04:35:15 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-07-24 04:35:15 +0000 |
commit | c034708c1d2b9c8c978c645b9851536cd58f4da2 (patch) | |
tree | fafbeb52c5ef5ea2e8b0bdc9b8c3b5fa02423e71 /src/cadet | |
parent | c954405ee75182cdb7d2a2a4a5e4d23e415120e9 (diff) | |
download | gnunet-c034708c1d2b9c8c978c645b9851536cd58f4da2.tar.gz gnunet-c034708c1d2b9c8c978c645b9851536cd58f4da2.zip |
- revamp almost all cadet tests, keep track of messages, sizes, acks
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/test_cadet.c | 119 |
1 files changed, 73 insertions, 46 deletions
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index eb54ad455..f42ba123d 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c | |||
@@ -33,7 +33,7 @@ | |||
33 | /** | 33 | /** |
34 | * How namy messages to send | 34 | * How namy messages to send |
35 | */ | 35 | */ |
36 | #define TOTAL_PACKETS 2000 | 36 | #define TOTAL_PACKETS 100 |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * How long until we give up on connecting the peers? | 39 | * How long until we give up on connecting the peers? |
@@ -107,19 +107,24 @@ unsigned int p_ids; | |||
107 | static int initialized; | 107 | static int initialized; |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Number of payload packes sent | 110 | * Number of payload packes sent. |
111 | */ | 111 | */ |
112 | static int data_sent; | 112 | static int data_sent; |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Number of payload packets received | 115 | * Number of payload packets received. |
116 | */ | 116 | */ |
117 | static int data_received; | 117 | static int data_received; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Number of payload packed explicitly (app level) acknowledged | 120 | * Number of payload packed acknowledgements sent. |
121 | */ | 121 | */ |
122 | static int data_ack; | 122 | static int ack_sent; |
123 | |||
124 | /** | ||
125 | * Number of payload packed explicitly (app level) acknowledged. | ||
126 | */ | ||
127 | static int ack_received; | ||
123 | 128 | ||
124 | /** | 129 | /** |
125 | * Total number of peers asked to run. | 130 | * Total number of peers asked to run. |
@@ -199,6 +204,22 @@ static unsigned int ka_received; | |||
199 | 204 | ||
200 | 205 | ||
201 | /** | 206 | /** |
207 | * Get the client number considered as the "target" or "receiver", depending on | ||
208 | * the test type and size. | ||
209 | * | ||
210 | * @return Peer # of the target client, either 0 (for backward tests) or | ||
211 | * the last peer in the line (for other tests). | ||
212 | */ | ||
213 | static unsigned int | ||
214 | get_expected_target () | ||
215 | { | ||
216 | if (SPEED == test && GNUNET_YES == test_backwards) | ||
217 | return 0; | ||
218 | else | ||
219 | return peers_requested - 1; | ||
220 | } | ||
221 | |||
222 | /** | ||
202 | * Show the results of the test (banwidth acheived) and log them to GAUGER | 223 | * Show the results of the test (banwidth acheived) and log them to GAUGER |
203 | */ | 224 | */ |
204 | static void | 225 | static void |
@@ -321,6 +342,7 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
321 | { | 342 | { |
322 | struct GNUNET_CADET_TransmitHandle *th; | 343 | struct GNUNET_CADET_TransmitHandle *th; |
323 | struct GNUNET_CADET_Channel *channel; | 344 | struct GNUNET_CADET_Channel *channel; |
345 | long src; | ||
324 | 346 | ||
325 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | 347 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) |
326 | return; | 348 | return; |
@@ -329,15 +351,17 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
329 | if (GNUNET_YES == test_backwards) | 351 | if (GNUNET_YES == test_backwards) |
330 | { | 352 | { |
331 | channel = incoming_ch; | 353 | channel = incoming_ch; |
354 | src = peers_requested - 1; | ||
332 | } | 355 | } |
333 | else | 356 | else |
334 | { | 357 | { |
335 | channel = ch; | 358 | channel = ch; |
359 | src = 0; | ||
336 | } | 360 | } |
337 | th = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, | 361 | th = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, |
338 | GNUNET_TIME_UNIT_FOREVER_REL, | 362 | GNUNET_TIME_UNIT_FOREVER_REL, |
339 | size_payload + data_sent, | 363 | size_payload + data_sent, |
340 | &tmt_rdy, (void *) 1L); | 364 | &tmt_rdy, (void *) src); |
341 | if (NULL == th) | 365 | if (NULL == th) |
342 | { | 366 | { |
343 | unsigned long i = (unsigned long) cls; | 367 | unsigned long i = (unsigned long) cls; |
@@ -347,7 +371,7 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
347 | { | 371 | { |
348 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n"); | 372 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n"); |
349 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 373 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, |
350 | &data_task, (void *)1UL); | 374 | &data_task, (void *) 1L); |
351 | } | 375 | } |
352 | else | 376 | else |
353 | { | 377 | { |
@@ -356,7 +380,7 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
356 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( | 380 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( |
357 | GNUNET_TIME_UNIT_MILLISECONDS, | 381 | GNUNET_TIME_UNIT_MILLISECONDS, |
358 | i), | 382 | i), |
359 | &data_task, (void *)i); | 383 | &data_task, (void *) i); |
360 | } | 384 | } |
361 | } | 385 | } |
362 | } | 386 | } |
@@ -365,7 +389,7 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
365 | /** | 389 | /** |
366 | * Transmit ready callback | 390 | * Transmit ready callback |
367 | * | 391 | * |
368 | * @param cls Closure (unused). | 392 | * @param cls Closure (peer # which is sending the data). |
369 | * @param size Size of the buffer we have. | 393 | * @param size Size of the buffer we have. |
370 | * @param buf Buffer to copy data to. | 394 | * @param buf Buffer to copy data to. |
371 | */ | 395 | */ |
@@ -375,37 +399,43 @@ tmt_rdy (void *cls, size_t size, void *buf) | |||
375 | struct GNUNET_MessageHeader *msg = buf; | 399 | struct GNUNET_MessageHeader *msg = buf; |
376 | size_t msg_size; | 400 | size_t msg_size; |
377 | uint32_t *data; | 401 | uint32_t *data; |
402 | long id = (long) cls; | ||
403 | unsigned int counter; | ||
378 | 404 | ||
379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy on %ld, filling buffer\n", id); |
380 | "tmt_rdy called, filling buffer\n"); | 406 | counter = get_expected_target () == id ? ack_sent : data_sent; |
381 | msg_size = size_payload + data_sent; | 407 | msg_size = size_payload + counter; |
382 | if (size < msg_size || NULL == buf) | 408 | if (size < msg_size || NULL == buf) |
383 | { | 409 | { |
384 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
385 | "size %u, buf %p, data_sent %u, data_received %u\n", | 411 | "size %u, buf %p, data_sent %u, ack_received %u\n", |
386 | size, buf, data_sent, data_received); | 412 | size, buf, data_sent, ack_received); |
387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal); | 413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal); |
388 | GNUNET_break (ok >= ok_goal - 2); | 414 | GNUNET_break (ok >= ok_goal - 2); |
389 | 415 | ||
390 | return 0; | 416 | return 0; |
391 | } | 417 | } |
392 | msg->size = htons (size); | 418 | msg->size = htons (size); |
393 | msg->type = htons ((long) cls); | 419 | msg->type = htons (1); |
394 | data = (uint32_t *) &msg[1]; | 420 | data = (uint32_t *) &msg[1]; |
395 | *data = htonl (data_sent); | 421 | *data = htonl (counter); |
396 | if (GNUNET_NO == initialized) | 422 | if (GNUNET_NO == initialized) |
397 | { | 423 | { |
398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n"); | 424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n"); |
399 | } | 425 | } |
400 | else if (SPEED == test) | 426 | else if (SPEED == test || SPEED_ACK == test) |
401 | { | 427 | { |
402 | data_sent++; | 428 | if (get_expected_target() == id) |
429 | ack_sent++; | ||
430 | else | ||
431 | data_sent++; | ||
432 | counter++; | ||
403 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " Sent message %d size %u\n", | 433 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " Sent message %d size %u\n", |
404 | data_sent, msg_size); | 434 | counter, msg_size); |
405 | if (data_sent < TOTAL_PACKETS) | 435 | if (data_sent < TOTAL_PACKETS && SPEED == test) |
406 | { | 436 | { |
407 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n", | 437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n", |
408 | data_sent + 1); | 438 | counter + 1); |
409 | GNUNET_SCHEDULER_add_now (&data_task, NULL); | 439 | GNUNET_SCHEDULER_add_now (&data_task, NULL); |
410 | } | 440 | } |
411 | } | 441 | } |
@@ -433,8 +463,10 @@ data_callback (void *cls, struct GNUNET_CADET_Channel *channel, | |||
433 | long expected_target_client; | 463 | long expected_target_client; |
434 | uint32_t *data; | 464 | uint32_t *data; |
435 | uint32_t payload; | 465 | uint32_t payload; |
466 | unsigned int counter; | ||
436 | 467 | ||
437 | ok++; | 468 | ok++; |
469 | counter = get_expected_target () == client ? data_received : ack_received; | ||
438 | 470 | ||
439 | GNUNET_CADET_receive_done (channel); | 471 | GNUNET_CADET_receive_done (channel); |
440 | 472 | ||
@@ -469,16 +501,9 @@ data_callback (void *cls, struct GNUNET_CADET_Channel *channel, | |||
469 | data = (uint32_t *) &message[1]; | 501 | data = (uint32_t *) &message[1]; |
470 | payload = ntohl (*data); | 502 | payload = ntohl (*data); |
471 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload: %u, data_received: %u\n", | 503 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload: %u, data_received: %u\n", |
472 | payload, data_received); | 504 | payload, counter); |
473 | GNUNET_break (payload == data_received); | 505 | GNUNET_break (payload == counter); |
474 | if (SPEED == test && GNUNET_YES == test_backwards) | 506 | expected_target_client = get_expected_target (); |
475 | { | ||
476 | expected_target_client = 0L; | ||
477 | } | ||
478 | else | ||
479 | { | ||
480 | expected_target_client = peers_requested - 1; | ||
481 | } | ||
482 | 507 | ||
483 | if (GNUNET_NO == initialized) | 508 | if (GNUNET_NO == initialized) |
484 | { | 509 | { |
@@ -492,16 +517,18 @@ data_callback (void *cls, struct GNUNET_CADET_Channel *channel, | |||
492 | } | 517 | } |
493 | } | 518 | } |
494 | 519 | ||
495 | if (client == expected_target_client) // Normally 4 | 520 | counter++; |
521 | if (client == expected_target_client) /* Normally 4 */ | ||
496 | { | 522 | { |
497 | data_received++; | 523 | data_received++; |
498 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received); | 524 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received); |
499 | if (SPEED != test || (ok_goal - 2) == ok) | 525 | if (SPEED != test || (ok_goal - 2) == ok) |
500 | { | 526 | { |
527 | /* Send ACK */ | ||
501 | GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, | 528 | GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, |
502 | GNUNET_TIME_UNIT_FOREVER_REL, | 529 | GNUNET_TIME_UNIT_FOREVER_REL, |
503 | size_payload + data_sent, | 530 | size_payload + ack_sent, &tmt_rdy, |
504 | &tmt_rdy, (void *) 1L); | 531 | (void *) client); |
505 | return GNUNET_OK; | 532 | return GNUNET_OK; |
506 | } | 533 | } |
507 | else | 534 | else |
@@ -510,17 +537,17 @@ data_callback (void *cls, struct GNUNET_CADET_Channel *channel, | |||
510 | return GNUNET_OK; | 537 | return GNUNET_OK; |
511 | } | 538 | } |
512 | } | 539 | } |
513 | else // Normally 0 | 540 | else /* Normally 0 */ |
514 | { | 541 | { |
515 | if (test == SPEED_ACK || test == SPEED) | 542 | if (SPEED_ACK == test || SPEED == test) |
516 | { | 543 | { |
517 | data_ack++; | 544 | ack_received++; |
518 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", data_ack); | 545 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received); |
519 | GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, | 546 | GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO, |
520 | GNUNET_TIME_UNIT_FOREVER_REL, | 547 | GNUNET_TIME_UNIT_FOREVER_REL, |
521 | size_payload + data_sent, | 548 | size_payload + data_sent, &tmt_rdy, |
522 | &tmt_rdy, (void *) 1L); | 549 | (void *) client); |
523 | if (data_ack < TOTAL_PACKETS && SPEED != test) | 550 | if (ack_received < TOTAL_PACKETS && SPEED != test) |
524 | return GNUNET_OK; | 551 | return GNUNET_OK; |
525 | if (ok == 2 && SPEED == test) | 552 | if (ok == 2 && SPEED == test) |
526 | return GNUNET_OK; | 553 | return GNUNET_OK; |
@@ -775,14 +802,14 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
775 | if (KEEPALIVE == test) | 802 | if (KEEPALIVE == test) |
776 | return; /* Don't send any data. */ | 803 | return; /* Don't send any data. */ |
777 | 804 | ||
778 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 805 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n"); |
779 | "Sending data initializer...\n"); | ||
780 | data_ack = 0; | ||
781 | data_received = 0; | 806 | data_received = 0; |
782 | data_sent = 0; | 807 | data_sent = 0; |
808 | ack_received = 0; | ||
809 | ack_sent = 0; | ||
783 | GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO, | 810 | GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO, |
784 | GNUNET_TIME_UNIT_FOREVER_REL, | 811 | GNUNET_TIME_UNIT_FOREVER_REL, |
785 | size_payload, &tmt_rdy, (void *) 1L); | 812 | size_payload, &tmt_rdy, (void *) 0L); |
786 | } | 813 | } |
787 | 814 | ||
788 | /** | 815 | /** |