diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-16 15:35:05 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-11-16 15:35:05 +0000 |
commit | cd3497d84532959a26c05342d01ea7107b146358 (patch) | |
tree | bea165dd7cfeeca40719cf71bea396a12dd48271 /src/core/test_core_quota_compliance.c | |
parent | 03b104dab570998b1f791994a8134d35b4b4dc0a (diff) | |
download | gnunet-cd3497d84532959a26c05342d01ea7107b146358.tar.gz gnunet-cd3497d84532959a26c05342d01ea7107b146358.zip |
Diffstat (limited to 'src/core/test_core_quota_compliance.c')
-rw-r--r-- | src/core/test_core_quota_compliance.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index c74a84cbd..d42149099 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include "gnunet_transport_service.h" | 36 | #include "gnunet_transport_service.h" |
37 | 37 | ||
38 | #define VERBOSE GNUNET_YES | 38 | #define VERBOSE GNUNET_YES |
39 | #define DEBUG_TRANSMISSION GNUNET_NO | ||
39 | 40 | ||
40 | #define START_ARM GNUNET_YES | 41 | #define START_ARM GNUNET_YES |
41 | 42 | ||
@@ -122,7 +123,6 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
122 | p1.th = NULL; | 123 | p1.th = NULL; |
123 | GNUNET_TRANSPORT_disconnect (p2.th); | 124 | GNUNET_TRANSPORT_disconnect (p2.th); |
124 | p2.th = NULL; | 125 | p2.th = NULL; |
125 | ok = 0; | ||
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
@@ -157,7 +157,6 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
157 | 157 | ||
158 | measure_task = GNUNET_SCHEDULER_NO_TASK; | 158 | measure_task = GNUNET_SCHEDULER_NO_TASK; |
159 | fprintf(stdout,"\n"); | 159 | fprintf(stdout,"\n"); |
160 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FINIIISH!\n"); | ||
161 | running = GNUNET_NO; | 160 | running = GNUNET_NO; |
162 | 161 | ||
163 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; | 162 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
@@ -176,12 +175,18 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
176 | else | 175 | else |
177 | quota_delta = max_quota_out / 10; | 176 | quota_delta = max_quota_out / 10; |
178 | 177 | ||
179 | if ((throughput < max_quota_out)&& (throughput < max_quota_in)) | 178 | if ((throughput < (max_quota_out/1024)) && (throughput < (max_quota_in/1024))) |
180 | { | 179 | { |
181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Throughput: %llu kb/s\n",throughput); | 180 | ok = 0; |
182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu kb/s\n",max_quota_in/1024); | ||
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu kb/s\n",max_quota_out/1024); | ||
184 | } | 181 | } |
182 | else | ||
183 | { | ||
184 | ok = 1; | ||
185 | } | ||
186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Throughput: %llu kb/s\n",throughput); | ||
187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu kb/s\n",max_quota_in/1024); | ||
188 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu kb/s\n",max_quota_out/1024); | ||
189 | |||
185 | GNUNET_SCHEDULER_cancel (err_task); | 190 | GNUNET_SCHEDULER_cancel (err_task); |
186 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | 191 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); |
187 | 192 | ||
@@ -216,7 +221,7 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
216 | cbuf = buf; | 221 | cbuf = buf; |
217 | do | 222 | do |
218 | { | 223 | { |
219 | #if VERBOSE | 224 | #if DEBUG_TRANSMISSION |
220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
221 | "Sending message %u of size %u at offset %u\n", | 226 | "Sending message %u of size %u at offset %u\n", |
222 | tr_n, | 227 | tr_n, |
@@ -241,9 +246,6 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
241 | &terminate_task_error, | 246 | &terminate_task_error, |
242 | NULL); | 247 | NULL); |
243 | 248 | ||
244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
245 | "Returning total message block of size %u\n", | ||
246 | ret); | ||
247 | total_bytes += ret; | 249 | total_bytes += ret; |
248 | return ret; | 250 | return ret; |
249 | } | 251 | } |
@@ -261,12 +263,14 @@ connect_notify (void *cls, | |||
261 | pc->connect_status = 1; | 263 | pc->connect_status = 1; |
262 | if (pc == &p1) | 264 | if (pc == &p1) |
263 | { | 265 | { |
266 | #if DEBUG_TRANSMISSION | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
265 | "Encrypted connection established to peer `%4s'\n", | 268 | "Encrypted connection established to peer `%4s'\n", |
266 | GNUNET_i2s (peer)); | 269 | GNUNET_i2s (peer)); |
267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
268 | "Asking core (1) for transmission to peer `%4s'\n", | 271 | "Asking core (1) for transmission to peer `%4s'\n", |
269 | GNUNET_i2s (&p2.id)); | 272 | GNUNET_i2s (&p2.id)); |
273 | #endif | ||
270 | err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 274 | err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
271 | &terminate_task_error, | 275 | &terminate_task_error, |
272 | NULL); | 276 | NULL); |
@@ -290,8 +294,10 @@ disconnect_notify (void *cls, | |||
290 | { | 294 | { |
291 | struct PeerContext *pc = cls; | 295 | struct PeerContext *pc = cls; |
292 | pc->connect_status = 0; | 296 | pc->connect_status = 0; |
297 | #if DEBUG_TRANSMISSION | ||
293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
294 | "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); | 299 | "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); |
300 | #endif | ||
295 | } | 301 | } |
296 | 302 | ||
297 | 303 | ||
@@ -301,7 +307,7 @@ inbound_notify (void *cls, | |||
301 | const struct GNUNET_MessageHeader *message, | 307 | const struct GNUNET_MessageHeader *message, |
302 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 308 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
303 | { | 309 | { |
304 | #if VERBOSE | 310 | #if DEBUG_TRANSMISSION |
305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
306 | "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other)); | 312 | "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other)); |
307 | #endif | 313 | #endif |
@@ -315,7 +321,7 @@ outbound_notify (void *cls, | |||
315 | const struct GNUNET_MessageHeader *message, | 321 | const struct GNUNET_MessageHeader *message, |
316 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 322 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
317 | { | 323 | { |
318 | #if VERBOSE | 324 | #if DEBUG_TRANSMISSION |
319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
320 | "Core notifies about outbound data for `%4s'.\n", | 326 | "Core notifies about outbound data for `%4s'.\n", |
321 | GNUNET_i2s (other)); | 327 | GNUNET_i2s (other)); |
@@ -361,7 +367,7 @@ process_mtype (void *cls, | |||
361 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); | 367 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); |
362 | return GNUNET_SYSERR; | 368 | return GNUNET_SYSERR; |
363 | } | 369 | } |
364 | #if VERBOSE | 370 | #if DEBUG_TRANSMISSION |
365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
366 | "Got message %u of size %u\n", | 372 | "Got message %u of size %u\n", |
367 | ntohl (hdr->num), | 373 | ntohl (hdr->num), |
@@ -431,9 +437,11 @@ init_notify (void *cls, | |||
431 | GNUNET_assert (ok == 3); | 437 | GNUNET_assert (ok == 3); |
432 | OKPP; | 438 | OKPP; |
433 | GNUNET_assert (cls == &p2); | 439 | GNUNET_assert (cls == &p2); |
440 | #if DEBUG_TRANSMISSION | ||
434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
435 | "Asking core (1) to connect to peer `%4s'\n", | 442 | "Asking core (1) to connect to peer `%4s'\n", |
436 | GNUNET_i2s (&p2.id)); | 443 | GNUNET_i2s (&p2.id)); |
444 | #endif | ||
437 | GNUNET_CORE_peer_request_connect (p1.ch, | 445 | GNUNET_CORE_peer_request_connect (p1.ch, |
438 | GNUNET_TIME_UNIT_SECONDS, | 446 | GNUNET_TIME_UNIT_SECONDS, |
439 | &p2.id, | 447 | &p2.id, |
@@ -449,9 +457,12 @@ process_hello (void *cls, | |||
449 | struct PeerContext *p = cls; | 457 | struct PeerContext *p = cls; |
450 | 458 | ||
451 | GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); | 459 | GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); |
460 | |||
461 | #if DEBUG_TRANSMISSION | ||
452 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
453 | "Received (my) `%s' from transport service\n", | 463 | "Received (my) `%s' from transport service\n", |
454 | "HELLO"); | 464 | "HELLO"); |
465 | #endif | ||
455 | GNUNET_assert (message != NULL); | 466 | GNUNET_assert (message != NULL); |
456 | p->hello = GNUNET_malloc (ntohs (message->size)); | 467 | p->hello = GNUNET_malloc (ntohs (message->size)); |
457 | memcpy (p->hello, message, ntohs (message->size)); | 468 | memcpy (p->hello, message, ntohs (message->size)); |