aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_reliability.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-10 14:09:14 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-10 14:09:14 +0000
commit61b479ac0ad609646ee3dd1fa3ba84205ee95f09 (patch)
tree154e4e250781ee22b4aa772bc22e06b8166d3a4d /src/transport/test_transport_api_reliability.c
parent81763b925d23a03e1899b945f83cf454fa7923a8 (diff)
downloadgnunet-61b479ac0ad609646ee3dd1fa3ba84205ee95f09.tar.gz
gnunet-61b479ac0ad609646ee3dd1fa3ba84205ee95f09.zip
working TCP PWNAT implementation (at least on my machine), also base testcase and reliability testcase
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r--src/transport/test_transport_api_reliability.c62
1 files changed, 45 insertions, 17 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 6be737309..755d5a576 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -75,8 +75,12 @@ static int ok;
75 75
76static int is_tcp; 76static int is_tcp;
77 77
78static int is_tcp_nat;
79
78static int is_http; 80static int is_http;
79 81
82static int connected;
83
80static unsigned long long total_bytes; 84static unsigned long long total_bytes;
81 85
82static struct GNUNET_TIME_Absolute start_time; 86static struct GNUNET_TIME_Absolute start_time;
@@ -193,10 +197,13 @@ notify_receive (void *cls,
193 return; 197 return;
194 } 198 }
195#if VERBOSE 199#if VERBOSE
196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 200 if (ntohl(hdr->num) % 5000 == 0)
197 "Got message %u of size %u\n", 201 {
198 ntohl (hdr->num), 202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
199 ntohs (message->size)); 203 "Got message %u of size %u\n",
204 ntohl (hdr->num),
205 ntohs (message->size));
206 }
200#endif 207#endif
201 n++; 208 n++;
202 if (0 == (n % (TOTAL_MSGS/100))) 209 if (0 == (n % (TOTAL_MSGS/100)))
@@ -243,10 +250,13 @@ notify_ready (void *cls, size_t size, void *buf)
243 memset (&cbuf[ret], n, s - sizeof (struct TestMessage)); 250 memset (&cbuf[ret], n, s - sizeof (struct TestMessage));
244 ret += s - sizeof (struct TestMessage); 251 ret += s - sizeof (struct TestMessage);
245#if VERBOSE 252#if VERBOSE
246 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 253 if (n % 5000 == 0)
247 "Sending message %u of size %u\n", 254 {
248 n, 255 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
249 s); 256 "Sending message %u of size %u\n",
257 n,
258 s);
259 }
250#endif 260#endif
251 n++; 261 n++;
252 s = get_size (n); 262 s = get_size (n);
@@ -260,9 +270,12 @@ notify_ready (void *cls, size_t size, void *buf)
260 s, 0, TIMEOUT, 270 s, 0, TIMEOUT,
261 &notify_ready, 271 &notify_ready,
262 NULL); 272 NULL);
263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 273 if (n % 5000 == 0)
264 "Returning total message block of size %u\n", 274 {
265 ret); 275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
276 "Returning total message block of size %u\n",
277 ret);
278 }
266 total_bytes += ret; 279 total_bytes += ret;
267 return ret; 280 return ret;
268} 281}
@@ -283,11 +296,7 @@ notify_connect (void *cls,
283 GNUNET_TIME_UNIT_FOREVER_REL, 296 GNUNET_TIME_UNIT_FOREVER_REL,
284 NULL, NULL); 297 NULL, NULL);
285 start_time = GNUNET_TIME_absolute_get (); 298 start_time = GNUNET_TIME_absolute_get ();
286 GNUNET_TRANSPORT_notify_transmit_ready (p1.th, 299 connected++;
287 &p2.id,
288 get_size (0), 0, TIMEOUT,
289 &notify_ready,
290 NULL);
291 } 300 }
292 else 301 else
293 { 302 {
@@ -297,6 +306,16 @@ notify_connect (void *cls,
297 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), 306 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024),
298 GNUNET_TIME_UNIT_FOREVER_REL, 307 GNUNET_TIME_UNIT_FOREVER_REL,
299 NULL, NULL); 308 NULL, NULL);
309 connected++;
310 }
311
312 if (connected == 2)
313 {
314 GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
315 &p2.id,
316 get_size (0), 0, TIMEOUT,
317 &notify_ready,
318 NULL);
300 } 319 }
301#if VERBOSE 320#if VERBOSE
302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 321 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -413,6 +432,11 @@ run (void *cls,
413 setup_peer (&p1, "test_transport_api_http_peer1.conf"); 432 setup_peer (&p1, "test_transport_api_http_peer1.conf");
414 setup_peer (&p2, "test_transport_api_http_peer2.conf"); 433 setup_peer (&p2, "test_transport_api_http_peer2.conf");
415 } 434 }
435 else if (is_tcp_nat)
436 {
437 setup_peer (&p1, "test_transport_api_tcp_nat_peer1.conf");
438 setup_peer (&p2, "test_transport_api_tcp_nat_peer2.conf");
439 }
416 else 440 else
417 GNUNET_assert (0); 441 GNUNET_assert (0);
418 GNUNET_assert(p1.th != NULL); 442 GNUNET_assert(p1.th != NULL);
@@ -456,7 +480,11 @@ main (int argc, char *argv[])
456#ifdef MINGW 480#ifdef MINGW
457 return GNUNET_SYSERR; 481 return GNUNET_SYSERR;
458#endif 482#endif
459 if (strstr(argv[0], "tcp") != NULL) 483 if (strstr(argv[0], "tcp_nat") != NULL)
484 {
485 is_tcp_nat = GNUNET_YES;
486 }
487 else if (strstr(argv[0], "tcp") != NULL)
460 { 488 {
461 is_tcp = GNUNET_YES; 489 is_tcp = GNUNET_YES;
462 } 490 }