diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-03-13 15:01:44 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-03-13 15:01:44 +0000 |
commit | d309f70641efc038d4b23558030b0551c3101256 (patch) | |
tree | c94b99f7861b13047a138eeaab78c4cea19ca8e9 /src | |
parent | 220cf75b15b4877944119762549a8e1f45dc88e0 (diff) | |
download | gnunet-d309f70641efc038d4b23558030b0551c3101256.tar.gz gnunet-d309f70641efc038d4b23558030b0551c3101256.zip |
- fix warnings, remove explicit keepalive count
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/mesh_profiler.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/src/mesh/mesh_profiler.c b/src/mesh/mesh_profiler.c index b42c1812e..50745ceb7 100644 --- a/src/mesh/mesh_profiler.c +++ b/src/mesh/mesh_profiler.c | |||
@@ -90,17 +90,18 @@ struct MeshPeer | |||
90 | struct MeshPeer *dest; | 90 | struct MeshPeer *dest; |
91 | struct MeshPeer *incoming; | 91 | struct MeshPeer *incoming; |
92 | GNUNET_SCHEDULER_TaskIdentifier ping_task; | 92 | GNUNET_SCHEDULER_TaskIdentifier ping_task; |
93 | struct GNUNET_TIME_Absolute timestamp; | ||
93 | }; | 94 | }; |
94 | 95 | ||
95 | /** | 96 | /** |
96 | * Testbed peer handles. | 97 | * Testbed peer handles. |
97 | */ | 98 | */ |
98 | struct GNUNET_TESTBED_Peer **testbed_handles; | 99 | static struct GNUNET_TESTBED_Peer **testbed_handles; |
99 | 100 | ||
100 | /** | 101 | /** |
101 | * Testbed Operation (to get stats). | 102 | * Testbed Operation (to get stats). |
102 | */ | 103 | */ |
103 | struct GNUNET_TESTBED_Operation *stats_op; | 104 | static struct GNUNET_TESTBED_Operation *stats_op; |
104 | 105 | ||
105 | /** | 106 | /** |
106 | * How many events have happened | 107 | * How many events have happened |
@@ -110,7 +111,7 @@ static int ok; | |||
110 | /** | 111 | /** |
111 | * Number of events expected to conclude the test successfully. | 112 | * Number of events expected to conclude the test successfully. |
112 | */ | 113 | */ |
113 | int ok_goal; | 114 | static int ok_goal; |
114 | 115 | ||
115 | /** | 116 | /** |
116 | * Size of each test packet | 117 | * Size of each test packet |
@@ -125,7 +126,7 @@ struct MeshPeer peers[TOTAL_PEERS]; | |||
125 | /** | 126 | /** |
126 | * Peer ids counter. | 127 | * Peer ids counter. |
127 | */ | 128 | */ |
128 | unsigned int p_ids; | 129 | static unsigned int p_ids; |
129 | 130 | ||
130 | /** | 131 | /** |
131 | * Is the setup initialized? | 132 | * Is the setup initialized? |
@@ -140,7 +141,7 @@ static unsigned long long peers_running; | |||
140 | /** | 141 | /** |
141 | * Test context (to shut down). | 142 | * Test context (to shut down). |
142 | */ | 143 | */ |
143 | struct GNUNET_MESH_TEST_Context *test_ctx; | 144 | static struct GNUNET_MESH_TEST_Context *test_ctx; |
144 | 145 | ||
145 | /** | 146 | /** |
146 | * Task called to shutdown test. | 147 | * Task called to shutdown test. |
@@ -164,10 +165,9 @@ static GNUNET_SCHEDULER_TaskIdentifier test_task; | |||
164 | static struct GNUNET_TIME_Absolute start_time; | 165 | static struct GNUNET_TIME_Absolute start_time; |
165 | 166 | ||
166 | /** | 167 | /** |
167 | * | 168 | * Flag to notify callbacks not to generate any new traffic anymore. |
168 | */ | 169 | */ |
169 | static unsigned int ka_sent; | 170 | static int test_finished; |
170 | static unsigned int ka_received; | ||
171 | 171 | ||
172 | /** | 172 | /** |
173 | * Calculate a random delay. | 173 | * Calculate a random delay. |
@@ -267,7 +267,7 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | * Abort test: schedule disconnect and shutdown immediately | 270 | * Finish test normally: schedule disconnect and shutdown |
271 | * | 271 | * |
272 | * @param line Line in the code the abort is requested from (__LINE__). | 272 | * @param line Line in the code the abort is requested from (__LINE__). |
273 | */ | 273 | */ |
@@ -282,7 +282,6 @@ abort_test (long line) | |||
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | |||
286 | /** | 285 | /** |
287 | * Stats callback. Finish the stats testbed operation and when all stats have | 286 | * Stats callback. Finish the stats testbed operation and when all stats have |
288 | * been iterated, shutdown the test. | 287 | * been iterated, shutdown the test. |
@@ -322,24 +321,12 @@ stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer, | |||
322 | const char *subsystem, const char *name, | 321 | const char *subsystem, const char *name, |
323 | uint64_t value, int is_persistent) | 322 | uint64_t value, int is_persistent) |
324 | { | 323 | { |
325 | static const char *s_sent = "# keepalives sent"; | ||
326 | static const char *s_recv = "# keepalives received"; | ||
327 | uint32_t i; | 324 | uint32_t i; |
328 | 325 | ||
329 | i = GNUNET_TESTBED_get_index (peer); | 326 | i = GNUNET_TESTBED_get_index (peer); |
330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u - %s [%s]: %llu\n", | 327 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u - %s [%s]: %llu\n", |
331 | i, subsystem, name, value); | 328 | i, subsystem, name, value); |
332 | if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i) | ||
333 | ka_sent = value; | ||
334 | 329 | ||
335 | if (0 == strncmp(s_recv, name, strlen (s_recv)) && 4 == i) | ||
336 | { | ||
337 | ka_received = value; | ||
338 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " sent: %u, received: %u\n", | ||
339 | ka_sent, ka_received); | ||
340 | if (ka_sent < 2 || ka_sent > ka_received + 1) | ||
341 | ok--; | ||
342 | } | ||
343 | 330 | ||
344 | return GNUNET_OK; | 331 | return GNUNET_OK; |
345 | } | 332 | } |
@@ -366,6 +353,25 @@ collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
366 | 353 | ||
367 | 354 | ||
368 | /** | 355 | /** |
356 | * @brief Finish profiler normally. | ||
357 | * | ||
358 | * @param cls Closure (unused). | ||
359 | * @param tc Task context. | ||
360 | */ | ||
361 | static void | ||
362 | finish_profiler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
363 | { | ||
364 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | ||
365 | return; | ||
366 | |||
367 | test_finished = GNUNET_YES; | ||
368 | show_end_data(); | ||
369 | GNUNET_SCHEDULER_add_now (&collect_stats, NULL); | ||
370 | } | ||
371 | |||
372 | |||
373 | |||
374 | /** | ||
369 | * Transmit ready callback. | 375 | * Transmit ready callback. |
370 | * | 376 | * |
371 | * @param cls Closure (peer). | 377 | * @param cls Closure (peer). |
@@ -475,8 +481,8 @@ tmt_rdy (void *cls, size_t size, void *buf) | |||
475 | GNUNET_SCHEDULER_add_now (&data_task, peer); | 481 | GNUNET_SCHEDULER_add_now (&data_task, peer); |
476 | } | 482 | } |
477 | } | 483 | } |
478 | 484 | peer->timestamp = GNUNET_TIME_absolute_get (); | |
479 | peers->ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (60 * 1000), | 485 | peer->ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (60 * 1000), |
480 | &ping, peer); | 486 | &ping, peer); |
481 | 487 | ||
482 | return size_payload; | 488 | return size_payload; |
@@ -699,6 +705,8 @@ tmain (void *cls, | |||
699 | GNUNET_assert (TOTAL_PEERS == num_peers); | 705 | GNUNET_assert (TOTAL_PEERS == num_peers); |
700 | peers_running = num_peers; | 706 | peers_running = num_peers; |
701 | testbed_handles = testbed_handles; | 707 | testbed_handles = testbed_handles; |
708 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | ||
709 | &finish_profiler, NULL); | ||
702 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, | 710 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, |
703 | &disconnect_mesh_peers, | 711 | &disconnect_mesh_peers, |
704 | (void *) __LINE__); | 712 | (void *) __LINE__); |
@@ -730,6 +738,7 @@ main (int argc, char *argv[]) | |||
730 | config_file = "test_mesh.conf"; | 738 | config_file = "test_mesh.conf"; |
731 | 739 | ||
732 | p_ids = 0; | 740 | p_ids = 0; |
741 | test_finished = GNUNET_NO; | ||
733 | ports[0] = 1; | 742 | ports[0] = 1; |
734 | ports[1] = 0; | 743 | ports[1] = 0; |
735 | GNUNET_MESH_TEST_run ("mesh_profiler", config_file, TOTAL_PEERS, | 744 | GNUNET_MESH_TEST_run ("mesh_profiler", config_file, TOTAL_PEERS, |