/*
This file is part of GNUnet.
- (C) 2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2014 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
/**
* Number of peers which should perform a PUT out of 100 peers
*/
-#define PUT_PROBABILITY 100
-
-/**
- * Percentage of peers that should act maliciously.
- * These peers will never start PUT/GET request.
- * n_active and n_malicious should not intersect.
- */
-#define MALICIOUS_PEERS 0
+#define PUT_PROBABILITY 50
/**
* Configuration
*/
struct Context
{
-
/**
* The testbed peer this context belongs to
*/
* Active context; NULL if this peer is not an active peer
*/
struct ActiveContext *ac;
-};
-
-
-#if ENABLE_MALICIOUS
-/**
- * Context for a peer which should act maliciously.
- */
-struct MaliciousContext
-{
- /**
- * The linked peer context
- */
- struct Context *ctx;
- /**
- * Handler to the DHT service
- */
- struct GNUNET_DHT_Handle *dht;
};
-/**
- * List of all the malicious peers contexts.
- */
-struct Context **malicious_peer_contexts = NULL;
-
-#endif
/**
* Context for a peer which actively does DHT PUT/GET
/**
* Delay task
*/
- GNUNET_SCHEDULER_TaskIdentifier delay_task;
+ struct GNUNET_SCHEDULER_Task * delay_task;
/**
* The size of the @e put_data
*/
static unsigned int num_peers;
-#if ENABLE_MALICIOUS
-/**
- * Number or malicious peers.
- */
-static unsigned int n_malicious;
-#endif
-
/**
* Number of active peers
*/
static struct GNUNET_TESTBED_Peer **testbed_handles;
/**
- * Total number of messages sent by peer.
+ * Total number of messages sent by peer.
*/
static uint64_t outgoing_bandwidth;
static double average_put_path_length;
/**
- * Average number of hops taken to do get.
+ * Average number of hops taken to do get.
*/
static double average_get_path_length;
/**
- * Total put path length across all peers.
+ * Total put path length across all peers.
*/
static unsigned int total_put_path_length;
/**
- * Total get path length across all peers.
+ * Total get path length across all peers.
*/
static unsigned int total_get_path_length;
/**
- * Hashmap to store pair of peer and its corresponding successor.
+ * Hashmap to store pair of peer and its corresponding successor.
*/
static struct GNUNET_CONTAINER_MultiHashMap *successor_peer_hashmap;
/**
- * Key to start the lookup on successor_peer_hashmap.
+ * Key to start the lookup on successor_peer_hashmap.
*/
static struct GNUNET_HashCode *start_key;
/**
* Task to collect peer and its current successor statistics.
*/
-static GNUNET_SCHEDULER_TaskIdentifier successor_stats_task;
+static struct GNUNET_SCHEDULER_Task * successor_stats_task;
/**
* Closure for successor_stats_task.
struct Collect_Stat_Context
{
/**
- * Current Peer Context.
+ * Current Peer Context.
*/
struct Context *service_connect_ctx;
-
+
/**
* Testbed operation acting on this peer
*/
struct Context **peer_contexts = NULL;
/**
- * Counter to keep track of peers added to peer_context lists.
+ * Counter to keep track of peers added to peer_context lists.
*/
static int peers_started = 0;
static int in_shutdown = 0;
/**
- * Task that collects successor statistics from all the peers.
+ * Total number of times to check if circle is formed or not.
+ */
+static unsigned int tries;
+
+
+/**
+ * Task that collects successor statistics from all the peers.
+ *
* @param cls
- * @param tc
*/
static void
-collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+collect_stats (void *cls);
+
+
+/**
+ * Connect to DHT services of active peers
+ */
+static void
+start_profiling (void);
+
/**
* Shutdown task. Cleanup all resources and operations.
*
* @param cls NULL
- * @param tc scheduler task context
*/
static void
-do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls)
{
struct ActiveContext *ac;
unsigned int cnt;
ac = a_ctx[cnt].ac;
if (NULL != ac)
{
- if (GNUNET_SCHEDULER_NO_TASK != ac->delay_task)
+ if (NULL != ac->delay_task)
GNUNET_SCHEDULER_cancel (ac->delay_task);
if (NULL != ac->put_data)
GNUNET_free (ac->put_data);
a_ctx = NULL;
}
//FIXME: Should we collect stats only for put/get not for other messages.
- if(NULL != bandwidth_stats_op)
+ if (NULL != bandwidth_stats_op)
+ {
GNUNET_TESTBED_operation_done (bandwidth_stats_op);
- bandwidth_stats_op = NULL;
+ bandwidth_stats_op = NULL;
+ }
+ if (NULL != successor_stats_op)
+ {
+ GNUNET_TESTBED_operation_done (successor_stats_op);
+ successor_stats_op = NULL;
+ }
+ if (NULL != successor_stats_task)
+ {
+ GNUNET_SCHEDULER_cancel (successor_stats_task);
+ successor_stats_task = NULL;
+ }
GNUNET_free_non_null (a_ac);
}
* operation has executed successfully.
*/
static void
-bandwidth_stats_cont (void *cls,
- struct GNUNET_TESTBED_Operation *op,
+bandwidth_stats_cont (void *cls,
+ struct GNUNET_TESTBED_Operation *op,
const char *emsg)
{
- INFO ("# Outgoing bandwidth: %u\n", outgoing_bandwidth);
- INFO ("# Incoming bandwidth: %u\n", incoming_bandwidth);
+ INFO ("# Outgoing bandwidth: %llu\n",
+ (unsigned long long) outgoing_bandwidth);
+ INFO ("# Incoming bandwidth: %llu\n",
+ (unsigned long long) incoming_bandwidth);
GNUNET_SCHEDULER_shutdown ();
}
* @param subsystem name of subsystem that created the statistic
* @param name the name of the datum
* @param value the current value
- * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
- * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
+ * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
+ * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/
static int
-bandwidth_stats_iterator (void *cls,
+bandwidth_stats_iterator (void *cls,
const struct GNUNET_TESTBED_Peer *peer,
- const char *subsystem,
+ const char *subsystem,
const char *name,
- uint64_t value,
+ uint64_t value,
int is_persistent)
{
static const char *s_sent = "# Bytes transmitted to other peers";
outgoing_bandwidth = outgoing_bandwidth + value;
else if (0 == strncmp(s_recv, name, strlen (s_recv)))
incoming_bandwidth = incoming_bandwidth + value;
-
+
return GNUNET_OK;
}
INFO ("# GETS failed: %u\n", n_gets_fail);
INFO ("# average_put_path_length: %f\n", average_put_path_length);
INFO ("# average_get_path_length: %f\n", average_get_path_length);
-
+
if (NULL == testbed_handles)
{
INFO ("No peers found\n");
/* Collect Stats*/
bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
"dht", NULL,
- bandwidth_stats_iterator,
+ bandwidth_stats_iterator,
bandwidth_stats_cont, NULL);
}
* Task to cancel DHT GET.
*
* @param cls NULL
- * @param tc scheduler task context
*/
static void
-cancel_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+cancel_get (void *cls)
{
struct ActiveContext *ac = cls;
struct Context *ctx = ac->ctx;
- ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
+ ac->delay_task = NULL;
GNUNET_assert (NULL != ac->dht_get);
GNUNET_DHT_get_stop (ac->dht_get);
ac->dht_get = NULL;
/* If profiling is complete, summarize */
if (n_active == n_gets_fail + n_gets_ok)
+ {
+ average_put_path_length = (double)total_put_path_length/(double)n_active;
+ average_get_path_length = (double)total_get_path_length/(double )n_gets_ok;
summarize ();
-
+ }
}
/* Check the keys of put and get match or not. */
GNUNET_assert (0 == memcmp (key, &get_ac->hash, sizeof (struct GNUNET_HashCode)));
/* we found the data we are looking for */
- DEBUG ("We found a GET request; %u remaining\n", n_gets - (n_gets_fail + n_gets_ok));
+ DEBUG ("We found a GET request; %u remaining\n", n_gets - (n_gets_fail + n_gets_ok)); //FIXME: It always prints 1.
n_gets_ok++;
get_ac->nrefs--;
GNUNET_DHT_get_stop (ac->dht_get);
ac->dht_get = NULL;
- if (ac->delay_task != GNUNET_SCHEDULER_NO_TASK)
+ if (ac->delay_task != NULL)
GNUNET_SCHEDULER_cancel (ac->delay_task);
- ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
+ ac->delay_task = NULL;
GNUNET_assert (NULL != ctx->op);
GNUNET_TESTBED_operation_done (ctx->op);
ctx->op = NULL;
-
- total_put_path_length = total_put_path_length + put_path_length;
- total_get_path_length = total_get_path_length + get_path_length;
-
+
+ total_put_path_length = total_put_path_length + (double)put_path_length;
+ total_get_path_length = total_get_path_length + (double)get_path_length;
+ DEBUG ("total_put_path_length = %u,put_path \n",
+ total_put_path_length);
/* Summarize if profiling is complete */
if (n_active == n_gets_fail + n_gets_ok)
{
* Task to do DHT GETs
*
* @param cls the active context
- * @param tc the scheduler task context
*/
static void
-delayed_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+delayed_get (void *cls)
{
struct ActiveContext *ac = cls;
struct ActiveContext *get_ac;
unsigned int r;
- ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
+ ac->delay_task = NULL;
get_ac = NULL;
while (1)
{
* clear the operation during shutdown.
*
* @param cls the context
- * @return tc scheduler task context.
*/
static void
-teardown_dht_connection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+teardown_dht_connection (void *cls)
{
struct Context *ctx = cls;
struct GNUNET_TESTBED_Operation *op;
- if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
- return;
GNUNET_assert (NULL != ctx);
GNUNET_assert (NULL != (op = ctx->op));
ctx->op = NULL;
/**
- * Task to do DHT PUTS
+ * Task to do DHT PUTs
*
* @param cls the active context
- * @param tc the scheduler task context
*/
static void
-delayed_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+delayed_put (void *cls)
{
struct ActiveContext *ac = cls;
- ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
+ ac->delay_task = NULL;
/* Generate and DHT PUT some random data */
ac->put_data_size = 16; /* minimum */
ac->put_data_size += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
ac->put_data, ac->put_data_size);
GNUNET_CRYPTO_hash (ac->put_data, ac->put_data_size, &ac->hash);
- DEBUG ("PUT_REQUEST_START key %s \n", GNUNET_h2s((struct GNUNET_HashCode *)ac->put_data));
- ac->dht_put = GNUNET_DHT_put (ac->dht, &ac->hash,
+ DEBUG ("PUT_REQUEST_START key %s\n",
+ GNUNET_h2s((struct GNUNET_HashCode *)ac->put_data));
+ ac->dht_put = GNUNET_DHT_put (ac->dht,
+ &ac->hash,
replication,
- GNUNET_DHT_RO_NONE,
+ GNUNET_DHT_RO_RECORD_ROUTE,
GNUNET_BLOCK_TYPE_TEST,
ac->put_data_size,
ac->put_data,
GNUNET_TIME_UNIT_FOREVER_ABS, /* expiration time */
- timeout, /* PUT timeout */
- put_cont, ac); /* continuation and its closure */
+ &put_cont, ac); /* continuation and its closure */
n_puts++;
}
{
struct GNUNET_TIME_Relative peer_delay_put;
peer_delay_put.rel_value_us =
- delay_put.rel_value_us +
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
delay_put.rel_value_us);
ac->delay_task = GNUNET_SCHEDULER_add_delayed (peer_delay_put, &delayed_put, ac);
}
-/**
- * Connect to DHT services of active peers
- */
-static void
-start_profiling();
-
-
/**
* Adapter function called to destroy a connection to
* a service.
}
}
-
/**
* Connect to DHT services of active peers
*/
}
}
-static int
-hashmap_iterate_remove(void *cls,
- const struct GNUNET_HashCode *key,
+/**
+ * Start collecting relevant statistics. If ENABLE_MALICIOUS set, first
+ * set the malicious peers. If not, then start with PUT operation on active
+ * peers.
+ */
+static void
+start_func()
+{
+ start_profiling();
+}
+
+
+/**
+ * Remove entry from successor peer hashmap.
+ * @param cls closure
+ * @param key current public key
+ * @param value value in the hash map
+ * @return #GNUNET_YES if we should continue to iterate,
+ * #GNUNET_NO if not.
+ */
+static int
+hashmap_iterate_remove(void *cls,
+ const struct GNUNET_HashCode *key,
void *value)
{
- GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(successor_peer_hashmap, key, value));
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove(successor_peer_hashmap, key, value));
return GNUNET_YES;
}
-static unsigned int tries;
-
/**
* Stats callback. Iterate over the hashmap and check if all th peers form
* a virtual ring topology.
* operation has executed successfully.
*/
static void
-successor_stats_cont (void *cls,
- struct GNUNET_TESTBED_Operation *op,
+successor_stats_cont (void *cls,
+ struct GNUNET_TESTBED_Operation *op,
const char *emsg)
{
struct GNUNET_HashCode *val;
struct GNUNET_HashCode *start_val;
struct GNUNET_HashCode *key;
int count;
-
+
/* Don't schedule the task till we are looking for circle here. */
- successor_stats_task = GNUNET_SCHEDULER_NO_TASK;
+ successor_stats_task = NULL;
GNUNET_TESTBED_operation_done (successor_stats_op);
successor_stats_op = NULL;
-
- start_val =
- (struct GNUNET_HashCode *) GNUNET_CONTAINER_multihashmap_get(successor_peer_hashmap,
- start_key);
+ if (0 == max_searches)
+ {
+ start_func ();
+ return;
+ }
+ GNUNET_assert (NULL != start_key);
+ start_val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap,
+ start_key);
+ GNUNET_assert (NULL != start_val);
val = start_val;
for (count = 0; count < num_peers; count++)
{
key = val;
val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap,
key);
- if(NULL == val)
- {
+ if (NULL == val)
break;
- }
/* Remove the entry from hashmap. This is done to take care of loop. */
- if (GNUNET_NO ==
- GNUNET_CONTAINER_multihashmap_remove (successor_peer_hashmap,
- key, val))
+ if (GNUNET_NO ==
+ GNUNET_CONTAINER_multihashmap_remove (successor_peer_hashmap,
+ key, val))
{
DEBUG ("Failed to remove entry from hashmap\n");
break;
}
/* If a peer has its own identity as its successor. */
if (0 == memcmp(key, val, sizeof (struct GNUNET_HashCode)))
- {
break;
- }
}
-
- GNUNET_assert(GNUNET_SYSERR !=
- GNUNET_CONTAINER_multihashmap_iterate (successor_peer_hashmap,
- hashmap_iterate_remove,
- NULL));
-
- successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
- GNUNET_NO);
- //TODO:Check if comparison is correct.
+
+ GNUNET_assert (GNUNET_SYSERR !=
+ GNUNET_CONTAINER_multihashmap_iterate (successor_peer_hashmap,
+ &hashmap_iterate_remove,
+ NULL));
+
+ successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
+ GNUNET_NO);
if ((start_val == val) && (count == num_peers))
{
- DEBUG("CIRCLE COMPLETED after %u tries", tries);
- //FIXME: FREE HASHMAP.
- //FIXME: If circle is done, then check that finger table of all the peers
- //are fill atleast O(log N) and then start with the experiments.
- if(GNUNET_SCHEDULER_NO_TASK == successor_stats_task)
- start_profiling();
-
+ DEBUG ("CIRCLE COMPLETED after %u tries", tries);
+ if(NULL == successor_stats_task)
+ {
+ start_func();
+ }
return;
}
- else
+ if (max_searches == ++tries)
{
- if (max_searches == ++tries)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Maximum tries %u exceeded while checking successor TOTAL TRIES %u"
- " cirle formation. Exiting\n",
- max_searches,tries);
- if (GNUNET_SCHEDULER_NO_TASK != successor_stats_task)
- {
- successor_stats_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if(GNUNET_SCHEDULER_NO_TASK == successor_stats_task)
- {
- start_profiling();
- }
-
- return;
- }
- else
- {
- flag = 0;
- successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats, &collect_stats, cls);
- }
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Maximum tries %u exceeded while checking successor TOTAL TRIES %u"
+ " circle formation. Exiting\n",
+ max_searches,tries);
+ start_func();
+ return;
+ }
+ flag = 0;
+ successor_stats_task
+ = GNUNET_SCHEDULER_add_delayed (delay_stats,
+ &collect_stats,
+ cls);
}
* @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
*/
static int
-successor_stats_iterator (void *cls,
+successor_stats_iterator (void *cls,
const struct GNUNET_TESTBED_Peer *peer,
- const char *subsystem,
+ const char *subsystem,
const char *name,
- uint64_t value,
+ uint64_t value,
int is_persistent)
{
static const char *key_string = "XDHT";
+ if (0 == max_searches)
+ return GNUNET_OK;
+
if (0 == strncmp (key_string, name, strlen (key_string)))
{
char *my_id_str;
char truncated_successor_str[13];
struct GNUNET_HashCode *my_id_key;
struct GNUNET_HashCode *succ_key;
-
+
strtok((char *)name,":");
my_id_str = strtok(NULL,":");
-
+
strncpy(truncated_my_id_str, my_id_str, 12);
truncated_my_id_str[12] = '\0';
my_id_key = GNUNET_new(struct GNUNET_HashCode);
GNUNET_STRINGS_data_to_string(&value, sizeof(uint64_t), successor_str, 13);
strncpy(truncated_successor_str, successor_str, 12);
truncated_successor_str[12] ='\0';
-
+
succ_key = GNUNET_new(struct GNUNET_HashCode);
GNUNET_CRYPTO_hash (truncated_successor_str, sizeof(truncated_successor_str),succ_key);
-
+
if (0 == flag)
{
+ GNUNET_assert(NULL != my_id_key);
start_key = my_id_key;
+ GNUNET_assert(NULL != start_key);
flag = 1;
}
- /* FIXME: GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE do not free the value
- which is replaced, need to free it. */
GNUNET_CONTAINER_multihashmap_put (successor_peer_hashmap,
my_id_key, (void *)succ_key,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
+
return GNUNET_OK;
}
-/*
- * Task that collects peer and its corresponding successors.
- *
+/*
+ * Task that collects peer and its corresponding successors.
+ *
* @param cls Closure (NULL).
- * @param tc Task Context.
*/
static void
-collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+collect_stats (void *cls)
{
- if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
- return;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n");
+ successor_stats_task = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Start collecting statistics...\n");
GNUNET_assert(NULL != testbed_handles);
- successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
- GNUNET_NO);
- successor_stats_op =
- GNUNET_TESTBED_get_statistics (num_peers, testbed_handles,
- "dht", NULL,
- successor_stats_iterator,
- successor_stats_cont, cls);
-
- GNUNET_assert(NULL != successor_stats_op);
-}
-
-#if ENABLE_MALICIOUS
-/**
- * Set the malicious variable in peer malicious context.
- */
-static void
-set_malicious()
-{
- unsigned int i;
- DEBUG ("Setting %u peers malicious");
- for(i = 0; i < n_malicious; i++)
- {
- struct MaliciousContext *mc = &a_mc[i];
- mc->ctx->op =
- GNUNET_TESTBED_service_connect (ac->ctx,
- ac->ctx->peer,
- "dht",
- &dht_set_malicious, mc,
- &dht_connect,
- &dht_finish,
- mc);
- }
+ if (0 != max_searches)
+ successor_peer_hashmap
+ = GNUNET_CONTAINER_multihashmap_create (num_peers,
+ GNUNET_NO);
+ successor_stats_op
+ = GNUNET_TESTBED_get_statistics (num_peers, testbed_handles,
+ "dht", NULL,
+ successor_stats_iterator,
+ successor_stats_cont, cls);
+ GNUNET_assert (NULL != successor_stats_op);
}
-#endif
/**
ctx->op = NULL;
peers_started++;
DEBUG("Peers Started = %d; num_peers = %d \n", peers_started, num_peers);
- if (GNUNET_SCHEDULER_NO_TASK == successor_stats_task && peers_started == num_peers)
+ if (NULL == successor_stats_task && peers_started == num_peers)
{
-#if ENABLE_MALICIOUS
- set_malicious();
-#endif
DEBUG("successor_stats_task \n");
struct Collect_Stat_Context *collect_stat_cls = GNUNET_new(struct Collect_Stat_Context);
collect_stat_cls->service_connect_ctx = cls;
collect_stat_cls->op = op;
- successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats,
- &collect_stats,
- collect_stat_cls);
+
+ successor_stats_task
+ = GNUNET_SCHEDULER_add_delayed (delay_stats,
+ &collect_stats,
+ collect_stat_cls);
}
}
{
unsigned int cnt;
unsigned int ac_cnt;
-
- testbed_handles = peers;
+ testbed_handles = peers;
if (NULL == peers)
{
/* exit */
GNUNET_free (a_ctx);
return;
}
-
-#if ENABLE_MALICIOUS
- if(PUT_PROBABILITY + MALICIOUS_PEERS > 100)
- {
- DEBUG ("Reduce either number of malicious peer or active peers. ");
- GNUNET_SCHEDULER_shutdown ();
- GNUNET_free (a_ctx);
- return;
- }
-
- /* Select the peers which should act maliciously. */
- n_malicious = num_peers * MALICIOUS_PEERS / 100;
-
- /* Select n_malicious peers and ensure that those are not active peers.
- keep all malicious peer at one place, and call act malicious for all
- those peers. */
-
-#endif
-
a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext));
ac_cnt = 0;
for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++)
{
- if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >=
- PUT_PROBABILITY)
+ if ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >=
+ PUT_PROBABILITY))
continue;
+
a_ctx[cnt].ac = &a_ac[ac_cnt];
a_ac[ac_cnt].ctx = &a_ctx[cnt];
ac_cnt++;
if (0 == num_peers)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Exiting as the number of peers is %u\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Exiting as the number of peers is %u\n"),
num_peers);
return;
}
event_mask = 0;
GNUNET_TESTBED_run (hosts_file, cfg, num_peers, event_mask, NULL,
NULL, &test_run, NULL);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ NULL);
}
gettext_noop ("number of peers to start"),
1, &GNUNET_GETOPT_set_uint, &num_peers},
{'s', "searches", "COUNT",
- gettext_noop ("maximum number of times we try to search for successor circle formation (default is 1)"),
+ gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"),
1, &GNUNET_GETOPT_set_uint, &max_searches},
{'H', "hosts", "FILENAME",
gettext_noop ("name of the file with the login information for the testbed"),
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
/* set default delays */
- delay_stats = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1);
- delay_put = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10);
- delay_get = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10);
- timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5);
+ delay_stats = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
+ delay_put = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
+ delay_get = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
+ timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
replication = 1; /* default replication */
rc = 0;
if (GNUNET_OK !=