diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-22 11:45:27 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-22 11:45:27 +0000 |
commit | 843c9594e270b312af68c8f9ba9e1fc9fa6cb490 (patch) | |
tree | f4b310314d44c4cbbe34ade3ea034573982e2911 /src/transport | |
parent | 0a14565c66948a5e2967994edd725d6945644f63 (diff) | |
download | gnunet-843c9594e270b312af68c8f9ba9e1fc9fa6cb490.tar.gz gnunet-843c9594e270b312af68c8f9ba9e1fc9fa6cb490.zip |
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/test_quota_compliance.c | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 37f2f8b71..4d312e5f2 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -47,10 +47,15 @@ | |||
47 | */ | 47 | */ |
48 | #define TOTAL_MSGS (10000 * 2) | 48 | #define TOTAL_MSGS (10000 * 2) |
49 | 49 | ||
50 | #define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20) | ||
51 | #define MEASUREMENT_MSG_SIZE 1024 | ||
52 | #define MEASUREMENT_MSG_SIZE_BIG 32768 | ||
53 | |||
50 | /** | 54 | /** |
51 | * How long until we give up on transmitting the message? | 55 | * Testcase timeout |
52 | */ | 56 | */ |
53 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 57 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 200) |
58 | |||
54 | 59 | ||
55 | #define MTYPE 12345 | 60 | #define MTYPE 12345 |
56 | 61 | ||
@@ -75,6 +80,8 @@ static int ok; | |||
75 | static int connected; | 80 | static int connected; |
76 | 81 | ||
77 | static unsigned long long total_bytes; | 82 | static unsigned long long total_bytes; |
83 | static unsigned long long current_quota_p1; | ||
84 | static unsigned long long current_quota_p2; | ||
78 | 85 | ||
79 | static struct GNUNET_TIME_Absolute start_time; | 86 | static struct GNUNET_TIME_Absolute start_time; |
80 | 87 | ||
@@ -312,6 +319,32 @@ notify_ready (void *cls, size_t size, void *buf) | |||
312 | return ret; | 319 | return ret; |
313 | } | 320 | } |
314 | 321 | ||
322 | static void measure () | ||
323 | { | ||
324 | #if VERBOSE | ||
325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
326 | "Both peers are connected, starting measurement...\n"); | ||
327 | #endif | ||
328 | GNUNET_TRANSPORT_set_quota (p1.th, | ||
329 | &p2.id, | ||
330 | GNUNET_BANDWIDTH_value_init (current_quota_p1 ), | ||
331 | GNUNET_BANDWIDTH_value_init (current_quota_p1 ), | ||
332 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
333 | NULL, NULL); | ||
334 | GNUNET_TRANSPORT_set_quota (p2.th, | ||
335 | &p1.id, | ||
336 | GNUNET_BANDWIDTH_value_init (current_quota_p2), | ||
337 | GNUNET_BANDWIDTH_value_init (current_quota_p2), | ||
338 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
339 | NULL, NULL); | ||
340 | GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | ||
341 | &p1.id, | ||
342 | get_size (0), 0, TIMEOUT, | ||
343 | ¬ify_ready, | ||
344 | NULL); | ||
345 | start_time = GNUNET_TIME_absolute_get (); | ||
346 | |||
347 | } | ||
315 | 348 | ||
316 | static void | 349 | static void |
317 | notify_connect (void *cls, | 350 | notify_connect (void *cls, |
@@ -323,38 +356,18 @@ notify_connect (void *cls, | |||
323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
324 | "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); | 357 | "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); |
325 | #endif | 358 | #endif |
326 | |||
327 | if (cls == &p1) | 359 | if (cls == &p1) |
328 | { | 360 | { |
329 | GNUNET_TRANSPORT_set_quota (p1.th, | ||
330 | &p2.id, | ||
331 | GNUNET_BANDWIDTH_value_init (1024 * 10 ), | ||
332 | GNUNET_BANDWIDTH_value_init (1024 * 10 ), | ||
333 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
334 | NULL, NULL); | ||
335 | start_time = GNUNET_TIME_absolute_get (); | ||
336 | connected++; | 361 | connected++; |
337 | } | 362 | } |
338 | else | 363 | else |
339 | { | 364 | { |
340 | GNUNET_TRANSPORT_set_quota (p2.th, | ||
341 | &p1.id, | ||
342 | GNUNET_BANDWIDTH_value_init (1024 * 10 ), | ||
343 | GNUNET_BANDWIDTH_value_init (1024 * 10 ), | ||
344 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
345 | NULL, NULL); | ||
346 | connected++; | 365 | connected++; |
347 | } | 366 | } |
348 | |||
349 | if (connected == 2) | 367 | if (connected == 2) |
350 | { | 368 | { |
351 | GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 369 | measure(); |
352 | &p1.id, | ||
353 | get_size (0), 0, TIMEOUT, | ||
354 | ¬ify_ready, | ||
355 | NULL); | ||
356 | } | 370 | } |
357 | |||
358 | } | 371 | } |
359 | 372 | ||
360 | 373 | ||
@@ -400,10 +413,7 @@ exchange_hello_last (void *cls, | |||
400 | struct PeerContext *me = cls; | 413 | struct PeerContext *me = cls; |
401 | 414 | ||
402 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me); | 415 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me); |
403 | #if VERBOSE | 416 | |
404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
405 | "Exchanging HELLO with peer (%p)!\n", cls); | ||
406 | #endif | ||
407 | GNUNET_assert (ok >= 3); | 417 | GNUNET_assert (ok >= 3); |
408 | OKPP; | 418 | OKPP; |
409 | GNUNET_assert (message != NULL); | 419 | GNUNET_assert (message != NULL); |
@@ -412,7 +422,7 @@ exchange_hello_last (void *cls, | |||
412 | message, &me->id)); | 422 | message, &me->id)); |
413 | /* both HELLOs exchanged, get ready to test transmission! */ | 423 | /* both HELLOs exchanged, get ready to test transmission! */ |
414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
415 | "Finished exchanging HELLOs, now waiting for transmission!\n"); | 425 | "Finished exchanging HELLOs, now waiting for peers to connect!\n"); |
416 | } | 426 | } |
417 | 427 | ||
418 | 428 | ||
@@ -423,22 +433,12 @@ exchange_hello (void *cls, | |||
423 | struct PeerContext *me = cls; | 433 | struct PeerContext *me = cls; |
424 | 434 | ||
425 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me); | 435 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me); |
426 | #if VERBOSE | ||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
428 | "Exchanging HELLO with peer (%p)!\n", cls); | ||
429 | #endif | ||
430 | GNUNET_assert (ok >= 2); | 436 | GNUNET_assert (ok >= 2); |
431 | OKPP; | 437 | OKPP; |
432 | GNUNET_assert (message != NULL); | 438 | GNUNET_assert (message != NULL); |
433 | GNUNET_assert (GNUNET_OK == | 439 | GNUNET_assert (GNUNET_OK == |
434 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | 440 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) |
435 | message, &me->id)); | 441 | message, &me->id)); |
436 | |||
437 | #if VERBOSE | ||
438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
439 | "Received HELLO size %d\n", | ||
440 | GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message)); | ||
441 | #endif | ||
442 | GNUNET_TRANSPORT_offer_hello (p2.th, message); | 442 | GNUNET_TRANSPORT_offer_hello (p2.th, message); |
443 | GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); | 443 | GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); |
444 | } | 444 | } |
@@ -458,6 +458,9 @@ run (void *cls, | |||
458 | &end_badly, | 458 | &end_badly, |
459 | NULL); | 459 | NULL); |
460 | 460 | ||
461 | /* Setting initial quota for both peers */ | ||
462 | current_quota_p1 = 1024 * 1024 * 1024; | ||
463 | current_quota_p2 = 1024 * 1024 * 1024; | ||
461 | 464 | ||
462 | setup_peer (&p1, "test_quota_compliance_peer1.conf"); | 465 | setup_peer (&p1, "test_quota_compliance_peer1.conf"); |
463 | setup_peer (&p2, "test_quota_compliance_peer2.conf"); | 466 | setup_peer (&p2, "test_quota_compliance_peer2.conf"); |