aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_reliability.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r--src/transport/test_transport_api_reliability.c88
1 files changed, 46 insertions, 42 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index e4b635905..5bbff2550 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -69,9 +69,9 @@ struct PeerContext *p1;
69 69
70struct PeerContext *p2; 70struct PeerContext *p2;
71 71
72struct PeerContext * sender; 72struct PeerContext *sender;
73 73
74struct PeerContext * receiver; 74struct PeerContext *receiver;
75 75
76struct GNUNET_TRANSPORT_TransmitHandle *th; 76struct GNUNET_TRANSPORT_TransmitHandle *th;
77 77
@@ -79,7 +79,7 @@ char *cfg_file_p1;
79 79
80char *cfg_file_p2; 80char *cfg_file_p2;
81 81
82struct GNUNET_TRANSPORT_TESTING_handle * tth; 82struct GNUNET_TRANSPORT_TESTING_handle *tth;
83 83
84static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; 84static GNUNET_TRANSPORT_TESTING_ConnectRequest cc;
85 85
@@ -151,7 +151,7 @@ end ()
151 th = NULL; 151 th = NULL;
152 152
153 if (cc != NULL) 153 if (cc != NULL)
154 GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); 154 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
155 155
156 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 156 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
157 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); 157 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
@@ -175,7 +175,7 @@ end_badly ()
175 th = NULL; 175 th = NULL;
176 176
177 if (cc != NULL) 177 if (cc != NULL)
178 GNUNET_TRANSPORT_TESTING_connect_peers_cancel(tth, cc); 178 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
179 179
180 if (p1 != NULL) 180 if (p1 != NULL)
181 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); 181 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1);
@@ -201,8 +201,7 @@ get_size (unsigned int iter)
201static void 201static void
202notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 202notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
203 const struct GNUNET_MessageHeader *message, 203 const struct GNUNET_MessageHeader *message,
204 const struct GNUNET_ATS_Information *ats, 204 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
205 uint32_t ats_count)
206{ 205{
207 static int n; 206 static int n;
208 unsigned int s; 207 unsigned int s;
@@ -253,9 +252,12 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
253 if (ntohl (hdr->num) % 5000 == 0) 252 if (ntohl (hdr->num) % 5000 == 0)
254 { 253 {
255 struct PeerContext *p = cls; 254 struct PeerContext *p = cls;
256 char * ps = strdup(GNUNET_i2s(&p->id)); 255 char *ps = strdup (GNUNET_i2s (&p->id));
257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", 256
258 p->no, ps, ntohl (hdr->num), ntohs (message->size), GNUNET_i2s(peer)); 257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
258 "Peer %u (`%s') got message %u of size %u from peer (`%s')\n",
259 p->no, ps, ntohl (hdr->num), ntohs (message->size),
260 GNUNET_i2s (peer));
259 GNUNET_free (ps); 261 GNUNET_free (ps);
260 } 262 }
261#endif 263#endif
@@ -289,7 +291,8 @@ notify_ready (void *cls, size_t size, void *buf)
289 if (buf == NULL) 291 if (buf == NULL)
290 { 292 {
291 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 293 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
292 "Timeout occurred while waiting for transmit_ready for message %u of %u\n", msg_scheduled, TOTAL_MSGS); 294 "Timeout occurred while waiting for transmit_ready for message %u of %u\n",
295 msg_scheduled, TOTAL_MSGS);
293 if (GNUNET_SCHEDULER_NO_TASK != die_task) 296 if (GNUNET_SCHEDULER_NO_TASK != die_task)
294 GNUNET_SCHEDULER_cancel (die_task); 297 GNUNET_SCHEDULER_cancel (die_task);
295 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); 298 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
@@ -316,12 +319,12 @@ notify_ready (void *cls, size_t size, void *buf)
316 if (n % 5000 == 0) 319 if (n % 5000 == 0)
317 { 320 {
318 321
319 char * receiver_s = strdup(GNUNET_i2s (&receiver->id)); 322 char *receiver_s = strdup (GNUNET_i2s (&receiver->id));
323
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
321 "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", 325 "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n",
322 n, 326 n, sender->no, GNUNET_i2s (&sender->id), receiver->no,
323 sender->no, 327 receiver_s);
324 GNUNET_i2s (&sender->id), receiver->no, receiver_s);
325 GNUNET_free (receiver_s); 328 GNUNET_free (receiver_s);
326 } 329 }
327#endif 330#endif
@@ -356,11 +359,11 @@ notify_ready (void *cls, size_t size, void *buf)
356 359
357static void 360static void
358notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, 361notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
359 const struct GNUNET_ATS_Information *ats, 362 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
360 uint32_t ats_count)
361{ 363{
362 364
363 struct PeerContext *p = cls; 365 struct PeerContext *p = cls;
366
364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", 367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n",
365 p->no, GNUNET_i2s (peer)); 368 p->no, GNUNET_i2s (peer));
366} 369}
@@ -370,8 +373,9 @@ static void
370notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 373notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
371{ 374{
372 struct PeerContext *p = cls; 375 struct PeerContext *p = cls;
373 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", 376
374 p->no, GNUNET_i2s (peer)); 377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", p->no,
378 GNUNET_i2s (peer));
375 if (th != NULL) 379 if (th != NULL)
376 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 380 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
377 th = NULL; 381 th = NULL;
@@ -391,9 +395,9 @@ static void
391testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) 395testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
392{ 396{
393 char *p1_c = strdup (GNUNET_i2s (&p1->id)); 397 char *p1_c = strdup (GNUNET_i2s (&p1->id));
398
394 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", 399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n",
395 p1->no, p1_c, 400 p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
396 p2->no, GNUNET_i2s (&p2->id));
397 GNUNET_free (p1_c); 401 GNUNET_free (p1_c);
398 402
399 cc = NULL; 403 cc = NULL;
@@ -402,37 +406,39 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
402 406
403} 407}
404 408
405void start_cb (struct PeerContext * p, 409void
406 void *cls) 410start_cb (struct PeerContext *p, void *cls)
407{ 411{
408 static int started; 412 static int started;
413
409 started++; 414 started++;
410 415
411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", 416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
412 p->no, 417 GNUNET_i2s (&p->id));
413 GNUNET_i2s (&p->id));
414 418
415 if (started != 2) 419 if (started != 2)
416 return; 420 return;
417 421
418 test_connected = GNUNET_NO; 422 test_connected = GNUNET_NO;
419 423
420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", 424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
421 p1->no, 425 "Peer %u: `%s' using configuration file `%s'\n", p1->no,
422 GNUNET_i2s (&p1->id), cfg_file_p1); 426 GNUNET_i2s (&p1->id), cfg_file_p1);
423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", 427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
424 p2->no, 428 "Peer %u: `%s' using configuration file `%s'\n", p2->no,
425 GNUNET_i2s (&p2->id), cfg_file_p2); 429 GNUNET_i2s (&p2->id), cfg_file_p2);
426 430
427 sender = p2; 431 sender = p2;
428 receiver = p1; 432 receiver = p1;
429 433
430 char *sender_c = strdup (GNUNET_i2s (&sender->id)); 434 char *sender_c = strdup (GNUNET_i2s (&sender->id));
431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test triest to send from %u (%s) -> peer %u (%s)\n",
432 sender->no, sender_c,
433 receiver->no, GNUNET_i2s (&receiver->id));
434 435
435 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL); 436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
437 "Test triest to send from %u (%s) -> peer %u (%s)\n", sender->no,
438 sender_c, receiver->no, GNUNET_i2s (&receiver->id));
439
440 cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
441 NULL);
436 442
437} 443}
438 444
@@ -444,14 +450,12 @@ run (void *cls, char *const *args, const char *cfgfile,
444 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 450 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
445 451
446 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, 452 p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
447 &notify_receive, 453 &notify_receive, &notify_connect,
448 &notify_connect, &notify_disconnect, 454 &notify_disconnect, &start_cb,
449 &start_cb,
450 NULL); 455 NULL);
451 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, 456 p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
452 &notify_receive, 457 &notify_receive, &notify_connect,
453 &notify_connect, &notify_disconnect, 458 &notify_disconnect, &start_cb,
454 &start_cb,
455 NULL); 459 NULL);
456 460
457 if ((p1 == NULL) || (p2 == NULL)) 461 if ((p1 == NULL) || (p2 == NULL))