diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/nse | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 208 | ||||
-rw-r--r-- | src/nse/gnunet-service-nse.c | 181 | ||||
-rw-r--r-- | src/nse/nse_api.c | 27 | ||||
-rw-r--r-- | src/nse/test_nse_api.c | 25 | ||||
-rw-r--r-- | src/nse/test_nse_multipeer.c | 52 |
5 files changed, 226 insertions, 267 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index b88dbc3fc..df26280c4 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -213,13 +213,12 @@ handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, | |||
213 | 213 | ||
214 | if (output_file != NULL) | 214 | if (output_file != NULL) |
215 | { | 215 | { |
216 | size = GNUNET_asprintf (&output_buffer, | 216 | size = |
217 | "%s %llu %llu %f %f %f\n", | 217 | GNUNET_asprintf (&output_buffer, "%s %llu %llu %f %f %f\n", |
218 | GNUNET_i2s (&peer->daemon->id), | 218 | GNUNET_i2s (&peer->daemon->id), peers_running, |
219 | peers_running, | 219 | timestamp.abs_value, |
220 | timestamp.abs_value, | 220 | GNUNET_NSE_log_estimate_to_n (estimate), estimate, |
221 | GNUNET_NSE_log_estimate_to_n (estimate), | 221 | std_dev); |
222 | estimate, std_dev); | ||
223 | if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) | 222 | if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) |
224 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); | 223 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); |
225 | GNUNET_free (output_buffer); | 224 | GNUNET_free (output_buffer); |
@@ -254,9 +253,9 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
254 | if (GNUNET_YES == | 253 | if (GNUNET_YES == |
255 | GNUNET_TESTING_daemon_running (GNUNET_TESTING_daemon_get (pg, i))) | 254 | GNUNET_TESTING_daemon_running (GNUNET_TESTING_daemon_get (pg, i))) |
256 | { | 255 | { |
257 | current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, | 256 | current_peer->nse_handle = |
258 | &handle_estimate, | 257 | GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate, |
259 | current_peer); | 258 | current_peer); |
260 | GNUNET_assert (current_peer->nse_handle != NULL); | 259 | GNUNET_assert (current_peer->nse_handle != NULL); |
261 | } | 260 | } |
262 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); | 261 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); |
@@ -264,8 +263,8 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
264 | } | 263 | } |
265 | 264 | ||
266 | 265 | ||
267 | static void | 266 | static void churn_peers (void *cls, |
268 | churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 267 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
269 | 268 | ||
270 | 269 | ||
271 | /** | 270 | /** |
@@ -286,9 +285,9 @@ stats_finished_callback (void *cls, int success) | |||
286 | { | 285 | { |
287 | /* Stats lookup successful, write out data */ | 286 | /* Stats lookup successful, write out data */ |
288 | buf = NULL; | 287 | buf = NULL; |
289 | buf_len = GNUNET_asprintf (&buf, | 288 | buf_len = |
290 | "TOTAL_NSE_BYTES: %u\n", | 289 | GNUNET_asprintf (&buf, "TOTAL_NSE_BYTES: %u\n", |
291 | stats_context->total_nse_bytes); | 290 | stats_context->total_nse_bytes); |
292 | if (buf_len > 0) | 291 | if (buf_len > 0) |
293 | { | 292 | { |
294 | GNUNET_DISK_file_write (data_file, buf, buf_len); | 293 | GNUNET_DISK_file_write (data_file, buf, buf_len); |
@@ -314,10 +313,9 @@ stats_finished_callback (void *cls, int success) | |||
314 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 313 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
315 | */ | 314 | */ |
316 | static int | 315 | static int |
317 | statistics_iterator (void *cls, | 316 | statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, |
318 | const struct GNUNET_PeerIdentity *peer, | 317 | const char *subsystem, const char *name, uint64_t value, |
319 | const char *subsystem, | 318 | int is_persistent) |
320 | const char *name, uint64_t value, int is_persistent) | ||
321 | { | 319 | { |
322 | struct StatsContext *stats_context = cls; | 320 | struct StatsContext *stats_context = cls; |
323 | 321 | ||
@@ -350,10 +348,9 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
350 | } | 348 | } |
351 | 349 | ||
352 | GNUNET_asprintf (&buf, "round%llu", current_round); | 350 | GNUNET_asprintf (&buf, "round%llu", current_round); |
353 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 351 | if (GNUNET_OK == |
354 | "nse-profiler", | 352 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", buf, |
355 | buf, | 353 | &peers_next_round)) |
356 | &peers_next_round)) | ||
357 | { | 354 | { |
358 | current_round++; | 355 | current_round++; |
359 | GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); | 356 | GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); |
@@ -364,8 +361,7 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
364 | stats_context = GNUNET_malloc (sizeof (struct StatsContext)); | 361 | stats_context = GNUNET_malloc (sizeof (struct StatsContext)); |
365 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 362 | GNUNET_SCHEDULER_cancel (shutdown_handle); |
366 | shutdown_handle = GNUNET_SCHEDULER_NO_TASK; | 363 | shutdown_handle = GNUNET_SCHEDULER_NO_TASK; |
367 | GNUNET_TESTING_get_statistics (pg, | 364 | GNUNET_TESTING_get_statistics (pg, &stats_finished_callback, |
368 | &stats_finished_callback, | ||
369 | &statistics_iterator, stats_context); | 365 | &statistics_iterator, stats_context); |
370 | } | 366 | } |
371 | GNUNET_free (buf); | 367 | GNUNET_free (buf); |
@@ -381,8 +377,8 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
381 | static void | 377 | static void |
382 | topology_output_callback (void *cls, const char *emsg) | 378 | topology_output_callback (void *cls, const char *emsg) |
383 | { | 379 | { |
384 | disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, | 380 | disconnect_task = |
385 | &disconnect_nse_peers, NULL); | 381 | GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_nse_peers, NULL); |
386 | GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); | 382 | GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); |
387 | } | 383 | } |
388 | 384 | ||
@@ -404,19 +400,18 @@ churn_callback (void *cls, const char *emsg) | |||
404 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 400 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
405 | "Round %llu, churn finished successfully.\n", current_round); | 401 | "Round %llu, churn finished successfully.\n", current_round); |
406 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); | 402 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); |
407 | GNUNET_asprintf (&temp_output_file, | 403 | GNUNET_asprintf (&temp_output_file, "%s_%llu.dot", topology_file, |
408 | "%s_%llu.dot", topology_file, current_round); | 404 | current_round); |
409 | GNUNET_TESTING_peergroup_topology_to_file (pg, | 405 | GNUNET_TESTING_peergroup_topology_to_file (pg, temp_output_file, |
410 | temp_output_file, | ||
411 | &topology_output_callback, NULL); | 406 | &topology_output_callback, NULL); |
412 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 407 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Writing topology to file %s\n", |
413 | "Writing topology to file %s\n", temp_output_file); | 408 | temp_output_file); |
414 | GNUNET_free (temp_output_file); | 409 | GNUNET_free (temp_output_file); |
415 | } | 410 | } |
416 | else | 411 | else |
417 | { | 412 | { |
418 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 413 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn FAILED!!\n", |
419 | "Round %llu, churn FAILED!!\n", current_round); | 414 | current_round); |
420 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 415 | GNUNET_SCHEDULER_cancel (shutdown_handle); |
421 | shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 416 | shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
422 | } | 417 | } |
@@ -433,9 +428,8 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
433 | /* Nothing to do... */ | 428 | /* Nothing to do... */ |
434 | GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); | 429 | GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); |
435 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); | 430 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); |
436 | disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, | 431 | disconnect_task = |
437 | &disconnect_nse_peers, | 432 | GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_nse_peers, NULL); |
438 | NULL); | ||
439 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", | 433 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", |
440 | current_round); | 434 | current_round); |
441 | } | 435 | } |
@@ -451,18 +445,18 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
451 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 445 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
452 | "Round %llu, turning off %llu peers, turning on %llu peers!\n", | 446 | "Round %llu, turning off %llu peers, turning on %llu peers!\n", |
453 | current_round, | 447 | current_round, |
454 | (peers_running > peers_next_round) | 448 | (peers_running > |
455 | ? peers_running - peers_next_round | 449 | peers_next_round) ? peers_running - peers_next_round : 0, |
456 | : 0, | 450 | (peers_next_round > |
457 | (peers_next_round > peers_running) | 451 | peers_running) ? peers_next_round - peers_running : 0); |
458 | ? peers_next_round - peers_running : 0); | ||
459 | GNUNET_TESTING_daemons_churn (pg, "nse", | 452 | GNUNET_TESTING_daemons_churn (pg, "nse", |
460 | (peers_running > peers_next_round) | 453 | (peers_running > |
461 | ? peers_running - peers_next_round | 454 | peers_next_round) ? peers_running - |
462 | : 0, | 455 | peers_next_round : 0, |
463 | (peers_next_round > peers_running) | 456 | (peers_next_round > |
464 | ? peers_next_round - peers_running | 457 | peers_running) ? peers_next_round - |
465 | : 0, wait_time, &churn_callback, NULL); | 458 | peers_running : 0, wait_time, &churn_callback, |
459 | NULL); | ||
466 | } | 460 | } |
467 | } | 461 | } |
468 | 462 | ||
@@ -495,8 +489,8 @@ my_cb (void *cls, const char *emsg) | |||
495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
496 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); | 490 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); |
497 | #endif | 491 | #endif |
498 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 492 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", |
499 | "Have %u connections\n", total_connections); | 493 | total_connections); |
500 | if (data_file != NULL) | 494 | if (data_file != NULL) |
501 | { | 495 | { |
502 | buf = NULL; | 496 | buf = NULL; |
@@ -506,9 +500,8 @@ my_cb (void *cls, const char *emsg) | |||
506 | GNUNET_free (buf); | 500 | GNUNET_free (buf); |
507 | } | 501 | } |
508 | peers_running = GNUNET_TESTING_daemons_running (pg); | 502 | peers_running = GNUNET_TESTING_daemons_running (pg); |
509 | GNUNET_TESTING_daemons_start_service (pg, | 503 | GNUNET_TESTING_daemons_start_service (pg, "nse", wait_time, &nse_started_cb, |
510 | "nse", | 504 | NULL); |
511 | wait_time, &nse_started_cb, NULL); | ||
512 | 505 | ||
513 | } | 506 | } |
514 | 507 | ||
@@ -528,10 +521,8 @@ my_cb (void *cls, const char *emsg) | |||
528 | * @param emsg error message (NULL on success) | 521 | * @param emsg error message (NULL on success) |
529 | */ | 522 | */ |
530 | static void | 523 | static void |
531 | connect_cb (void *cls, | 524 | connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, |
532 | const struct GNUNET_PeerIdentity *first, | 525 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
533 | const struct GNUNET_PeerIdentity *second, | ||
534 | uint32_t distance, | ||
535 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 526 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
536 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 527 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
537 | struct GNUNET_TESTING_Daemon *first_daemon, | 528 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -543,9 +534,8 @@ connect_cb (void *cls, | |||
543 | 534 | ||
544 | 535 | ||
545 | static void | 536 | static void |
546 | run (void *cls, | 537 | run (void *cls, char *const *args, const char *cfgfile, |
547 | char *const *args, | 538 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
548 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
549 | { | 539 | { |
550 | char *temp_str; | 540 | char *temp_str; |
551 | unsigned long long temp_wait; | 541 | unsigned long long temp_wait; |
@@ -555,100 +545,99 @@ run (void *cls, | |||
555 | testing_cfg = GNUNET_CONFIGURATION_create (); | 545 | testing_cfg = GNUNET_CONFIGURATION_create (); |
556 | #if VERBOSE | 546 | #if VERBOSE |
557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); | 547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); |
558 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, | 548 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", |
559 | "testing", "use_progressbars", "YES"); | 549 | "use_progressbars", "YES"); |
560 | #endif | 550 | #endif |
561 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 551 | if (GNUNET_OK != |
562 | "testing", | 552 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", |
563 | "num_peers", | 553 | "num_peers", &num_peers)) |
564 | &num_peers)) | ||
565 | { | 554 | { |
566 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 555 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
567 | "Option TESTING:NUM_PEERS is required!\n"); | 556 | "Option TESTING:NUM_PEERS is required!\n"); |
568 | return; | 557 | return; |
569 | } | 558 | } |
570 | 559 | ||
571 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 560 | if (GNUNET_OK != |
572 | "nse-profiler", | 561 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", |
573 | "wait_time", | 562 | "wait_time", &temp_wait)) |
574 | &temp_wait)) | ||
575 | { | 563 | { |
576 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 564 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
577 | "Option nse-profiler:wait_time is required!\n"); | 565 | "Option nse-profiler:wait_time is required!\n"); |
578 | return; | 566 | return; |
579 | } | 567 | } |
580 | 568 | ||
581 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 569 | if (GNUNET_OK != |
582 | "nse-profiler", | 570 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", |
583 | "connection_limit", | 571 | "connection_limit", |
584 | &connection_limit)) | 572 | &connection_limit)) |
585 | { | 573 | { |
586 | connection_limit = 0; | 574 | connection_limit = 0; |
587 | } | 575 | } |
588 | 576 | ||
589 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, | 577 | if (GNUNET_OK != |
590 | "nse-profiler", | 578 | GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", |
591 | "topology_output_file", | 579 | "topology_output_file", |
592 | &topology_file)) | 580 | &topology_file)) |
593 | { | 581 | { |
594 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 582 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
595 | "Option nse-profiler:topology_output_file is required!\n"); | 583 | "Option nse-profiler:topology_output_file is required!\n"); |
596 | return; | 584 | return; |
597 | } | 585 | } |
598 | 586 | ||
599 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, | 587 | if (GNUNET_OK != |
600 | "nse-profiler", | 588 | GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", |
601 | "data_output_file", | 589 | "data_output_file", |
602 | &data_filename)) | 590 | &data_filename)) |
603 | { | 591 | { |
604 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 592 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
605 | "Option nse-profiler:data_output_file is required!\n"); | 593 | "Option nse-profiler:data_output_file is required!\n"); |
606 | return; | 594 | return; |
607 | } | 595 | } |
608 | 596 | ||
609 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, | 597 | if (GNUNET_YES == |
610 | "nse-profiler", | 598 | GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, "nse-profiler", |
611 | "skew_clock")) | 599 | "skew_clock")) |
612 | { | 600 | { |
613 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Setting our clock as skewed...\n"); | 601 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Setting our clock as skewed...\n"); |
614 | clock_skew = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | 602 | clock_skew = |
615 | GNUNET_TIME_UNIT_MINUTES.rel_value); | 603 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, |
604 | GNUNET_TIME_UNIT_MINUTES.rel_value); | ||
616 | } | 605 | } |
617 | 606 | ||
618 | 607 | ||
619 | data_file = GNUNET_DISK_file_open (data_filename, | 608 | data_file = |
620 | GNUNET_DISK_OPEN_READWRITE | 609 | GNUNET_DISK_file_open (data_filename, |
621 | | GNUNET_DISK_OPEN_CREATE, | 610 | GNUNET_DISK_OPEN_READWRITE | |
622 | GNUNET_DISK_PERM_USER_READ | | 611 | GNUNET_DISK_OPEN_CREATE, |
623 | GNUNET_DISK_PERM_USER_WRITE); | 612 | GNUNET_DISK_PERM_USER_READ | |
613 | GNUNET_DISK_PERM_USER_WRITE); | ||
624 | if (data_file == NULL) | 614 | if (data_file == NULL) |
625 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 615 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", |
626 | "Failed to open %s for output!\n", data_filename); | 616 | data_filename); |
627 | GNUNET_free (data_filename); | 617 | GNUNET_free (data_filename); |
628 | 618 | ||
629 | wait_time = | 619 | wait_time = |
630 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait); | 620 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait); |
631 | 621 | ||
632 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, | 622 | if (GNUNET_YES == |
633 | "nse-profiler", | 623 | GNUNET_CONFIGURATION_get_value_string (cfg, "nse-profiler", "output_file", |
634 | "output_file", | 624 | &temp_str)) |
635 | &temp_str)) | ||
636 | { | 625 | { |
637 | output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE | 626 | output_file = |
638 | | GNUNET_DISK_OPEN_CREATE, | 627 | GNUNET_DISK_file_open (temp_str, |
639 | GNUNET_DISK_PERM_USER_READ | | 628 | GNUNET_DISK_OPEN_READWRITE | |
640 | GNUNET_DISK_PERM_USER_WRITE); | 629 | GNUNET_DISK_OPEN_CREATE, |
630 | GNUNET_DISK_PERM_USER_READ | | ||
631 | GNUNET_DISK_PERM_USER_WRITE); | ||
641 | if (output_file == NULL) | 632 | if (output_file == NULL) |
642 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 633 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", |
643 | "Failed to open %s for output!\n", temp_str); | 634 | temp_str); |
644 | } | 635 | } |
645 | GNUNET_free_non_null (temp_str); | 636 | GNUNET_free_non_null (temp_str); |
646 | 637 | ||
647 | hosts = GNUNET_TESTING_hosts_load (testing_cfg); | 638 | hosts = GNUNET_TESTING_hosts_load (testing_cfg); |
648 | 639 | ||
649 | pg = GNUNET_TESTING_peergroup_start (testing_cfg, | 640 | pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT, |
650 | num_peers, | ||
651 | TIMEOUT, | ||
652 | &connect_cb, &my_cb, NULL, hosts); | 641 | &connect_cb, &my_cb, NULL, hosts); |
653 | GNUNET_assert (pg != NULL); | 642 | GNUNET_assert (pg != NULL); |
654 | shutdown_handle = | 643 | shutdown_handle = |
@@ -679,8 +668,7 @@ main (int argc, char *argv[]) | |||
679 | "WARNING", | 668 | "WARNING", |
680 | #endif | 669 | #endif |
681 | NULL); | 670 | NULL); |
682 | GNUNET_PROGRAM_run (argc, | 671 | GNUNET_PROGRAM_run (argc, argv, "nse-profiler", |
683 | argv, "nse-profiler", | ||
684 | gettext_noop | 672 | gettext_noop |
685 | ("Measure quality and performance of the NSE service."), | 673 | ("Measure quality and performance of the NSE service."), |
686 | options, &run, NULL); | 674 | options, &run, NULL); |
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 9da9abba2..5f880088f 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -315,8 +315,10 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) | |||
315 | sumweight = 0.0; | 315 | sumweight = 0.0; |
316 | for (i = 0; i < estimate_count; i++) | 316 | for (i = 0; i < estimate_count; i++) |
317 | { | 317 | { |
318 | val = htonl (size_estimate_messages[(estimate_index - i + HISTORY_SIZE) | 318 | val = |
319 | % HISTORY_SIZE].matching_bits); | 319 | htonl (size_estimate_messages |
320 | [(estimate_index - i + | ||
321 | HISTORY_SIZE) % HISTORY_SIZE].matching_bits); | ||
320 | weight = 1; /* was: estimate_count + 1 - i; */ | 322 | weight = 1; /* was: estimate_count + 1 - i; */ |
321 | 323 | ||
322 | temp = weight + sumweight; | 324 | temp = weight + sumweight; |
@@ -338,8 +340,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) | |||
338 | em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | 340 | em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); |
339 | em->size_estimate = mean - 1.0 / 3.0; | 341 | em->size_estimate = mean - 1.0 / 3.0; |
340 | em->std_deviation = std_dev; | 342 | em->std_deviation = std_dev; |
341 | GNUNET_STATISTICS_set (stats, | 343 | GNUNET_STATISTICS_set (stats, "# nodes in the network (estimate)", |
342 | "# nodes in the network (estimate)", | ||
343 | (uint64_t) pow (2, mean - 1.0 / 3.0), GNUNET_NO); | 344 | (uint64_t) pow (2, mean - 1.0 / 3.0), GNUNET_NO); |
344 | } | 345 | } |
345 | 346 | ||
@@ -385,8 +386,7 @@ get_matching_bits_delay (uint32_t matching_bits) | |||
385 | // f is frequency (gnunet_nse_interval) | 386 | // f is frequency (gnunet_nse_interval) |
386 | // x is matching_bits | 387 | // x is matching_bits |
387 | // p' is current_size_estimate | 388 | // p' is current_size_estimate |
388 | return ((double) gnunet_nse_interval.rel_value / (double) 2.0) | 389 | return ((double) gnunet_nse_interval.rel_value / (double) 2.0) - |
389 | - | ||
390 | ((gnunet_nse_interval.rel_value / M_PI) * | 390 | ((gnunet_nse_interval.rel_value / M_PI) * |
391 | atan (matching_bits - current_size_estimate)); | 391 | atan (matching_bits - current_size_estimate)); |
392 | } | 392 | } |
@@ -406,12 +406,12 @@ get_delay_randomization (uint32_t matching_bits) | |||
406 | 406 | ||
407 | if (matching_bits == 0) | 407 | if (matching_bits == 0) |
408 | return GNUNET_TIME_UNIT_ZERO; | 408 | return GNUNET_TIME_UNIT_ZERO; |
409 | ret.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 409 | ret.rel_value = |
410 | (uint32_t) (get_matching_bits_delay | 410 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
411 | (matching_bits - | 411 | (uint32_t) (get_matching_bits_delay |
412 | 1) / | 412 | (matching_bits - |
413 | (double) (hop_count_max | 413 | 1) / (double) (hop_count_max + |
414 | + 1))); | 414 | 1))); |
415 | return ret; | 415 | return ret; |
416 | #else | 416 | #else |
417 | return GNUNET_TIME_UNIT_ZERO; | 417 | return GNUNET_TIME_UNIT_ZERO; |
@@ -432,8 +432,8 @@ get_matching_bits (struct GNUNET_TIME_Absolute timestamp, | |||
432 | { | 432 | { |
433 | GNUNET_HashCode timestamp_hash; | 433 | GNUNET_HashCode timestamp_hash; |
434 | 434 | ||
435 | GNUNET_CRYPTO_hash (×tamp.abs_value, | 435 | GNUNET_CRYPTO_hash (×tamp.abs_value, sizeof (timestamp.abs_value), |
436 | sizeof (timestamp.abs_value), ×tamp_hash); | 436 | ×tamp_hash); |
437 | return GNUNET_CRYPTO_hash_matching_bits (×tamp_hash, &id->hashPubKey); | 437 | return GNUNET_CRYPTO_hash_matching_bits (×tamp_hash, &id->hashPubKey); |
438 | } | 438 | } |
439 | 439 | ||
@@ -498,8 +498,8 @@ get_transmit_delay (int round_offset) | |||
498 | * @param cls the 'struct NSEPeerEntry' | 498 | * @param cls the 'struct NSEPeerEntry' |
499 | * @param tc scheduler context | 499 | * @param tc scheduler context |
500 | */ | 500 | */ |
501 | static void | 501 | static void transmit_task (void *cls, |
502 | transmit_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 502 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
503 | 503 | ||
504 | 504 | ||
505 | /** | 505 | /** |
@@ -545,17 +545,15 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
546 | "In round %llu, sending to `%s' estimate with %u bits\n", | 546 | "In round %llu, sending to `%s' estimate with %u bits\n", |
547 | (unsigned long long) | 547 | (unsigned long long) |
548 | GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx]. | 548 | GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx].timestamp). |
549 | timestamp).abs_value, | 549 | abs_value, GNUNET_i2s (&peer_entry->id), |
550 | GNUNET_i2s (&peer_entry->id), | ||
551 | (unsigned int) ntohl (size_estimate_messages[idx].matching_bits)); | 550 | (unsigned int) ntohl (size_estimate_messages[idx].matching_bits)); |
552 | #endif | 551 | #endif |
553 | if (ntohl (size_estimate_messages[idx].hop_count) == 0) | 552 | if (ntohl (size_estimate_messages[idx].hop_count) == 0) |
554 | GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); | 553 | GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); |
555 | GNUNET_STATISTICS_update (stats, | 554 | GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1, |
556 | "# flood messages transmitted", 1, GNUNET_NO); | 555 | GNUNET_NO); |
557 | memcpy (buf, | 556 | memcpy (buf, &size_estimate_messages[idx], |
558 | &size_estimate_messages[idx], | ||
559 | sizeof (struct GNUNET_NSE_FloodMessage)); | 557 | sizeof (struct GNUNET_NSE_FloodMessage)); |
560 | GNUNET_STATISTICS_update (stats, "# flood messages sent", 1, GNUNET_NO); | 558 | GNUNET_STATISTICS_update (stats, "# flood messages sent", 1, GNUNET_NO); |
561 | return sizeof (struct GNUNET_NSE_FloodMessage); | 559 | return sizeof (struct GNUNET_NSE_FloodMessage); |
@@ -575,15 +573,13 @@ transmit_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
575 | 573 | ||
576 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 574 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
577 | GNUNET_assert (NULL == peer_entry->th); | 575 | GNUNET_assert (NULL == peer_entry->th); |
578 | peer_entry->th | 576 | peer_entry->th = |
579 | = GNUNET_CORE_notify_transmit_ready (coreAPI, | 577 | GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO, NSE_PRIORITY, |
580 | GNUNET_NO, | 578 | GNUNET_TIME_UNIT_FOREVER_REL, |
581 | NSE_PRIORITY, | 579 | &peer_entry->id, |
582 | GNUNET_TIME_UNIT_FOREVER_REL, | 580 | sizeof (struct |
583 | &peer_entry->id, | 581 | GNUNET_NSE_FloodMessage), |
584 | sizeof (struct | 582 | &transmit_ready, peer_entry); |
585 | GNUNET_NSE_FloodMessage), | ||
586 | &transmit_ready, peer_entry); | ||
587 | } | 583 | } |
588 | 584 | ||
589 | 585 | ||
@@ -622,10 +618,10 @@ setup_flood_message (unsigned int slot, struct GNUNET_TIME_Absolute ts) | |||
622 | fm->header.type = htons (GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD); | 618 | fm->header.type = htons (GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD); |
623 | fm->hop_count = htonl (0); | 619 | fm->hop_count = htonl (0); |
624 | fm->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_NSE_SEND); | 620 | fm->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_NSE_SEND); |
625 | fm->purpose.size = htonl (sizeof (struct GNUNET_NSE_FloodMessage) | 621 | fm->purpose.size = |
626 | - sizeof (struct GNUNET_MessageHeader) | 622 | htonl (sizeof (struct GNUNET_NSE_FloodMessage) - |
627 | - sizeof (uint32_t) | 623 | sizeof (struct GNUNET_MessageHeader) - sizeof (uint32_t) - |
628 | - sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 624 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
629 | fm->matching_bits = htonl (matching_bits); | 625 | fm->matching_bits = htonl (matching_bits); |
630 | fm->timestamp = GNUNET_TIME_absolute_hton (ts); | 626 | fm->timestamp = GNUNET_TIME_absolute_hton (ts); |
631 | fm->pkey = my_public_key; | 627 | fm->pkey = my_public_key; |
@@ -684,13 +680,13 @@ update_flood_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
684 | if (0 != offset.rel_value) | 680 | if (0 != offset.rel_value) |
685 | { | 681 | { |
686 | /* somehow run early, delay more */ | 682 | /* somehow run early, delay more */ |
687 | flood_task | 683 | flood_task = |
688 | = GNUNET_SCHEDULER_add_delayed (offset, &update_flood_message, NULL); | 684 | GNUNET_SCHEDULER_add_delayed (offset, &update_flood_message, NULL); |
689 | return; | 685 | return; |
690 | } | 686 | } |
691 | current_timestamp = next_timestamp; | 687 | current_timestamp = next_timestamp; |
692 | next_timestamp = GNUNET_TIME_absolute_add (current_timestamp, | 688 | next_timestamp = |
693 | gnunet_nse_interval); | 689 | GNUNET_TIME_absolute_add (current_timestamp, gnunet_nse_interval); |
694 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; | 690 | estimate_index = (estimate_index + 1) % HISTORY_SIZE; |
695 | if (estimate_count < HISTORY_SIZE) | 691 | if (estimate_count < HISTORY_SIZE) |
696 | estimate_count++; | 692 | estimate_count++; |
@@ -699,16 +695,16 @@ update_flood_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
699 | { | 695 | { |
700 | /* we received a message for this round way early, use it! */ | 696 | /* we received a message for this round way early, use it! */ |
701 | size_estimate_messages[estimate_index] = next_message; | 697 | size_estimate_messages[estimate_index] = next_message; |
702 | size_estimate_messages[estimate_index].hop_count | 698 | size_estimate_messages[estimate_index].hop_count = |
703 | = htonl (1 + ntohl (next_message.hop_count)); | 699 | htonl (1 + ntohl (next_message.hop_count)); |
704 | } | 700 | } |
705 | else | 701 | else |
706 | setup_flood_message (estimate_index, current_timestamp); | 702 | setup_flood_message (estimate_index, current_timestamp); |
707 | next_message.matching_bits = htonl (0); /* reset for 'next' round */ | 703 | next_message.matching_bits = htonl (0); /* reset for 'next' round */ |
708 | hop_count_max = 0; | 704 | hop_count_max = 0; |
709 | for (i = 0; i < HISTORY_SIZE; i++) | 705 | for (i = 0; i < HISTORY_SIZE; i++) |
710 | hop_count_max = GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), | 706 | hop_count_max = |
711 | hop_count_max); | 707 | GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max); |
712 | GNUNET_CONTAINER_multihashmap_iterate (peers, &schedule_current_round, NULL); | 708 | GNUNET_CONTAINER_multihashmap_iterate (peers, &schedule_current_round, NULL); |
713 | flood_task = | 709 | flood_task = |
714 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 710 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
@@ -753,8 +749,8 @@ check_proof_of_work (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pkey, | |||
753 | GNUNET_HashCode result; | 749 | GNUNET_HashCode result; |
754 | 750 | ||
755 | memcpy (buf, &val, sizeof (val)); | 751 | memcpy (buf, &val, sizeof (val)); |
756 | memcpy (&buf[sizeof (val)], | 752 | memcpy (&buf[sizeof (val)], pkey, |
757 | pkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 753 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
758 | GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); | 754 | GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); |
759 | return (count_leading_zeroes (&result) >= | 755 | return (count_leading_zeroes (&result) >= |
760 | nse_work_required) ? GNUNET_YES : GNUNET_NO; | 756 | nse_work_required) ? GNUNET_YES : GNUNET_NO; |
@@ -773,9 +769,7 @@ write_proof () | |||
773 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) | 769 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) |
774 | return; | 770 | return; |
775 | if (sizeof (my_proof) != | 771 | if (sizeof (my_proof) != |
776 | GNUNET_DISK_fn_write (proof, | 772 | GNUNET_DISK_fn_write (proof, &my_proof, sizeof (my_proof), |
777 | &my_proof, | ||
778 | sizeof (my_proof), | ||
779 | GNUNET_DISK_PERM_USER_READ | | 773 | GNUNET_DISK_PERM_USER_READ | |
780 | GNUNET_DISK_PERM_USER_WRITE)) | 774 | GNUNET_DISK_PERM_USER_WRITE)) |
781 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", proof); | 775 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", proof); |
@@ -801,8 +795,7 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
801 | unsigned int i; | 795 | unsigned int i; |
802 | 796 | ||
803 | proof_task = GNUNET_SCHEDULER_NO_TASK; | 797 | proof_task = GNUNET_SCHEDULER_NO_TASK; |
804 | memcpy (&buf[sizeof (uint64_t)], | 798 | memcpy (&buf[sizeof (uint64_t)], &my_public_key, |
805 | &my_public_key, | ||
806 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 799 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
807 | i = 0; | 800 | i = 0; |
808 | counter = my_proof; | 801 | counter = my_proof; |
@@ -814,8 +807,7 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
814 | { | 807 | { |
815 | my_proof = counter; | 808 | my_proof = counter; |
816 | #if DEBUG_NSE | 809 | #if DEBUG_NSE |
817 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 810 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n", |
818 | "Proof of work found: %llu!\n", | ||
819 | (unsigned long long) GNUNET_ntohll (counter)); | 811 | (unsigned long long) GNUNET_ntohll (counter)); |
820 | #endif | 812 | #endif |
821 | for (i = 0; i < HISTORY_SIZE; i++) | 813 | for (i = 0; i < HISTORY_SIZE; i++) |
@@ -835,8 +827,7 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
835 | if (my_proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE)) | 827 | if (my_proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE)) |
836 | { | 828 | { |
837 | #if DEBUG_NSE | 829 | #if DEBUG_NSE |
838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 830 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing proofs currently at %llu\n", |
839 | "Testing proofs currently at %llu\n", | ||
840 | (unsigned long long) counter); | 831 | (unsigned long long) counter); |
841 | #endif | 832 | #endif |
842 | /* remember progress every 100 rounds */ | 833 | /* remember progress every 100 rounds */ |
@@ -847,8 +838,8 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
847 | { | 838 | { |
848 | my_proof = counter; | 839 | my_proof = counter; |
849 | } | 840 | } |
850 | proof_task = GNUNET_SCHEDULER_add_delayed (proof_find_delay, | 841 | proof_task = |
851 | &find_proof, NULL); | 842 | GNUNET_SCHEDULER_add_delayed (proof_find_delay, &find_proof, NULL); |
852 | } | 843 | } |
853 | 844 | ||
854 | 845 | ||
@@ -869,10 +860,9 @@ verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood) | |||
869 | check_proof_of_work (&incoming_flood->pkey, | 860 | check_proof_of_work (&incoming_flood->pkey, |
870 | incoming_flood->proof_of_work)) | 861 | incoming_flood->proof_of_work)) |
871 | { | 862 | { |
872 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 863 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Proof of work invalid: %llu!\n"), |
873 | _("Proof of work invalid: %llu!\n"), | 864 | (unsigned long long) GNUNET_ntohll (incoming_flood-> |
874 | (unsigned long long) | 865 | proof_of_work)); |
875 | GNUNET_ntohll (incoming_flood->proof_of_work)); | ||
876 | GNUNET_break_op (0); | 866 | GNUNET_break_op (0); |
877 | return GNUNET_NO; | 867 | return GNUNET_NO; |
878 | } | 868 | } |
@@ -923,9 +913,8 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value) | |||
923 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 913 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
924 | } | 914 | } |
925 | delay = get_transmit_delay (0); | 915 | delay = get_transmit_delay (0); |
926 | peer_entry->transmit_task = GNUNET_SCHEDULER_add_delayed (delay, | 916 | peer_entry->transmit_task = |
927 | &transmit_task, | 917 | GNUNET_SCHEDULER_add_delayed (delay, &transmit_task, peer_entry); |
928 | peer_entry); | ||
929 | return GNUNET_OK; | 918 | return GNUNET_OK; |
930 | } | 919 | } |
931 | 920 | ||
@@ -940,8 +929,7 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value) | |||
940 | * | 929 | * |
941 | */ | 930 | */ |
942 | static int | 931 | static int |
943 | handle_p2p_size_estimate (void *cls, | 932 | handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, |
944 | const struct GNUNET_PeerIdentity *peer, | ||
945 | const struct GNUNET_MessageHeader *message, | 933 | const struct GNUNET_MessageHeader *message, |
946 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 934 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
947 | { | 935 | { |
@@ -971,9 +959,9 @@ handle_p2p_size_estimate (void *cls, | |||
971 | GNUNET_snprintf (pred, sizeof (pred), "%s", GNUNET_i2s (peer)); | 959 | GNUNET_snprintf (pred, sizeof (pred), "%s", GNUNET_i2s (peer)); |
972 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 960 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
973 | "Flood at %llu from `%s' via `%s' at `%s' with bits %u\n", | 961 | "Flood at %llu from `%s' via `%s' at `%s' with bits %u\n", |
974 | (unsigned long long) | 962 | (unsigned long long) GNUNET_TIME_absolute_ntoh (incoming_flood-> |
975 | GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp).abs_value, | 963 | timestamp). |
976 | origin, pred, GNUNET_i2s (&my_identity), | 964 | abs_value, origin, pred, GNUNET_i2s (&my_identity), |
977 | (unsigned int) matching_bits); | 965 | (unsigned int) matching_bits); |
978 | } | 966 | } |
979 | #endif | 967 | #endif |
@@ -1015,8 +1003,8 @@ handle_p2p_size_estimate (void *cls, | |||
1015 | if (0 == (memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)))) | 1003 | if (0 == (memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)))) |
1016 | { | 1004 | { |
1017 | /* send to self, update our own estimate IF this also comes from us! */ | 1005 | /* send to self, update our own estimate IF this also comes from us! */ |
1018 | if (0 == memcmp (&incoming_flood->pkey, | 1006 | if (0 == |
1019 | &my_public_key, sizeof (my_public_key))) | 1007 | memcmp (&incoming_flood->pkey, &my_public_key, sizeof (my_public_key))) |
1020 | update_network_size_estimate (); | 1008 | update_network_size_estimate (); |
1021 | return GNUNET_OK; | 1009 | return GNUNET_OK; |
1022 | } | 1010 | } |
@@ -1057,8 +1045,8 @@ handle_p2p_size_estimate (void *cls, | |||
1057 | { | 1045 | { |
1058 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) | 1046 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) |
1059 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 1047 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
1060 | peer_entry->transmit_task = GNUNET_SCHEDULER_add_now (&transmit_task, | 1048 | peer_entry->transmit_task = |
1061 | peer_entry); | 1049 | GNUNET_SCHEDULER_add_now (&transmit_task, peer_entry); |
1062 | } | 1050 | } |
1063 | /* Not closer than our most recent message, no need to do work here */ | 1051 | /* Not closer than our most recent message, no need to do work here */ |
1064 | GNUNET_STATISTICS_update (stats, | 1052 | GNUNET_STATISTICS_update (stats, |
@@ -1081,8 +1069,8 @@ handle_p2p_size_estimate (void *cls, | |||
1081 | update_network_size_estimate (); | 1069 | update_network_size_estimate (); |
1082 | 1070 | ||
1083 | /* flood to rest */ | 1071 | /* flood to rest */ |
1084 | GNUNET_CONTAINER_multihashmap_iterate (peers, | 1072 | GNUNET_CONTAINER_multihashmap_iterate (peers, &update_flood_times, |
1085 | &update_flood_times, peer_entry); | 1073 | peer_entry); |
1086 | return GNUNET_OK; | 1074 | return GNUNET_OK; |
1087 | } | 1075 | } |
1088 | 1076 | ||
@@ -1102,14 +1090,12 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1102 | struct NSEPeerEntry *peer_entry; | 1090 | struct NSEPeerEntry *peer_entry; |
1103 | 1091 | ||
1104 | #if DEBUG_NSE | 1092 | #if DEBUG_NSE |
1105 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected to us\n", |
1106 | "Peer `%s' connected to us\n", GNUNET_i2s (peer)); | 1094 | GNUNET_i2s (peer)); |
1107 | #endif | 1095 | #endif |
1108 | peer_entry = GNUNET_malloc (sizeof (struct NSEPeerEntry)); | 1096 | peer_entry = GNUNET_malloc (sizeof (struct NSEPeerEntry)); |
1109 | peer_entry->id = *peer; | 1097 | peer_entry->id = *peer; |
1110 | GNUNET_CONTAINER_multihashmap_put (peers, | 1098 | GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, peer_entry, |
1111 | &peer->hashPubKey, | ||
1112 | peer_entry, | ||
1113 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1099 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1114 | peer_entry->transmit_task = | 1100 | peer_entry->transmit_task = |
1115 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task, | 1101 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task, |
@@ -1129,8 +1115,8 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1129 | struct NSEPeerEntry *pos; | 1115 | struct NSEPeerEntry *pos; |
1130 | 1116 | ||
1131 | #if DEBUG_NSE | 1117 | #if DEBUG_NSE |
1132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected from us\n", |
1133 | "Peer `%s' disconnected from us\n", GNUNET_i2s (peer)); | 1119 | GNUNET_i2s (peer)); |
1134 | #endif | 1120 | #endif |
1135 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 1121 | pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
1136 | if (NULL == pos) | 1122 | if (NULL == pos) |
@@ -1139,8 +1125,8 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1139 | return; | 1125 | return; |
1140 | } | 1126 | } |
1141 | GNUNET_assert (GNUNET_YES == | 1127 | GNUNET_assert (GNUNET_YES == |
1142 | GNUNET_CONTAINER_multihashmap_remove (peers, | 1128 | GNUNET_CONTAINER_multihashmap_remove (peers, &peer->hashPubKey, |
1143 | &peer->hashPubKey, pos)); | 1129 | pos)); |
1144 | if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) | 1130 | if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) |
1145 | GNUNET_SCHEDULER_cancel (pos->transmit_task); | 1131 | GNUNET_SCHEDULER_cancel (pos->transmit_task); |
1146 | if (pos->th != NULL) | 1132 | if (pos->th != NULL) |
@@ -1251,8 +1237,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1251 | } | 1237 | } |
1252 | estimate_index = HISTORY_SIZE - 1; | 1238 | estimate_index = HISTORY_SIZE - 1; |
1253 | estimate_count = 2; | 1239 | estimate_count = 2; |
1254 | flood_task | 1240 | flood_task = |
1255 | = | ||
1256 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 1241 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
1257 | (next_timestamp), &update_flood_message, | 1242 | (next_timestamp), &update_flood_message, |
1258 | NULL); | 1243 | NULL); |
@@ -1286,16 +1271,13 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1286 | cfg = c; | 1271 | cfg = c; |
1287 | 1272 | ||
1288 | if ((GNUNET_OK != | 1273 | if ((GNUNET_OK != |
1289 | GNUNET_CONFIGURATION_get_value_time (cfg, | 1274 | GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "INTERVAL", |
1290 | "NSE", "INTERVAL", | ||
1291 | &gnunet_nse_interval)) || | 1275 | &gnunet_nse_interval)) || |
1292 | (GNUNET_OK != | 1276 | (GNUNET_OK != |
1293 | GNUNET_CONFIGURATION_get_value_time (cfg, | 1277 | GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "WORKDELAY", |
1294 | "NSE", "WORKDELAY", | ||
1295 | &proof_find_delay)) || | 1278 | &proof_find_delay)) || |
1296 | (GNUNET_OK != | 1279 | (GNUNET_OK != |
1297 | GNUNET_CONFIGURATION_get_value_number (cfg, | 1280 | GNUNET_CONFIGURATION_get_value_number (cfg, "NSE", "WORKBITS", |
1298 | "NSE", "WORKBITS", | ||
1299 | &nse_work_required))) | 1281 | &nse_work_required))) |
1300 | { | 1282 | { |
1301 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1283 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1314,8 +1296,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1314 | 1296 | ||
1315 | 1297 | ||
1316 | if (GNUNET_OK != | 1298 | if (GNUNET_OK != |
1317 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 1299 | GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", |
1318 | "GNUNETD", "HOSTKEY", &keyfile)) | 1300 | &keyfile)) |
1319 | { | 1301 | { |
1320 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1302 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1321 | _ | 1303 | _ |
@@ -1374,8 +1356,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1374 | NULL, /* Don't want notified about all outbound messages */ | 1356 | NULL, /* Don't want notified about all outbound messages */ |
1375 | GNUNET_NO, /* For header only outbound notification */ | 1357 | GNUNET_NO, /* For header only outbound notification */ |
1376 | core_handlers); /* Register these handlers */ | 1358 | core_handlers); /* Register these handlers */ |
1377 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1359 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
1378 | &shutdown_task, NULL); | 1360 | NULL); |
1379 | #if ENABLE_HISTOGRAM | 1361 | #if ENABLE_HISTOGRAM |
1380 | if (GNUNET_OK == | 1362 | if (GNUNET_OK == |
1381 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "HISTOGRAM", &proof)) | 1363 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "HISTOGRAM", &proof)) |
@@ -1403,10 +1385,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1403 | int | 1385 | int |
1404 | main (int argc, char *const *argv) | 1386 | main (int argc, char *const *argv) |
1405 | { | 1387 | { |
1406 | return (GNUNET_OK == GNUNET_SERVICE_run (argc, argv, | 1388 | return (GNUNET_OK == |
1407 | "nse", | 1389 | GNUNET_SERVICE_run (argc, argv, "nse", GNUNET_SERVICE_OPTION_NONE, |
1408 | GNUNET_SERVICE_OPTION_NONE, &run, | 1390 | &run, NULL)) ? 0 : 1; |
1409 | NULL)) ? 0 : 1; | ||
1410 | } | 1391 | } |
1411 | 1392 | ||
1412 | /* end of gnunet-service-nse.c */ | 1393 | /* end of gnunet-service-nse.c */ |
diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c index 62c58ca77..8ff0256b9 100644 --- a/src/nse/nse_api.c +++ b/src/nse/nse_api.c | |||
@@ -85,8 +85,8 @@ struct GNUNET_NSE_Handle | |||
85 | * @param cls the handle to the transport service | 85 | * @param cls the handle to the transport service |
86 | * @param tc scheduler context | 86 | * @param tc scheduler context |
87 | */ | 87 | */ |
88 | static void | 88 | static void reconnect (void *cls, |
89 | reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 89 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
90 | 90 | ||
91 | 91 | ||
92 | /** | 92 | /** |
@@ -107,8 +107,8 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
107 | /* Error, timeout, death */ | 107 | /* Error, timeout, death */ |
108 | GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); | 108 | GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); |
109 | h->client = NULL; | 109 | h->client = NULL; |
110 | h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, | 110 | h->reconnect_task = |
111 | &reconnect, h); | 111 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | if ((ntohs (msg->size) != sizeof (struct GNUNET_NSE_ClientMessage)) || | 114 | if ((ntohs (msg->size) != sizeof (struct GNUNET_NSE_ClientMessage)) || |
@@ -118,11 +118,10 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | client_msg = (const struct GNUNET_NSE_ClientMessage *) msg; | 120 | client_msg = (const struct GNUNET_NSE_ClientMessage *) msg; |
121 | h->recv_cb (h->recv_cb_cls, | 121 | h->recv_cb (h->recv_cb_cls, GNUNET_TIME_absolute_ntoh (client_msg->timestamp), |
122 | GNUNET_TIME_absolute_ntoh (client_msg->timestamp), | ||
123 | client_msg->size_estimate, client_msg->std_deviation); | 122 | client_msg->size_estimate, client_msg->std_deviation); |
124 | GNUNET_CLIENT_receive (h->client, | 123 | GNUNET_CLIENT_receive (h->client, &message_handler, h, |
125 | &message_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); | 124 | GNUNET_TIME_UNIT_FOREVER_REL); |
126 | } | 125 | } |
127 | 126 | ||
128 | 127 | ||
@@ -153,8 +152,8 @@ reschedule_connect (struct GNUNET_NSE_Handle *h) | |||
153 | "Scheduling task to reconnect to nse service in %llu ms.\n", | 152 | "Scheduling task to reconnect to nse service in %llu ms.\n", |
154 | h->reconnect_delay.rel_value); | 153 | h->reconnect_delay.rel_value); |
155 | #endif | 154 | #endif |
156 | h->reconnect_task | 155 | h->reconnect_task = |
157 | = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); | 156 | GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); |
158 | if (h->reconnect_delay.rel_value == 0) | 157 | if (h->reconnect_delay.rel_value == 0) |
159 | { | 158 | { |
160 | h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; | 159 | h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; |
@@ -162,8 +161,8 @@ reschedule_connect (struct GNUNET_NSE_Handle *h) | |||
162 | else | 161 | else |
163 | { | 162 | { |
164 | h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); | 163 | h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); |
165 | h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, | 164 | h->reconnect_delay = |
166 | h->reconnect_delay); | 165 | GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, h->reconnect_delay); |
167 | } | 166 | } |
168 | } | 167 | } |
169 | 168 | ||
@@ -201,8 +200,8 @@ send_start (void *cls, size_t size, void *buf) | |||
201 | msg = (struct GNUNET_MessageHeader *) buf; | 200 | msg = (struct GNUNET_MessageHeader *) buf; |
202 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | 201 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); |
203 | msg->type = htons (GNUNET_MESSAGE_TYPE_NSE_START); | 202 | msg->type = htons (GNUNET_MESSAGE_TYPE_NSE_START); |
204 | GNUNET_CLIENT_receive (h->client, | 203 | GNUNET_CLIENT_receive (h->client, &message_handler, h, |
205 | &message_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); | 204 | GNUNET_TIME_UNIT_FOREVER_REL); |
206 | return sizeof (struct GNUNET_MessageHeader); | 205 | return sizeof (struct GNUNET_MessageHeader); |
207 | } | 206 | } |
208 | 207 | ||
diff --git a/src/nse/test_nse_api.c b/src/nse/test_nse_api.c index c06b2be8b..e4d2ba409 100644 --- a/src/nse/test_nse_api.c +++ b/src/nse/test_nse_api.c | |||
@@ -88,8 +88,7 @@ end_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
88 | * | 88 | * |
89 | */ | 89 | */ |
90 | static void | 90 | static void |
91 | check_nse_message (void *cls, | 91 | check_nse_message (void *cls, struct GNUNET_TIME_Absolute timestamp, |
92 | struct GNUNET_TIME_Absolute timestamp, | ||
93 | double estimate, double std_dev) | 92 | double estimate, double std_dev) |
94 | { | 93 | { |
95 | int *ok = cls; | 94 | int *ok = cls; |
@@ -110,13 +109,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
110 | { | 109 | { |
111 | p->cfg = GNUNET_CONFIGURATION_create (); | 110 | p->cfg = GNUNET_CONFIGURATION_create (); |
112 | #if START_ARM | 111 | #if START_ARM |
113 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, | 112 | p->arm_proc = |
114 | "gnunet-service-arm", | 113 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
115 | "gnunet-service-arm", | 114 | "gnunet-service-arm", |
116 | #if VERBOSE_ARM | 115 | #if VERBOSE_ARM |
117 | "-L", "DEBUG", | 116 | "-L", "DEBUG", |
118 | #endif | 117 | #endif |
119 | "-c", cfgname, NULL); | 118 | "-c", cfgname, NULL); |
120 | #endif | 119 | #endif |
121 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 120 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
122 | 121 | ||
@@ -125,13 +124,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
125 | 124 | ||
126 | 125 | ||
127 | static void | 126 | static void |
128 | run (void *cls, | 127 | run (void *cls, char *const *args, const char *cfgfile, |
129 | char *const *args, | 128 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
130 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
131 | { | 129 | { |
132 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 130 | die_task = |
133 | (GNUNET_TIME_UNIT_MINUTES, 1), | 131 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
134 | &end_test, NULL); | 132 | (GNUNET_TIME_UNIT_MINUTES, 1), &end_test, |
133 | NULL); | ||
135 | 134 | ||
136 | setup_peer (&p1, cfgfile); | 135 | setup_peer (&p1, cfgfile); |
137 | h = GNUNET_NSE_connect (cfg, &check_nse_message, cls); | 136 | h = GNUNET_NSE_connect (cfg, &check_nse_message, cls); |
diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c index 29e5cd6cc..1db00415f 100644 --- a/src/nse/test_nse_multipeer.c +++ b/src/nse/test_nse_multipeer.c | |||
@@ -72,8 +72,8 @@ shutdown_callback (void *cls, const char *emsg) | |||
72 | if (emsg != NULL) | 72 | if (emsg != NULL) |
73 | { | 73 | { |
74 | #if VERBOSE | 74 | #if VERBOSE |
75 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 75 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed: %s!\n", |
76 | "Shutdown of peers failed: %s!\n", emsg); | 76 | emsg); |
77 | #endif | 77 | #endif |
78 | if (ok == 0) | 78 | if (ok == 0) |
79 | ok = 666; | 79 | ok = 666; |
@@ -117,17 +117,15 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
117 | * | 117 | * |
118 | */ | 118 | */ |
119 | static void | 119 | static void |
120 | handle_estimate (void *cls, | 120 | handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, |
121 | struct GNUNET_TIME_Absolute timestamp, | ||
122 | double estimate, double std_dev) | 121 | double estimate, double std_dev) |
123 | { | 122 | { |
124 | struct NSEPeer *peer = cls; | 123 | struct NSEPeer *peer = cls; |
125 | 124 | ||
126 | fprintf (stderr, | 125 | fprintf (stderr, |
127 | "Received network size estimate from peer %s. logSize: %f std.dev. %f (%f/%u)\n", | 126 | "Received network size estimate from peer %s. logSize: %f std.dev. %f (%f/%u)\n", |
128 | GNUNET_i2s (&peer->daemon->id), | 127 | GNUNET_i2s (&peer->daemon->id), estimate, std_dev, |
129 | estimate, | 128 | GNUNET_NSE_log_estimate_to_n (estimate), num_peers); |
130 | std_dev, GNUNET_NSE_log_estimate_to_n (estimate), num_peers); | ||
131 | } | 129 | } |
132 | 130 | ||
133 | 131 | ||
@@ -144,9 +142,9 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
144 | { | 142 | { |
145 | current_peer = GNUNET_malloc (sizeof (struct NSEPeer)); | 143 | current_peer = GNUNET_malloc (sizeof (struct NSEPeer)); |
146 | current_peer->daemon = GNUNET_TESTING_daemon_get (pg, i); | 144 | current_peer->daemon = GNUNET_TESTING_daemon_get (pg, i); |
147 | current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, | 145 | current_peer->nse_handle = |
148 | &handle_estimate, | 146 | GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate, |
149 | current_peer); | 147 | current_peer); |
150 | GNUNET_assert (current_peer->nse_handle != NULL); | 148 | GNUNET_assert (current_peer->nse_handle != NULL); |
151 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); | 149 | GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); |
152 | } | 150 | } |
@@ -169,8 +167,8 @@ my_cb (void *cls, const char *emsg) | |||
169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
170 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); | 168 | "Peer Group started successfully, connecting to NSE service for each peer!\n"); |
171 | #endif | 169 | #endif |
172 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 170 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", |
173 | "Have %u connections\n", total_connections); | 171 | total_connections); |
174 | 172 | ||
175 | GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); | 173 | GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); |
176 | } | 174 | } |
@@ -191,10 +189,8 @@ my_cb (void *cls, const char *emsg) | |||
191 | * @param emsg error message (NULL on success) | 189 | * @param emsg error message (NULL on success) |
192 | */ | 190 | */ |
193 | static void | 191 | static void |
194 | connect_cb (void *cls, | 192 | connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, |
195 | const struct GNUNET_PeerIdentity *first, | 193 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
196 | const struct GNUNET_PeerIdentity *second, | ||
197 | uint32_t distance, | ||
198 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 194 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
199 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 195 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
200 | struct GNUNET_TESTING_Daemon *first_daemon, | 196 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -210,9 +206,8 @@ connect_cb (void *cls, | |||
210 | 206 | ||
211 | 207 | ||
212 | static void | 208 | static void |
213 | run (void *cls, | 209 | run (void *cls, char *const *args, const char *cfgfile, |
214 | char *const *args, | 210 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
215 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
216 | { | 211 | { |
217 | struct GNUNET_CONFIGURATION_Handle *testing_cfg; | 212 | struct GNUNET_CONFIGURATION_Handle *testing_cfg; |
218 | unsigned long long total_peers; | 213 | unsigned long long total_peers; |
@@ -223,20 +218,17 @@ run (void *cls, | |||
223 | 218 | ||
224 | #if VERBOSE | 219 | #if VERBOSE |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); | 220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); |
226 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, | 221 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", |
227 | "testing", "use_progressbars", "YES"); | 222 | "use_progressbars", "YES"); |
228 | #endif | 223 | #endif |
229 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 224 | if (GNUNET_OK != |
230 | "testing", | 225 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", |
231 | "num_peers", | 226 | "num_peers", &total_peers)) |
232 | &total_peers)) | ||
233 | total_peers = NUM_PEERS; | 227 | total_peers = NUM_PEERS; |
234 | 228 | ||
235 | peers_left = total_peers; | 229 | peers_left = total_peers; |
236 | num_peers = peers_left; | 230 | num_peers = peers_left; |
237 | pg = GNUNET_TESTING_peergroup_start (testing_cfg, | 231 | pg = GNUNET_TESTING_peergroup_start (testing_cfg, peers_left, TIMEOUT, |
238 | peers_left, | ||
239 | TIMEOUT, | ||
240 | &connect_cb, &my_cb, NULL, NULL); | 232 | &connect_cb, &my_cb, NULL, NULL); |
241 | GNUNET_assert (pg != NULL); | 233 | GNUNET_assert (pg != NULL); |
242 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); | 234 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); |
@@ -257,8 +249,8 @@ check () | |||
257 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 249 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
258 | GNUNET_GETOPT_OPTION_END | 250 | GNUNET_GETOPT_OPTION_END |
259 | }; | 251 | }; |
260 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 252 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
261 | argv, "test-nse-multipeer", "nohelp", options, &run, &ok); | 253 | "test-nse-multipeer", "nohelp", options, &run, &ok); |
262 | return ok; | 254 | return ok; |
263 | } | 255 | } |
264 | 256 | ||