return evaluate ();
}
-/**
- * @brief Try to ensure that `/tmp/rps` exists.
- *
- * @return #GNUNET_YES on success
- * #GNUNET_SYSERR on failure
- */
-static int ensure_folder_exist (void)
-{
- if (GNUNET_NO == GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
- {
- GNUNET_DISK_directory_create ("/tmp/rps");
- }
- if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
- {
- return GNUNET_SYSERR;
- }
- return GNUNET_YES;
-}
-
-static const char *
-store_prefix_file_name (struct RPSPeer *rps_peer, const char *prefix)
-{
- unsigned int len_file_name;
- unsigned int out_size;
- char *file_name;
- const char *pid_long;
-
- if (GNUNET_SYSERR == ensure_folder_exist()) return NULL;
- pid_long = GNUNET_i2s_full (rps_peer->peer_id);
- len_file_name = (strlen (prefix) +
- strlen (pid_long) +
- 11)
- * sizeof (char);
- file_name = GNUNET_malloc (len_file_name);
- out_size = GNUNET_snprintf (file_name,
- len_file_name,
- "/tmp/rps/%s-%s",
- prefix,
- pid_long);
- if (len_file_name < out_size ||
- 0 > out_size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Failed to write string to buffer (size: %i, out_size: %i)\n",
- len_file_name,
- out_size);
- }
- return file_name;
-}
-
static uint32_t fac (uint32_t x)
{
if (1 >= x)
* @param a
* @param b
*
- * @return
+ * @return
*/
static int is_in_view (uint32_t a, uint32_t b)
{
{
//double probs[num_peers] = { 0 };
double probs[num_peers];
- size_t probs_as_str_size = (num_peers * 6 + 1) * sizeof (char);
+ size_t probs_as_str_size = (num_peers * 10 + 1) * sizeof (char);
char *probs_as_str = GNUNET_malloc (probs_as_str_size);
char *probs_as_str_cpy;
uint32_t i;
peer_idx,
i,
prob_push);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "\t\tposs choices from view: %" PRIu32 ", containing i: %" PRIu32 "\n",
+ binom (view_size, 0.45 * view_size),
+ binom (0.45 * view_size, 1));
} else {
prob_push = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
binom (view_size - cont_views, 0.45 * view_size));
if (0 != number_of_being_in_pull_events)
{
- prob_pull = 1.0 / number_of_being_in_pull_events;
+ prob_pull = number_of_being_in_pull_events
+ /
+ (1.0 * binom (view_size, 0.45 * view_size));
} else
{
prob_pull = 0;
probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
tmp = GNUNET_snprintf (probs_as_str,
probs_as_str_size,
- "%s %3.2f", probs_as_str_cpy, probs[i]);
+ "%s %7.6f", probs_as_str_cpy, probs[i]);
GNUNET_free (probs_as_str_cpy);
GNUNET_assert (0 <= tmp);
}
rps_peer->cur_view_count,
view_size);
//*rps_peer->cur_view = *peers;
- memcpy (rps_peer->cur_view,
- peers,
- view_size * sizeof (struct GNUNET_PeerIdentity));
+ GNUNET_memcpy (rps_peer->cur_view,
+ peers,
+ view_size * sizeof (struct GNUNET_PeerIdentity));
to_file ("/tmp/rps/count_in_views.txt",
"%" PRIu64 " %" PRIu32 "",
rps_peer->index,
count_peer_in_views_2 (rps_peer->index));
cumulated_view_sizes();
- to_file ("/tmp/rps/repr.txt",
- "%" PRIu64 /* index */
- " %" PRIu32 /* occurrence in views */
- " %" PRIu32 /* view sizes */
- " %f" /* fraction of repr in views */
- " %f" /* average view size */
- " %f" /* prob of occurrence in view slot */
- " %f" "", /* exp frac of repr in views */
- rps_peer->index,
- count_peer_in_views_2 (rps_peer->index),
- view_sizes,
- count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */
- view_sizes / (view_size * 1.0), /* average view size */
- 1.0 /view_size, /* prob of occurrence in view slot */
- (1.0/view_size) * (view_sizes/view_size) /* expected fraction of repr in views */
- );
+ if (0 != view_size)
+ {
+ to_file ("/tmp/rps/repr.txt",
+ "%" PRIu64 /* index */
+ " %" PRIu32 /* occurrence in views */
+ " %" PRIu32 /* view sizes */
+ " %f" /* fraction of repr in views */
+ " %f" /* average view size */
+ " %f" /* prob of occurrence in view slot */
+ " %f" "", /* exp frac of repr in views */
+ rps_peer->index,
+ count_peer_in_views_2 (rps_peer->index),
+ view_sizes,
+ count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */
+ view_sizes / (view_size * 1.0), /* average view size */
+ 1.0 /view_size, /* prob of occurrence in view slot */
+ (1.0/view_size) * (view_sizes/view_size) /* expected fraction of repr in views */
+ );
+ }
compute_probabilities (rps_peer->index);
all_views_updated_cb();
}
static void
pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
{
- rps_peer->file_name_probs = store_prefix_file_name (rps_peer, "probs");
+ rps_peer->file_name_probs =
+ store_prefix_file_name (rps_peer->peer_id, "probs");
GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
}
stat_cls = GNUNET_malloc (sizeof (struct STATcls));
stat_cls->rps_peer = rps_peer;
stat_cls->stat_type = stat_type;
- rps_peer->file_name_stats = store_prefix_file_name (rps_peer, "stats");
+ rps_peer->file_name_stats =
+ store_prefix_file_name (rps_peer->peer_id, "stats");
GNUNET_STATISTICS_get (rps_peer->stats_h,
"rps",
stat_type_2_str (stat_type),
cur_test_run.main_test = churn_test_cb;
cur_test_run.reply_handle = default_reply_handle;
cur_test_run.eval_cb = default_eval_cb;
- cur_test_run.have_churn = HAVE_CHURN;
+ cur_test_run.have_churn = HAVE_NO_CHURN;
cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
}
cur_test_run.post_test = post_profiler;
cur_test_run.request_interval = 2;
cur_test_run.num_requests = 5;
- cur_test_run.have_churn = HAVE_CHURN;
+ //cur_test_run.have_churn = HAVE_CHURN;
+ cur_test_run.have_churn = HAVE_NO_CHURN;
cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
cur_test_run.have_collect_statistics = COLLECT_STATISTICS;
cur_test_run.stat_collect_flags = STAT_TYPE_ROUNDS |