aboutsummaryrefslogtreecommitdiff
path: root/src/ats/perf_ats.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-08-22 15:24:35 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-08-22 15:24:35 +0000
commit4ff24baadae628818de7f81deff9f4eba70ba942 (patch)
tree4df2a511a85f66a7f69f2c44d9341972b98e3d53 /src/ats/perf_ats.c
parent883972c483849025aeb4943281edfef3df04a609 (diff)
downloadgnunet-4ff24baadae628818de7f81deff9f4eba70ba942.tar.gz
gnunet-4ff24baadae628818de7f81deff9f4eba70ba942.zip
communication done
Diffstat (limited to 'src/ats/perf_ats.c')
-rw-r--r--src/ats/perf_ats.c141
1 files changed, 134 insertions, 7 deletions
diff --git a/src/ats/perf_ats.c b/src/ats/perf_ats.c
index 2b8a51d8b..208e08b0a 100644
--- a/src/ats/perf_ats.c
+++ b/src/ats/perf_ats.c
@@ -84,11 +84,20 @@ struct BenchmarkPeer
84 /* Message exchange */ 84 /* Message exchange */
85 struct GNUNET_CORE_TransmitHandle *cth; 85 struct GNUNET_CORE_TransmitHandle *cth;
86 86
87 struct PendingMessages *p_head;
88 struct PendingMessages *p_tail;
89
87 int last_slave; 90 int last_slave;
88 91
89 int core_connections; 92 int core_connections;
90 93
91 int slave_connections; 94 int slave_connections;
95
96 /**
97 * Statistics
98 */
99 unsigned int messages_sent;
100 unsigned int messages_received;
92}; 101};
93 102
94 103
@@ -140,6 +149,16 @@ static int result;
140static char *solver; 149static char *solver;
141static char *preference; 150static char *preference;
142 151
152/**
153 * Pending Responses
154 */
155struct PendingMessages
156{
157 struct PendingMessages *prev;
158 struct PendingMessages *next;
159 struct GNUNET_PeerIdentity target;
160};
161
143 162
144/** 163/**
145 * Information we track for a peer in the testbed. 164 * Information we track for a peer in the testbed.
@@ -163,6 +182,18 @@ core_connect_completion_cb (void *cls,
163 void *ca_result, 182 void *ca_result,
164 const char *emsg ); 183 const char *emsg );
165 184
185
186static void evaluate ()
187{
188 int c_p;
189 for (c_p = 0; c_p < c_master_peers; c_p++)
190 {
191 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Peer %u: %u KiB/s \n"),
192 bp_master[c_p].no,
193 (bp_master[c_p].messages_sent * TEST_MESSAGE_SIZE) / 10240);
194 }
195}
196
166/** 197/**
167 * Shutdown nicely 198 * Shutdown nicely
168 * 199 *
@@ -174,13 +205,32 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
174{ 205{
175 int c_p; 206 int c_p;
176 int c_op; 207 int c_op;
208 struct PendingMessages *cur;
209 struct PendingMessages *next;
210
177 shutdown_task = GNUNET_SCHEDULER_NO_TASK; 211 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
178 212
179 state.benchmarking = GNUNET_NO; 213 state.benchmarking = GNUNET_NO;
214
215 evaluate ();
180 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n")); 216 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
181 217
182 for (c_p = 0; c_p < c_master_peers; c_p++) 218 for (c_p = 0; c_p < c_master_peers; c_p++)
183 { 219 {
220 next = bp_master[c_p].p_head;
221 for (cur = next; cur != NULL; cur = next )
222 {
223 next = cur->next;
224 GNUNET_CONTAINER_DLL_remove (bp_master[c_p].p_head, bp_master[c_p].p_tail, cur);
225 GNUNET_free (cur);
226 }
227
228 if (NULL != bp_master[c_p].cth)
229 {
230 GNUNET_CORE_notify_transmit_ready_cancel(bp_master[c_p].cth);
231 bp_master[c_p].cth = NULL;
232 }
233
184 if (NULL != bp_master[c_p].ats_perf_op) 234 if (NULL != bp_master[c_p].ats_perf_op)
185 { 235 {
186 GNUNET_TESTBED_operation_done (bp_master[c_p].ats_perf_op); 236 GNUNET_TESTBED_operation_done (bp_master[c_p].ats_perf_op);
@@ -215,6 +265,20 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
215 265
216 for (c_p = 0; c_p < c_slave_peers; c_p++) 266 for (c_p = 0; c_p < c_slave_peers; c_p++)
217 { 267 {
268 next = bp_slaves[c_p].p_head;
269 for (cur = next; cur != NULL; cur = next )
270 {
271 next = cur->next;
272 GNUNET_CONTAINER_DLL_remove (bp_slaves[c_p].p_head, bp_slaves[c_p].p_tail, cur);
273 GNUNET_free (cur);
274 }
275
276 if (NULL != bp_slaves[c_p].cth)
277 {
278 GNUNET_CORE_notify_transmit_ready_cancel(bp_slaves[c_p].cth);
279 bp_slaves[c_p].cth = NULL;
280 }
281
218 if (NULL != bp_slaves[c_p].ats_perf_op) 282 if (NULL != bp_slaves[c_p].ats_perf_op)
219 { 283 {
220 GNUNET_TESTBED_operation_done (bp_slaves[c_p].ats_perf_op); 284 GNUNET_TESTBED_operation_done (bp_slaves[c_p].ats_perf_op);
@@ -300,7 +364,7 @@ ats_performance_info_cb (void *cls,
300 peer_id = GNUNET_strdup (GNUNET_i2s (&p->id)); 364 peer_id = GNUNET_strdup (GNUNET_i2s (&p->id));
301 for (c_a = 0; c_a < ats_count; c_a++) 365 for (c_a = 0; c_a < ats_count; c_a++)
302 { 366 {
303 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%c %03u: %s %s %u\n"), 367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("%c %03u: %s %s %u\n"),
304 (GNUNET_YES == p->master) ? 'M' : 'S', 368 (GNUNET_YES == p->master) ? 'M' : 'S',
305 p->no, 369 p->no,
306 GNUNET_i2s (&address->peer), 370 GNUNET_i2s (&address->peer),
@@ -323,13 +387,13 @@ core_send_ready (void *cls, size_t size, void *buf)
323 struct GNUNET_MessageHeader *msg; 387 struct GNUNET_MessageHeader *msg;
324 388
325 bp->cth = NULL; 389 bp->cth = NULL;
390 bp->messages_sent ++;
326 391
327 msg = (struct GNUNET_MessageHeader *) &msgbuf; 392 msg = (struct GNUNET_MessageHeader *) &msgbuf;
328 memset (&msgbuf, 'a', TEST_MESSAGE_SIZE); 393 memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
329 msg->type = htons (TEST_MESSAGE_TYPE_PING); 394 msg->type = htons (TEST_MESSAGE_TYPE_PING);
330 msg->size = htons (TEST_MESSAGE_SIZE); 395 msg->size = htons (TEST_MESSAGE_SIZE);
331 memcpy (buf, msg, TEST_MESSAGE_SIZE); 396 memcpy (buf, msg, TEST_MESSAGE_SIZE);
332 /* GNUNET_break (0); */
333 return TEST_MESSAGE_SIZE; 397 return TEST_MESSAGE_SIZE;
334} 398}
335 399
@@ -338,7 +402,6 @@ static void
338do_benchmark () 402do_benchmark ()
339{ 403{
340 int c_m; 404 int c_m;
341 int c_s;
342 405
343 if ((state.connected_ATS_service == GNUNET_NO) || 406 if ((state.connected_ATS_service == GNUNET_NO) ||
344 (state.connected_CORE_service == GNUNET_NO) || 407 (state.connected_CORE_service == GNUNET_NO) ||
@@ -572,6 +635,8 @@ core_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
572 GNUNET_free (id); 635 GNUNET_free (id);
573} 636}
574 637
638static size_t
639core_send_echo_queued_ready (void *cls, size_t size, void *buf);
575 640
576static size_t 641static size_t
577core_send_echo_ready (void *cls, size_t size, void *buf) 642core_send_echo_ready (void *cls, size_t size, void *buf)
@@ -587,10 +652,33 @@ core_send_echo_ready (void *cls, size_t size, void *buf)
587 msg->type = htons (TEST_MESSAGE_TYPE_PONG); 652 msg->type = htons (TEST_MESSAGE_TYPE_PONG);
588 msg->size = htons (TEST_MESSAGE_SIZE); 653 msg->size = htons (TEST_MESSAGE_SIZE);
589 memcpy (buf, msg, TEST_MESSAGE_SIZE); 654 memcpy (buf, msg, TEST_MESSAGE_SIZE);
590 /* GNUNET_break (0); */ 655
656 /* send echo */
657 if (NULL != bp->p_head)
658 bp->cth = GNUNET_CORE_notify_transmit_ready (bp->ch,
659 GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES,
660 &bp->p_head->target,
661 TEST_MESSAGE_SIZE, &core_send_echo_queued_ready, bp);
662
591 return TEST_MESSAGE_SIZE; 663 return TEST_MESSAGE_SIZE;
592} 664}
593 665
666static size_t
667core_send_echo_queued_ready (void *cls, size_t size, void *buf)
668{
669 struct BenchmarkPeer *bp = cls;
670 struct PendingMessages *pm;
671 GNUNET_assert (NULL != bp->p_head);
672
673 pm = bp->p_head;
674 GNUNET_CONTAINER_DLL_remove (bp->p_head, bp->p_tail, pm);
675 GNUNET_free (pm);
676
677
678 return core_send_echo_ready (cls, size, buf);
679
680}
681
594 682
595static int 683static int
596core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other, 684core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
@@ -598,6 +686,7 @@ core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
598{ 686{
599 struct BenchmarkPeer *me = cls; 687 struct BenchmarkPeer *me = cls;
600 struct BenchmarkPeer *remote; 688 struct BenchmarkPeer *remote;
689 struct PendingMessages *pm;
601 690
602 remote = find_peer (other); 691 remote = find_peer (other);
603 692
@@ -609,24 +698,62 @@ core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
609 698
610 if (NULL != me->cth) 699 if (NULL != me->cth)
611 { 700 {
701 pm = GNUNET_malloc (sizeof (struct PendingMessages));
702 pm->target = (*other);
703 GNUNET_CONTAINER_DLL_insert_tail (me->p_head, me->p_tail, pm);
704 return GNUNET_OK;
705 }
706
707 if (GNUNET_NO == remote->master)
708 {
612 GNUNET_break (0); 709 GNUNET_break (0);
710 return GNUNET_OK;
613 } 711 }
614 712
713 me->messages_received ++;
615 /* send echo */ 714 /* send echo */
616 me->cth = GNUNET_CORE_notify_transmit_ready (me->ch, 715 me->cth = GNUNET_CORE_notify_transmit_ready (me->ch,
617 GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, 716 GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES,
618 &remote->id, 717 &remote->id,
619 TEST_MESSAGE_SIZE, &core_send_echo_ready, me); 718 TEST_MESSAGE_SIZE, &core_send_echo_ready, me);
620
621 return GNUNET_OK; 719 return GNUNET_OK;
622} 720}
623 721
624
625static int 722static int
626core_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, 723core_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
627 const struct GNUNET_MessageHeader *message) 724 const struct GNUNET_MessageHeader *message)
628{ 725{
629 /* GNUNET_break (0); */ 726 struct BenchmarkPeer *me = cls;
727 struct BenchmarkPeer *remote;
728
729 remote = find_peer (other);
730
731 if (NULL == remote)
732 {
733 GNUNET_break (0);
734 return GNUNET_SYSERR;
735 }
736
737 if (NULL != me->cth)
738 {
739 GNUNET_break (0);
740 return GNUNET_OK;
741 }
742
743 if (GNUNET_YES == remote->master)
744 {
745 GNUNET_break (0);
746 return GNUNET_OK;
747 }
748 me->messages_received ++;
749 me->last_slave++;
750 if (me->last_slave == c_slave_peers)
751 me->last_slave = 0;
752 me->cth = GNUNET_CORE_notify_transmit_ready (me->ch,
753 GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES,
754 &bp_slaves[me->last_slave].id,
755 TEST_MESSAGE_SIZE, &core_send_ready, me);
756
630 return GNUNET_OK; 757 return GNUNET_OK;
631} 758}
632 759