aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-03-21 18:44:29 +0000
committerBart Polot <bart@net.in.tum.de>2014-03-21 18:44:29 +0000
commita046086765eaa8fa0014971ac4b619b82af0103a (patch)
tree8361d220d0910fa7495b1d6316971798c7179535 /src/mesh
parent547f6fded23aef584fe5970c0a231b7eca111db4 (diff)
downloadgnunet-a046086765eaa8fa0014971ac4b619b82af0103a.tar.gz
gnunet-a046086765eaa8fa0014971ac4b619b82af0103a.zip
- changes to round system, stats collection
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-mesh-profiler.c91
1 files changed, 62 insertions, 29 deletions
diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c
index 8ff4b73ee..14316c5dd 100644
--- a/src/mesh/gnunet-mesh-profiler.c
+++ b/src/mesh/gnunet-mesh-profiler.c
@@ -35,23 +35,22 @@
35/** 35/**
36 * How many peers to run 36 * How many peers to run
37 */ 37 */
38#define TOTAL_PEERS 10 38#define TOTAL_PEERS 20
39 39
40/** 40/**
41 * How many peers do pinging 41 * How many peers do pinging
42 */ 42 */
43#define PING_PEERS 1 43#define PING_PEERS 3
44
45 44
46/** 45/**
47 * Duration of each round. 46 * Duration of each round.
48 */ 47 */
49#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 48#define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
50 49
51/** 50/**
52 * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD) 51 * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD)
53 */ 52 */
54#define PING_PERIOD 2000 53#define PING_PERIOD 1000
55 54
56/** 55/**
57 * How long until we give up on connecting the peers? 56 * How long until we give up on connecting the peers?
@@ -63,9 +62,17 @@
63 */ 62 */
64#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) 63#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
65 64
65/**
66 * Ratio of peers active. First round always is 1.0.
67 */
66static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.0}; 68static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.0};
67 69
68/** 70/**
71 * Total number of rounds.
72 */
73static const unsigned int number_rounds = sizeof(rounds)/sizeof(rounds[0]);
74
75/**
69 * Message type for pings. 76 * Message type for pings.
70 */ 77 */
71struct MeshPingMessage 78struct MeshPingMessage
@@ -84,6 +91,11 @@ struct MeshPingMessage
84 * Time the message was sent. 91 * Time the message was sent.
85 */ 92 */
86 struct GNUNET_TIME_AbsoluteNBO timestamp; 93 struct GNUNET_TIME_AbsoluteNBO timestamp;
94
95 /**
96 * Round number.
97 */
98 uint32_t round_number;
87}; 99};
88 100
89/** 101/**
@@ -126,6 +138,9 @@ struct MeshPeer
126 */ 138 */
127 int data_received; 139 int data_received;
128 140
141 /**
142 * Is peer up?
143 */
129 int up; 144 int up;
130 145
131 /** 146 /**
@@ -142,6 +157,12 @@ struct MeshPeer
142 * Task to do the next ping. 157 * Task to do the next ping.
143 */ 158 */
144 GNUNET_SCHEDULER_TaskIdentifier ping_task; 159 GNUNET_SCHEDULER_TaskIdentifier ping_task;
160
161 float mean[number_rounds];
162 float var[number_rounds];
163 unsigned int pongs[number_rounds];
164 unsigned int pings[number_rounds];
165
145}; 166};
146 167
147/** 168/**
@@ -160,16 +181,6 @@ static struct GNUNET_TESTBED_Peer **testbed_handles;
160static struct GNUNET_TESTBED_Operation *stats_op; 181static struct GNUNET_TESTBED_Operation *stats_op;
161 182
162/** 183/**
163 * How many events have happened
164 */
165static int ok;
166
167/**
168 * Number of events expected to conclude the test successfully.
169 */
170static int ok_goal;
171
172/**
173 * Operation to get peer ids. 184 * Operation to get peer ids.
174 */ 185 */
175struct MeshPeer peers[TOTAL_PEERS]; 186struct MeshPeer peers[TOTAL_PEERS];
@@ -204,6 +215,10 @@ static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
204 */ 215 */
205static GNUNET_SCHEDULER_TaskIdentifier test_task; 216static GNUNET_SCHEDULER_TaskIdentifier test_task;
206 217
218/**
219 * Round number.
220 */
221static unsigned int current_round;
207 222
208/** 223/**
209 * Flag to notify callbacks not to generate any new traffic anymore. 224 * Flag to notify callbacks not to generate any new traffic anymore.
@@ -247,6 +262,20 @@ get_index (struct MeshPeer *peer)
247static void 262static void
248show_end_data (void) 263show_end_data (void)
249{ 264{
265 struct MeshPeer *peer;
266 unsigned int i;
267 unsigned int j;
268
269 for (i = 0; i < number_rounds; i++)
270 {
271 for (j = 0; j < PING_PEERS; j++)
272 {
273 peer = &peers[j];
274 FPRINTF (stdout, "ROUND %u PEER %u: %f, PINGS: %u, PONGS: %u\n",
275 i, j, ((float)peer->sum_delay[i])/peer->pongs[i],
276 peer->pings[i], peer->pongs[i]);
277 }
278 }
250} 279}
251 280
252 281
@@ -481,21 +510,20 @@ adjust_running_peers (unsigned int target)
481static void 510static void
482next_rnd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 511next_rnd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
483{ 512{
484 long round = (long) cls;
485
486 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) 513 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
487 return; 514 return;
488 515
489 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ROUND %ld\n", round); 516 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ROUND %ld\n", current_round);
490 if (0.0 == rounds[round]) 517 if (0.0 == rounds[current_round])
491 { 518 {
492 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Finishing\n"); 519 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Finishing\n");
493 GNUNET_SCHEDULER_add_now (&finish_profiler, NULL); 520 GNUNET_SCHEDULER_add_now (&finish_profiler, NULL);
494 return; 521 return;
495 } 522 }
496 adjust_running_peers (rounds[round] * TOTAL_PEERS); 523 adjust_running_peers (rounds[current_round] * TOTAL_PEERS);
524 current_round++;
497 525
498 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, (void *) (round + 1)); 526 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL);
499} 527}
500 528
501 529
@@ -612,7 +640,9 @@ tmt_rdy_ping (void *cls, size_t size, void *buf)
612 msg->header.size = htons (size); 640 msg->header.size = htons (size);
613 msg->header.type = htons (PING); 641 msg->header.type = htons (PING);
614 msg->counter = htonl (peer->data_sent++); 642 msg->counter = htonl (peer->data_sent++);
643 msg->round_number = htonl (current_round);
615 msg->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 644 msg->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
645 peer->pings[current_round]++;
616 peer->ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (PING_PERIOD), 646 peer->ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (PING_PERIOD),
617 &ping, peer); 647 &ping, peer);
618 648
@@ -666,6 +696,7 @@ pong_handler (void *cls, struct GNUNET_MESH_Channel *channel,
666 struct MeshPingMessage *msg; 696 struct MeshPingMessage *msg;
667 struct GNUNET_TIME_Absolute send_time; 697 struct GNUNET_TIME_Absolute send_time;
668 struct GNUNET_TIME_Relative latency; 698 struct GNUNET_TIME_Relative latency;
699 unsigned int ping_round;
669 700
670 GNUNET_MESH_receive_done (channel); 701 GNUNET_MESH_receive_done (channel);
671 peer = &peers[n]; 702 peer = &peers[n];
@@ -674,9 +705,12 @@ pong_handler (void *cls, struct GNUNET_MESH_Channel *channel,
674 705
675 send_time = GNUNET_TIME_absolute_ntoh (msg->timestamp); 706 send_time = GNUNET_TIME_absolute_ntoh (msg->timestamp);
676 latency = GNUNET_TIME_absolute_get_duration (send_time); 707 latency = GNUNET_TIME_absolute_get_duration (send_time);
708 ping_round = ntohl (msg->round_number);
677 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <- %u (%u) latency: %s\n", 709 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <- %u (%u) latency: %s\n",
678 get_index (peer), get_index (peer->dest), ntohl (msg->counter), 710 get_index (peer), get_index (peer->dest), ntohl (msg->counter),
679 GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO)); 711 GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO));
712 peer->sum_delay[ping_round] += latency.rel_value_us;
713 peer->pongs[ping_round]++;
680 714
681 return GNUNET_OK; 715 return GNUNET_OK;
682} 716}
@@ -800,6 +834,13 @@ start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
800 &ping, &peers[i]); 834 &ping, &peers[i]);
801 } 835 }
802 peers_running = TOTAL_PEERS; 836 peers_running = TOTAL_PEERS;
837 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
838 GNUNET_SCHEDULER_cancel (disconnect_task);
839 disconnect_task =
840 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(ROUND_TIME,
841 number_rounds + 1),
842 &disconnect_mesh_peers,
843 (void *) __LINE__);
803 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL); 844 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL);
804} 845}
805 846
@@ -864,7 +905,6 @@ tmain (void *cls,
864 unsigned long i; 905 unsigned long i;
865 906
866 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n"); 907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
867 ok = 0;
868 test_ctx = ctx; 908 test_ctx = ctx;
869 GNUNET_assert (TOTAL_PEERS > 2 * PING_PEERS); 909 GNUNET_assert (TOTAL_PEERS > 2 * PING_PEERS);
870 GNUNET_assert (TOTAL_PEERS == num_peers); 910 GNUNET_assert (TOTAL_PEERS == num_peers);
@@ -912,13 +952,6 @@ main (int argc, char *argv[])
912 &incoming_channel, &channel_cleaner, 952 &incoming_channel, &channel_cleaner,
913 handlers, ports); 953 handlers, ports);
914 954
915 if (ok_goal > ok)
916 {
917 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
918 "FAILED! (%d/%d)\n", ok, ok_goal);
919 return 1;
920 }
921 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
922 return 0; 955 return 0;
923} 956}
924 957