diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-28 14:08:22 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-10-28 14:08:22 +0000 |
commit | 61abda51be5dcee909dd56a4a15e5e5d94ca097f (patch) | |
tree | 1c38fb8dbb89ce24695f5e7eb552f794a19d78bb /src/transport/test_quota_compliance.c | |
parent | 265502fad2304198e401ace40f1b2f7798784aa0 (diff) | |
download | gnunet-61abda51be5dcee909dd56a4a15e5e5d94ca097f.tar.gz gnunet-61abda51be5dcee909dd56a4a15e5e5d94ca097f.zip |
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r-- | src/transport/test_quota_compliance.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index c01fc8474..194222183 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -42,14 +42,7 @@ | |||
42 | #define DEBUG_MEASUREMENT GNUNET_NO | 42 | #define DEBUG_MEASUREMENT GNUNET_NO |
43 | #define DEBUG_CONNECTIONS GNUNET_NO | 43 | #define DEBUG_CONNECTIONS GNUNET_NO |
44 | 44 | ||
45 | /** | 45 | #define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) |
46 | * Note that this value must not significantly exceed | ||
47 | * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise | ||
48 | * messages may be dropped even for a reliable transport. | ||
49 | */ | ||
50 | #define TOTAL_MSGS (10000 * 2) | ||
51 | |||
52 | #define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
53 | #define MEASUREMENT_MSG_SIZE 10000 | 46 | #define MEASUREMENT_MSG_SIZE 10000 |
54 | #define MEASUREMENT_MSG_SIZE_BIG 32768 | 47 | #define MEASUREMENT_MSG_SIZE_BIG 32768 |
55 | #define MEASUREMENT_MAX_QUOTA 1024 * 1024 * 1024 | 48 | #define MEASUREMENT_MAX_QUOTA 1024 * 1024 * 1024 |
@@ -154,6 +147,13 @@ struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle; | |||
154 | #endif | 147 | #endif |
155 | 148 | ||
156 | 149 | ||
150 | |||
151 | static void | ||
152 | end_send () | ||
153 | { | ||
154 | |||
155 | } | ||
156 | |||
157 | static void | 157 | static void |
158 | end () | 158 | end () |
159 | { | 159 | { |
@@ -244,6 +244,8 @@ notify_receive_new (void *cls, | |||
244 | 244 | ||
245 | hdr = (const struct TestMessage*) message; | 245 | hdr = (const struct TestMessage*) message; |
246 | s = get_size (n); | 246 | s = get_size (n); |
247 | if (measurement_running == GNUNET_NO) | ||
248 | return; | ||
247 | if (MTYPE != ntohs (message->type)) | 249 | if (MTYPE != ntohs (message->type)) |
248 | return; | 250 | return; |
249 | #if DEBUG_MEASUREMENT | 251 | #if DEBUG_MEASUREMENT |
@@ -274,14 +276,18 @@ notify_ready_new (void *cls, size_t size, void *buf) | |||
274 | 276 | ||
275 | if (buf == NULL) | 277 | if (buf == NULL) |
276 | { | 278 | { |
277 | GNUNET_break (0); | ||
278 | ok = 42; | 279 | ok = 42; |
279 | return 0; | 280 | return 0; |
280 | } | 281 | } |
281 | 282 | ||
282 | if (measurement_running != GNUNET_YES) | 283 | if (measurement_running != GNUNET_YES) |
284 | { | ||
285 | send_running = GNUNET_NO; | ||
286 | end_send(); | ||
283 | return 0; | 287 | return 0; |
288 | } | ||
284 | 289 | ||
290 | send_running = GNUNET_YES; | ||
285 | ret = 0; | 291 | ret = 0; |
286 | s = get_size (n); | 292 | s = get_size (n); |
287 | GNUNET_assert (size >= s); | 293 | GNUNET_assert (size >= s); |
@@ -349,6 +355,7 @@ measurement_end (void *cls, | |||
349 | measurement_running = GNUNET_NO; | 355 | measurement_running = GNUNET_NO; |
350 | struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); | 356 | struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); |
351 | 357 | ||
358 | |||
352 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) | 359 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) |
353 | { | 360 | { |
354 | GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); | 361 | GNUNET_SCHEDULER_cancel (sched, measurement_counter_task); |
@@ -357,11 +364,13 @@ measurement_end (void *cls, | |||
357 | #if VERBOSE | 364 | #if VERBOSE |
358 | fprintf(stderr,"\n"); | 365 | fprintf(stderr,"\n"); |
359 | #endif | 366 | #endif |
367 | /* | ||
360 | if (transmit_handle != NULL) | 368 | if (transmit_handle != NULL) |
361 | { | 369 | { |
362 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); | 370 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); |
363 | transmit_handle = NULL; | 371 | transmit_handle = NULL; |
364 | } | 372 | } |
373 | */ | ||
365 | if ((total_bytes/(duration.rel_value / 1000)) > (current_quota_p1 + (current_quota_p1 / 10))) | 374 | if ((total_bytes/(duration.rel_value / 1000)) > (current_quota_p1 + (current_quota_p1 / 10))) |
366 | { | 375 | { |
367 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 376 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -369,8 +378,8 @@ measurement_end (void *cls, | |||
369 | "Quota allowed: %10llu kB/s\n"\ | 378 | "Quota allowed: %10llu kB/s\n"\ |
370 | "Throughput : %10llu kB/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.rel_value / 1000)/1024)); | 379 | "Throughput : %10llu kB/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.rel_value / 1000)/1024)); |
371 | ok = 1; | 380 | ok = 1; |
372 | end(); | 381 | /* end(); |
373 | return; | 382 | return;*/ |
374 | } | 383 | } |
375 | else | 384 | else |
376 | { | 385 | { |
@@ -381,11 +390,20 @@ measurement_end (void *cls, | |||
381 | "Throughput : %10llu kB/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.rel_value / 1000)/1024)); | 390 | "Throughput : %10llu kB/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.rel_value / 1000)/1024)); |
382 | ok = 0; | 391 | ok = 0; |
383 | } | 392 | } |
393 | |||
384 | if (current_quota_p1 < MEASUREMENT_MIN_QUOTA) | 394 | if (current_quota_p1 < MEASUREMENT_MIN_QUOTA) |
395 | { | ||
385 | end(); | 396 | end(); |
397 | return; | ||
398 | } | ||
386 | else | 399 | else |
387 | 400 | { | |
388 | measure (current_quota_p1 / 1024, current_quota_p2 / 1024); | 401 | #if VERBOSE |
402 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
403 | "Scheduling next measurement\n"); | ||
404 | #endif | ||
405 | measure (current_quota_p1 / 10, current_quota_p2 / 10); | ||
406 | } | ||
389 | } | 407 | } |
390 | 408 | ||
391 | static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | 409 | static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) |
@@ -394,7 +412,7 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | |||
394 | current_quota_p2 = quota_p2; | 412 | current_quota_p2 = quota_p2; |
395 | #if VERBOSE | 413 | #if VERBOSE |
396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
397 | "Starting transport level measurement for %u and quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024); | 415 | "Starting transport level measurement for %u seconds and quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p1 / 1024); |
398 | #endif | 416 | #endif |
399 | GNUNET_TRANSPORT_set_quota (p1.th, | 417 | GNUNET_TRANSPORT_set_quota (p1.th, |
400 | &p2.id, | 418 | &p2.id, |
@@ -430,7 +448,6 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) | |||
430 | 448 | ||
431 | if (transmit_handle != NULL) | 449 | if (transmit_handle != NULL) |
432 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); | 450 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); |
433 | |||
434 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 451 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, |
435 | &p1.id, | 452 | &p1.id, |
436 | get_size (0), 0, SEND_TIMEOUT, | 453 | get_size (0), 0, SEND_TIMEOUT, |