diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-09-17 21:51:42 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-09-17 21:51:42 +0000 |
commit | e2ff8e18f5ea9e6be03f13c4482dedb6647d5e2c (patch) | |
tree | d64021bb2c3f1fc6d3d3e8b3542be581d566f4a8 /src/dht/gnunet_dht_profiler.c | |
parent | 25ecacf03e0da98ee59486c1dc0128e3355ff9b1 (diff) | |
download | gnunet-e2ff8e18f5ea9e6be03f13c4482dedb6647d5e2c.tar.gz gnunet-e2ff8e18f5ea9e6be03f13c4482dedb6647d5e2c.zip |
Removing trail compression message
Diffstat (limited to 'src/dht/gnunet_dht_profiler.c')
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c index 27aa892fa..5fa4a105d 100644 --- a/src/dht/gnunet_dht_profiler.c +++ b/src/dht/gnunet_dht_profiler.c | |||
@@ -38,8 +38,15 @@ | |||
38 | /** | 38 | /** |
39 | * Number of peers which should perform a PUT out of 100 peers | 39 | * Number of peers which should perform a PUT out of 100 peers |
40 | */ | 40 | */ |
41 | #define PUT_PROBABILITY 100 | 41 | #define PUT_PROBABILITY 20 |
42 | 42 | ||
43 | #if ENABLE_MALICIOUS | ||
44 | /** | ||
45 | * Number of peers which should act as malicious peers | ||
46 | */ | ||
47 | #define MALICIOUS_PROBABILITY 50 | ||
48 | |||
49 | #endif | ||
43 | /** | 50 | /** |
44 | * Percentage of peers that should act maliciously. | 51 | * Percentage of peers that should act maliciously. |
45 | * These peers will never start PUT/GET request. | 52 | * These peers will never start PUT/GET request. |
@@ -175,8 +182,27 @@ struct ActiveContext | |||
175 | * The number of peers currently doing GET on our data | 182 | * The number of peers currently doing GET on our data |
176 | */ | 183 | */ |
177 | uint16_t nrefs; | 184 | uint16_t nrefs; |
185 | |||
186 | /** | ||
187 | * If set this peer will act maliciously. | ||
188 | */ | ||
189 | unsigned int malicious; | ||
178 | }; | 190 | }; |
179 | 191 | ||
192 | #if ENABLE_MALICIOUS | ||
193 | struct Malicious_Context | ||
194 | { | ||
195 | /** | ||
196 | * The linked peer context | ||
197 | */ | ||
198 | struct Context *ctx; | ||
199 | |||
200 | /** | ||
201 | * Handler to the DHT service | ||
202 | */ | ||
203 | struct GNUNET_DHT_Handle *dht; | ||
204 | }; | ||
205 | #endif | ||
180 | 206 | ||
181 | /** | 207 | /** |
182 | * An array of contexts. The size of this array should be equal to @a num_peers | 208 | * An array of contexts. The size of this array should be equal to @a num_peers |
@@ -188,6 +214,13 @@ static struct Context *a_ctx; | |||
188 | */ | 214 | */ |
189 | static struct ActiveContext *a_ac; | 215 | static struct ActiveContext *a_ac; |
190 | 216 | ||
217 | #if ENABLE_MALICIOUS | ||
218 | /** | ||
219 | * Array of malicious peers. | ||
220 | */ | ||
221 | static struct MaliciousContext *a_mc; | ||
222 | #endif | ||
223 | |||
191 | /** | 224 | /** |
192 | * The delay between rounds for collecting statistics | 225 | * The delay between rounds for collecting statistics |
193 | */ | 226 | */ |
@@ -1074,6 +1107,7 @@ collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1074 | 1107 | ||
1075 | 1108 | ||
1076 | #if ENABLE_MALICIOUS | 1109 | #if ENABLE_MALICIOUS |
1110 | #if 0 | ||
1077 | /** | 1111 | /** |
1078 | * Set the malicious variable in peer malicious context. | 1112 | * Set the malicious variable in peer malicious context. |
1079 | */ | 1113 | */ |
@@ -1096,6 +1130,7 @@ set_malicious() | |||
1096 | } | 1130 | } |
1097 | } | 1131 | } |
1098 | #endif | 1132 | #endif |
1133 | #endif | ||
1099 | 1134 | ||
1100 | 1135 | ||
1101 | /** | 1136 | /** |
@@ -1122,7 +1157,7 @@ service_started (void *cls, | |||
1122 | if (GNUNET_SCHEDULER_NO_TASK == successor_stats_task && peers_started == num_peers) | 1157 | if (GNUNET_SCHEDULER_NO_TASK == successor_stats_task && peers_started == num_peers) |
1123 | { | 1158 | { |
1124 | #if ENABLE_MALICIOUS | 1159 | #if ENABLE_MALICIOUS |
1125 | set_malicious(); | 1160 | //set_malicious(); |
1126 | #endif | 1161 | #endif |
1127 | 1162 | ||
1128 | DEBUG("successor_stats_task \n"); | 1163 | DEBUG("successor_stats_task \n"); |
@@ -1156,7 +1191,7 @@ test_run (void *cls, | |||
1156 | { | 1191 | { |
1157 | unsigned int cnt; | 1192 | unsigned int cnt; |
1158 | unsigned int ac_cnt; | 1193 | unsigned int ac_cnt; |
1159 | 1194 | unsigned int malicious_peers; | |
1160 | testbed_handles = peers; | 1195 | testbed_handles = peers; |
1161 | if (NULL == peers) | 1196 | if (NULL == peers) |
1162 | { | 1197 | { |
@@ -1175,6 +1210,9 @@ test_run (void *cls, | |||
1175 | return; | 1210 | return; |
1176 | } | 1211 | } |
1177 | 1212 | ||
1213 | a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext)); | ||
1214 | ac_cnt = 0; | ||
1215 | |||
1178 | #if ENABLE_MALICIOUS | 1216 | #if ENABLE_MALICIOUS |
1179 | 1217 | ||
1180 | if(PUT_PROBABILITY + MALICIOUS_PEERS > 100) | 1218 | if(PUT_PROBABILITY + MALICIOUS_PEERS > 100) |
@@ -1191,6 +1229,19 @@ test_run (void *cls, | |||
1191 | /* Select n_malicious peers and ensure that those are not active peers. | 1229 | /* Select n_malicious peers and ensure that those are not active peers. |
1192 | keep all malicious peer at one place, and call act malicious for all | 1230 | keep all malicious peer at one place, and call act malicious for all |
1193 | those peers. */ | 1231 | those peers. */ |
1232 | a_mc = GNUNET_malloc (n_malicious * sizeof (struct MaliciousContext)); | ||
1233 | malicious_peers = 0; | ||
1234 | |||
1235 | for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) | ||
1236 | { | ||
1237 | if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >= | ||
1238 | MALICIOUS_PROBABILITY) | ||
1239 | continue; | ||
1240 | a_ac[ac_cnt].malicious = 1; | ||
1241 | a_mc[ac_cnt].ctx = &a_ctx[cnt]; | ||
1242 | malicious_peers++; | ||
1243 | } | ||
1244 | INFO ("Malicious Peers: %u\n",malicious_peers); | ||
1194 | 1245 | ||
1195 | #endif | 1246 | #endif |
1196 | 1247 | ||
@@ -1198,9 +1249,10 @@ test_run (void *cls, | |||
1198 | ac_cnt = 0; | 1249 | ac_cnt = 0; |
1199 | for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) | 1250 | for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++) |
1200 | { | 1251 | { |
1201 | if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >= | 1252 | if ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >= |
1202 | PUT_PROBABILITY) | 1253 | PUT_PROBABILITY) || (a_ac[ac_cnt].malicious == 1)) |
1203 | continue; | 1254 | continue; |
1255 | |||
1204 | a_ctx[cnt].ac = &a_ac[ac_cnt]; | 1256 | a_ctx[cnt].ac = &a_ac[ac_cnt]; |
1205 | a_ac[ac_cnt].ctx = &a_ctx[cnt]; | 1257 | a_ac[ac_cnt].ctx = &a_ctx[cnt]; |
1206 | ac_cnt++; | 1258 | ac_cnt++; |
@@ -1266,7 +1318,7 @@ main (int argc, char *const *argv) | |||
1266 | gettext_noop ("number of peers to start"), | 1318 | gettext_noop ("number of peers to start"), |
1267 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, | 1319 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, |
1268 | {'s', "searches", "COUNT", | 1320 | {'s', "searches", "COUNT", |
1269 | gettext_noop ("maximum number of times we try to search for successor circle formation (default is 1)"), | 1321 | gettext_noop ("maximum number of times we try to search for successor circle formation (0 for R5N)"), |
1270 | 1, &GNUNET_GETOPT_set_uint, &max_searches}, | 1322 | 1, &GNUNET_GETOPT_set_uint, &max_searches}, |
1271 | {'H', "hosts", "FILENAME", | 1323 | {'H', "hosts", "FILENAME", |
1272 | gettext_noop ("name of the file with the login information for the testbed"), | 1324 | gettext_noop ("name of the file with the login information for the testbed"), |