diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-03 15:35:42 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-03 15:35:42 +0000 |
commit | 0283d45a7318a2ac34a75b65793e934ca37a912b (patch) | |
tree | 90a63936df2e14150a7b6cd7fb64bb9e35880b71 /src/core | |
parent | cb0e06cb6e3d86d0ceee12d9bec806fe67669dc0 (diff) | |
download | gnunet-0283d45a7318a2ac34a75b65793e934ca37a912b.tar.gz gnunet-0283d45a7318a2ac34a75b65793e934ca37a912b.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/test_core_quota_compliance.c | 84 |
1 files changed, 46 insertions, 38 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 10421349e..3546e542c 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #define VERBOSE GNUNET_YES | 38 | #define VERBOSE GNUNET_YES |
39 | 39 | ||
40 | #define START_ARM GNUNET_YES | 40 | #define START_ARM GNUNET_YES |
41 | #define DEBUG_CONNECTIONS GNUNET_YES | 41 | #define DEBUG_CONNECTIONS GNUNET_NO |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Note that this value must not significantly exceed | 44 | * Note that this value must not significantly exceed |
@@ -68,8 +68,10 @@ | |||
68 | 68 | ||
69 | static int is_asymmetric_send_constant; | 69 | static int is_asymmetric_send_constant; |
70 | static int is_asymmetric_recv_constant; | 70 | static int is_asymmetric_recv_constant; |
71 | static unsigned long long current_quota_p1; | 71 | static unsigned long long current_quota_p1_in; |
72 | static unsigned long long current_quota_p2; | 72 | static unsigned long long current_quota_p1_out; |
73 | static unsigned long long current_quota_p2_in; | ||
74 | static unsigned long long current_quota_p2_out; | ||
73 | 75 | ||
74 | static unsigned long long total_bytes; | 76 | static unsigned long long total_bytes; |
75 | static unsigned long long total_bytes_sent; | 77 | static unsigned long long total_bytes_sent; |
@@ -154,9 +156,11 @@ connect_notify (void *cls, | |||
154 | struct PeerContext *pc = cls; | 156 | struct PeerContext *pc = cls; |
155 | GNUNET_assert (pc->connect_status == 0); | 157 | GNUNET_assert (pc->connect_status == 0); |
156 | pc->connect_status = 1; | 158 | pc->connect_status = 1; |
159 | #if DEBUG_CONNECTIONS | ||
157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
158 | "Encrypted connection established to peer `%4s'\n", | 161 | "Encrypted connection established to peer `%4s'\n", |
159 | GNUNET_i2s (peer)); | 162 | GNUNET_i2s (peer)); |
163 | #endif | ||
160 | } | 164 | } |
161 | 165 | ||
162 | 166 | ||
@@ -166,8 +170,10 @@ disconnect_notify (void *cls, | |||
166 | { | 170 | { |
167 | struct PeerContext *pc = cls; | 171 | struct PeerContext *pc = cls; |
168 | pc->connect_status = 0; | 172 | pc->connect_status = 0; |
173 | #if DEBUG_CONNECTIONS | ||
169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
170 | "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); | 175 | "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); |
176 | #endif | ||
171 | } | 177 | } |
172 | 178 | ||
173 | 179 | ||
@@ -219,13 +225,10 @@ measurement_end (void *cls, | |||
219 | measurement_running = GNUNET_NO; | 225 | measurement_running = GNUNET_NO; |
220 | 226 | ||
221 | duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); | 227 | duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); |
222 | |||
223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
224 | "TIMEOUT\n"); | ||
225 | |||
226 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 228 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
227 | "\nQuota compliance: \n"\ | 229 | "\nQuota compliance: \n"\ |
228 | "Throughput : %10llu kB/s\n", (total_bytes_sent/(duration.rel_value / 1000)/1024)); | 230 | "Throughput : %10llu kB/s\n"\ |
231 | "Quota : %10llu kB/s\n", (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); | ||
229 | 232 | ||
230 | if (err_task != GNUNET_SCHEDULER_NO_TASK) | 233 | if (err_task != GNUNET_SCHEDULER_NO_TASK) |
231 | GNUNET_SCHEDULER_cancel (sched, err_task); | 234 | GNUNET_SCHEDULER_cancel (sched, err_task); |
@@ -237,35 +240,20 @@ transmit_ready (void *cls, size_t size, void *buf); | |||
237 | 240 | ||
238 | static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | 241 | static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) |
239 | { | 242 | { |
240 | |||
241 | current_quota_p1 = quota_p1; | ||
242 | current_quota_p2 = quota_p2; | ||
243 | #if VERBOSE | 243 | #if VERBOSE |
244 | if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES)) | 244 | if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES)) |
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 245 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
246 | "Starting core level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024, current_quota_p2 / 1024); | 246 | "Starting core level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1_in / 1024, current_quota_p2_out / 1024); |
247 | else | 247 | else |
248 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 248 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
249 | "Starting core level measurement for %u seconds, symmetric quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p2 / 1024); | 249 | "Starting core level measurement for %u seconds, symmetric quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p2_out / 1024); |
250 | 250 | ||
251 | #endif | 251 | #endif |
252 | 252 | #if DEBUG_CONNECTIONS | |
253 | GNUNET_TRANSPORT_set_quota (p1.th, | ||
254 | &p2.id, | ||
255 | GNUNET_BANDWIDTH_value_init (current_quota_p1 ), | ||
256 | GNUNET_BANDWIDTH_value_init (current_quota_p1 ), | ||
257 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
258 | NULL, NULL); | ||
259 | GNUNET_TRANSPORT_set_quota (p2.th, | ||
260 | &p1.id, | ||
261 | GNUNET_BANDWIDTH_value_init (current_quota_p2), | ||
262 | GNUNET_BANDWIDTH_value_init (current_quota_p2), | ||
263 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
264 | NULL, NULL); | ||
265 | |||
266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
267 | "Asking core (1) for transmission to peer `%4s'\n", | 254 | "Asking core (1) for transmission to peer `%4s'\n", |
268 | GNUNET_i2s (&p2.id)); | 255 | GNUNET_i2s (&p2.id)); |
256 | #endif | ||
269 | err_task = GNUNET_SCHEDULER_add_delayed (sched, | 257 | err_task = GNUNET_SCHEDULER_add_delayed (sched, |
270 | TIMEOUT, | 258 | TIMEOUT, |
271 | &terminate_task_error, | 259 | &terminate_task_error, |
@@ -392,7 +380,7 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
392 | 0, | 380 | 0, |
393 | FAST_TIMEOUT, | 381 | FAST_TIMEOUT, |
394 | &p2.id, | 382 | &p2.id, |
395 | sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE, | 383 | sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE, |
396 | &transmit_ready, &p1); | 384 | &transmit_ready, &p1); |
397 | return ret; | 385 | return ret; |
398 | } | 386 | } |
@@ -406,10 +394,11 @@ init_notify (void *cls, | |||
406 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 394 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
407 | { | 395 | { |
408 | struct PeerContext *p = cls; | 396 | struct PeerContext *p = cls; |
409 | 397 | #if DEBUG_CONNECTIONS | |
410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
411 | "Connection to CORE service of `%4s' established\n", | 399 | "Connection to CORE service of `%4s' established\n", |
412 | GNUNET_i2s (my_identity)); | 400 | GNUNET_i2s (my_identity)); |
401 | #endif | ||
413 | GNUNET_assert (server != NULL); | 402 | GNUNET_assert (server != NULL); |
414 | p->id = *my_identity; | 403 | p->id = *my_identity; |
415 | p->ch = server; | 404 | p->ch = server; |
@@ -448,9 +437,11 @@ process_hello (void *cls, | |||
448 | struct PeerContext *p = cls; | 437 | struct PeerContext *p = cls; |
449 | 438 | ||
450 | GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); | 439 | GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); |
440 | #if DEBUG_CONNECTIONS | ||
451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
452 | "Received (my) `%s' from transport service\n", | 442 | "Received (my) `%s' from transport service\n", |
453 | "HELLO"); | 443 | "HELLO"); |
444 | #endif | ||
454 | GNUNET_assert (message != NULL); | 445 | GNUNET_assert (message != NULL); |
455 | p->hello = GNUNET_malloc (ntohs (message->size)); | 446 | p->hello = GNUNET_malloc (ntohs (message->size)); |
456 | memcpy (p->hello, message, ntohs (message->size)); | 447 | memcpy (p->hello, message, ntohs (message->size)); |
@@ -496,18 +487,35 @@ run (void *cls, | |||
496 | GNUNET_assert (ok == 1); | 487 | GNUNET_assert (ok == 1); |
497 | OKPP; | 488 | OKPP; |
498 | sched = s; | 489 | sched = s; |
499 | setup_peer (&p1, "test_core_api_peer1.conf"); | 490 | setup_peer (&p1, "test_core_quota_peer1.conf"); |
500 | setup_peer (&p2, "test_core_api_peer2.conf"); | 491 | setup_peer (&p2, "test_core_quota_peer2.conf"); |
501 | GNUNET_CORE_connect (sched, | 492 | GNUNET_CORE_connect (sched, |
502 | p1.cfg, | 493 | p1.cfg, |
503 | TIMEOUT, | 494 | TIMEOUT, |
504 | &p1, | 495 | &p1, |
505 | &init_notify, | 496 | &init_notify, |
506 | &connect_notify, | 497 | &connect_notify, |
507 | &disconnect_notify, | 498 | &disconnect_notify, |
508 | NULL, | 499 | NULL, |
509 | &inbound_notify, | 500 | &inbound_notify, |
510 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 501 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
502 | |||
503 | GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p1.cfg, | ||
504 | "CORE", | ||
505 | "TOTAL_QUOTA_IN", | ||
506 | ¤t_quota_p1_in)); | ||
507 | GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p2.cfg, | ||
508 | "CORE", | ||
509 | "TOTAL_QUOTA_IN", | ||
510 | ¤t_quota_p2_in)); | ||
511 | GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p1.cfg, | ||
512 | "CORE", | ||
513 | "TOTAL_QUOTA_OUT", | ||
514 | ¤t_quota_p1_out)); | ||
515 | GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p2.cfg, | ||
516 | "CORE", | ||
517 | "TOTAL_QUOTA_OUT", | ||
518 | ¤t_quota_p2_out)); | ||
511 | } | 519 | } |
512 | 520 | ||
513 | 521 | ||
@@ -528,7 +536,7 @@ stop_arm (struct PeerContext *p) | |||
528 | static int | 536 | static int |
529 | check () | 537 | check () |
530 | { | 538 | { |
531 | char *const argv[] = { "test-core-api-reliability", | 539 | char *const argv[] = { "test-core-quota-compliance", |
532 | "-c", | 540 | "-c", |
533 | "test_core_api_data.conf", | 541 | "test_core_api_data.conf", |
534 | #if VERBOSE | 542 | #if VERBOSE |
@@ -560,8 +568,8 @@ main (int argc, char *argv[]) | |||
560 | #endif | 568 | #endif |
561 | NULL); | 569 | NULL); |
562 | ret = check (); | 570 | ret = check (); |
563 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); | 571 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-quota-peer-2"); |
564 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); | 572 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-quota-peer-2"); |
565 | 573 | ||
566 | return ret; | 574 | return ret; |
567 | } | 575 | } |