aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-10-05 12:15:57 +0000
committerChristian Grothoff <christian@grothoff.org>2014-10-05 12:15:57 +0000
commit8b8b247945ba271e657f66bbe408ca99a793565e (patch)
treefe32216d08b9fc8a8b9bf5f46862b23f84c9640b /src/dht
parent7a05042e7e4982725669f0d12846052e2ceb1701 (diff)
downloadgnunet-8b8b247945ba271e657f66bbe408ca99a793565e.tar.gz
gnunet-8b8b247945ba271e657f66bbe408ca99a793565e.zip
-add assertion
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet_dht_profiler.c166
1 files changed, 81 insertions, 85 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index e69307eac..ec9e54de2 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -47,7 +47,7 @@
47#define MALICIOUS_PROBABILITY 20 47#define MALICIOUS_PROBABILITY 20
48 48
49/** 49/**
50 * Context for a peer which should act maliciously. 50 * Context for a peer which should act maliciously.
51 */ 51 */
52struct MaliciousContext; 52struct MaliciousContext;
53#endif 53#endif
@@ -87,10 +87,10 @@ struct Context
87 * Active context; NULL if this peer is not an active peer 87 * Active context; NULL if this peer is not an active peer
88 */ 88 */
89 struct ActiveContext *ac; 89 struct ActiveContext *ac;
90 90
91#if ENABLE_MALICIOUS 91#if ENABLE_MALICIOUS
92 /** 92 /**
93 * Malicious context; NULL if this peer is NOT malicious. 93 * Malicious context; NULL if this peer is NOT malicious.
94 */ 94 */
95 struct MaliciousContext *mc; 95 struct MaliciousContext *mc;
96#endif 96#endif
@@ -112,7 +112,7 @@ struct MaliciousContext
112 * Handler to the DHT service 112 * Handler to the DHT service
113 */ 113 */
114 struct GNUNET_DHT_Handle *dht; 114 struct GNUNET_DHT_Handle *dht;
115 115
116 /** 116 /**
117 * Handler to malicious api 117 * Handler to malicious api
118 */ 118 */
@@ -310,7 +310,7 @@ static struct GNUNET_TESTBED_Operation *successor_stats_op;
310static struct GNUNET_TESTBED_Peer **testbed_handles; 310static struct GNUNET_TESTBED_Peer **testbed_handles;
311 311
312/** 312/**
313 * Total number of messages sent by peer. 313 * Total number of messages sent by peer.
314 */ 314 */
315static uint64_t outgoing_bandwidth; 315static uint64_t outgoing_bandwidth;
316 316
@@ -325,27 +325,27 @@ static uint64_t incoming_bandwidth;
325static double average_put_path_length; 325static double average_put_path_length;
326 326
327/** 327/**
328 * Average number of hops taken to do get. 328 * Average number of hops taken to do get.
329 */ 329 */
330static double average_get_path_length; 330static double average_get_path_length;
331 331
332/** 332/**
333 * Total put path length across all peers. 333 * Total put path length across all peers.
334 */ 334 */
335static unsigned int total_put_path_length; 335static unsigned int total_put_path_length;
336 336
337/** 337/**
338 * Total get path length across all peers. 338 * Total get path length across all peers.
339 */ 339 */
340static unsigned int total_get_path_length; 340static unsigned int total_get_path_length;
341 341
342/** 342/**
343 * Hashmap to store pair of peer and its corresponding successor. 343 * Hashmap to store pair of peer and its corresponding successor.
344 */ 344 */
345static struct GNUNET_CONTAINER_MultiHashMap *successor_peer_hashmap; 345static struct GNUNET_CONTAINER_MultiHashMap *successor_peer_hashmap;
346 346
347/** 347/**
348 * Key to start the lookup on successor_peer_hashmap. 348 * Key to start the lookup on successor_peer_hashmap.
349 */ 349 */
350static struct GNUNET_HashCode *start_key; 350static struct GNUNET_HashCode *start_key;
351 351
@@ -365,10 +365,10 @@ static GNUNET_SCHEDULER_TaskIdentifier successor_stats_task;
365struct Collect_Stat_Context 365struct Collect_Stat_Context
366{ 366{
367 /** 367 /**
368 * Current Peer Context. 368 * Current Peer Context.
369 */ 369 */
370 struct Context *service_connect_ctx; 370 struct Context *service_connect_ctx;
371 371
372 /** 372 /**
373 * Testbed operation acting on this peer 373 * Testbed operation acting on this peer
374 */ 374 */
@@ -381,7 +381,7 @@ struct Collect_Stat_Context
381struct Context **peer_contexts = NULL; 381struct Context **peer_contexts = NULL;
382 382
383/** 383/**
384 * Counter to keep track of peers added to peer_context lists. 384 * Counter to keep track of peers added to peer_context lists.
385 */ 385 */
386static int peers_started = 0; 386static int peers_started = 0;
387 387
@@ -407,7 +407,7 @@ static int in_shutdown = 0;
407static unsigned int tries; 407static unsigned int tries;
408 408
409/** 409/**
410 * Task that collects successor statistics from all the peers. 410 * Task that collects successor statistics from all the peers.
411 * @param cls 411 * @param cls
412 * @param tc 412 * @param tc
413 */ 413 */
@@ -476,8 +476,8 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
476 * operation has executed successfully. 476 * operation has executed successfully.
477 */ 477 */
478static void 478static void
479bandwidth_stats_cont (void *cls, 479bandwidth_stats_cont (void *cls,
480 struct GNUNET_TESTBED_Operation *op, 480 struct GNUNET_TESTBED_Operation *op,
481 const char *emsg) 481 const char *emsg)
482{ 482{
483 INFO ("# Outgoing bandwidth: %u\n", outgoing_bandwidth); 483 INFO ("# Outgoing bandwidth: %u\n", outgoing_bandwidth);
@@ -498,11 +498,11 @@ bandwidth_stats_cont (void *cls,
498 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 498 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
499 */ 499 */
500static int 500static int
501bandwidth_stats_iterator (void *cls, 501bandwidth_stats_iterator (void *cls,
502 const struct GNUNET_TESTBED_Peer *peer, 502 const struct GNUNET_TESTBED_Peer *peer,
503 const char *subsystem, 503 const char *subsystem,
504 const char *name, 504 const char *name,
505 uint64_t value, 505 uint64_t value,
506 int is_persistent) 506 int is_persistent)
507{ 507{
508 static const char *s_sent = "# Bytes transmitted to other peers"; 508 static const char *s_sent = "# Bytes transmitted to other peers";
@@ -512,7 +512,7 @@ bandwidth_stats_iterator (void *cls,
512 outgoing_bandwidth = outgoing_bandwidth + value; 512 outgoing_bandwidth = outgoing_bandwidth + value;
513 else if (0 == strncmp(s_recv, name, strlen (s_recv))) 513 else if (0 == strncmp(s_recv, name, strlen (s_recv)))
514 incoming_bandwidth = incoming_bandwidth + value; 514 incoming_bandwidth = incoming_bandwidth + value;
515 515
516 return GNUNET_OK; 516 return GNUNET_OK;
517} 517}
518 518
@@ -528,7 +528,7 @@ summarize ()
528 INFO ("# GETS failed: %u\n", n_gets_fail); 528 INFO ("# GETS failed: %u\n", n_gets_fail);
529 INFO ("# average_put_path_length: %f\n", average_put_path_length); 529 INFO ("# average_put_path_length: %f\n", average_put_path_length);
530 INFO ("# average_get_path_length: %f\n", average_get_path_length); 530 INFO ("# average_get_path_length: %f\n", average_get_path_length);
531 531
532 if (NULL == testbed_handles) 532 if (NULL == testbed_handles)
533 { 533 {
534 INFO ("No peers found\n"); 534 INFO ("No peers found\n");
@@ -537,7 +537,7 @@ summarize ()
537 /* Collect Stats*/ 537 /* Collect Stats*/
538 bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles, 538 bandwidth_stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
539 "dht", NULL, 539 "dht", NULL,
540 bandwidth_stats_iterator, 540 bandwidth_stats_iterator,
541 bandwidth_stats_cont, NULL); 541 bandwidth_stats_cont, NULL);
542} 542}
543 543
@@ -619,7 +619,7 @@ get_iter (void *cls,
619 GNUNET_assert (NULL != ctx->op); 619 GNUNET_assert (NULL != ctx->op);
620 GNUNET_TESTBED_operation_done (ctx->op); 620 GNUNET_TESTBED_operation_done (ctx->op);
621 ctx->op = NULL; 621 ctx->op = NULL;
622 622
623 total_put_path_length = total_put_path_length + (double)put_path_length; 623 total_put_path_length = total_put_path_length + (double)put_path_length;
624 total_get_path_length = total_get_path_length + (double)get_path_length; 624 total_get_path_length = total_get_path_length + (double)get_path_length;
625 DEBUG ("total_put_path_length = %f,put_path \n",total_put_path_length); 625 DEBUG ("total_put_path_length = %f,put_path \n",total_put_path_length);
@@ -875,7 +875,7 @@ start_profiling()
875{ 875{
876 struct Context *ctx; 876 struct Context *ctx;
877 unsigned int i; 877 unsigned int i;
878 878
879 DEBUG("GNUNET_TESTBED_service_connect \n"); 879 DEBUG("GNUNET_TESTBED_service_connect \n");
880 GNUNET_break (GNUNET_YES != in_shutdown); 880 GNUNET_break (GNUNET_YES != in_shutdown);
881 for(i = 0; i < n_active; i++) 881 for(i = 0; i < n_active; i++)
@@ -914,7 +914,7 @@ act_malicious_cont (void *cls, int success)
914{ 914{
915 struct MaliciousContext *mc = cls; 915 struct MaliciousContext *mc = cls;
916 struct Context *ctx = mc->ctx; 916 struct Context *ctx = mc->ctx;
917 917
918 GNUNET_TESTBED_operation_done (ctx->op); 918 GNUNET_TESTBED_operation_done (ctx->op);
919 ctx->op = NULL; 919 ctx->op = NULL;
920 return; 920 return;
@@ -929,7 +929,7 @@ act_malicious_cont (void *cls, int success)
929 * @param emsg error message in case the operation has failed; will be NULL if 929 * @param emsg error message in case the operation has failed; will be NULL if
930 * operation has executed successfully. 930 * operation has executed successfully.
931 */ 931 */
932void 932void
933dht_set_malicious(void *cls, 933dht_set_malicious(void *cls,
934 struct GNUNET_TESTBED_Operation *op, 934 struct GNUNET_TESTBED_Operation *op,
935 void *ca_result, 935 void *ca_result,
@@ -974,7 +974,7 @@ dht_disconnect_malicious (void *cls, void *op_result)
974 974
975 if (0 != n_dht) 975 if (0 != n_dht)
976 return; 976 return;
977 977
978 if(n_malicious == count_malicious) 978 if(n_malicious == count_malicious)
979 { 979 {
980 DEBUG("\n Call start_profiling()"); 980 DEBUG("\n Call start_profiling()");
@@ -991,7 +991,7 @@ set_malicious()
991{ 991{
992 unsigned int i; 992 unsigned int i;
993 DEBUG ("Setting %u peers malicious",n_malicious); 993 DEBUG ("Setting %u peers malicious",n_malicious);
994 994
995 for(i = 0; i < n_malicious; i++) 995 for(i = 0; i < n_malicious; i++)
996 { 996 {
997 struct MaliciousContext *mc = &a_mc[i]; 997 struct MaliciousContext *mc = &a_mc[i];
@@ -1020,7 +1020,7 @@ start_func()
1020#if ENABLE_MALICIOUS 1020#if ENABLE_MALICIOUS
1021 set_malicious(); 1021 set_malicious();
1022 return; 1022 return;
1023#endif 1023#endif
1024 start_profiling(); 1024 start_profiling();
1025} 1025}
1026 1026
@@ -1033,12 +1033,12 @@ start_func()
1033 * @return #GNUNET_YES if we should continue to iterate, 1033 * @return #GNUNET_YES if we should continue to iterate,
1034 * #GNUNET_NO if not. 1034 * #GNUNET_NO if not.
1035 */ 1035 */
1036static int 1036static int
1037hashmap_iterate_remove(void *cls, 1037hashmap_iterate_remove(void *cls,
1038 const struct GNUNET_HashCode *key, 1038 const struct GNUNET_HashCode *key,
1039 void *value) 1039 void *value)
1040{ 1040{
1041 GNUNET_assert (GNUNET_YES == 1041 GNUNET_assert (GNUNET_YES ==
1042 GNUNET_CONTAINER_multihashmap_remove(successor_peer_hashmap, key, value)); 1042 GNUNET_CONTAINER_multihashmap_remove(successor_peer_hashmap, key, value));
1043 return GNUNET_YES; 1043 return GNUNET_YES;
1044} 1044}
@@ -1054,61 +1054,56 @@ hashmap_iterate_remove(void *cls,
1054 * operation has executed successfully. 1054 * operation has executed successfully.
1055 */ 1055 */
1056static void 1056static void
1057successor_stats_cont (void *cls, 1057successor_stats_cont (void *cls,
1058 struct GNUNET_TESTBED_Operation *op, 1058 struct GNUNET_TESTBED_Operation *op,
1059 const char *emsg) 1059 const char *emsg)
1060{ 1060{
1061 struct GNUNET_HashCode *val; 1061 struct GNUNET_HashCode *val;
1062 struct GNUNET_HashCode *start_val; 1062 struct GNUNET_HashCode *start_val;
1063 struct GNUNET_HashCode *key; 1063 struct GNUNET_HashCode *key;
1064 int count; 1064 int count;
1065 1065
1066 /* Don't schedule the task till we are looking for circle here. */ 1066 /* Don't schedule the task till we are looking for circle here. */
1067 successor_stats_task = GNUNET_SCHEDULER_NO_TASK; 1067 successor_stats_task = GNUNET_SCHEDULER_NO_TASK;
1068 GNUNET_TESTBED_operation_done (successor_stats_op); 1068 GNUNET_TESTBED_operation_done (successor_stats_op);
1069 successor_stats_op = NULL; 1069 successor_stats_op = NULL;
1070 if (0 == max_searches) 1070 if (0 == max_searches)
1071 { 1071 {
1072 start_func(); 1072 start_func();
1073 return; 1073 return;
1074 } 1074 }
1075 1075
1076 GNUNET_assert (NULL != start_key); 1076 GNUNET_assert (NULL != start_key);
1077 start_val = 1077 start_val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap,
1078 (struct GNUNET_HashCode *) GNUNET_CONTAINER_multihashmap_get(successor_peer_hashmap, 1078 start_key);
1079 start_key); 1079 GNUNET_assert (NULL != start_val);
1080
1081 val = start_val; 1080 val = start_val;
1082 for (count = 0; count < num_peers; count++) 1081 for (count = 0; count < num_peers; count++)
1083 { 1082 {
1084 key = val; 1083 key = val;
1085 val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap, 1084 val = GNUNET_CONTAINER_multihashmap_get (successor_peer_hashmap,
1086 key); 1085 key);
1087 if(NULL == val) 1086 if (NULL == val)
1088 {
1089 break; 1087 break;
1090 }
1091 /* Remove the entry from hashmap. This is done to take care of loop. */ 1088 /* Remove the entry from hashmap. This is done to take care of loop. */
1092 if (GNUNET_NO == 1089 if (GNUNET_NO ==
1093 GNUNET_CONTAINER_multihashmap_remove (successor_peer_hashmap, 1090 GNUNET_CONTAINER_multihashmap_remove (successor_peer_hashmap,
1094 key, val)) 1091 key, val))
1095 { 1092 {
1096 DEBUG ("Failed to remove entry from hashmap\n"); 1093 DEBUG ("Failed to remove entry from hashmap\n");
1097 break; 1094 break;
1098 } 1095 }
1099 /* If a peer has its own identity as its successor. */ 1096 /* If a peer has its own identity as its successor. */
1100 if (0 == memcmp(key, val, sizeof (struct GNUNET_HashCode))) 1097 if (0 == memcmp(key, val, sizeof (struct GNUNET_HashCode)))
1101 {
1102 break; 1098 break;
1103 }
1104 } 1099 }
1105 1100
1106 GNUNET_assert(GNUNET_SYSERR != 1101 GNUNET_assert (GNUNET_SYSERR !=
1107 GNUNET_CONTAINER_multihashmap_iterate (successor_peer_hashmap, 1102 GNUNET_CONTAINER_multihashmap_iterate (successor_peer_hashmap,
1108 hashmap_iterate_remove, 1103 &hashmap_iterate_remove,
1109 NULL)); 1104 NULL));
1110 1105
1111 successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers, 1106 successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
1112 GNUNET_NO); 1107 GNUNET_NO);
1113 if ((start_val == val) && (count == num_peers)) 1108 if ((start_val == val) && (count == num_peers))
1114 { 1109 {
@@ -1135,15 +1130,16 @@ successor_stats_cont (void *cls,
1135 { 1130 {
1136 start_func(); 1131 start_func();
1137 } 1132 }
1138 1133
1139 return; 1134 return;
1140 } 1135 }
1141 else 1136 else
1142 { 1137 {
1143 flag = 0; 1138 flag = 0;
1144 successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats, &collect_stats, cls); 1139 successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats,
1140 &collect_stats, cls);
1145 } 1141 }
1146 } 1142 }
1147} 1143}
1148 1144
1149 1145
@@ -1159,11 +1155,11 @@ successor_stats_cont (void *cls,
1159 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 1155 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
1160 */ 1156 */
1161static int 1157static int
1162successor_stats_iterator (void *cls, 1158successor_stats_iterator (void *cls,
1163 const struct GNUNET_TESTBED_Peer *peer, 1159 const struct GNUNET_TESTBED_Peer *peer,
1164 const char *subsystem, 1160 const char *subsystem,
1165 const char *name, 1161 const char *name,
1166 uint64_t value, 1162 uint64_t value,
1167 int is_persistent) 1163 int is_persistent)
1168{ 1164{
1169 static const char *key_string = "XDHT"; 1165 static const char *key_string = "XDHT";
@@ -1178,10 +1174,10 @@ successor_stats_iterator (void *cls,
1178 char truncated_successor_str[13]; 1174 char truncated_successor_str[13];
1179 struct GNUNET_HashCode *my_id_key; 1175 struct GNUNET_HashCode *my_id_key;
1180 struct GNUNET_HashCode *succ_key; 1176 struct GNUNET_HashCode *succ_key;
1181 1177
1182 strtok((char *)name,":"); 1178 strtok((char *)name,":");
1183 my_id_str = strtok(NULL,":"); 1179 my_id_str = strtok(NULL,":");
1184 1180
1185 strncpy(truncated_my_id_str, my_id_str, 12); 1181 strncpy(truncated_my_id_str, my_id_str, 12);
1186 truncated_my_id_str[12] = '\0'; 1182 truncated_my_id_str[12] = '\0';
1187 my_id_key = GNUNET_new(struct GNUNET_HashCode); 1183 my_id_key = GNUNET_new(struct GNUNET_HashCode);
@@ -1189,7 +1185,7 @@ successor_stats_iterator (void *cls,
1189 GNUNET_STRINGS_data_to_string(&value, sizeof(uint64_t), successor_str, 13); 1185 GNUNET_STRINGS_data_to_string(&value, sizeof(uint64_t), successor_str, 13);
1190 strncpy(truncated_successor_str, successor_str, 12); 1186 strncpy(truncated_successor_str, successor_str, 12);
1191 truncated_successor_str[12] ='\0'; 1187 truncated_successor_str[12] ='\0';
1192 1188
1193 succ_key = GNUNET_new(struct GNUNET_HashCode); 1189 succ_key = GNUNET_new(struct GNUNET_HashCode);
1194 GNUNET_CRYPTO_hash (truncated_successor_str, sizeof(truncated_successor_str),succ_key); 1190 GNUNET_CRYPTO_hash (truncated_successor_str, sizeof(truncated_successor_str),succ_key);
1195 1191
@@ -1209,9 +1205,9 @@ successor_stats_iterator (void *cls,
1209} 1205}
1210 1206
1211 1207
1212/* 1208/*
1213 * Task that collects peer and its corresponding successors. 1209 * Task that collects peer and its corresponding successors.
1214 * 1210 *
1215 * @param cls Closure (NULL). 1211 * @param cls Closure (NULL).
1216 * @param tc Task Context. 1212 * @param tc Task Context.
1217 */ 1213 */
@@ -1223,16 +1219,16 @@ collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1223 1219
1224 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n"); 1220 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n");
1225 GNUNET_assert(NULL != testbed_handles); 1221 GNUNET_assert(NULL != testbed_handles);
1226 1222
1227 if (0 != max_searches) 1223 if (0 != max_searches)
1228 successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers, 1224 successor_peer_hashmap = GNUNET_CONTAINER_multihashmap_create (num_peers,
1229 GNUNET_NO); 1225 GNUNET_NO);
1230 successor_stats_op = 1226 successor_stats_op =
1231 GNUNET_TESTBED_get_statistics (num_peers, testbed_handles, 1227 GNUNET_TESTBED_get_statistics (num_peers, testbed_handles,
1232 "dht", NULL, 1228 "dht", NULL,
1233 successor_stats_iterator, 1229 successor_stats_iterator,
1234 successor_stats_cont, cls); 1230 successor_stats_cont, cls);
1235 1231
1236 GNUNET_assert(NULL != successor_stats_op); 1232 GNUNET_assert(NULL != successor_stats_op);
1237} 1233}
1238 1234
@@ -1264,7 +1260,7 @@ service_started (void *cls,
1264 struct Collect_Stat_Context *collect_stat_cls = GNUNET_new(struct Collect_Stat_Context); 1260 struct Collect_Stat_Context *collect_stat_cls = GNUNET_new(struct Collect_Stat_Context);
1265 collect_stat_cls->service_connect_ctx = cls; 1261 collect_stat_cls->service_connect_ctx = cls;
1266 collect_stat_cls->op = op; 1262 collect_stat_cls->op = op;
1267 1263
1268 successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats, 1264 successor_stats_task = GNUNET_SCHEDULER_add_delayed (delay_stats,
1269 &collect_stats, 1265 &collect_stats,
1270 collect_stat_cls); 1266 collect_stat_cls);
@@ -1292,7 +1288,7 @@ test_run (void *cls,
1292{ 1288{
1293 unsigned int cnt; 1289 unsigned int cnt;
1294 unsigned int ac_cnt; 1290 unsigned int ac_cnt;
1295 testbed_handles = peers; 1291 testbed_handles = peers;
1296 if (NULL == peers) 1292 if (NULL == peers)
1297 { 1293 {
1298 /* exit */ 1294 /* exit */
@@ -1309,10 +1305,10 @@ test_run (void *cls,
1309 GNUNET_free (a_ctx); 1305 GNUNET_free (a_ctx);
1310 return; 1306 return;
1311 } 1307 }
1312 1308
1313 a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext)); 1309 a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext));
1314 ac_cnt = 0; 1310 ac_cnt = 0;
1315 1311
1316#if ENABLE_MALICIOUS 1312#if ENABLE_MALICIOUS
1317 unsigned int malicious_peers; 1313 unsigned int malicious_peers;
1318 if(PUT_PROBABILITY + MALICIOUS_PROBABILITY > 100) 1314 if(PUT_PROBABILITY + MALICIOUS_PROBABILITY > 100)
@@ -1322,13 +1318,13 @@ test_run (void *cls,
1322 GNUNET_free (a_ctx); 1318 GNUNET_free (a_ctx);
1323 return; 1319 return;
1324 } 1320 }
1325 1321
1326 /* Select the peers which should act maliciously. */ 1322 /* Select the peers which should act maliciously. */
1327 n_malicious = num_peers * MALICIOUS_PROBABILITY / 100; 1323 n_malicious = num_peers * MALICIOUS_PROBABILITY / 100;
1328 1324
1329 a_mc = GNUNET_malloc (n_malicious * sizeof (struct MaliciousContext)); 1325 a_mc = GNUNET_malloc (n_malicious * sizeof (struct MaliciousContext));
1330 malicious_peers = 0; 1326 malicious_peers = 0;
1331 1327
1332 for (cnt = 0; cnt < num_peers && malicious_peers < n_malicious; cnt++) 1328 for (cnt = 0; cnt < num_peers && malicious_peers < n_malicious; cnt++)
1333 { 1329 {
1334 if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >= 1330 if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >=
@@ -1337,12 +1333,12 @@ test_run (void *cls,
1337 a_ctx[cnt].mc = &a_mc[malicious_peers]; 1333 a_ctx[cnt].mc = &a_mc[malicious_peers];
1338 a_mc[malicious_peers].ctx = &a_ctx[cnt]; 1334 a_mc[malicious_peers].ctx = &a_ctx[cnt];
1339 malicious_peers++; 1335 malicious_peers++;
1340 } 1336 }
1341 n_malicious = malicious_peers; 1337 n_malicious = malicious_peers;
1342 INFO ("Malicious Peers: %u\n",malicious_peers); 1338 INFO ("Malicious Peers: %u\n",malicious_peers);
1343 1339
1344#endif 1340#endif
1345 1341
1346 a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext)); 1342 a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext));
1347 ac_cnt = 0; 1343 ac_cnt = 0;
1348 for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) 1344 for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++)
@@ -1350,12 +1346,12 @@ test_run (void *cls,
1350 if ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >= 1346 if ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >=
1351 PUT_PROBABILITY)) 1347 PUT_PROBABILITY))
1352 continue; 1348 continue;
1353 1349
1354#if ENABLE_MALICIOUS 1350#if ENABLE_MALICIOUS
1355 if(a_ctx[ac_cnt].mc != NULL) 1351 if(a_ctx[ac_cnt].mc != NULL)
1356 continue; 1352 continue;
1357#endif 1353#endif
1358 1354
1359 a_ctx[cnt].ac = &a_ac[ac_cnt]; 1355 a_ctx[cnt].ac = &a_ac[ac_cnt];
1360 a_ac[ac_cnt].ctx = &a_ctx[cnt]; 1356 a_ac[ac_cnt].ctx = &a_ctx[cnt];
1361 ac_cnt++; 1357 ac_cnt++;