aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-10-22 13:34:55 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-10-22 13:34:55 +0000
commit0c210cc47cee6e65f7c93dc825ff24e7f7a9031e (patch)
tree5b23e8fa734db49c3d716381d8ebe0a907d3e89f /src/transport
parent28ec7b4a5f711ee355dd5fb2a23d5016e56432a7 (diff)
downloadgnunet-0c210cc47cee6e65f7c93dc825ff24e7f7a9031e.tar.gz
gnunet-0c210cc47cee6e65f7c93dc825ff24e7f7a9031e.zip
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/test_quota_compliance.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index a800dae73..b9fd319e6 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -40,6 +40,7 @@
40 40
41#define START_ARM GNUNET_YES 41#define START_ARM GNUNET_YES
42#define DEBUG_MEASUREMENT GNUNET_NO 42#define DEBUG_MEASUREMENT GNUNET_NO
43#define DEBUG_CONNECTIONS GNUNET_NO
43 44
44/** 45/**
45 * Note that this value must not significantly exceed 46 * Note that this value must not significantly exceed
@@ -48,9 +49,11 @@
48 */ 49 */
49#define TOTAL_MSGS (10000 * 2) 50#define TOTAL_MSGS (10000 * 2)
50 51
51#define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) 52#define MEASUREMENT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
52#define MEASUREMENT_MSG_SIZE 1024 53#define MEASUREMENT_MSG_SIZE 1024
53#define MEASUREMENT_MSG_SIZE_BIG 32768 54#define MEASUREMENT_MSG_SIZE_BIG 32768
55#define MEASUREMENT_MAX_QUOTA 1024*1024*1024
56#define MEASUREMENT_MIN_QUOTA 1024
54 57
55/** 58/**
56 * Testcase timeout 59 * Testcase timeout
@@ -248,14 +251,9 @@ notify_receive_new (void *cls,
248 n++; 251 n++;
249 252
250 253
251 if (0 == (n % (TOTAL_MSGS/1000))) 254 if (0 == (n % (TOTAL_MSGS/10)))
252 { 255 {
253 fprintf (stderr, "."); 256 fprintf (stderr, ".");
254 GNUNET_SCHEDULER_cancel (sched, die_task);
255 die_task = GNUNET_SCHEDULER_add_delayed (sched,
256 TIMEOUT,
257 &end_badly,
258 NULL);
259 } 257 }
260} 258}
261 259
@@ -312,25 +310,32 @@ notify_ready_new (void *cls, size_t size, void *buf)
312 return ret; 310 return ret;
313} 311}
314 312
313static void measure (unsigned long long quota_p1, unsigned long long quota_p2 );
314
315static void 315static void
316stop_measurement (void *cls, 316stop_measurement (void *cls,
317 const struct GNUNET_SCHEDULER_TaskContext *tc) 317 const struct GNUNET_SCHEDULER_TaskContext *tc)
318{ 318{
319 struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); 319 struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
320 320 fprintf (stderr, "\n");
321 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 321 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
322 "Measurement: %u bytes sent in %llu sec. : %llu\n kb/s", total_bytes, (duration.value/1000) ,(total_bytes/(duration.value / 1000)/1024)); 322 "Measurement finished: \n Quota allowed: %llu kb/s\n Throughput: %llu kb/s\n", (current_quota_p1 / (1024)) , (total_bytes/(duration.value / 1000)/1024));
323 323 if (current_quota_p1 < (MEASUREMENT_MIN_QUOTA))
324 end(); 324 end();
325 else
326 measure (current_quota_p1/100, current_quota_p2/100);
325} 327}
326 328
327 329
328static void measure () 330static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
329{ 331{
332 current_quota_p1 = quota_p1;
333 current_quota_p2 = quota_p2;
330#if VERBOSE 334#if VERBOSE
331 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
332 "Both peers are connected, starting measurement...\n"); 336 "Starting measurement: Duration: %u Quota: %u\n", MEASUREMENT_INTERVALL, current_quota_p1);
333#endif 337#endif
338
334 GNUNET_TRANSPORT_set_quota (p1.th, 339 GNUNET_TRANSPORT_set_quota (p1.th,
335 &p2.id, 340 &p2.id,
336 GNUNET_BANDWIDTH_value_init (current_quota_p1 ), 341 GNUNET_BANDWIDTH_value_init (current_quota_p1 ),
@@ -348,6 +353,12 @@ static void measure ()
348 get_size_new (0), 0, TIMEOUT, 353 get_size_new (0), 0, TIMEOUT,
349 &notify_ready_new, 354 &notify_ready_new,
350 NULL); 355 NULL);
356
357 GNUNET_SCHEDULER_cancel (sched, die_task);
358 die_task = GNUNET_SCHEDULER_add_delayed (sched,
359 TIMEOUT,
360 &end_badly,
361 NULL);
351 measurement_task = GNUNET_SCHEDULER_add_delayed (sched, 362 measurement_task = GNUNET_SCHEDULER_add_delayed (sched,
352 MEASUREMENT_INTERVALL, 363 MEASUREMENT_INTERVALL,
353 &stop_measurement, 364 &stop_measurement,
@@ -362,21 +373,25 @@ notify_connect (void *cls,
362 struct GNUNET_TIME_Relative latency, 373 struct GNUNET_TIME_Relative latency,
363 uint32_t distance) 374 uint32_t distance)
364{ 375{
365#if VERBOSE
366 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
367 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
368#endif
369 if (cls == &p1) 376 if (cls == &p1)
370 { 377 {
371 connected++; 378#if DEBUG_CONNECTIONS
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
380 "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
381#endif
382 connected++;
372 } 383 }
373 else 384 else
374 { 385 {
386#if DEBUG_CONNECTIONS
387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
388 "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
389#endif
375 connected++; 390 connected++;
376 } 391 }
377 if (connected == 2) 392 if (connected == 2)
378 { 393 {
379 measure(); 394 measure(MEASUREMENT_MAX_QUOTA,MEASUREMENT_MAX_QUOTA);
380 } 395 }
381} 396}
382 397
@@ -384,7 +399,7 @@ notify_connect (void *cls,
384static void 399static void
385notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 400notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
386{ 401{
387#if VERBOSE 402#if DEBUG_CONNECTIONS
388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
389 "Peer `%4s' disconnected (%p)!\n", 404 "Peer `%4s' disconnected (%p)!\n",
390 GNUNET_i2s (peer), cls); 405 GNUNET_i2s (peer), cls);
@@ -431,8 +446,6 @@ exchange_hello_last (void *cls,
431 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 446 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
432 message, &me->id)); 447 message, &me->id));
433 /* both HELLOs exchanged, get ready to test transmission! */ 448 /* both HELLOs exchanged, get ready to test transmission! */
434 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
435 "Finished exchanging HELLOs, now waiting for peers to connect!\n");
436} 449}
437 450
438 451