diff options
Diffstat (limited to 'src/transport/test_quota_compliance.c')
-rw-r--r-- | src/transport/test_quota_compliance.c | 910 |
1 files changed, 455 insertions, 455 deletions
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 921fa9542..e4638e4fc 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -141,7 +141,7 @@ static GNUNET_SCHEDULER_TaskIdentifier tct; | |||
141 | static GNUNET_SCHEDULER_TaskIdentifier measurement_task; | 141 | static GNUNET_SCHEDULER_TaskIdentifier measurement_task; |
142 | static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task; | 142 | static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task; |
143 | 143 | ||
144 | static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle; | 144 | static struct GNUNET_TRANSPORT_TransmitHandle *transmit_handle; |
145 | 145 | ||
146 | #define OKPP do { ok++; } while (0) | 146 | #define OKPP do { ok++; } while (0) |
147 | 147 | ||
@@ -151,28 +151,27 @@ end () | |||
151 | { | 151 | { |
152 | GNUNET_SCHEDULER_cancel (die_task); | 152 | GNUNET_SCHEDULER_cancel (die_task); |
153 | die_task = GNUNET_SCHEDULER_NO_TASK; | 153 | die_task = GNUNET_SCHEDULER_NO_TASK; |
154 | 154 | ||
155 | if (measurement_task != GNUNET_SCHEDULER_NO_TASK) | 155 | if (measurement_task != GNUNET_SCHEDULER_NO_TASK) |
156 | { | 156 | { |
157 | GNUNET_SCHEDULER_cancel (measurement_task); | 157 | GNUNET_SCHEDULER_cancel (measurement_task); |
158 | measurement_task = GNUNET_SCHEDULER_NO_TASK; | 158 | measurement_task = GNUNET_SCHEDULER_NO_TASK; |
159 | } | 159 | } |
160 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) | 160 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) |
161 | { | 161 | { |
162 | GNUNET_SCHEDULER_cancel (measurement_counter_task); | 162 | GNUNET_SCHEDULER_cancel (measurement_counter_task); |
163 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; | 163 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; |
164 | } | 164 | } |
165 | fprintf(stderr,"\n"); | 165 | fprintf (stderr, "\n"); |
166 | GNUNET_SCHEDULER_shutdown (); | 166 | GNUNET_SCHEDULER_shutdown (); |
167 | #if DEBUG_CONNECTIONS | 167 | #if DEBUG_CONNECTIONS |
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); |
169 | "Disconnecting from transports!\n"); | ||
170 | #endif | 169 | #endif |
171 | GNUNET_TRANSPORT_disconnect (p1.th); | 170 | GNUNET_TRANSPORT_disconnect (p1.th); |
172 | GNUNET_TRANSPORT_disconnect (p2.th); | 171 | GNUNET_TRANSPORT_disconnect (p2.th); |
173 | #if DEBUG_CONNECTIONS | 172 | #if DEBUG_CONNECTIONS |
174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
175 | "Transports disconnected, returning success!\n"); | 174 | "Transports disconnected, returning success!\n"); |
176 | #endif | 175 | #endif |
177 | GNUNET_SCHEDULER_shutdown (); | 176 | GNUNET_SCHEDULER_shutdown (); |
178 | } | 177 | } |
@@ -194,8 +193,7 @@ stop_arm (struct PeerContext *p) | |||
194 | 193 | ||
195 | 194 | ||
196 | static void | 195 | static void |
197 | end_badly (void *cls, | 196 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
198 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
199 | { | 197 | { |
200 | if (measurement_task != GNUNET_SCHEDULER_NO_TASK) | 198 | if (measurement_task != GNUNET_SCHEDULER_NO_TASK) |
201 | { | 199 | { |
@@ -203,16 +201,16 @@ end_badly (void *cls, | |||
203 | measurement_task = GNUNET_SCHEDULER_NO_TASK; | 201 | measurement_task = GNUNET_SCHEDULER_NO_TASK; |
204 | } | 202 | } |
205 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) | 203 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) |
206 | { | 204 | { |
207 | GNUNET_SCHEDULER_cancel (measurement_counter_task); | 205 | GNUNET_SCHEDULER_cancel (measurement_counter_task); |
208 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; | 206 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; |
209 | } | 207 | } |
210 | GNUNET_break (0); | 208 | GNUNET_break (0); |
211 | if (GNUNET_SCHEDULER_NO_TASK != tct) | 209 | if (GNUNET_SCHEDULER_NO_TASK != tct) |
212 | { | 210 | { |
213 | GNUNET_SCHEDULER_cancel (tct); | 211 | GNUNET_SCHEDULER_cancel (tct); |
214 | tct = GNUNET_SCHEDULER_NO_TASK; | 212 | tct = GNUNET_SCHEDULER_NO_TASK; |
215 | } | 213 | } |
216 | if (p1.th != NULL) | 214 | if (p1.th != NULL) |
217 | GNUNET_TRANSPORT_disconnect (p1.th); | 215 | GNUNET_TRANSPORT_disconnect (p1.th); |
218 | if (p2.th != NULL) | 216 | if (p2.th != NULL) |
@@ -235,32 +233,32 @@ get_size () | |||
235 | 233 | ||
236 | static void | 234 | static void |
237 | notify_receive_new (void *cls, | 235 | notify_receive_new (void *cls, |
238 | const struct GNUNET_PeerIdentity *peer, | 236 | const struct GNUNET_PeerIdentity *peer, |
239 | const struct GNUNET_MessageHeader *message, | 237 | const struct GNUNET_MessageHeader *message, |
240 | const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) | 238 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
239 | uint32_t ats_count) | ||
241 | { | 240 | { |
242 | const struct TestMessage *hdr; | 241 | const struct TestMessage *hdr; |
243 | 242 | ||
244 | GNUNET_assert (message != NULL); | 243 | GNUNET_assert (message != NULL); |
245 | hdr = (const struct TestMessage*) message; | 244 | hdr = (const struct TestMessage *) message; |
246 | if (measurement_running == GNUNET_NO) | 245 | if (measurement_running == GNUNET_NO) |
247 | return; | 246 | return; |
248 | if (MTYPE != ntohs (message->type)) | 247 | if (MTYPE != ntohs (message->type)) |
249 | return; | 248 | return; |
250 | 249 | ||
251 | #if DEBUG_MEASUREMENT | 250 | #if DEBUG_MEASUREMENT |
252 | if (ntohl(hdr->num) % 5000 == 0) | 251 | if (ntohl (hdr->num) % 5000 == 0) |
253 | { | 252 | { |
254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
255 | "Got message %u of size %u\n", | 254 | "Got message %u of size %u\n", |
256 | ntohl (hdr->num), | 255 | ntohl (hdr->num), ntohs (message->size)); |
257 | ntohs (message->size)); | 256 | } |
258 | } | ||
259 | #endif | 257 | #endif |
260 | /* | 258 | /* |
261 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 259 | * GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
262 | "Got message %u\n", | 260 | * "Got message %u\n", |
263 | ntohl (hdr->num));*/ | 261 | * ntohl (hdr->num)); */ |
264 | last_msg_recv = ntohl (hdr->num); | 262 | last_msg_recv = ntohl (hdr->num); |
265 | } | 263 | } |
266 | 264 | ||
@@ -278,15 +276,15 @@ notify_ready (void *cls, size_t size, void *buf) | |||
278 | return 0; | 276 | return 0; |
279 | 277 | ||
280 | if (buf == NULL) | 278 | if (buf == NULL) |
281 | { | 279 | { |
282 | ok = 42; | 280 | ok = 42; |
283 | return 0; | 281 | return 0; |
284 | } | 282 | } |
285 | if (measurement_running != GNUNET_YES) | 283 | if (measurement_running != GNUNET_YES) |
286 | { | 284 | { |
287 | send_running = GNUNET_NO; | 285 | send_running = GNUNET_NO; |
288 | return 0; | 286 | return 0; |
289 | } | 287 | } |
290 | send_running = GNUNET_YES; | 288 | send_running = GNUNET_YES; |
291 | ret = 0; | 289 | ret = 0; |
292 | s = get_size (); | 290 | s = get_size (); |
@@ -295,271 +293,268 @@ notify_ready (void *cls, size_t size, void *buf) | |||
295 | last_msg_sent++; | 293 | last_msg_sent++; |
296 | cbuf = buf; | 294 | cbuf = buf; |
297 | do | 295 | do |
298 | { | 296 | { |
299 | hdr.header.size = htons (s); | 297 | hdr.header.size = htons (s); |
300 | hdr.header.type = htons (MTYPE); | 298 | hdr.header.type = htons (MTYPE); |
301 | hdr.num = htonl (last_msg_sent); | 299 | hdr.num = htonl (last_msg_sent); |
302 | memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage)); | 300 | memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage)); |
303 | ret += sizeof (struct TestMessage); | 301 | ret += sizeof (struct TestMessage); |
304 | memset (&cbuf[ret], last_msg_sent, s - sizeof (struct TestMessage)); | 302 | memset (&cbuf[ret], last_msg_sent, s - sizeof (struct TestMessage)); |
305 | ret += s - sizeof (struct TestMessage); | 303 | ret += s - sizeof (struct TestMessage); |
306 | #if DEBUG_MEASUREMENT | 304 | #if DEBUG_MEASUREMENT |
307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u\n", last_msg_sent); |
308 | "Sending message %u\n", | ||
309 | last_msg_sent); | ||
310 | #endif | 306 | #endif |
311 | s = get_size (); | 307 | s = get_size (); |
312 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16)) | 308 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16)) |
313 | break; /* sometimes pack buffer full, sometimes not */ | 309 | break; /* sometimes pack buffer full, sometimes not */ |
314 | } | 310 | } |
315 | while (size - ret >= s); | 311 | while (size - ret >= s); |
316 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 312 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, |
317 | &p1.id, | 313 | &p1.id, |
318 | s, 0, SEND_TIMEOUT, | 314 | s, 0, SEND_TIMEOUT, |
319 | ¬ify_ready, | 315 | ¬ify_ready, |
320 | NULL); | 316 | NULL); |
321 | total_bytes_sent += s; | 317 | total_bytes_sent += s; |
322 | return ret; | 318 | return ret; |
323 | } | 319 | } |
324 | 320 | ||
325 | 321 | ||
326 | static void | 322 | static void measure (unsigned long long quota_p1, unsigned long long quota_p2); |
327 | measure (unsigned long long quota_p1, unsigned long long quota_p2); | ||
328 | 323 | ||
329 | static void | 324 | static void |
330 | measurement_counter (void *cls, | 325 | measurement_counter (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
331 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
332 | { | 326 | { |
333 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; | 327 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; |
334 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 328 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
335 | return; | 329 | return; |
336 | 330 | ||
337 | fprintf(stderr,"."); | 331 | fprintf (stderr, "."); |
338 | measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 332 | measurement_counter_task = |
339 | &measurement_counter, | 333 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
340 | NULL); | 334 | &measurement_counter, NULL); |
341 | } | 335 | } |
342 | 336 | ||
343 | 337 | ||
344 | static void | 338 | static void |
345 | measurement_end (void *cls, | 339 | measurement_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
346 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
347 | { | 340 | { |
348 | static int strike_counter; | 341 | static int strike_counter; |
349 | static int failed_measurement_counter = 1; | 342 | static int failed_measurement_counter = 1; |
350 | unsigned long long quota_allowed = 0; | 343 | unsigned long long quota_allowed = 0; |
351 | int delta = 0; | 344 | int delta = 0; |
352 | 345 | ||
353 | measurement_task = GNUNET_SCHEDULER_NO_TASK; | 346 | measurement_task = GNUNET_SCHEDULER_NO_TASK; |
354 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 347 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
355 | return; | 348 | return; |
356 | 349 | ||
357 | measurement_running = GNUNET_NO; | 350 | measurement_running = GNUNET_NO; |
358 | struct GNUNET_TIME_Relative duration | 351 | struct GNUNET_TIME_Relative duration |
359 | = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); | 352 | = GNUNET_TIME_absolute_get_difference (start_time, |
353 | GNUNET_TIME_absolute_get ()); | ||
360 | 354 | ||
361 | 355 | ||
362 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) | 356 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) |
363 | { | 357 | { |
364 | GNUNET_SCHEDULER_cancel (measurement_counter_task); | 358 | GNUNET_SCHEDULER_cancel (measurement_counter_task); |
365 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; | 359 | measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; |
366 | } | 360 | } |
367 | 361 | ||
368 | if (transmit_handle != NULL) | 362 | if (transmit_handle != NULL) |
369 | { | 363 | { |
370 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); | 364 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); |
371 | transmit_handle = NULL; | 365 | transmit_handle = NULL; |
372 | } | 366 | } |
373 | 367 | ||
374 | if (current_quota_p1 < current_quota_p2) | 368 | if (current_quota_p1 < current_quota_p2) |
375 | quota_allowed = current_quota_p1; | 369 | quota_allowed = current_quota_p1; |
376 | else | 370 | else |
377 | quota_allowed = current_quota_p2; | 371 | quota_allowed = current_quota_p2; |
378 | 372 | ||
379 | 373 | ||
380 | if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/3)) | 374 | if (MEASUREMENT_SOFT_LIMIT > (quota_allowed / 3)) |
381 | delta = MEASUREMENT_SOFT_LIMIT; | 375 | delta = MEASUREMENT_SOFT_LIMIT; |
382 | else | 376 | else |
383 | delta = (quota_allowed/3); | 377 | delta = (quota_allowed / 3); |
384 | 378 | ||
385 | /* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */ | 379 | /* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */ |
386 | if ((total_bytes_sent/(duration.rel_value / 1000)) < 100) | 380 | if ((total_bytes_sent / (duration.rel_value / 1000)) < 100) |
381 | { | ||
382 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
383 | "\nQuota compliance failed: \n" | ||
384 | "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" | ||
385 | "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" | ||
386 | "Throughput : %10llu kB/s (%llu B/s)\n", | ||
387 | (quota_allowed / (1024)), quota_allowed, | ||
388 | ((quota_allowed + delta) / (1024)), quota_allowed + delta, | ||
389 | (total_bytes_sent / (duration.rel_value / 1000) / 1024), | ||
390 | total_bytes_sent / (duration.rel_value / 1000)); | ||
391 | ok = 1; | ||
392 | failed_measurement_counter--; | ||
393 | if (failed_measurement_counter < 0) | ||
387 | { | 394 | { |
388 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 395 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
389 | "\nQuota compliance failed: \n" \ | 396 | "\nQuota measurement failed and no free strike: %i\n", |
390 | "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \ | 397 | failed_measurement_counter); |
391 | "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \ | 398 | end (); |
392 | "Throughput : %10llu kB/s (%llu B/s)\n", | 399 | return; |
393 | (quota_allowed / (1024)), quota_allowed, | ||
394 | ((quota_allowed+delta) / (1024)), quota_allowed+delta, | ||
395 | (total_bytes_sent/(duration.rel_value / 1000)/1024), | ||
396 | total_bytes_sent/(duration.rel_value / 1000)); | ||
397 | ok = 1; | ||
398 | failed_measurement_counter--; | ||
399 | if (failed_measurement_counter < 0) | ||
400 | { | ||
401 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
402 | "\nQuota measurement failed and no free strike: %i\n", | ||
403 | failed_measurement_counter); | ||
404 | end(); | ||
405 | return; | ||
406 | } | ||
407 | else | ||
408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
409 | "\nQuota measurement failed and %i free strikes\n", | ||
410 | failed_measurement_counter); | ||
411 | } | 400 | } |
412 | 401 | else | |
413 | /* Throughput is bigger than allowed quota + some extra*/ | 402 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
414 | if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta)) | 403 | "\nQuota measurement failed and %i free strikes\n", |
404 | failed_measurement_counter); | ||
405 | } | ||
406 | |||
407 | /* Throughput is bigger than allowed quota + some extra */ | ||
408 | if ((total_bytes_sent / (duration.rel_value / 1000)) > | ||
409 | (quota_allowed + delta)) | ||
410 | { | ||
411 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
412 | "\nQuota compliance failed: \n" | ||
413 | "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" | ||
414 | "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" | ||
415 | "Throughput : %10llu kB/s (%llu B/s)\n", | ||
416 | (quota_allowed / (1024)), quota_allowed, | ||
417 | ((quota_allowed + delta) / (1024)), quota_allowed + delta, | ||
418 | (total_bytes_sent / (duration.rel_value / 1000) / 1024), | ||
419 | total_bytes_sent / (duration.rel_value / 1000)); | ||
420 | ok = 1; | ||
421 | failed_measurement_counter--; | ||
422 | if (failed_measurement_counter < 0) | ||
415 | { | 423 | { |
416 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 424 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
417 | "\nQuota compliance failed: \n" \ | 425 | "\nQuota measurement failed and no free strike: %i\n", |
418 | "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \ | 426 | failed_measurement_counter); |
419 | "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \ | 427 | end (); |
420 | "Throughput : %10llu kB/s (%llu B/s)\n", | 428 | return; |
421 | (quota_allowed / (1024)), quota_allowed, | ||
422 | ((quota_allowed+delta) / (1024)), quota_allowed+delta, | ||
423 | (total_bytes_sent/(duration.rel_value / 1000)/1024), | ||
424 | total_bytes_sent/(duration.rel_value / 1000)); | ||
425 | ok = 1; | ||
426 | failed_measurement_counter--; | ||
427 | if (failed_measurement_counter < 0) | ||
428 | { | ||
429 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
430 | "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter); | ||
431 | end(); | ||
432 | return; | ||
433 | } | ||
434 | else | ||
435 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
436 | "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter); | ||
437 | } | 429 | } |
430 | else | ||
431 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
432 | "\nQuota measurement failed and %i free strikes\n", | ||
433 | failed_measurement_counter); | ||
434 | } | ||
438 | else | 435 | else |
436 | { | ||
437 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
438 | "\nQuota compliance ok: \n" | ||
439 | "Quota allowed: %10llu kB/s\n" | ||
440 | "Throughput : %10llu kB/s\n", | ||
441 | (quota_allowed / (1024)), | ||
442 | (total_bytes_sent / (duration.rel_value / 1000) / 1024)); | ||
443 | if (failed_measurement_counter < 2) | ||
444 | failed_measurement_counter++; | ||
445 | ok = 0; | ||
446 | } | ||
447 | |||
448 | if ((quota_allowed) > (2 * (total_bytes_sent / (duration.rel_value / 1000)))) | ||
449 | { | ||
450 | if (failed_measurement_counter < 2) | ||
451 | failed_measurement_counter++; | ||
452 | if (strike_counter == 2) | ||
439 | { | 453 | { |
440 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 454 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
441 | "\nQuota compliance ok: \n" \ | 455 | "Maximum transmission rate reached, stopping test\n"); |
442 | "Quota allowed: %10llu kB/s\n" \ | 456 | end (); |
443 | "Throughput : %10llu kB/s\n", | 457 | return; |
444 | (quota_allowed / (1024)), | ||
445 | (total_bytes_sent/(duration.rel_value / 1000)/1024)); | ||
446 | if (failed_measurement_counter < 2) | ||
447 | failed_measurement_counter++; | ||
448 | ok = 0; | ||
449 | } | ||
450 | |||
451 | if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000)))) | ||
452 | { | ||
453 | if (failed_measurement_counter < 2) | ||
454 | failed_measurement_counter++; | ||
455 | if (strike_counter == 2) | ||
456 | { | ||
457 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
458 | "Maximum transmission rate reached, stopping test\n"); | ||
459 | end(); | ||
460 | return; | ||
461 | } | ||
462 | } | 458 | } |
459 | } | ||
463 | else | 460 | else |
464 | { | 461 | { |
465 | strike_counter = 0; | 462 | strike_counter = 0; |
466 | } | 463 | } |
467 | 464 | ||
468 | if (quota_allowed == MEASUREMENT_MAX_QUOTA) | 465 | if (quota_allowed == MEASUREMENT_MAX_QUOTA) |
469 | { | 466 | { |
470 | end(); | 467 | end (); |
471 | return; | 468 | return; |
472 | } | 469 | } |
473 | if (is_asymmetric_send_constant == GNUNET_YES) | 470 | if (is_asymmetric_send_constant == GNUNET_YES) |
474 | { | 471 | { |
475 | if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) | 472 | if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) |
476 | measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA); | 473 | measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA); |
477 | else | 474 | else |
478 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); | 475 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); |
479 | } | 476 | } |
480 | else if (is_asymmetric_recv_constant == GNUNET_YES) | 477 | else if (is_asymmetric_recv_constant == GNUNET_YES) |
481 | { | 478 | { |
482 | if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) | 479 | if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) |
483 | measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2); | 480 | measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2); |
484 | else | 481 | else |
485 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); | 482 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); |
486 | } | 483 | } |
487 | else | 484 | else |
488 | { | 485 | { |
489 | if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) | 486 | if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) |
490 | measure ((current_quota_p1) * 2, (current_quota_p2) * 2); | 487 | measure ((current_quota_p1) * 2, (current_quota_p2) * 2); |
491 | else | 488 | else |
492 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); | 489 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); |
493 | } | 490 | } |
494 | } | 491 | } |
495 | 492 | ||
496 | static void | 493 | static void |
497 | measure (unsigned long long quota_p1, unsigned long long quota_p2) | 494 | measure (unsigned long long quota_p1, unsigned long long quota_p2) |
498 | { | 495 | { |
499 | current_quota_p1 = quota_p1; | 496 | current_quota_p1 = quota_p1; |
500 | current_quota_p2 = quota_p2; | 497 | current_quota_p2 = quota_p2; |
501 | #if VERBOSE | 498 | #if VERBOSE |
502 | if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES)) | 499 | if ((is_asymmetric_send_constant == GNUNET_YES) || |
500 | (is_asymmetric_recv_constant == GNUNET_YES)) | ||
503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
504 | "Starting transport level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n", | 502 | "Starting transport level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n", |
505 | MEASUREMENT_INTERVALL.rel_value / 1000 , | 503 | MEASUREMENT_INTERVALL.rel_value / 1000, current_quota_p1 / 1024, |
506 | current_quota_p1 / 1024, | 504 | current_quota_p2 / 1024); |
507 | current_quota_p2 / 1024); | ||
508 | else | 505 | else |
509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
510 | "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n", | 507 | "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n", |
511 | MEASUREMENT_INTERVALL.rel_value / 1000, | 508 | MEASUREMENT_INTERVALL.rel_value / 1000, |
512 | current_quota_p2 / 1024); | 509 | current_quota_p2 / 1024); |
513 | 510 | ||
514 | #endif | 511 | #endif |
515 | GNUNET_TRANSPORT_set_quota (p1.th, | 512 | GNUNET_TRANSPORT_set_quota (p1.th, |
516 | &p2.id, | 513 | &p2.id, |
517 | GNUNET_BANDWIDTH_value_init (current_quota_p1), | 514 | GNUNET_BANDWIDTH_value_init (current_quota_p1), |
518 | GNUNET_BANDWIDTH_value_init (current_quota_p1)); | 515 | GNUNET_BANDWIDTH_value_init (current_quota_p1)); |
519 | GNUNET_TRANSPORT_set_quota (p2.th, | 516 | GNUNET_TRANSPORT_set_quota (p2.th, |
520 | &p1.id, | 517 | &p1.id, |
521 | GNUNET_BANDWIDTH_value_init (current_quota_p2), | 518 | GNUNET_BANDWIDTH_value_init (current_quota_p2), |
522 | GNUNET_BANDWIDTH_value_init (current_quota_p2)); | 519 | GNUNET_BANDWIDTH_value_init (current_quota_p2)); |
523 | GNUNET_SCHEDULER_cancel (die_task); | 520 | GNUNET_SCHEDULER_cancel (die_task); |
524 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 521 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
525 | &end_badly, | ||
526 | NULL); | ||
527 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) | 522 | if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) |
528 | GNUNET_SCHEDULER_cancel (measurement_counter_task); | 523 | GNUNET_SCHEDULER_cancel (measurement_counter_task); |
529 | measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 524 | measurement_counter_task = |
530 | &measurement_counter, | 525 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
531 | NULL); | 526 | &measurement_counter, NULL); |
532 | measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL, | 527 | measurement_task = |
533 | &measurement_end, | 528 | GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL, &measurement_end, |
534 | NULL); | 529 | NULL); |
535 | total_bytes_sent = 0; | 530 | total_bytes_sent = 0; |
536 | last_msg_sent = 0; | 531 | last_msg_sent = 0; |
537 | last_msg_recv = 0; | 532 | last_msg_recv = 0; |
538 | measurement_running = GNUNET_YES; | 533 | measurement_running = GNUNET_YES; |
539 | start_time = GNUNET_TIME_absolute_get (); | 534 | start_time = GNUNET_TIME_absolute_get (); |
540 | 535 | ||
541 | if (transmit_handle != NULL) | 536 | if (transmit_handle != NULL) |
542 | GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); | 537 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); |
543 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, | 538 | transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, |
544 | &p1.id, | 539 | &p1.id, |
545 | get_size (), 0, SEND_TIMEOUT, | 540 | get_size (), 0, |
546 | ¬ify_ready, | 541 | SEND_TIMEOUT, |
547 | NULL); | 542 | ¬ify_ready, |
543 | NULL); | ||
548 | } | 544 | } |
549 | 545 | ||
550 | 546 | ||
551 | static void | 547 | static void |
552 | exchange_hello_last (void *cls, | 548 | exchange_hello_last (void *cls, const struct GNUNET_MessageHeader *message) |
553 | const struct GNUNET_MessageHeader *message) | ||
554 | { | 549 | { |
555 | struct PeerContext *me = cls; | 550 | struct PeerContext *me = cls; |
556 | 551 | ||
557 | GNUNET_assert (message != NULL); | 552 | GNUNET_assert (message != NULL); |
558 | #if DEBUG_CONNECTIONS | 553 | #if DEBUG_CONNECTIONS |
559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 554 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
560 | "Exchanging HELLO of size %d with peer (%s)!\n", | 555 | "Exchanging HELLO of size %d with peer (%s)!\n", |
561 | (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message), | 556 | (int) GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) |
562 | GNUNET_i2s (&me->id)); | 557 | message), GNUNET_i2s (&me->id)); |
563 | #endif | 558 | #endif |
564 | GNUNET_assert (GNUNET_OK == | 559 | GNUNET_assert (GNUNET_OK == |
565 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | 560 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) |
@@ -570,8 +565,7 @@ exchange_hello_last (void *cls, | |||
570 | 565 | ||
571 | 566 | ||
572 | static void | 567 | static void |
573 | exchange_hello (void *cls, | 568 | exchange_hello (void *cls, const struct GNUNET_MessageHeader *message) |
574 | const struct GNUNET_MessageHeader *message) | ||
575 | { | 569 | { |
576 | struct PeerContext *me = cls; | 570 | struct PeerContext *me = cls; |
577 | 571 | ||
@@ -581,9 +575,9 @@ exchange_hello (void *cls, | |||
581 | message, &me->id)); | 575 | message, &me->id)); |
582 | #if DEBUG_CONNECTIONS | 576 | #if DEBUG_CONNECTIONS |
583 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 577 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
584 | "Exchanging HELLO of size %d from peer %s!\n", | 578 | "Exchanging HELLO of size %d from peer %s!\n", |
585 | (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message), | 579 | (int) GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) |
586 | GNUNET_i2s (&me->id)); | 580 | message), GNUNET_i2s (&me->id)); |
587 | #endif | 581 | #endif |
588 | GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL); | 582 | GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL); |
589 | } | 583 | } |
@@ -592,43 +586,40 @@ exchange_hello (void *cls, | |||
592 | static void | 586 | static void |
593 | notify_connect (void *cls, | 587 | notify_connect (void *cls, |
594 | const struct GNUNET_PeerIdentity *peer, | 588 | const struct GNUNET_PeerIdentity *peer, |
595 | const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) | 589 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
596 | { | 590 | uint32_t ats_count) |
591 | { | ||
597 | connected++; | 592 | connected++; |
598 | if (cls == &p1) | 593 | if (cls == &p1) |
599 | { | 594 | { |
600 | #if DEBUG_CONNECTIONS | 595 | #if DEBUG_CONNECTIONS |
601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 596 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
602 | "Peer 1 `%4s' connected to us (%p)!\n", | 597 | "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); |
603 | GNUNET_i2s (peer), | ||
604 | cls); | ||
605 | #endif | 598 | #endif |
606 | } | 599 | } |
607 | else | 600 | else |
608 | { | 601 | { |
609 | #if DEBUG_CONNECTIONS | 602 | #if DEBUG_CONNECTIONS |
610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
611 | "Peer 2 `%4s' connected to us (%p)!\n", | 604 | "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); |
612 | GNUNET_i2s (peer), | ||
613 | cls); | ||
614 | #endif | 605 | #endif |
615 | } | 606 | } |
616 | if (connected == 2) | 607 | if (connected == 2) |
608 | { | ||
609 | if (GNUNET_SCHEDULER_NO_TASK != tct) | ||
617 | { | 610 | { |
618 | if (GNUNET_SCHEDULER_NO_TASK != tct) | 611 | GNUNET_SCHEDULER_cancel (tct); |
619 | { | 612 | tct = GNUNET_SCHEDULER_NO_TASK; |
620 | GNUNET_SCHEDULER_cancel (tct); | ||
621 | tct = GNUNET_SCHEDULER_NO_TASK; | ||
622 | } | ||
623 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2); | ||
624 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); | ||
625 | if (is_asymmetric_send_constant == GNUNET_YES) | ||
626 | measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA); | ||
627 | else if (is_asymmetric_recv_constant == GNUNET_YES) | ||
628 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA); | ||
629 | else | ||
630 | measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA); | ||
631 | } | 613 | } |
614 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2); | ||
615 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); | ||
616 | if (is_asymmetric_send_constant == GNUNET_YES) | ||
617 | measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA); | ||
618 | else if (is_asymmetric_recv_constant == GNUNET_YES) | ||
619 | measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA); | ||
620 | else | ||
621 | measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA); | ||
622 | } | ||
632 | } | 623 | } |
633 | 624 | ||
634 | 625 | ||
@@ -636,18 +627,17 @@ static void | |||
636 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 627 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
637 | { | 628 | { |
638 | if (cls == &p2) | 629 | if (cls == &p2) |
630 | { | ||
631 | if (NULL != transmit_handle) | ||
639 | { | 632 | { |
640 | if (NULL != transmit_handle) | 633 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); |
641 | { | 634 | transmit_handle = NULL; |
642 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); | ||
643 | transmit_handle = NULL; | ||
644 | } | ||
645 | } | 635 | } |
636 | } | ||
646 | connected--; | 637 | connected--; |
647 | #if DEBUG_CONNECTIONS | 638 | #if DEBUG_CONNECTIONS |
648 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
649 | "Peer `%4s' disconnected (%p)!\n", | 640 | "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); |
650 | GNUNET_i2s (peer), cls); | ||
651 | #endif | 641 | #endif |
652 | } | 642 | } |
653 | 643 | ||
@@ -657,46 +647,41 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
657 | { | 647 | { |
658 | p->cfg = GNUNET_CONFIGURATION_create (); | 648 | p->cfg = GNUNET_CONFIGURATION_create (); |
659 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 649 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
660 | if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME")) | 650 | if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) |
661 | { | 651 | { |
662 | GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome); | 652 | GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", |
663 | GNUNET_DISK_directory_remove (p->servicehome); | 653 | &p->servicehome); |
664 | } | 654 | GNUNET_DISK_directory_remove (p->servicehome); |
655 | } | ||
665 | 656 | ||
666 | #if START_ARM | 657 | #if START_ARM |
667 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, | 658 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, |
668 | "gnunet-service-arm", | 659 | "gnunet-service-arm", |
669 | "gnunet-service-arm", | 660 | "gnunet-service-arm", |
670 | #if VERBOSE_ARM | 661 | #if VERBOSE_ARM |
671 | "-L", "DEBUG", | 662 | "-L", "DEBUG", |
672 | #endif | 663 | #endif |
673 | "-c", cfgname, NULL); | 664 | "-c", cfgname, NULL); |
674 | #endif | 665 | #endif |
675 | 666 | ||
676 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, | 667 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, |
677 | p, | 668 | p, |
678 | ¬ify_receive_new, | 669 | ¬ify_receive_new, |
679 | ¬ify_connect, | 670 | ¬ify_connect, ¬ify_disconnect); |
680 | ¬ify_disconnect); | ||
681 | GNUNET_assert (p->th != NULL); | 671 | GNUNET_assert (p->th != NULL); |
682 | } | 672 | } |
683 | 673 | ||
684 | 674 | ||
685 | static void | 675 | static void |
686 | try_connect (void *cls, | 676 | try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
687 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
688 | { | 677 | { |
689 | #if DEBUG_CONNECTIONS | 678 | #if DEBUG_CONNECTIONS |
690 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 679 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking peers to connect...\n"); |
691 | "Asking peers to connect...\n"); | ||
692 | #endif | 680 | #endif |
693 | GNUNET_TRANSPORT_try_connect (p2.th, | 681 | GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); |
694 | &p1.id); | 682 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); |
695 | GNUNET_TRANSPORT_try_connect (p1.th, | ||
696 | &p2.id); | ||
697 | tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 683 | tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
698 | &try_connect, | 684 | &try_connect, NULL); |
699 | NULL); | ||
700 | } | 685 | } |
701 | 686 | ||
702 | 687 | ||
@@ -708,102 +693,100 @@ run (void *cls, | |||
708 | GNUNET_assert (ok == 1); | 693 | GNUNET_assert (ok == 1); |
709 | OKPP; | 694 | OKPP; |
710 | 695 | ||
711 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 696 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
712 | &end_badly, | ||
713 | NULL); | ||
714 | measurement_running = GNUNET_NO; | 697 | measurement_running = GNUNET_NO; |
715 | send_running = GNUNET_NO; | 698 | send_running = GNUNET_NO; |
716 | recv_running = GNUNET_NO; | 699 | recv_running = GNUNET_NO; |
717 | 700 | ||
718 | if (is_tcp) | 701 | if (is_tcp) |
719 | { | 702 | { |
720 | if (is_asymmetric_recv_constant == GNUNET_YES) | 703 | if (is_asymmetric_recv_constant == GNUNET_YES) |
721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
722 | "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n"); | 705 | "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n"); |
723 | else if (is_asymmetric_send_constant == GNUNET_YES) | 706 | else if (is_asymmetric_send_constant == GNUNET_YES) |
724 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
725 | "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n"); | 708 | "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n"); |
726 | else | 709 | else |
727 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 710 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
728 | "Testing symmetric quota compliance for TCP transport plugin\n"); | 711 | "Testing symmetric quota compliance for TCP transport plugin\n"); |
729 | setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); | 712 | setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); |
730 | setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); | 713 | setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); |
731 | } | 714 | } |
732 | else if (is_http) | 715 | else if (is_http) |
733 | { | 716 | { |
734 | if (is_asymmetric_recv_constant == GNUNET_YES) | 717 | if (is_asymmetric_recv_constant == GNUNET_YES) |
735 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
736 | "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n"); | 719 | "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n"); |
737 | else if (is_asymmetric_send_constant == GNUNET_YES) | 720 | else if (is_asymmetric_send_constant == GNUNET_YES) |
738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
739 | "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n"); | 722 | "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n"); |
740 | else | 723 | else |
741 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 724 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
742 | "Testing symmetric quota compliance for HTTP transport plugin\n"); | 725 | "Testing symmetric quota compliance for HTTP transport plugin\n"); |
743 | setup_peer (&p1, "test_quota_compliance_http_peer1.conf"); | 726 | setup_peer (&p1, "test_quota_compliance_http_peer1.conf"); |
744 | setup_peer (&p2, "test_quota_compliance_http_peer2.conf"); | 727 | setup_peer (&p2, "test_quota_compliance_http_peer2.conf"); |
745 | } | 728 | } |
746 | else if (is_https) | 729 | else if (is_https) |
747 | { | 730 | { |
748 | if (is_asymmetric_recv_constant == GNUNET_YES) | 731 | if (is_asymmetric_recv_constant == GNUNET_YES) |
749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 732 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
750 | "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n"); | 733 | "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n"); |
751 | else if (is_asymmetric_send_constant == GNUNET_YES) | 734 | else if (is_asymmetric_send_constant == GNUNET_YES) |
752 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 735 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
753 | "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n"); | 736 | "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n"); |
754 | else | 737 | else |
755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
756 | "Testing symmetric quota compliance for HTTPS transport plugin\n"); | 739 | "Testing symmetric quota compliance for HTTPS transport plugin\n"); |
757 | setup_peer (&p1, "test_quota_compliance_https_peer1.conf"); | 740 | setup_peer (&p1, "test_quota_compliance_https_peer1.conf"); |
758 | setup_peer (&p2, "test_quota_compliance_https_peer2.conf"); | 741 | setup_peer (&p2, "test_quota_compliance_https_peer2.conf"); |
759 | } | 742 | } |
760 | else if (is_udp) | 743 | else if (is_udp) |
761 | { | 744 | { |
762 | if (is_asymmetric_recv_constant == GNUNET_YES) | 745 | if (is_asymmetric_recv_constant == GNUNET_YES) |
763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 746 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
764 | "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n"); | 747 | "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n"); |
765 | else if (is_asymmetric_send_constant == GNUNET_YES) | 748 | else if (is_asymmetric_send_constant == GNUNET_YES) |
766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
767 | "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n"); | 750 | "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n"); |
768 | else | 751 | else |
769 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 752 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
770 | "Testing symmetric quota compliance for UDP transport plugin\n"); | 753 | "Testing symmetric quota compliance for UDP transport plugin\n"); |
771 | setup_peer (&p1, "test_quota_compliance_udp_peer1.conf"); | 754 | setup_peer (&p1, "test_quota_compliance_udp_peer1.conf"); |
772 | setup_peer (&p2, "test_quota_compliance_udp_peer2.conf"); | 755 | setup_peer (&p2, "test_quota_compliance_udp_peer2.conf"); |
773 | } | 756 | } |
774 | else if (is_unix) | 757 | else if (is_unix) |
775 | { | 758 | { |
776 | if (is_asymmetric_recv_constant == GNUNET_YES) | 759 | if (is_asymmetric_recv_constant == GNUNET_YES) |
777 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
778 | "Testing asymmetric quota compliance (receiver quota constant) for UNIX transport plugin\n"); | 761 | "Testing asymmetric quota compliance (receiver quota constant) for UNIX transport plugin\n"); |
779 | else if (is_asymmetric_send_constant == GNUNET_YES) | 762 | else if (is_asymmetric_send_constant == GNUNET_YES) |
780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
781 | "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n"); | 764 | "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n"); |
782 | else | 765 | else |
783 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
784 | "Testing symmetric quota compliance for UNIX transport plugin\n"); | 767 | "Testing symmetric quota compliance for UNIX transport plugin\n"); |
785 | setup_peer (&p1, "test_quota_compliance_unix_peer1.conf"); | 768 | setup_peer (&p1, "test_quota_compliance_unix_peer1.conf"); |
786 | setup_peer (&p2, "test_quota_compliance_unix_peer2.conf"); | 769 | setup_peer (&p2, "test_quota_compliance_unix_peer2.conf"); |
787 | } | 770 | } |
788 | else if (is_tcp_nat) | 771 | else if (is_tcp_nat) |
789 | { | 772 | { |
790 | if (is_asymmetric_recv_constant == GNUNET_YES) | 773 | if (is_asymmetric_recv_constant == GNUNET_YES) |
791 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
792 | "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n"); | 775 | "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n"); |
793 | else if (is_asymmetric_send_constant == GNUNET_YES) | 776 | else if (is_asymmetric_send_constant == GNUNET_YES) |
794 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 777 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
795 | "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n"); | 778 | "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n"); |
796 | else | 779 | else |
797 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
798 | "Testing symmetric quota compliance for TCP NAT transport plugin\n"); | 781 | "Testing symmetric quota compliance for TCP NAT transport plugin\n"); |
799 | setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); | 782 | setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); |
800 | setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); | 783 | setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); |
801 | } | 784 | } |
802 | else | 785 | else |
803 | GNUNET_assert (0); | 786 | GNUNET_assert (0); |
804 | 787 | ||
805 | GNUNET_assert(p1.th != NULL); | 788 | GNUNET_assert (p1.th != NULL); |
806 | GNUNET_assert(p2.th != NULL); | 789 | GNUNET_assert (p2.th != NULL); |
807 | GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); | 790 | GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); |
808 | GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); | 791 | GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); |
809 | tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL); | 792 | tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL); |
@@ -814,96 +797,114 @@ int | |||
814 | main (int argc, char *argv[]) | 797 | main (int argc, char *argv[]) |
815 | { | 798 | { |
816 | int ret = 0; | 799 | int ret = 0; |
817 | if (strstr(argv[0], "tcp_nat") != NULL) | ||
818 | { | ||
819 | is_tcp_nat = GNUNET_YES; | ||
820 | } | ||
821 | else if (strstr(argv[0], "tcp") != NULL) | ||
822 | { | ||
823 | is_tcp = GNUNET_YES; | ||
824 | } | ||
825 | else if (strstr(argv[0], "https") != NULL) | ||
826 | { | ||
827 | is_https = GNUNET_YES; | ||
828 | } | ||
829 | else if (strstr(argv[0], "http") != NULL) | ||
830 | { | ||
831 | is_http = GNUNET_YES; | ||
832 | } | ||
833 | else if (strstr(argv[0], "udp") != NULL) | ||
834 | { | ||
835 | is_udp = GNUNET_YES; | ||
836 | } | ||
837 | else if (strstr(argv[0], "unix") != NULL) | ||
838 | { | ||
839 | is_unix = GNUNET_YES; | ||
840 | } | ||
841 | 800 | ||
842 | if (strstr(argv[0], "asymmetric_recv") != NULL) | 801 | if (strstr (argv[0], "tcp_nat") != NULL) |
802 | { | ||
803 | is_tcp_nat = GNUNET_YES; | ||
804 | } | ||
805 | else if (strstr (argv[0], "tcp") != NULL) | ||
806 | { | ||
807 | is_tcp = GNUNET_YES; | ||
808 | } | ||
809 | else if (strstr (argv[0], "https") != NULL) | ||
810 | { | ||
811 | is_https = GNUNET_YES; | ||
812 | } | ||
813 | else if (strstr (argv[0], "http") != NULL) | ||
814 | { | ||
815 | is_http = GNUNET_YES; | ||
816 | } | ||
817 | else if (strstr (argv[0], "udp") != NULL) | ||
818 | { | ||
819 | is_udp = GNUNET_YES; | ||
820 | } | ||
821 | else if (strstr (argv[0], "unix") != NULL) | ||
822 | { | ||
823 | is_unix = GNUNET_YES; | ||
824 | } | ||
825 | |||
826 | if (strstr (argv[0], "asymmetric_recv") != NULL) | ||
843 | { | 827 | { |
844 | is_asymmetric_recv_constant = GNUNET_YES; | 828 | is_asymmetric_recv_constant = GNUNET_YES; |
845 | } | 829 | } |
846 | else | 830 | else |
847 | is_asymmetric_recv_constant = GNUNET_NO; | 831 | is_asymmetric_recv_constant = GNUNET_NO; |
848 | if (strstr(argv[0], "asymmetric_send") != NULL) | 832 | if (strstr (argv[0], "asymmetric_send") != NULL) |
849 | { | 833 | { |
850 | is_asymmetric_send_constant = GNUNET_YES; | 834 | is_asymmetric_send_constant = GNUNET_YES; |
851 | } | 835 | } |
852 | else | 836 | else |
853 | is_asymmetric_send_constant = GNUNET_NO; | 837 | is_asymmetric_send_constant = GNUNET_NO; |
854 | 838 | ||
855 | char * logger; | 839 | char *logger; |
840 | |||
856 | if (is_tcp == GNUNET_YES) | 841 | if (is_tcp == GNUNET_YES) |
857 | { | 842 | { |
858 | if (is_asymmetric_recv_constant == GNUNET_YES) | 843 | if (is_asymmetric_recv_constant == GNUNET_YES) |
859 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant"); | 844 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "tcp", |
860 | else if (is_asymmetric_send_constant == GNUNET_YES) | 845 | "asymmetric_recv_constant"); |
861 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant"); | 846 | else if (is_asymmetric_send_constant == GNUNET_YES) |
862 | else | 847 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "tcp", |
863 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric"); | 848 | "asymmetric_send_constant"); |
864 | } | 849 | else |
850 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "tcp", | ||
851 | "symmetric"); | ||
852 | } | ||
865 | else if (is_udp == GNUNET_YES) | 853 | else if (is_udp == GNUNET_YES) |
866 | { | 854 | { |
867 | if (is_asymmetric_recv_constant == GNUNET_YES) | 855 | if (is_asymmetric_recv_constant == GNUNET_YES) |
868 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant"); | 856 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "udp", |
869 | else if (is_asymmetric_send_constant == GNUNET_YES) | 857 | "asymmetric_recv_constant"); |
870 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant"); | 858 | else if (is_asymmetric_send_constant == GNUNET_YES) |
871 | else | 859 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "udp", |
872 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric"); | 860 | "asymmetric_send_constant"); |
873 | } | 861 | else |
862 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "udp", | ||
863 | "symmetric"); | ||
864 | } | ||
874 | else if (is_unix == GNUNET_YES) | 865 | else if (is_unix == GNUNET_YES) |
875 | { | 866 | { |
876 | if (is_asymmetric_recv_constant == GNUNET_YES) | 867 | if (is_asymmetric_recv_constant == GNUNET_YES) |
877 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_recv_constant"); | 868 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "unix", |
878 | else if (is_asymmetric_send_constant == GNUNET_YES) | 869 | "asymmetric_recv_constant"); |
879 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_send_constant"); | 870 | else if (is_asymmetric_send_constant == GNUNET_YES) |
880 | else | 871 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "unix", |
881 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","symmetric"); | 872 | "asymmetric_send_constant"); |
882 | } | 873 | else |
874 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "unix", | ||
875 | "symmetric"); | ||
876 | } | ||
883 | else if (is_http == GNUNET_YES) | 877 | else if (is_http == GNUNET_YES) |
884 | { | 878 | { |
885 | if (is_asymmetric_recv_constant == GNUNET_YES) | 879 | if (is_asymmetric_recv_constant == GNUNET_YES) |
886 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant"); | 880 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "http", |
887 | else if (is_asymmetric_send_constant == GNUNET_YES) | 881 | "asymmetric_recv_constant"); |
888 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant"); | 882 | else if (is_asymmetric_send_constant == GNUNET_YES) |
889 | else | 883 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "http", |
890 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric"); | 884 | "asymmetric_send_constant"); |
891 | } | 885 | else |
886 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "http", | ||
887 | "symmetric"); | ||
888 | } | ||
892 | else if (is_https == GNUNET_YES) | 889 | else if (is_https == GNUNET_YES) |
893 | { | 890 | { |
894 | if (is_asymmetric_recv_constant == GNUNET_YES) | 891 | if (is_asymmetric_recv_constant == GNUNET_YES) |
895 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant"); | 892 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "https", |
896 | else if (is_asymmetric_send_constant == GNUNET_YES) | 893 | "asymmetric_recv_constant"); |
897 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant"); | 894 | else if (is_asymmetric_send_constant == GNUNET_YES) |
898 | else | 895 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "https", |
899 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric"); | 896 | "asymmetric_send_constant"); |
900 | } | 897 | else |
898 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "https", | ||
899 | "symmetric"); | ||
900 | } | ||
901 | else | 901 | else |
902 | { | 902 | { |
903 | GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none"); | 903 | GNUNET_asprintf (&logger, "test-quota-compliance-%s-%s", "noplugin", |
904 | } | 904 | "none"); |
905 | } | ||
905 | 906 | ||
906 | fprintf(stderr, "Running `%s'\n", logger); | 907 | fprintf (stderr, "Running `%s'\n", logger); |
907 | GNUNET_log_setup ("test-quota-compliance", | 908 | GNUNET_log_setup ("test-quota-compliance", |
908 | #if VERBOSE | 909 | #if VERBOSE |
909 | "DEBUG", | 910 | "DEBUG", |
@@ -924,23 +925,22 @@ main (int argc, char *argv[]) | |||
924 | }; | 925 | }; |
925 | ok = 1; | 926 | ok = 1; |
926 | GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, | 927 | GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, |
927 | argv1, logger , "nohelp", | 928 | argv1, logger, "nohelp", options, &run, &ok); |
928 | options, &run, &ok); | ||
929 | ret = ok; | 929 | ret = ok; |
930 | stop_arm (&p1); | 930 | stop_arm (&p1); |
931 | stop_arm (&p2); | 931 | stop_arm (&p2); |
932 | 932 | ||
933 | if (p1.servicehome != NULL) | 933 | if (p1.servicehome != NULL) |
934 | { | 934 | { |
935 | GNUNET_DISK_directory_remove (p1.servicehome); | 935 | GNUNET_DISK_directory_remove (p1.servicehome); |
936 | GNUNET_free(p1.servicehome); | 936 | GNUNET_free (p1.servicehome); |
937 | } | 937 | } |
938 | if (p2.servicehome != NULL) | 938 | if (p2.servicehome != NULL) |
939 | { | 939 | { |
940 | GNUNET_DISK_directory_remove (p2.servicehome); | 940 | GNUNET_DISK_directory_remove (p2.servicehome); |
941 | GNUNET_free(p2.servicehome); | 941 | GNUNET_free (p2.servicehome); |
942 | } | 942 | } |
943 | GNUNET_free(logger); | 943 | GNUNET_free (logger); |
944 | return ret; | 944 | return ret; |
945 | } | 945 | } |
946 | 946 | ||