aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-11-05 20:41:31 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-11-05 20:41:31 +0000
commitbfaeaf104997e6a3f9be262caf6e43ae54314d5c (patch)
treec8c1fe1c13d5d5299e31c82d80d7db85f3128a6c /src
parent4a85f64645e42530852e83eb1074451349212ed1 (diff)
downloadgnunet-bfaeaf104997e6a3f9be262caf6e43ae54314d5c.tar.gz
gnunet-bfaeaf104997e6a3f9be262caf6e43ae54314d5c.zip
changing to fixed number of packets instead of fixed size test data
Diffstat (limited to 'src')
-rw-r--r--src/stream/perf_stream_api.c111
1 files changed, 87 insertions, 24 deletions
diff --git a/src/stream/perf_stream_api.c b/src/stream/perf_stream_api.c
index fdce1c5c1..43696ce1c 100644
--- a/src/stream/perf_stream_api.c
+++ b/src/stream/perf_stream_api.c
@@ -47,8 +47,6 @@
47#include "gnunet_testing_lib.h" 47#include "gnunet_testing_lib.h"
48#include "gnunet_testbed_service.h" 48#include "gnunet_testbed_service.h"
49#include "gnunet_stream_lib.h" 49#include "gnunet_stream_lib.h"
50
51
52 50
53/** 51/**
54 * Simple struct to keep track of progress, and print a 52 * Simple struct to keep track of progress, and print a
@@ -130,12 +128,22 @@ struct PeerData
130 /** 128 /**
131 * Bytes the peer has written 129 * Bytes the peer has written
132 */ 130 */
133 unsigned int bytes_wrote; 131 size_t bytes_wrote;
134 132
135 /** 133 /**
136 * Byte the peer has read 134 * Byte the peer has read
137 */ 135 */
138 unsigned int bytes_read; 136 size_t bytes_read;
137
138 /**
139 * number of packets sent
140 */
141 unsigned int packets_wrote;
142
143 /**
144 * number of packets read
145 */
146 unsigned int packets_read;
139}; 147};
140 148
141 149
@@ -167,6 +175,11 @@ enum TestStage
167#define DATA_SIZE 5000000 /* 5mB */ 175#define DATA_SIZE 5000000 /* 5mB */
168 176
169/** 177/**
178 * Fixed number of packets we send in each direction during each subtest
179 */
180#define MAX_PACKETS 2000
181
182/**
170 * Listen socket of peer2 183 * Listen socket of peer2
171 */ 184 */
172struct GNUNET_STREAM_ListenSocket *peer2_listen_socket; 185struct GNUNET_STREAM_ListenSocket *peer2_listen_socket;
@@ -225,7 +238,7 @@ static uint32_t data[DATA_SIZE / 4];
225 * Payload sizes to test each major test with 238 * Payload sizes to test each major test with
226 */ 239 */
227static uint16_t payload_size[] = 240static uint16_t payload_size[] =
228{ 20, 500, 2000, 7000, 13000, 25000, 50000, 60000, 63000, 64000 }; 241{ 20, 500, 2000, 7000, 13000, 25000, 50000};//, 60000, 63000, 64000 };
229 242
230/** 243/**
231 * Current step of testing 244 * Current step of testing
@@ -243,6 +256,11 @@ static unsigned int payload_size_index;
243static int num_peers; 256static int num_peers;
244 257
245/** 258/**
259 * Flag to indicate that the other peer should reset its data read source index
260 */
261static int reset_read;
262
263/**
246 * Testing result of a major test 264 * Testing result of a major test
247 */ 265 */
248static enum TestStage result; 266static enum TestStage result;
@@ -429,7 +447,7 @@ stream_write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
429 * 447 *
430 * @param cls the closure from GNUNET_STREAM_write/read 448 * @param cls the closure from GNUNET_STREAM_write/read
431 * @param status the status of the stream at the time this function is called 449 * @param status the status of the stream at the time this function is called
432 * @param size the number of bytes read or written 450 * @param size the number of bytes written
433 */ 451 */
434static void 452static void
435write_completion (void *cls, enum GNUNET_STREAM_Status status, size_t size) 453write_completion (void *cls, enum GNUNET_STREAM_Status status, size_t size)
@@ -437,6 +455,7 @@ write_completion (void *cls, enum GNUNET_STREAM_Status status, size_t size)
437 struct PeerData *pdata = cls; 455 struct PeerData *pdata = cls;
438 double throughput; 456 double throughput;
439 double prof_time_sec; 457 double prof_time_sec;
458 unsigned int packets_wrote;
440 459
441 if (GNUNET_STREAM_OK != status) 460 if (GNUNET_STREAM_OK != status)
442 { 461 {
@@ -445,11 +464,18 @@ write_completion (void *cls, enum GNUNET_STREAM_Status status, size_t size)
445 return; 464 return;
446 } 465 }
447 GNUNET_assert (size <= DATA_SIZE); 466 GNUNET_assert (size <= DATA_SIZE);
467 packets_wrote = (size + payload_size[payload_size_index] - 1)
468 / payload_size[payload_size_index];
448 pdata->bytes_wrote += size; 469 pdata->bytes_wrote += size;
449 for (;size > 0; size--) 470 for (;packets_wrote > 0; packets_wrote--)
471 {
450 update_meter (meter); 472 update_meter (meter);
451 if (pdata->bytes_wrote < DATA_SIZE) /* Have more data to send */ 473 pdata->packets_wrote++;
452 { 474 }
475 if (pdata->packets_wrote < MAX_PACKETS) /* Have more data to send */
476 {
477 size_t write_amount;
478
453 if (GNUNET_SCHEDULER_NO_TASK != abort_task) 479 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
454 { 480 {
455 GNUNET_SCHEDULER_cancel (abort_task); 481 GNUNET_SCHEDULER_cancel (abort_task);
@@ -458,12 +484,15 @@ write_completion (void *cls, enum GNUNET_STREAM_Status status, size_t size)
458 (GNUNET_TIME_UNIT_SECONDS, 300), &do_abort, 484 (GNUNET_TIME_UNIT_SECONDS, 300), &do_abort,
459 NULL); 485 NULL);
460 } 486 }
461 pdata->io_write_handle = 487 write_amount = (MAX_PACKETS - pdata->packets_wrote) *
462 GNUNET_STREAM_write (pdata->socket, 488 payload_size[payload_size_index];
463 ((void *) data) + pdata->bytes_wrote, 489 if (write_amount > DATA_SIZE)
464 sizeof (data) - pdata->bytes_wrote, 490 write_amount = DATA_SIZE;
465 GNUNET_TIME_UNIT_FOREVER_REL, &write_completion, 491 reset_read = GNUNET_YES;
466 pdata); 492 pdata->io_write_handle = GNUNET_STREAM_write (pdata->socket, data,
493 write_amount,
494 GNUNET_TIME_UNIT_FOREVER_REL,
495 &write_completion, pdata);
467 GNUNET_assert (NULL != pdata->io_write_handle); 496 GNUNET_assert (NULL != pdata->io_write_handle);
468 } 497 }
469 else 498 else
@@ -472,7 +501,7 @@ write_completion (void *cls, enum GNUNET_STREAM_Status status, size_t size)
472 meter = NULL; 501 meter = NULL;
473 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); 502 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
474 prof_time_sec = (((double) prof_time.rel_value)/ ((double) 1000)); 503 prof_time_sec = (((double) prof_time.rel_value)/ ((double) 1000));
475 throughput = (((float) sizeof (data)) / prof_time_sec); 504 throughput = ((float) pdata->bytes_wrote) / prof_time_sec;
476 PRINTF ("Throughput %.2f kB/sec\n", throughput / 1000.00); 505 PRINTF ("Throughput %.2f kB/sec\n", throughput / 1000.00);
477 switch (result) 506 switch (result)
478 { 507 {
@@ -481,7 +510,8 @@ write_completion (void *cls, enum GNUNET_STREAM_Status status, size_t size)
481 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == read_task); 510 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == read_task);
482 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == write_task); 511 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == write_task);
483 pdata->bytes_read = 0; 512 pdata->bytes_read = 0;
484 meter = create_meter (sizeof (data), "Testing Downlink\n", GNUNET_YES); 513 pdata->packets_read = 0;
514 meter = create_meter (MAX_PACKETS, "Testing Downlink\n", GNUNET_YES);
485 read_task = GNUNET_SCHEDULER_add_now (&stream_read_task, &peer_data[0]); 515 read_task = GNUNET_SCHEDULER_add_now (&stream_read_task, &peer_data[0]);
486 write_task = GNUNET_SCHEDULER_add_now (&stream_write_task, &peer_data[1]); 516 write_task = GNUNET_SCHEDULER_add_now (&stream_write_task, &peer_data[1]);
487 break; 517 break;
@@ -506,7 +536,8 @@ static void
506stream_write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 536stream_write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
507{ 537{
508 struct PeerData *pdata = cls; 538 struct PeerData *pdata = cls;
509 539 size_t write_amount;
540
510 if (GNUNET_SCHEDULER_NO_TASK != abort_task) 541 if (GNUNET_SCHEDULER_NO_TASK != abort_task)
511 { 542 {
512 GNUNET_SCHEDULER_cancel (abort_task); 543 GNUNET_SCHEDULER_cancel (abort_task);
@@ -518,8 +549,13 @@ stream_write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
518 write_task = GNUNET_SCHEDULER_NO_TASK; 549 write_task = GNUNET_SCHEDULER_NO_TASK;
519 prof_start_time = GNUNET_TIME_absolute_get (); 550 prof_start_time = GNUNET_TIME_absolute_get ();
520 pdata->bytes_wrote = 0; 551 pdata->bytes_wrote = 0;
552 pdata->packets_wrote = 0;
553 write_amount = MAX_PACKETS * payload_size[payload_size_index];
554 if (write_amount > DATA_SIZE)
555 write_amount = DATA_SIZE;
556 reset_read = GNUNET_YES;
521 pdata->io_write_handle = GNUNET_STREAM_write (pdata->socket, data, 557 pdata->io_write_handle = GNUNET_STREAM_write (pdata->socket, data,
522 sizeof (data), 558 write_amount,
523 GNUNET_TIME_UNIT_FOREVER_REL, 559 GNUNET_TIME_UNIT_FOREVER_REL,
524 &write_completion, pdata); 560 &write_completion, pdata);
525 GNUNET_assert (NULL != pdata->io_write_handle); 561 GNUNET_assert (NULL != pdata->io_write_handle);
@@ -556,11 +592,36 @@ input_processor (void *cls, enum GNUNET_STREAM_Status status,
556 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); 592 abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL);
557 return 0; 593 return 0;
558 } 594 }
559 GNUNET_assert (size < DATA_SIZE); 595 GNUNET_assert (size <= DATA_SIZE);
596 if (GNUNET_YES == reset_read)
597 {
598 pdata->bytes_read = 0;
599 reset_read = GNUNET_NO;
600 }
601 GNUNET_assert ((pdata->bytes_read + size) <= DATA_SIZE);
602 /* if (pdata->bytes_read + size > DATA_SIZE) */
603 /* { */
604 /* size_t split_size; */
605
606 /* split_size = DATA_SIZE - pdata->bytes_read; */
607 /* GNUNET_assert (0 == memcmp (((void *) data) + pdata->bytes_read, */
608 /* input_data, split_size)); */
609 /* GNUNET_assert (0 == memcmp (((void *) data), input_data + split_size, */
610 /* size - split_size)); */
611 /* pdata->bytes_read = size - split_size; */
612 /* printf ("?"); */
613 /* } */
614 /* else */
615 /* { */
560 GNUNET_assert (0 == memcmp (((void *)data ) + pdata->bytes_read, 616 GNUNET_assert (0 == memcmp (((void *)data ) + pdata->bytes_read,
561 input_data, size)); 617 input_data, size));
562 pdata->bytes_read += size; 618 pdata->bytes_read += size;
563 if (pdata->bytes_read < DATA_SIZE) 619 /* } */
620 /* if ((64 * payload_size[payload_size_index]) == pdata->bytes_read) */
621 /* pdata->bytes_read = 0; */
622 pdata->packets_read += (size + payload_size[payload_size_index] - 1)
623 / payload_size[payload_size_index];
624 if (pdata->packets_read < MAX_PACKETS)
564 { 625 {
565 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == read_task); 626 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == read_task);
566 read_task = GNUNET_SCHEDULER_add_now (&stream_read_task, pdata); 627 read_task = GNUNET_SCHEDULER_add_now (&stream_read_task, pdata);
@@ -639,7 +700,7 @@ stream_open_cb (void *cls,
639 struct PeerData *pdata = cls; 700 struct PeerData *pdata = cls;
640 701
641 GNUNET_assert (socket == pdata->socket); 702 GNUNET_assert (socket == pdata->socket);
642 meter = create_meter (sizeof (data), "Testing Uplink\n", GNUNET_YES); 703 meter = create_meter (MAX_PACKETS, "Testing Uplink\n", GNUNET_YES);
643 write_task = GNUNET_SCHEDULER_add_now (&stream_write_task, pdata); 704 write_task = GNUNET_SCHEDULER_add_now (&stream_write_task, pdata);
644} 705}
645 706
@@ -928,6 +989,7 @@ int main (int argc, char **argv)
928 payload_size[payload_size_index]); 989 payload_size[payload_size_index]);
929 (void) memset (peer_data, 0, sizeof (peer_data)); 990 (void) memset (peer_data, 0, sizeof (peer_data));
930 result = INIT; 991 result = INIT;
992 reset_read = GNUNET_NO;
931 ret = GNUNET_TESTING_peer_run (test_name, cfg_file, &run, NULL); 993 ret = GNUNET_TESTING_peer_run (test_name, cfg_file, &run, NULL);
932 if ((0 != ret) || (DOWNLINK_OK != result)) 994 if ((0 != ret) || (DOWNLINK_OK != result))
933 goto return_fail; 995 goto return_fail;
@@ -945,6 +1007,7 @@ int main (int argc, char **argv)
945 payload_size[payload_size_index]); 1007 payload_size[payload_size_index]);
946 (void) memset (peer_data, 0, sizeof (peer_data)); 1008 (void) memset (peer_data, 0, sizeof (peer_data));
947 result = INIT; 1009 result = INIT;
1010 reset_read = GNUNET_NO;
948 GNUNET_TESTBED_test_run (test_name, cfg_file, num_peers, event_mask, 1011 GNUNET_TESTBED_test_run (test_name, cfg_file, num_peers, event_mask,
949 &controller_event_cb, NULL, &test_master, NULL); 1012 &controller_event_cb, NULL, &test_master, NULL);
950 if (DOWNLINK_OK != result) 1013 if (DOWNLINK_OK != result)