diff options
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 3144 |
1 files changed, 1596 insertions, 1548 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index a963476cf..03b96f264 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -25,7 +25,7 @@ | |||
25 | * for one message from each peer. | 25 | * for one message from each peer. |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | //#include "rps_test_lib.h" | 28 | // #include "rps_test_lib.h" |
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_testbed_service.h" | 30 | #include "gnunet_testbed_service.h" |
31 | 31 | ||
@@ -74,7 +74,8 @@ static unsigned int mal_type = 0; | |||
74 | */ | 74 | */ |
75 | static struct GNUNET_TESTBED_Peer **testbed_peers; | 75 | static struct GNUNET_TESTBED_Peer **testbed_peers; |
76 | 76 | ||
77 | enum STAT_TYPE { | 77 | enum STAT_TYPE |
78 | { | ||
78 | STAT_TYPE_ROUNDS, /* 0 */ | 79 | STAT_TYPE_ROUNDS, /* 0 */ |
79 | STAT_TYPE_BLOCKS, /* 1 */ | 80 | STAT_TYPE_BLOCKS, /* 1 */ |
80 | STAT_TYPE_BLOCKS_MANY_PUSH, /* 2 */ | 81 | STAT_TYPE_BLOCKS_MANY_PUSH, /* 2 */ |
@@ -110,7 +111,7 @@ enum STAT_TYPE { | |||
110 | STAT_TYPE_MAX, /* 32 */ | 111 | STAT_TYPE_MAX, /* 32 */ |
111 | }; | 112 | }; |
112 | 113 | ||
113 | static char* stat_type_strings[] = { | 114 | static char*stat_type_strings[] = { |
114 | "# rounds", | 115 | "# rounds", |
115 | "# rounds blocked", | 116 | "# rounds blocked", |
116 | "# rounds blocked - too many pushes", | 117 | "# rounds blocked - too many pushes", |
@@ -145,7 +146,8 @@ static char* stat_type_strings[] = { | |||
145 | "view size aim", | 146 | "view size aim", |
146 | }; | 147 | }; |
147 | 148 | ||
148 | struct STATcls { | 149 | struct STATcls |
150 | { | ||
149 | struct RPSPeer *rps_peer; | 151 | struct RPSPeer *rps_peer; |
150 | enum STAT_TYPE stat_type; | 152 | enum STAT_TYPE stat_type; |
151 | }; | 153 | }; |
@@ -158,200 +160,214 @@ struct STATcls { | |||
158 | * | 160 | * |
159 | * @return corresponding enum | 161 | * @return corresponding enum |
160 | */ | 162 | */ |
161 | enum STAT_TYPE stat_str_2_type(const char *stat_str) | 163 | enum STAT_TYPE stat_str_2_type (const char *stat_str) |
162 | { | 164 | { |
163 | if (0 == strncmp(stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL], | 165 | if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL], |
164 | stat_str, | 166 | stat_str, |
165 | strlen(stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL]))) | 167 | strlen (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL]))) |
166 | { | 168 | { |
167 | return STAT_TYPE_BLOCKS_NO_PULL; | 169 | return STAT_TYPE_BLOCKS_NO_PULL; |
168 | } | 170 | } |
169 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL], | 171 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL], |
170 | stat_str, | 172 | stat_str, |
171 | strlen(stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL]))) | 173 | strlen ( |
172 | { | 174 | stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL]))) |
173 | return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL; | 175 | { |
174 | } | 176 | return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL; |
175 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH], | 177 | } |
176 | stat_str, | 178 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH], |
177 | strlen(stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH]))) | 179 | stat_str, |
178 | { | 180 | strlen ( |
179 | return STAT_TYPE_BLOCKS_MANY_PUSH; | 181 | stat_type_strings[STAT_TYPE_BLOCKS_MANY_PUSH]))) |
180 | } | 182 | { |
181 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL], | 183 | return STAT_TYPE_BLOCKS_MANY_PUSH; |
182 | stat_str, | 184 | } |
183 | strlen(stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL]))) | 185 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL], |
184 | { | 186 | stat_str, |
185 | return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL; | 187 | strlen ( |
186 | } | 188 | stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL]))) |
187 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH], | 189 | { |
188 | stat_str, | 190 | return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL; |
189 | strlen(stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH]))) | 191 | } |
190 | { | 192 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH], |
191 | return STAT_TYPE_BLOCKS_NO_PUSH; | 193 | stat_str, |
192 | } | 194 | strlen (stat_type_strings[STAT_TYPE_BLOCKS_NO_PUSH]))) |
193 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_BLOCKS], | 195 | { |
194 | stat_str, | 196 | return STAT_TYPE_BLOCKS_NO_PUSH; |
195 | strlen(stat_type_strings[STAT_TYPE_BLOCKS]))) | 197 | } |
196 | { | 198 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS], |
197 | return STAT_TYPE_BLOCKS; | 199 | stat_str, |
198 | } | 200 | strlen (stat_type_strings[STAT_TYPE_BLOCKS]))) |
199 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_ROUNDS], | 201 | { |
200 | stat_str, | 202 | return STAT_TYPE_BLOCKS; |
201 | strlen(stat_type_strings[STAT_TYPE_ROUNDS]))) | 203 | } |
202 | { | 204 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_ROUNDS], |
203 | return STAT_TYPE_ROUNDS; | 205 | stat_str, |
204 | } | 206 | strlen (stat_type_strings[STAT_TYPE_ROUNDS]))) |
205 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND], | 207 | { |
206 | stat_str, | 208 | return STAT_TYPE_ROUNDS; |
207 | strlen(stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND]))) | 209 | } |
208 | { | 210 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND], |
209 | return STAT_TYPE_ISSUED_PUSH_SEND; | 211 | stat_str, |
210 | } | 212 | strlen ( |
211 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH], | 213 | stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND]))) |
212 | stat_str, | 214 | { |
213 | strlen(stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH]))) | 215 | return STAT_TYPE_ISSUED_PUSH_SEND; |
214 | { | 216 | } |
215 | return STAT_TYPE_ISSUED_PUSH_SEND_MH; | 217 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH], |
216 | } | 218 | stat_str, |
217 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ], | 219 | strlen ( |
218 | stat_str, | 220 | stat_type_strings[STAT_TYPE_ISSUED_PUSH_SEND_MH]))) |
219 | strlen(stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ]))) | 221 | { |
220 | { | 222 | return STAT_TYPE_ISSUED_PUSH_SEND_MH; |
221 | return STAT_TYPE_ISSUED_PULL_REQ; | 223 | } |
222 | } | 224 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ], |
223 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH], | 225 | stat_str, |
224 | stat_str, | 226 | strlen (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ]))) |
225 | strlen(stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH]))) | 227 | { |
226 | { | 228 | return STAT_TYPE_ISSUED_PULL_REQ; |
227 | return STAT_TYPE_ISSUED_PULL_REQ_MH; | 229 | } |
228 | } | 230 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH], |
229 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_ISSUED_PULL_REP], | 231 | stat_str, |
230 | stat_str, | 232 | strlen ( |
231 | strlen(stat_type_strings[STAT_TYPE_ISSUED_PULL_REP]))) | 233 | stat_type_strings[STAT_TYPE_ISSUED_PULL_REQ_MH]))) |
232 | { | 234 | { |
233 | return STAT_TYPE_ISSUED_PULL_REP; | 235 | return STAT_TYPE_ISSUED_PULL_REQ_MH; |
234 | } | 236 | } |
235 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_SENT_PUSH_SEND], | 237 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_ISSUED_PULL_REP], |
236 | stat_str, | 238 | stat_str, |
237 | strlen(stat_type_strings[STAT_TYPE_SENT_PUSH_SEND]))) | 239 | strlen (stat_type_strings[STAT_TYPE_ISSUED_PULL_REP]))) |
238 | { | 240 | { |
239 | return STAT_TYPE_SENT_PUSH_SEND; | 241 | return STAT_TYPE_ISSUED_PULL_REP; |
240 | } | 242 | } |
241 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_SENT_PULL_REQ], | 243 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PUSH_SEND], |
242 | stat_str, | 244 | stat_str, |
243 | strlen(stat_type_strings[STAT_TYPE_SENT_PULL_REQ]))) | 245 | strlen (stat_type_strings[STAT_TYPE_SENT_PUSH_SEND]))) |
244 | { | 246 | { |
245 | return STAT_TYPE_SENT_PULL_REQ; | 247 | return STAT_TYPE_SENT_PUSH_SEND; |
246 | } | 248 | } |
247 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH], | 249 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REQ], |
248 | stat_str, | 250 | stat_str, |
249 | strlen(stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH]))) | 251 | strlen (stat_type_strings[STAT_TYPE_SENT_PULL_REQ]))) |
250 | { | 252 | { |
251 | return STAT_TYPE_SENT_PULL_REQ_MH; | 253 | return STAT_TYPE_SENT_PULL_REQ; |
252 | } | 254 | } |
253 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_SENT_PULL_REP], | 255 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH], |
254 | stat_str, | 256 | stat_str, |
255 | strlen(stat_type_strings[STAT_TYPE_SENT_PULL_REP]))) | 257 | strlen ( |
256 | { | 258 | stat_type_strings[STAT_TYPE_SENT_PULL_REQ_MH]))) |
257 | return STAT_TYPE_SENT_PULL_REP; | 259 | { |
258 | } | 260 | return STAT_TYPE_SENT_PULL_REQ_MH; |
259 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_RECV_PUSH_SEND], | 261 | } |
260 | stat_str, | 262 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_SENT_PULL_REP], |
261 | strlen(stat_type_strings[STAT_TYPE_RECV_PUSH_SEND]))) | 263 | stat_str, |
262 | { | 264 | strlen (stat_type_strings[STAT_TYPE_SENT_PULL_REP]))) |
263 | return STAT_TYPE_RECV_PUSH_SEND; | 265 | { |
264 | } | 266 | return STAT_TYPE_SENT_PULL_REP; |
265 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH], | 267 | } |
266 | stat_str, | 268 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND], |
267 | strlen(stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH]))) | 269 | stat_str, |
268 | { | 270 | strlen (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND]))) |
269 | return STAT_TYPE_RECV_PUSH_SEND_MH; | 271 | { |
270 | } | 272 | return STAT_TYPE_RECV_PUSH_SEND; |
271 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_RECV_PULL_REQ], | 273 | } |
272 | stat_str, | 274 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH], |
273 | strlen(stat_type_strings[STAT_TYPE_RECV_PULL_REQ]))) | 275 | stat_str, |
274 | { | 276 | strlen ( |
275 | return STAT_TYPE_RECV_PULL_REQ; | 277 | stat_type_strings[STAT_TYPE_RECV_PUSH_SEND_MH]))) |
276 | } | 278 | { |
277 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH], | 279 | return STAT_TYPE_RECV_PUSH_SEND_MH; |
278 | stat_str, | 280 | } |
279 | strlen(stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH]))) | 281 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REQ], |
280 | { | 282 | stat_str, |
281 | return STAT_TYPE_RECV_PULL_REQ_MH; | 283 | strlen (stat_type_strings[STAT_TYPE_RECV_PULL_REQ]))) |
282 | } | 284 | { |
283 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_RECV_PULL_REP], | 285 | return STAT_TYPE_RECV_PULL_REQ; |
284 | stat_str, | 286 | } |
285 | strlen(stat_type_strings[STAT_TYPE_RECV_PULL_REP]))) | 287 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH], |
286 | { | 288 | stat_str, |
287 | return STAT_TYPE_RECV_PULL_REP; | 289 | strlen ( |
288 | } | 290 | stat_type_strings[STAT_TYPE_RECV_PULL_REQ_MH]))) |
289 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH], | 291 | { |
290 | stat_str, | 292 | return STAT_TYPE_RECV_PULL_REQ_MH; |
291 | strlen(stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH]))) | 293 | } |
292 | { | 294 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REP], |
293 | return STAT_TYPE_RECV_PULL_REP_MH; | 295 | stat_str, |
294 | } | 296 | strlen (stat_type_strings[STAT_TYPE_RECV_PULL_REP]))) |
295 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_VIEW_SIZE], | 297 | { |
296 | stat_str, | 298 | return STAT_TYPE_RECV_PULL_REP; |
297 | strlen(stat_type_strings[STAT_TYPE_VIEW_SIZE]))) | 299 | } |
298 | { | 300 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH], |
299 | return STAT_TYPE_VIEW_SIZE; | 301 | stat_str, |
300 | } | 302 | strlen ( |
301 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_KNOWN_PEERS], | 303 | stat_type_strings[STAT_TYPE_RECV_PULL_REP_MH]))) |
302 | stat_str, | 304 | { |
303 | strlen(stat_type_strings[STAT_TYPE_KNOWN_PEERS]))) | 305 | return STAT_TYPE_RECV_PULL_REP_MH; |
304 | { | 306 | } |
305 | return STAT_TYPE_KNOWN_PEERS; | 307 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_VIEW_SIZE], |
306 | } | 308 | stat_str, |
307 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_VALID_PEERS], | 309 | strlen (stat_type_strings[STAT_TYPE_VIEW_SIZE]))) |
308 | stat_str, | 310 | { |
309 | strlen(stat_type_strings[STAT_TYPE_VALID_PEERS]))) | 311 | return STAT_TYPE_VIEW_SIZE; |
310 | { | 312 | } |
311 | return STAT_TYPE_VALID_PEERS; | 313 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_KNOWN_PEERS], |
312 | } | 314 | stat_str, |
313 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_LEARND_PEERS], | 315 | strlen (stat_type_strings[STAT_TYPE_KNOWN_PEERS]))) |
314 | stat_str, | 316 | { |
315 | strlen(stat_type_strings[STAT_TYPE_LEARND_PEERS]))) | 317 | return STAT_TYPE_KNOWN_PEERS; |
316 | { | 318 | } |
317 | return STAT_TYPE_LEARND_PEERS; | 319 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_VALID_PEERS], |
318 | } | 320 | stat_str, |
319 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS], | 321 | strlen (stat_type_strings[STAT_TYPE_VALID_PEERS]))) |
320 | stat_str, | 322 | { |
321 | strlen(stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS]))) | 323 | return STAT_TYPE_VALID_PEERS; |
322 | { | 324 | } |
323 | return STAT_TYPE_PENDING_ONLINE_CHECKS; | 325 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_LEARND_PEERS], |
324 | } | 326 | stat_str, |
325 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES], | 327 | strlen (stat_type_strings[STAT_TYPE_LEARND_PEERS]))) |
326 | stat_str, | 328 | { |
327 | strlen(stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES]))) | 329 | return STAT_TYPE_LEARND_PEERS; |
328 | { | 330 | } |
329 | return STAT_TYPE_UNREQUESTED_PULL_REPLIES; | 331 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS], |
330 | } | 332 | stat_str, |
331 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP], | 333 | strlen ( |
332 | stat_str, | 334 | stat_type_strings[STAT_TYPE_PENDING_ONLINE_CHECKS]))) |
333 | strlen(stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP]))) | 335 | { |
334 | { | 336 | return STAT_TYPE_PENDING_ONLINE_CHECKS; |
335 | return STAT_TYPE_PEERS_IN_PUSH_MAP; | 337 | } |
336 | } | 338 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES], |
337 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP], | 339 | stat_str, |
338 | stat_str, | 340 | strlen ( |
339 | strlen(stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP]))) | 341 | stat_type_strings[STAT_TYPE_UNREQUESTED_PULL_REPLIES]))) |
340 | { | 342 | { |
341 | return STAT_TYPE_PEERS_IN_PULL_MAP; | 343 | return STAT_TYPE_UNREQUESTED_PULL_REPLIES; |
342 | } | 344 | } |
343 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_PEERS_IN_VIEW], | 345 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP], |
344 | stat_str, | 346 | stat_str, |
345 | strlen(stat_type_strings[STAT_TYPE_PEERS_IN_VIEW]))) | 347 | strlen ( |
346 | { | 348 | stat_type_strings[STAT_TYPE_PEERS_IN_PUSH_MAP]))) |
347 | return STAT_TYPE_PEERS_IN_VIEW; | 349 | { |
348 | } | 350 | return STAT_TYPE_PEERS_IN_PUSH_MAP; |
349 | else if (0 == strncmp(stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM], | 351 | } |
350 | stat_str, | 352 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP], |
351 | strlen(stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM]))) | 353 | stat_str, |
352 | { | 354 | strlen ( |
353 | return STAT_TYPE_VIEW_SIZE_AIM; | 355 | stat_type_strings[STAT_TYPE_PEERS_IN_PULL_MAP]))) |
354 | } | 356 | { |
357 | return STAT_TYPE_PEERS_IN_PULL_MAP; | ||
358 | } | ||
359 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_PEERS_IN_VIEW], | ||
360 | stat_str, | ||
361 | strlen (stat_type_strings[STAT_TYPE_PEERS_IN_VIEW]))) | ||
362 | { | ||
363 | return STAT_TYPE_PEERS_IN_VIEW; | ||
364 | } | ||
365 | else if (0 == strncmp (stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM], | ||
366 | stat_str, | ||
367 | strlen (stat_type_strings[STAT_TYPE_VIEW_SIZE_AIM]))) | ||
368 | { | ||
369 | return STAT_TYPE_VIEW_SIZE_AIM; | ||
370 | } | ||
355 | return STAT_TYPE_MAX; | 371 | return STAT_TYPE_MAX; |
356 | } | 372 | } |
357 | 373 | ||
@@ -359,7 +375,8 @@ enum STAT_TYPE stat_str_2_type(const char *stat_str) | |||
359 | /** | 375 | /** |
360 | * @brief Indicates whether peer should go off- or online | 376 | * @brief Indicates whether peer should go off- or online |
361 | */ | 377 | */ |
362 | enum PEER_ONLINE_DELTA { | 378 | enum PEER_ONLINE_DELTA |
379 | { | ||
363 | /** | 380 | /** |
364 | * @brief Indicates peer going online | 381 | * @brief Indicates peer going online |
365 | */ | 382 | */ |
@@ -373,7 +390,8 @@ enum PEER_ONLINE_DELTA { | |||
373 | /** | 390 | /** |
374 | * Operation map entry | 391 | * Operation map entry |
375 | */ | 392 | */ |
376 | struct OpListEntry { | 393 | struct OpListEntry |
394 | { | ||
377 | /** | 395 | /** |
378 | * DLL next ptr | 396 | * DLL next ptr |
379 | */ | 397 | */ |
@@ -415,7 +433,8 @@ static struct OpListEntry *oplist_tail; | |||
415 | /** | 433 | /** |
416 | * A pending reply: A request was sent and the reply is pending. | 434 | * A pending reply: A request was sent and the reply is pending. |
417 | */ | 435 | */ |
418 | struct PendingReply { | 436 | struct PendingReply |
437 | { | ||
419 | /** | 438 | /** |
420 | * DLL next,prev ptr | 439 | * DLL next,prev ptr |
421 | */ | 440 | */ |
@@ -437,7 +456,8 @@ struct PendingReply { | |||
437 | /** | 456 | /** |
438 | * A pending request: A request was not made yet but is scheduled for later. | 457 | * A pending request: A request was not made yet but is scheduled for later. |
439 | */ | 458 | */ |
440 | struct PendingRequest { | 459 | struct PendingRequest |
460 | { | ||
441 | /** | 461 | /** |
442 | * DLL next,prev ptr | 462 | * DLL next,prev ptr |
443 | */ | 463 | */ |
@@ -459,7 +479,8 @@ struct PendingRequest { | |||
459 | /** | 479 | /** |
460 | * Information we track for each peer. | 480 | * Information we track for each peer. |
461 | */ | 481 | */ |
462 | struct RPSPeer { | 482 | struct RPSPeer |
483 | { | ||
463 | /** | 484 | /** |
464 | * Index of the peer. | 485 | * Index of the peer. |
465 | */ | 486 | */ |
@@ -483,7 +504,7 @@ struct RPSPeer { | |||
483 | /** | 504 | /** |
484 | * A request handle to check for an request | 505 | * A request handle to check for an request |
485 | */ | 506 | */ |
486 | //struct GNUNET_RPS_Request_Handle *req_handle; | 507 | // struct GNUNET_RPS_Request_Handle *req_handle; |
487 | 508 | ||
488 | /** | 509 | /** |
489 | * Peer on- or offline? | 510 | * Peer on- or offline? |
@@ -685,7 +706,8 @@ typedef int (*EvaluationCallback) (void); | |||
685 | /** | 706 | /** |
686 | * @brief Do we have Churn? | 707 | * @brief Do we have Churn? |
687 | */ | 708 | */ |
688 | enum OPTION_CHURN { | 709 | enum OPTION_CHURN |
710 | { | ||
689 | /** | 711 | /** |
690 | * @brief If we have churn this is set | 712 | * @brief If we have churn this is set |
691 | */ | 713 | */ |
@@ -699,7 +721,8 @@ enum OPTION_CHURN { | |||
699 | /** | 721 | /** |
700 | * @brief Is it ok to quit the test before the timeout? | 722 | * @brief Is it ok to quit the test before the timeout? |
701 | */ | 723 | */ |
702 | enum OPTION_QUICK_QUIT { | 724 | enum OPTION_QUICK_QUIT |
725 | { | ||
703 | /** | 726 | /** |
704 | * @brief It is ok for the test to quit before the timeout triggers | 727 | * @brief It is ok for the test to quit before the timeout triggers |
705 | */ | 728 | */ |
@@ -714,7 +737,8 @@ enum OPTION_QUICK_QUIT { | |||
714 | /** | 737 | /** |
715 | * @brief Do we collect statistics at the end? | 738 | * @brief Do we collect statistics at the end? |
716 | */ | 739 | */ |
717 | enum OPTION_COLLECT_STATISTICS { | 740 | enum OPTION_COLLECT_STATISTICS |
741 | { | ||
718 | /** | 742 | /** |
719 | * @brief We collect statistics at the end | 743 | * @brief We collect statistics at the end |
720 | */ | 744 | */ |
@@ -729,7 +753,8 @@ enum OPTION_COLLECT_STATISTICS { | |||
729 | /** | 753 | /** |
730 | * @brief Do we collect views during run? | 754 | * @brief Do we collect views during run? |
731 | */ | 755 | */ |
732 | enum OPTION_COLLECT_VIEW { | 756 | enum OPTION_COLLECT_VIEW |
757 | { | ||
733 | /** | 758 | /** |
734 | * @brief We collect view during run | 759 | * @brief We collect view during run |
735 | */ | 760 | */ |
@@ -744,7 +769,8 @@ enum OPTION_COLLECT_VIEW { | |||
744 | /** | 769 | /** |
745 | * Structure to define a single test | 770 | * Structure to define a single test |
746 | */ | 771 | */ |
747 | struct SingleTestRun { | 772 | struct SingleTestRun |
773 | { | ||
748 | /** | 774 | /** |
749 | * Name of the test | 775 | * Name of the test |
750 | */ | 776 | */ |
@@ -831,7 +857,7 @@ static int in_shutdown; | |||
831 | * Append arguments to file | 857 | * Append arguments to file |
832 | */ | 858 | */ |
833 | static void | 859 | static void |
834 | tofile_(const char *file_name, const char *line) | 860 | tofile_ (const char *file_name, const char *line) |
835 | { | 861 | { |
836 | struct GNUNET_DISK_FileHandle *f; | 862 | struct GNUNET_DISK_FileHandle *f; |
837 | /* char output_buffer[512]; */ | 863 | /* char output_buffer[512]; */ |
@@ -839,20 +865,20 @@ tofile_(const char *file_name, const char *line) | |||
839 | /* int size; */ | 865 | /* int size; */ |
840 | size_t size2; | 866 | size_t size2; |
841 | 867 | ||
842 | if (NULL == (f = GNUNET_DISK_file_open(file_name, | 868 | if (NULL == (f = GNUNET_DISK_file_open (file_name, |
843 | GNUNET_DISK_OPEN_APPEND | | 869 | GNUNET_DISK_OPEN_APPEND |
844 | GNUNET_DISK_OPEN_WRITE | | 870 | | GNUNET_DISK_OPEN_WRITE |
845 | GNUNET_DISK_OPEN_CREATE, | 871 | | GNUNET_DISK_OPEN_CREATE, |
846 | GNUNET_DISK_PERM_USER_READ | | 872 | GNUNET_DISK_PERM_USER_READ |
847 | GNUNET_DISK_PERM_USER_WRITE | | 873 | | GNUNET_DISK_PERM_USER_WRITE |
848 | GNUNET_DISK_PERM_GROUP_READ | | 874 | | GNUNET_DISK_PERM_GROUP_READ |
849 | GNUNET_DISK_PERM_OTHER_READ))) | 875 | | GNUNET_DISK_PERM_OTHER_READ))) |
850 | { | 876 | { |
851 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 877 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
852 | "Not able to open file %s\n", | 878 | "Not able to open file %s\n", |
853 | file_name); | 879 | file_name); |
854 | return; | 880 | return; |
855 | } | 881 | } |
856 | /* size = GNUNET_snprintf (output_buffer, | 882 | /* size = GNUNET_snprintf (output_buffer, |
857 | sizeof (output_buffer), | 883 | sizeof (output_buffer), |
858 | "%llu %s\n", | 884 | "%llu %s\n", |
@@ -866,43 +892,43 @@ tofile_(const char *file_name, const char *line) | |||
866 | return; | 892 | return; |
867 | } */ | 893 | } */ |
868 | 894 | ||
869 | size = strlen(line) * sizeof(char); | 895 | size = strlen (line) * sizeof(char); |
870 | 896 | ||
871 | size2 = GNUNET_DISK_file_write(f, line, size); | 897 | size2 = GNUNET_DISK_file_write (f, line, size); |
872 | if (size != size2) | 898 | if (size != size2) |
899 | { | ||
900 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
901 | "Unable to write to file! (Size: %lu, size2: %lu)\n", | ||
902 | size, | ||
903 | size2); | ||
904 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) | ||
873 | { | 905 | { |
874 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 906 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
875 | "Unable to write to file! (Size: %lu, size2: %lu)\n", | 907 | "Unable to close file\n"); |
876 | size, | ||
877 | size2); | ||
878 | if (GNUNET_YES != GNUNET_DISK_file_close(f)) | ||
879 | { | ||
880 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
881 | "Unable to close file\n"); | ||
882 | } | ||
883 | return; | ||
884 | } | 908 | } |
909 | return; | ||
910 | } | ||
885 | 911 | ||
886 | if (GNUNET_YES != GNUNET_DISK_file_close(f)) | 912 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) |
887 | { | 913 | { |
888 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 914 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
889 | "Unable to close file\n"); | 915 | "Unable to close file\n"); |
890 | } | 916 | } |
891 | } | 917 | } |
892 | 918 | ||
893 | /** | 919 | /** |
894 | * This function is used to facilitate writing important information to disk | 920 | * This function is used to facilitate writing important information to disk |
895 | */ | 921 | */ |
896 | #define tofile(file_name, ...) do { \ | 922 | #define tofile(file_name, ...) do { \ |
897 | char tmp_buf[512]; \ | 923 | char tmp_buf[512]; \ |
898 | int size; \ | 924 | int size; \ |
899 | size = GNUNET_snprintf(tmp_buf, sizeof(tmp_buf), __VA_ARGS__); \ | 925 | size = GNUNET_snprintf (tmp_buf, sizeof(tmp_buf), __VA_ARGS__); \ |
900 | if (0 > size) \ | 926 | if (0 > size) \ |
901 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ | 927 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ |
902 | "Failed to create tmp_buf\n"); \ | 928 | "Failed to create tmp_buf\n"); \ |
903 | else \ | 929 | else \ |
904 | tofile_ (file_name, tmp_buf); \ | 930 | tofile_ (file_name, tmp_buf); \ |
905 | } while (0); | 931 | } while (0); |
906 | 932 | ||
907 | 933 | ||
908 | /** | 934 | /** |
@@ -929,7 +955,7 @@ tofile_(const char *file_name, const char *line) | |||
929 | * Test the success of a single test | 955 | * Test the success of a single test |
930 | */ | 956 | */ |
931 | static int | 957 | static int |
932 | evaluate(void) | 958 | evaluate (void) |
933 | { | 959 | { |
934 | unsigned int i; | 960 | unsigned int i; |
935 | int tmp_ok; | 961 | int tmp_ok; |
@@ -937,16 +963,16 @@ evaluate(void) | |||
937 | tmp_ok = 1; | 963 | tmp_ok = 1; |
938 | 964 | ||
939 | for (i = 0; i < num_peers; i++) | 965 | for (i = 0; i < num_peers; i++) |
940 | { | 966 | { |
941 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
942 | "%u. peer [%s] received %u of %u expected peer_ids: %i\n", | 968 | "%u. peer [%s] received %u of %u expected peer_ids: %i\n", |
943 | i, | 969 | i, |
944 | GNUNET_i2s(rps_peers[i].peer_id), | 970 | GNUNET_i2s (rps_peers[i].peer_id), |
945 | rps_peers[i].num_recv_ids, | 971 | rps_peers[i].num_recv_ids, |
946 | rps_peers[i].num_ids_to_request, | 972 | rps_peers[i].num_ids_to_request, |
947 | (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids)); | 973 | (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids)); |
948 | tmp_ok &= (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids); | 974 | tmp_ok &= (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids); |
949 | } | 975 | } |
950 | return tmp_ok ? 0 : 1; | 976 | return tmp_ok ? 0 : 1; |
951 | } | 977 | } |
952 | 978 | ||
@@ -955,12 +981,12 @@ evaluate(void) | |||
955 | * Creates an oplist entry and adds it to the oplist DLL | 981 | * Creates an oplist entry and adds it to the oplist DLL |
956 | */ | 982 | */ |
957 | static struct OpListEntry * | 983 | static struct OpListEntry * |
958 | make_oplist_entry() | 984 | make_oplist_entry () |
959 | { | 985 | { |
960 | struct OpListEntry *entry; | 986 | struct OpListEntry *entry; |
961 | 987 | ||
962 | entry = GNUNET_new(struct OpListEntry); | 988 | entry = GNUNET_new (struct OpListEntry); |
963 | GNUNET_CONTAINER_DLL_insert_tail(oplist_head, oplist_tail, entry); | 989 | GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry); |
964 | return entry; | 990 | return entry; |
965 | } | 991 | } |
966 | 992 | ||
@@ -974,15 +1000,15 @@ make_oplist_entry() | |||
974 | * @return #GNUNET_YES if so | 1000 | * @return #GNUNET_YES if so |
975 | * #GNUNET_NO otherwise | 1001 | * #GNUNET_NO otherwise |
976 | */ | 1002 | */ |
977 | static int check_statistics_collect_completed_single_peer( | 1003 | static int check_statistics_collect_completed_single_peer ( |
978 | const struct RPSPeer *rps_peer) | 1004 | const struct RPSPeer *rps_peer) |
979 | { | 1005 | { |
980 | if (cur_test_run.stat_collect_flags != | 1006 | if (cur_test_run.stat_collect_flags != |
981 | (cur_test_run.stat_collect_flags & | 1007 | (cur_test_run.stat_collect_flags |
982 | rps_peer->stat_collected_flags)) | 1008 | & rps_peer->stat_collected_flags)) |
983 | { | 1009 | { |
984 | return GNUNET_NO; | 1010 | return GNUNET_NO; |
985 | } | 1011 | } |
986 | return GNUNET_YES; | 1012 | return GNUNET_YES; |
987 | } | 1013 | } |
988 | /** | 1014 | /** |
@@ -992,153 +1018,155 @@ static int check_statistics_collect_completed_single_peer( | |||
992 | * @return #GNUNET_YES if so | 1018 | * @return #GNUNET_YES if so |
993 | * #GNUNET_NO otherwise | 1019 | * #GNUNET_NO otherwise |
994 | */ | 1020 | */ |
995 | static int check_statistics_collect_completed() | 1021 | static int check_statistics_collect_completed () |
996 | { | 1022 | { |
997 | uint32_t i; | 1023 | uint32_t i; |
998 | 1024 | ||
999 | for (i = 0; i < num_peers; i++) | 1025 | for (i = 0; i < num_peers; i++) |
1000 | { | 1026 | { |
1001 | if (GNUNET_NO == check_statistics_collect_completed_single_peer(&rps_peers[i])) | 1027 | if (GNUNET_NO == check_statistics_collect_completed_single_peer ( |
1002 | { | 1028 | &rps_peers[i])) |
1003 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1029 | { |
1004 | "At least Peer %" PRIu32 " did not yet receive all statistics values\n", | 1030 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1005 | i); | 1031 | "At least Peer %" PRIu32 |
1006 | return GNUNET_NO; | 1032 | " did not yet receive all statistics values\n", |
1007 | } | 1033 | i); |
1034 | return GNUNET_NO; | ||
1008 | } | 1035 | } |
1009 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1036 | } |
1010 | "All peers received their statistics values\n"); | 1037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1038 | "All peers received their statistics values\n"); | ||
1011 | return GNUNET_YES; | 1039 | return GNUNET_YES; |
1012 | } | 1040 | } |
1013 | 1041 | ||
1014 | static void | 1042 | static void |
1015 | rps_disconnect_adapter(void *cls, | 1043 | rps_disconnect_adapter (void *cls, |
1016 | void *op_result); | 1044 | void *op_result); |
1017 | 1045 | ||
1018 | static void | 1046 | static void |
1019 | cancel_pending_req(struct PendingRequest *pending_req) | 1047 | cancel_pending_req (struct PendingRequest *pending_req) |
1020 | { | 1048 | { |
1021 | struct RPSPeer *rps_peer; | 1049 | struct RPSPeer *rps_peer; |
1022 | 1050 | ||
1023 | rps_peer = pending_req->rps_peer; | 1051 | rps_peer = pending_req->rps_peer; |
1024 | GNUNET_CONTAINER_DLL_remove(rps_peer->pending_req_head, | 1052 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, |
1025 | rps_peer->pending_req_tail, | 1053 | rps_peer->pending_req_tail, |
1026 | pending_req); | 1054 | pending_req); |
1027 | rps_peer->num_pending_reqs--; | 1055 | rps_peer->num_pending_reqs--; |
1028 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1056 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1029 | "Cancelling pending rps get request\n"); | 1057 | "Cancelling pending rps get request\n"); |
1030 | GNUNET_SCHEDULER_cancel(pending_req->request_task); | 1058 | GNUNET_SCHEDULER_cancel (pending_req->request_task); |
1031 | GNUNET_free(pending_req); | 1059 | GNUNET_free (pending_req); |
1032 | } | 1060 | } |
1033 | 1061 | ||
1034 | static void | 1062 | static void |
1035 | cancel_request(struct PendingReply *pending_rep) | 1063 | cancel_request (struct PendingReply *pending_rep) |
1036 | { | 1064 | { |
1037 | struct RPSPeer *rps_peer; | 1065 | struct RPSPeer *rps_peer; |
1038 | 1066 | ||
1039 | rps_peer = pending_rep->rps_peer; | 1067 | rps_peer = pending_rep->rps_peer; |
1040 | GNUNET_CONTAINER_DLL_remove(rps_peer->pending_rep_head, | 1068 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head, |
1041 | rps_peer->pending_rep_tail, | 1069 | rps_peer->pending_rep_tail, |
1042 | pending_rep); | 1070 | pending_rep); |
1043 | rps_peer->num_pending_reps--; | 1071 | rps_peer->num_pending_reps--; |
1044 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1072 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1045 | "Cancelling rps get reply\n"); | 1073 | "Cancelling rps get reply\n"); |
1046 | GNUNET_assert(NULL != pending_rep->req_handle); | 1074 | GNUNET_assert (NULL != pending_rep->req_handle); |
1047 | GNUNET_RPS_request_single_info_cancel(pending_rep->req_handle); | 1075 | GNUNET_RPS_request_single_info_cancel (pending_rep->req_handle); |
1048 | pending_rep->req_handle = NULL; | 1076 | pending_rep->req_handle = NULL; |
1049 | GNUNET_free(pending_rep); | 1077 | GNUNET_free (pending_rep); |
1050 | pending_rep = NULL; | 1078 | pending_rep = NULL; |
1051 | } | 1079 | } |
1052 | 1080 | ||
1053 | void | 1081 | void |
1054 | clean_peer(unsigned peer_index) | 1082 | clean_peer (unsigned peer_index) |
1055 | { | 1083 | { |
1056 | struct PendingRequest *pending_req; | 1084 | struct PendingRequest *pending_req; |
1057 | 1085 | ||
1058 | while (NULL != (pending_req = rps_peers[peer_index].pending_req_head)) | 1086 | while (NULL != (pending_req = rps_peers[peer_index].pending_req_head)) |
1059 | { | 1087 | { |
1060 | cancel_pending_req(pending_req); | 1088 | cancel_pending_req (pending_req); |
1061 | } | 1089 | } |
1062 | pending_req = rps_peers[peer_index].pending_req_head; | 1090 | pending_req = rps_peers[peer_index].pending_req_head; |
1063 | rps_disconnect_adapter(&rps_peers[peer_index], | 1091 | rps_disconnect_adapter (&rps_peers[peer_index], |
1064 | &rps_peers[peer_index].rps_handle); | 1092 | &rps_peers[peer_index].rps_handle); |
1065 | for (unsigned stat_type = STAT_TYPE_ROUNDS; | 1093 | for (unsigned stat_type = STAT_TYPE_ROUNDS; |
1066 | stat_type < STAT_TYPE_MAX; | 1094 | stat_type < STAT_TYPE_MAX; |
1067 | stat_type++) | 1095 | stat_type++) |
1096 | { | ||
1097 | if (NULL != rps_peers[peer_index].h_stat_get[stat_type]) | ||
1068 | { | 1098 | { |
1069 | if (NULL != rps_peers[peer_index].h_stat_get[stat_type]) | 1099 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1070 | { | 1100 | "(%u) did not yet receive stat value for `%s'\n", |
1071 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1101 | rps_peers[peer_index].index, |
1072 | "(%u) did not yet receive stat value for `%s'\n", | 1102 | stat_type_strings[stat_type]); |
1073 | rps_peers[peer_index].index, | 1103 | GNUNET_STATISTICS_get_cancel ( |
1074 | stat_type_strings[stat_type]); | 1104 | rps_peers[peer_index].h_stat_get[stat_type]); |
1075 | GNUNET_STATISTICS_get_cancel( | ||
1076 | rps_peers[peer_index].h_stat_get[stat_type]); | ||
1077 | } | ||
1078 | } | 1105 | } |
1106 | } | ||
1079 | if (NULL != rps_peers[peer_index].op) | 1107 | if (NULL != rps_peers[peer_index].op) |
1080 | { | 1108 | { |
1081 | GNUNET_TESTBED_operation_done(rps_peers[peer_index].op); | 1109 | GNUNET_TESTBED_operation_done (rps_peers[peer_index].op); |
1082 | rps_peers[peer_index].op = NULL; | 1110 | rps_peers[peer_index].op = NULL; |
1083 | } | 1111 | } |
1084 | } | 1112 | } |
1085 | 1113 | ||
1086 | /** | 1114 | /** |
1087 | * Task run on timeout to shut everything down. | 1115 | * Task run on timeout to shut everything down. |
1088 | */ | 1116 | */ |
1089 | static void | 1117 | static void |
1090 | shutdown_op(void *cls) | 1118 | shutdown_op (void *cls) |
1091 | { | 1119 | { |
1092 | unsigned int i; | 1120 | unsigned int i; |
1093 | struct OpListEntry *entry; | 1121 | struct OpListEntry *entry; |
1094 | 1122 | ||
1095 | (void)cls; | 1123 | (void) cls; |
1096 | 1124 | ||
1097 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1125 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1098 | "Shutdown task scheduled, going down.\n"); | 1126 | "Shutdown task scheduled, going down.\n"); |
1099 | in_shutdown = GNUNET_YES; | 1127 | in_shutdown = GNUNET_YES; |
1100 | 1128 | ||
1101 | if (NULL != shutdown_task) | 1129 | if (NULL != shutdown_task) |
1102 | { | 1130 | { |
1103 | GNUNET_SCHEDULER_cancel(shutdown_task); | 1131 | GNUNET_SCHEDULER_cancel (shutdown_task); |
1104 | shutdown_task = NULL; | 1132 | shutdown_task = NULL; |
1105 | } | 1133 | } |
1106 | if (NULL != post_test_task) | 1134 | if (NULL != post_test_task) |
1107 | { | 1135 | { |
1108 | GNUNET_SCHEDULER_cancel(post_test_task); | 1136 | GNUNET_SCHEDULER_cancel (post_test_task); |
1109 | post_test_task = NULL; | 1137 | post_test_task = NULL; |
1110 | } | 1138 | } |
1111 | if (NULL != churn_task) | 1139 | if (NULL != churn_task) |
1112 | { | 1140 | { |
1113 | GNUNET_SCHEDULER_cancel(churn_task); | 1141 | GNUNET_SCHEDULER_cancel (churn_task); |
1114 | churn_task = NULL; | 1142 | churn_task = NULL; |
1115 | } | 1143 | } |
1116 | entry = oplist_head; | 1144 | entry = oplist_head; |
1117 | while (NULL != (entry = oplist_head)) | 1145 | while (NULL != (entry = oplist_head)) |
1118 | { | 1146 | { |
1119 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1147 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1120 | "Operation still pending on shutdown (%u)\n", | 1148 | "Operation still pending on shutdown (%u)\n", |
1121 | entry->index); | 1149 | entry->index); |
1122 | GNUNET_TESTBED_operation_done(entry->op); | 1150 | GNUNET_TESTBED_operation_done (entry->op); |
1123 | GNUNET_CONTAINER_DLL_remove(oplist_head, oplist_tail, entry); | 1151 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
1124 | GNUNET_free(entry); | 1152 | GNUNET_free (entry); |
1125 | } | 1153 | } |
1126 | for (i = 0; i < num_peers; i++) | 1154 | for (i = 0; i < num_peers; i++) |
1127 | { | 1155 | { |
1128 | clean_peer(i); | 1156 | clean_peer (i); |
1129 | } | 1157 | } |
1130 | close_all_files(); | 1158 | close_all_files (); |
1131 | } | 1159 | } |
1132 | 1160 | ||
1133 | static void | 1161 | static void |
1134 | trigger_shutdown(void *cls) | 1162 | trigger_shutdown (void *cls) |
1135 | { | 1163 | { |
1136 | (void)cls; | 1164 | (void) cls; |
1137 | 1165 | ||
1138 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1166 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1139 | "Shutdown was triggerd by timeout, going down.\n"); | 1167 | "Shutdown was triggerd by timeout, going down.\n"); |
1140 | shutdown_task = NULL; | 1168 | shutdown_task = NULL; |
1141 | GNUNET_SCHEDULER_shutdown(); | 1169 | GNUNET_SCHEDULER_shutdown (); |
1142 | } | 1170 | } |
1143 | 1171 | ||
1144 | 1172 | ||
@@ -1146,47 +1174,48 @@ trigger_shutdown(void *cls) | |||
1146 | * Task run after #duration to collect statistics and potentially shut down. | 1174 | * Task run after #duration to collect statistics and potentially shut down. |
1147 | */ | 1175 | */ |
1148 | static void | 1176 | static void |
1149 | post_test_op(void *cls) | 1177 | post_test_op (void *cls) |
1150 | { | 1178 | { |
1151 | unsigned int i; | 1179 | unsigned int i; |
1152 | 1180 | ||
1153 | (void)cls; | 1181 | (void) cls; |
1154 | 1182 | ||
1155 | post_test_task = NULL; | 1183 | post_test_task = NULL; |
1156 | post_test = GNUNET_YES; | 1184 | post_test = GNUNET_YES; |
1157 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1185 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1158 | "Executing post test op.\n"); | 1186 | "Executing post test op.\n"); |
1159 | if (NULL != churn_task) | 1187 | if (NULL != churn_task) |
1160 | { | 1188 | { |
1161 | GNUNET_SCHEDULER_cancel(churn_task); | 1189 | GNUNET_SCHEDULER_cancel (churn_task); |
1162 | churn_task = NULL; | 1190 | churn_task = NULL; |
1163 | } | 1191 | } |
1164 | for (i = 0; i < num_peers; i++) | 1192 | for (i = 0; i < num_peers; i++) |
1193 | { | ||
1194 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1195 | "Executing post test op. (peer %" PRIu32 ")\n", | ||
1196 | rps_peers[i].index); | ||
1197 | if (NULL != rps_peers[i].op) | ||
1165 | { | 1198 | { |
1166 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1199 | GNUNET_TESTBED_operation_done (rps_peers[i].op); |
1167 | "Executing post test op. (peer %" PRIu32 ")\n", | 1200 | rps_peers[i].op = NULL; |
1168 | rps_peers[i].index); | 1201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1169 | if (NULL != rps_peers[i].op) | 1202 | "Cancelled testbed operation\n"); |
1170 | { | ||
1171 | GNUNET_TESTBED_operation_done(rps_peers[i].op); | ||
1172 | rps_peers[i].op = NULL; | ||
1173 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
1174 | "Cancelled testbed operation\n"); | ||
1175 | } | ||
1176 | if (NULL != cur_test_run.post_test) | ||
1177 | { | ||
1178 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i); | ||
1179 | cur_test_run.post_test(&rps_peers[i]); | ||
1180 | } | ||
1181 | } | 1203 | } |
1182 | /* If we do not collect statistics, shut down directly */ | 1204 | if (NULL != cur_test_run.post_test) |
1183 | if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics || | ||
1184 | GNUNET_YES == check_statistics_collect_completed()) | ||
1185 | { | 1205 | { |
1186 | GNUNET_SCHEDULER_cancel(shutdown_task); | 1206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", |
1187 | shutdown_task = NULL; | 1207 | i); |
1188 | GNUNET_SCHEDULER_shutdown(); | 1208 | cur_test_run.post_test (&rps_peers[i]); |
1189 | } | 1209 | } |
1210 | } | ||
1211 | /* If we do not collect statistics, shut down directly */ | ||
1212 | if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics)|| | ||
1213 | (GNUNET_YES == check_statistics_collect_completed ()) ) | ||
1214 | { | ||
1215 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
1216 | shutdown_task = NULL; | ||
1217 | GNUNET_SCHEDULER_shutdown (); | ||
1218 | } | ||
1190 | } | 1219 | } |
1191 | 1220 | ||
1192 | 1221 | ||
@@ -1194,22 +1223,22 @@ post_test_op(void *cls) | |||
1194 | * Seed peers. | 1223 | * Seed peers. |
1195 | */ | 1224 | */ |
1196 | static void | 1225 | static void |
1197 | seed_peers(void *cls) | 1226 | seed_peers (void *cls) |
1198 | { | 1227 | { |
1199 | struct RPSPeer *peer = cls; | 1228 | struct RPSPeer *peer = cls; |
1200 | unsigned int amount; | 1229 | unsigned int amount; |
1201 | unsigned int i; | 1230 | unsigned int i; |
1202 | 1231 | ||
1203 | // TODO if malicious don't seed mal peers | 1232 | // TODO if malicious don't seed mal peers |
1204 | amount = round(.5 * num_peers); | 1233 | amount = round (.5 * num_peers); |
1205 | 1234 | ||
1206 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n"); | 1235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n"); |
1207 | for (i = 0; i < amount; i++) | 1236 | for (i = 0; i < amount; i++) |
1208 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n", | 1237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n", |
1209 | i, | 1238 | i, |
1210 | GNUNET_i2s(&rps_peer_ids[i])); | 1239 | GNUNET_i2s (&rps_peer_ids[i])); |
1211 | 1240 | ||
1212 | GNUNET_RPS_seed_ids(peer->rps_handle, amount, rps_peer_ids); | 1241 | GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids); |
1213 | } | 1242 | } |
1214 | 1243 | ||
1215 | 1244 | ||
@@ -1217,48 +1246,48 @@ seed_peers(void *cls) | |||
1217 | * Get the id of peer i. | 1246 | * Get the id of peer i. |
1218 | */ | 1247 | */ |
1219 | void | 1248 | void |
1220 | info_cb(void *cb_cls, | 1249 | info_cb (void *cb_cls, |
1221 | struct GNUNET_TESTBED_Operation *op, | 1250 | struct GNUNET_TESTBED_Operation *op, |
1222 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | 1251 | const struct GNUNET_TESTBED_PeerInformation *pinfo, |
1223 | const char *emsg) | 1252 | const char *emsg) |
1224 | { | 1253 | { |
1225 | struct OpListEntry *entry = (struct OpListEntry *)cb_cls; | 1254 | struct OpListEntry *entry = (struct OpListEntry *) cb_cls; |
1226 | 1255 | ||
1227 | (void)op; | 1256 | (void) op; |
1228 | 1257 | ||
1229 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 1258 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
1230 | { | 1259 | { |
1231 | return; | 1260 | return; |
1232 | } | 1261 | } |
1233 | 1262 | ||
1234 | if (NULL == pinfo || NULL != emsg) | 1263 | if ((NULL == pinfo)||(NULL != emsg)) |
1235 | { | 1264 | { |
1236 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); | 1265 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); |
1237 | GNUNET_TESTBED_operation_done(entry->op); | 1266 | GNUNET_TESTBED_operation_done (entry->op); |
1238 | return; | 1267 | return; |
1239 | } | 1268 | } |
1240 | 1269 | ||
1241 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1242 | "Peer %u is %s\n", | 1271 | "Peer %u is %s\n", |
1243 | entry->index, | 1272 | entry->index, |
1244 | GNUNET_i2s(pinfo->result.id)); | 1273 | GNUNET_i2s (pinfo->result.id)); |
1245 | 1274 | ||
1246 | rps_peer_ids[entry->index] = *(pinfo->result.id); | 1275 | rps_peer_ids[entry->index] = *(pinfo->result.id); |
1247 | rps_peers[entry->index].peer_id = &rps_peer_ids[entry->index]; | 1276 | rps_peers[entry->index].peer_id = &rps_peer_ids[entry->index]; |
1248 | 1277 | ||
1249 | GNUNET_assert(GNUNET_OK == | 1278 | GNUNET_assert (GNUNET_OK == |
1250 | GNUNET_CONTAINER_multipeermap_put(peer_map, | 1279 | GNUNET_CONTAINER_multipeermap_put (peer_map, |
1251 | &rps_peer_ids[entry->index], | 1280 | &rps_peer_ids[entry->index], |
1252 | &rps_peers[entry->index], | 1281 | &rps_peers[entry->index], |
1253 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1282 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1254 | tofile("/tmp/rps/peer_ids", | 1283 | tofile ("/tmp/rps/peer_ids", |
1255 | "%u\t%s\n", | 1284 | "%u\t%s\n", |
1256 | entry->index, | 1285 | entry->index, |
1257 | GNUNET_i2s_full(&rps_peer_ids[entry->index])); | 1286 | GNUNET_i2s_full (&rps_peer_ids[entry->index])); |
1258 | 1287 | ||
1259 | GNUNET_CONTAINER_DLL_remove(oplist_head, oplist_tail, entry); | 1288 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
1260 | GNUNET_TESTBED_operation_done(entry->op); | 1289 | GNUNET_TESTBED_operation_done (entry->op); |
1261 | GNUNET_free(entry); | 1290 | GNUNET_free (entry); |
1262 | } | 1291 | } |
1263 | 1292 | ||
1264 | 1293 | ||
@@ -1272,39 +1301,39 @@ info_cb(void *cb_cls, | |||
1272 | * operation has executed successfully. | 1301 | * operation has executed successfully. |
1273 | */ | 1302 | */ |
1274 | static void | 1303 | static void |
1275 | rps_connect_complete_cb(void *cls, | 1304 | rps_connect_complete_cb (void *cls, |
1276 | struct GNUNET_TESTBED_Operation *op, | 1305 | struct GNUNET_TESTBED_Operation *op, |
1277 | void *ca_result, | 1306 | void *ca_result, |
1278 | const char *emsg) | 1307 | const char *emsg) |
1279 | { | 1308 | { |
1280 | struct RPSPeer *rps_peer = cls; | 1309 | struct RPSPeer *rps_peer = cls; |
1281 | struct GNUNET_RPS_Handle *rps = ca_result; | 1310 | struct GNUNET_RPS_Handle *rps = ca_result; |
1282 | 1311 | ||
1283 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 1312 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
1284 | { | 1313 | { |
1285 | return; | 1314 | return; |
1286 | } | 1315 | } |
1287 | 1316 | ||
1288 | rps_peer->rps_handle = rps; | 1317 | rps_peer->rps_handle = rps; |
1289 | rps_peer->online = GNUNET_YES; | 1318 | rps_peer->online = GNUNET_YES; |
1290 | num_peers_online++; | 1319 | num_peers_online++; |
1291 | 1320 | ||
1292 | GNUNET_assert(op == rps_peer->op); | 1321 | GNUNET_assert (op == rps_peer->op); |
1293 | if (NULL != emsg) | 1322 | if (NULL != emsg) |
1294 | { | 1323 | { |
1295 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1324 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1296 | "Failed to connect to RPS service: %s\n", | 1325 | "Failed to connect to RPS service: %s\n", |
1297 | emsg); | 1326 | emsg); |
1298 | ok = 1; | 1327 | ok = 1; |
1299 | GNUNET_SCHEDULER_shutdown(); | 1328 | GNUNET_SCHEDULER_shutdown (); |
1300 | return; | 1329 | return; |
1301 | } | 1330 | } |
1302 | 1331 | ||
1303 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1304 | "Started client successfully (%u)\n", | 1333 | "Started client successfully (%u)\n", |
1305 | rps_peer->index); | 1334 | rps_peer->index); |
1306 | 1335 | ||
1307 | cur_test_run.main_test(rps_peer); | 1336 | cur_test_run.main_test (rps_peer); |
1308 | } | 1337 | } |
1309 | 1338 | ||
1310 | 1339 | ||
@@ -1319,15 +1348,15 @@ rps_connect_complete_cb(void *cls, | |||
1319 | * @return service handle to return in 'op_result', NULL on error | 1348 | * @return service handle to return in 'op_result', NULL on error |
1320 | */ | 1349 | */ |
1321 | static void * | 1350 | static void * |
1322 | rps_connect_adapter(void *cls, | 1351 | rps_connect_adapter (void *cls, |
1323 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1352 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1324 | { | 1353 | { |
1325 | struct GNUNET_RPS_Handle *h; | 1354 | struct GNUNET_RPS_Handle *h; |
1326 | 1355 | ||
1327 | h = GNUNET_RPS_connect(cfg); | 1356 | h = GNUNET_RPS_connect (cfg); |
1328 | 1357 | ||
1329 | if (NULL != cur_test_run.pre_test) | 1358 | if (NULL != cur_test_run.pre_test) |
1330 | cur_test_run.pre_test(cls, h); | 1359 | cur_test_run.pre_test (cls, h); |
1331 | 1360 | ||
1332 | return h; | 1361 | return h; |
1333 | } | 1362 | } |
@@ -1342,12 +1371,12 @@ rps_connect_adapter(void *cls, | |||
1342 | * @return service handle to return in 'op_result', NULL on error | 1371 | * @return service handle to return in 'op_result', NULL on error |
1343 | */ | 1372 | */ |
1344 | static void * | 1373 | static void * |
1345 | stat_connect_adapter(void *cls, | 1374 | stat_connect_adapter (void *cls, |
1346 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1375 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1347 | { | 1376 | { |
1348 | struct RPSPeer *peer = cls; | 1377 | struct RPSPeer *peer = cls; |
1349 | 1378 | ||
1350 | peer->stats_h = GNUNET_STATISTICS_create("rps-profiler", cfg); | 1379 | peer->stats_h = GNUNET_STATISTICS_create ("rps-profiler", cfg); |
1351 | return peer->stats_h; | 1380 | return peer->stats_h; |
1352 | } | 1381 | } |
1353 | 1382 | ||
@@ -1358,17 +1387,17 @@ stat_connect_adapter(void *cls, | |||
1358 | * @param op_result service handle returned from the connect adapter | 1387 | * @param op_result service handle returned from the connect adapter |
1359 | */ | 1388 | */ |
1360 | static void | 1389 | static void |
1361 | stat_disconnect_adapter(void *cls, void *op_result) | 1390 | stat_disconnect_adapter (void *cls, void *op_result) |
1362 | { | 1391 | { |
1363 | struct RPSPeer *peer = cls; | 1392 | struct RPSPeer *peer = cls; |
1364 | 1393 | ||
1365 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel | 1394 | // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel |
1366 | // (peer->stats_h, "core", "# peers connected", | 1395 | // (peer->stats_h, "core", "# peers connected", |
1367 | // stat_iterator, peer)); | 1396 | // stat_iterator, peer)); |
1368 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel | 1397 | // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel |
1369 | // (peer->stats_h, "nse", "# peers connected", | 1398 | // (peer->stats_h, "nse", "# peers connected", |
1370 | // stat_iterator, peer)); | 1399 | // stat_iterator, peer)); |
1371 | GNUNET_STATISTICS_destroy(op_result, GNUNET_NO); | 1400 | GNUNET_STATISTICS_destroy (op_result, GNUNET_NO); |
1372 | peer->stats_h = NULL; | 1401 | peer->stats_h = NULL; |
1373 | } | 1402 | } |
1374 | 1403 | ||
@@ -1383,26 +1412,26 @@ stat_disconnect_adapter(void *cls, void *op_result) | |||
1383 | * operation has executed successfully. | 1412 | * operation has executed successfully. |
1384 | */ | 1413 | */ |
1385 | static void | 1414 | static void |
1386 | stat_complete_cb(void *cls, | 1415 | stat_complete_cb (void *cls, |
1387 | struct GNUNET_TESTBED_Operation *op, | 1416 | struct GNUNET_TESTBED_Operation *op, |
1388 | void *ca_result, | 1417 | void *ca_result, |
1389 | const char *emsg) | 1418 | const char *emsg) |
1390 | { | 1419 | { |
1391 | //struct GNUNET_STATISTICS_Handle *sh = ca_result; | 1420 | // struct GNUNET_STATISTICS_Handle *sh = ca_result; |
1392 | //struct RPSPeer *peer = (struct RPSPeer *) cls; | 1421 | // struct RPSPeer *peer = (struct RPSPeer *) cls; |
1393 | (void)cls; | 1422 | (void) cls; |
1394 | (void)op; | 1423 | (void) op; |
1395 | (void)ca_result; | 1424 | (void) ca_result; |
1396 | 1425 | ||
1397 | if (NULL != emsg) | 1426 | if (NULL != emsg) |
1398 | { | 1427 | { |
1399 | GNUNET_break(0); | 1428 | GNUNET_break (0); |
1400 | return; | 1429 | return; |
1401 | } | 1430 | } |
1402 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch | 1431 | // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch |
1403 | // (sh, "core", "# peers connected", | 1432 | // (sh, "core", "# peers connected", |
1404 | // stat_iterator, peer)); | 1433 | // stat_iterator, peer)); |
1405 | //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch | 1434 | // GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch |
1406 | // (sh, "nse", "# peers connected", | 1435 | // (sh, "nse", "# peers connected", |
1407 | // stat_iterator, peer)); | 1436 | // stat_iterator, peer)); |
1408 | } | 1437 | } |
@@ -1416,31 +1445,31 @@ stat_complete_cb(void *cls, | |||
1416 | * @param op_result service handle returned from the connect adapter | 1445 | * @param op_result service handle returned from the connect adapter |
1417 | */ | 1446 | */ |
1418 | static void | 1447 | static void |
1419 | rps_disconnect_adapter(void *cls, | 1448 | rps_disconnect_adapter (void *cls, |
1420 | void *op_result) | 1449 | void *op_result) |
1421 | { | 1450 | { |
1422 | struct RPSPeer *peer = cls; | 1451 | struct RPSPeer *peer = cls; |
1423 | struct GNUNET_RPS_Handle *h = op_result; | 1452 | struct GNUNET_RPS_Handle *h = op_result; |
1424 | struct PendingReply *pending_rep; | 1453 | struct PendingReply *pending_rep; |
1425 | 1454 | ||
1426 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1427 | "disconnect_adapter (%u)\n", | 1456 | "disconnect_adapter (%u)\n", |
1428 | peer->index); | 1457 | peer->index); |
1429 | GNUNET_assert(NULL != peer); | 1458 | GNUNET_assert (NULL != peer); |
1430 | if (NULL != peer->rps_handle) | 1459 | if (NULL != peer->rps_handle) |
1460 | { | ||
1461 | while (NULL != (pending_rep = peer->pending_rep_head)) | ||
1462 | { | ||
1463 | cancel_request (pending_rep); | ||
1464 | } | ||
1465 | GNUNET_assert (h == peer->rps_handle); | ||
1466 | if (NULL != h) | ||
1431 | { | 1467 | { |
1432 | while (NULL != (pending_rep = peer->pending_rep_head)) | 1468 | GNUNET_RPS_disconnect (h); |
1433 | { | 1469 | h = NULL; |
1434 | cancel_request(pending_rep); | ||
1435 | } | ||
1436 | GNUNET_assert(h == peer->rps_handle); | ||
1437 | if (NULL != h) | ||
1438 | { | ||
1439 | GNUNET_RPS_disconnect(h); | ||
1440 | h = NULL; | ||
1441 | } | ||
1442 | peer->rps_handle = NULL; | ||
1443 | } | 1470 | } |
1471 | peer->rps_handle = NULL; | ||
1472 | } | ||
1444 | } | 1473 | } |
1445 | 1474 | ||
1446 | 1475 | ||
@@ -1456,88 +1485,88 @@ rps_disconnect_adapter(void *cls, | |||
1456 | * @param recv_peers the received peers | 1485 | * @param recv_peers the received peers |
1457 | */ | 1486 | */ |
1458 | static void | 1487 | static void |
1459 | default_reply_handle(void *cls, | 1488 | default_reply_handle (void *cls, |
1460 | uint64_t n, | 1489 | uint64_t n, |
1461 | const struct GNUNET_PeerIdentity *recv_peers) | 1490 | const struct GNUNET_PeerIdentity *recv_peers) |
1462 | { | 1491 | { |
1463 | struct RPSPeer *rps_peer; | 1492 | struct RPSPeer *rps_peer; |
1464 | struct PendingReply *pending_rep = (struct PendingReply *)cls; | 1493 | struct PendingReply *pending_rep = (struct PendingReply *) cls; |
1465 | unsigned int i; | 1494 | unsigned int i; |
1466 | 1495 | ||
1467 | rps_peer = pending_rep->rps_peer; | 1496 | rps_peer = pending_rep->rps_peer; |
1468 | GNUNET_CONTAINER_DLL_remove(rps_peer->pending_rep_head, | 1497 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head, |
1469 | rps_peer->pending_rep_tail, | 1498 | rps_peer->pending_rep_tail, |
1470 | pending_rep); | 1499 | pending_rep); |
1471 | rps_peer->num_pending_reps--; | 1500 | rps_peer->num_pending_reps--; |
1472 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1473 | "[%s] got %" PRIu64 " peers:\n", | 1502 | "[%s] got %" PRIu64 " peers:\n", |
1474 | GNUNET_i2s(rps_peer->peer_id), | 1503 | GNUNET_i2s (rps_peer->peer_id), |
1475 | n); | 1504 | n); |
1476 | 1505 | ||
1477 | for (i = 0; i < n; i++) | 1506 | for (i = 0; i < n; i++) |
1478 | { | 1507 | { |
1479 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1480 | "%u: %s\n", | 1509 | "%u: %s\n", |
1481 | i, | 1510 | i, |
1482 | GNUNET_i2s(&recv_peers[i])); | 1511 | GNUNET_i2s (&recv_peers[i])); |
1483 | 1512 | ||
1484 | rps_peer->num_recv_ids++; | 1513 | rps_peer->num_recv_ids++; |
1485 | } | 1514 | } |
1486 | 1515 | ||
1487 | if (GNUNET_YES != post_test) | 1516 | if (GNUNET_YES != post_test) |
1488 | return; | 1517 | return; |
1489 | if (HAVE_QUICK_QUIT != cur_test_run.have_quick_quit) | 1518 | if (HAVE_QUICK_QUIT != cur_test_run.have_quick_quit) |
1490 | return; | 1519 | return; |
1491 | if (0 == evaluate()) | 1520 | if (0 == evaluate ()) |
1492 | { | 1521 | { |
1493 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1522 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1494 | "Test succeeded before end of duration\n"); | 1523 | "Test succeeded before end of duration\n"); |
1495 | if (NULL != post_test_task) | 1524 | if (NULL != post_test_task) |
1496 | GNUNET_SCHEDULER_cancel(post_test_task); | 1525 | GNUNET_SCHEDULER_cancel (post_test_task); |
1497 | post_test_task = GNUNET_SCHEDULER_add_now(&post_test_op, NULL); | 1526 | post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); |
1498 | GNUNET_assert(NULL != post_test_task); | 1527 | GNUNET_assert (NULL != post_test_task); |
1499 | } | 1528 | } |
1500 | } | 1529 | } |
1501 | 1530 | ||
1502 | 1531 | ||
1503 | static void | 1532 | static void |
1504 | profiler_reply_handle_info(void *cls, | 1533 | profiler_reply_handle_info (void *cls, |
1505 | const struct GNUNET_PeerIdentity *recv_peer, | 1534 | const struct GNUNET_PeerIdentity *recv_peer, |
1506 | double probability, | 1535 | double probability, |
1507 | uint32_t num_observed); | 1536 | uint32_t num_observed); |
1508 | 1537 | ||
1509 | /** | 1538 | /** |
1510 | * Request random peers. | 1539 | * Request random peers. |
1511 | */ | 1540 | */ |
1512 | static void | 1541 | static void |
1513 | request_peers(void *cls) | 1542 | request_peers (void *cls) |
1514 | { | 1543 | { |
1515 | struct PendingRequest *pending_req = cls; | 1544 | struct PendingRequest *pending_req = cls; |
1516 | struct RPSPeer *rps_peer; | 1545 | struct RPSPeer *rps_peer; |
1517 | struct PendingReply *pending_rep; | 1546 | struct PendingReply *pending_rep; |
1518 | 1547 | ||
1519 | rps_peer = pending_req->rps_peer; | 1548 | rps_peer = pending_req->rps_peer; |
1520 | GNUNET_assert(1 <= rps_peer->num_pending_reqs); | 1549 | GNUNET_assert (1 <= rps_peer->num_pending_reqs); |
1521 | GNUNET_CONTAINER_DLL_remove(rps_peer->pending_req_head, | 1550 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, |
1522 | rps_peer->pending_req_tail, | 1551 | rps_peer->pending_req_tail, |
1523 | pending_req); | 1552 | pending_req); |
1524 | rps_peer->num_pending_reqs--; | 1553 | rps_peer->num_pending_reqs--; |
1525 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 1554 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
1526 | return; | 1555 | return; |
1527 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1528 | "Requesting one peer\n"); | 1557 | "Requesting one peer\n"); |
1529 | pending_rep = GNUNET_new(struct PendingReply); | 1558 | pending_rep = GNUNET_new (struct PendingReply); |
1530 | pending_rep->rps_peer = rps_peer; | 1559 | pending_rep->rps_peer = rps_peer; |
1531 | //pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle, | 1560 | // pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle, |
1532 | // 1, | 1561 | // 1, |
1533 | // cur_test_run.reply_handle, | 1562 | // cur_test_run.reply_handle, |
1534 | // pending_rep); | 1563 | // pending_rep); |
1535 | pending_rep->req_handle = GNUNET_RPS_request_peer_info(rps_peer->rps_handle, | 1564 | pending_rep->req_handle = GNUNET_RPS_request_peer_info (rps_peer->rps_handle, |
1536 | profiler_reply_handle_info, | 1565 | profiler_reply_handle_info, |
1537 | pending_rep); | 1566 | pending_rep); |
1538 | GNUNET_CONTAINER_DLL_insert_tail(rps_peer->pending_rep_head, | 1567 | GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head, |
1539 | rps_peer->pending_rep_tail, | 1568 | rps_peer->pending_rep_tail, |
1540 | pending_rep); | 1569 | pending_rep); |
1541 | rps_peer->num_pending_reps++; | 1570 | rps_peer->num_pending_reps++; |
1542 | } | 1571 | } |
1543 | 1572 | ||
@@ -1547,45 +1576,45 @@ request_peers(void *cls) | |||
1547 | * issued, nor replied | 1576 | * issued, nor replied |
1548 | */ | 1577 | */ |
1549 | void | 1578 | void |
1550 | schedule_missing_requests(struct RPSPeer *rps_peer) | 1579 | schedule_missing_requests (struct RPSPeer *rps_peer) |
1551 | { | 1580 | { |
1552 | unsigned int i; | 1581 | unsigned int i; |
1553 | struct PendingRequest *pending_req; | 1582 | struct PendingRequest *pending_req; |
1554 | 1583 | ||
1555 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1584 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1556 | "Scheduling %u - %u missing requests\n", | 1585 | "Scheduling %u - %u missing requests\n", |
1557 | rps_peer->num_ids_to_request, | 1586 | rps_peer->num_ids_to_request, |
1558 | rps_peer->num_pending_reqs + rps_peer->num_pending_reps); | 1587 | rps_peer->num_pending_reqs + rps_peer->num_pending_reps); |
1559 | GNUNET_assert(rps_peer->num_pending_reqs + rps_peer->num_pending_reps <= | 1588 | GNUNET_assert (rps_peer->num_pending_reqs + rps_peer->num_pending_reps <= |
1560 | rps_peer->num_ids_to_request); | 1589 | rps_peer->num_ids_to_request); |
1561 | for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps; | 1590 | for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps; |
1562 | i < rps_peer->num_ids_to_request; i++) | 1591 | i < rps_peer->num_ids_to_request; i++) |
1563 | { | 1592 | { |
1564 | pending_req = GNUNET_new(struct PendingRequest); | 1593 | pending_req = GNUNET_new (struct PendingRequest); |
1565 | pending_req->rps_peer = rps_peer; | 1594 | pending_req->rps_peer = rps_peer; |
1566 | pending_req->request_task = GNUNET_SCHEDULER_add_delayed( | 1595 | pending_req->request_task = GNUNET_SCHEDULER_add_delayed ( |
1567 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 1596 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
1568 | cur_test_run.request_interval * i), | 1597 | cur_test_run.request_interval * i), |
1569 | request_peers, | 1598 | request_peers, |
1570 | pending_req); | 1599 | pending_req); |
1571 | GNUNET_CONTAINER_DLL_insert_tail(rps_peer->pending_req_head, | 1600 | GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_req_head, |
1572 | rps_peer->pending_req_tail, | 1601 | rps_peer->pending_req_tail, |
1573 | pending_req); | 1602 | pending_req); |
1574 | rps_peer->num_pending_reqs++; | 1603 | rps_peer->num_pending_reqs++; |
1575 | } | 1604 | } |
1576 | } | 1605 | } |
1577 | 1606 | ||
1578 | void | 1607 | void |
1579 | cancel_pending_req_rep(struct RPSPeer *rps_peer) | 1608 | cancel_pending_req_rep (struct RPSPeer *rps_peer) |
1580 | { | 1609 | { |
1581 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1582 | "Cancelling all (pending) requests.\n"); | 1611 | "Cancelling all (pending) requests.\n"); |
1583 | while (NULL != rps_peer->pending_req_head) | 1612 | while (NULL != rps_peer->pending_req_head) |
1584 | cancel_pending_req(rps_peer->pending_req_head); | 1613 | cancel_pending_req (rps_peer->pending_req_head); |
1585 | GNUNET_assert(0 == rps_peer->num_pending_reqs); | 1614 | GNUNET_assert (0 == rps_peer->num_pending_reqs); |
1586 | while (NULL != rps_peer->pending_rep_head) | 1615 | while (NULL != rps_peer->pending_rep_head) |
1587 | cancel_request(rps_peer->pending_rep_head); | 1616 | cancel_request (rps_peer->pending_rep_head); |
1588 | GNUNET_assert(0 == rps_peer->num_pending_reps); | 1617 | GNUNET_assert (0 == rps_peer->num_pending_reps); |
1589 | } | 1618 | } |
1590 | 1619 | ||
1591 | /*********************************** | 1620 | /*********************************** |
@@ -1595,9 +1624,9 @@ cancel_pending_req_rep(struct RPSPeer *rps_peer) | |||
1595 | /** | 1624 | /** |
1596 | * Initialise only non-mal RPSPeers | 1625 | * Initialise only non-mal RPSPeers |
1597 | */ | 1626 | */ |
1598 | static void mal_init_peer(struct RPSPeer *rps_peer) | 1627 | static void mal_init_peer (struct RPSPeer *rps_peer) |
1599 | { | 1628 | { |
1600 | if (rps_peer->index >= round(portion * num_peers)) | 1629 | if (rps_peer->index >= round (portion * num_peers)) |
1601 | rps_peer->num_ids_to_request = 1; | 1630 | rps_peer->num_ids_to_request = 1; |
1602 | } | 1631 | } |
1603 | 1632 | ||
@@ -1611,51 +1640,53 @@ static void mal_init_peer(struct RPSPeer *rps_peer) | |||
1611 | * @param h the handle to the service | 1640 | * @param h the handle to the service |
1612 | */ | 1641 | */ |
1613 | static void | 1642 | static void |
1614 | mal_pre(struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | 1643 | mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) |
1615 | { | 1644 | { |
1616 | #if ENABLE_MALICIOUS | 1645 | #if ENABLE_MALICIOUS |
1617 | uint32_t num_mal_peers; | 1646 | uint32_t num_mal_peers; |
1618 | 1647 | ||
1619 | GNUNET_assert((1 >= portion) && | 1648 | GNUNET_assert ((1 >= portion) && |
1620 | (0 < portion)); | 1649 | (0 < portion)); |
1621 | num_mal_peers = round(portion * num_peers); | 1650 | num_mal_peers = round (portion * num_peers); |
1622 | 1651 | ||
1623 | if (rps_peer->index < num_mal_peers) | 1652 | if (rps_peer->index < num_mal_peers) |
1624 | { | 1653 | { |
1625 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1654 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1626 | "%u. peer [%s] of %" PRIu32 " malicious peers turning malicious\n", | 1655 | "%u. peer [%s] of %" PRIu32 |
1627 | rps_peer->index, | 1656 | " malicious peers turning malicious\n", |
1628 | GNUNET_i2s(rps_peer->peer_id), | 1657 | rps_peer->index, |
1629 | num_mal_peers); | 1658 | GNUNET_i2s (rps_peer->peer_id), |
1630 | 1659 | num_mal_peers); | |
1631 | GNUNET_RPS_act_malicious(h, mal_type, num_mal_peers, | 1660 | |
1632 | rps_peer_ids, target_peer); | 1661 | GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers, |
1633 | } | 1662 | rps_peer_ids, target_peer); |
1663 | } | ||
1634 | #endif /* ENABLE_MALICIOUS */ | 1664 | #endif /* ENABLE_MALICIOUS */ |
1635 | } | 1665 | } |
1636 | 1666 | ||
1637 | static void | 1667 | static void |
1638 | mal_cb(struct RPSPeer *rps_peer) | 1668 | mal_cb (struct RPSPeer *rps_peer) |
1639 | { | 1669 | { |
1640 | uint32_t num_mal_peers; | 1670 | uint32_t num_mal_peers; |
1641 | 1671 | ||
1642 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 1672 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
1643 | { | 1673 | { |
1644 | return; | 1674 | return; |
1645 | } | 1675 | } |
1646 | 1676 | ||
1647 | #if ENABLE_MALICIOUS | 1677 | #if ENABLE_MALICIOUS |
1648 | GNUNET_assert((1 >= portion) && | 1678 | GNUNET_assert ((1 >= portion) && |
1649 | (0 < portion)); | 1679 | (0 < portion)); |
1650 | num_mal_peers = round(portion * num_peers); | 1680 | num_mal_peers = round (portion * num_peers); |
1651 | 1681 | ||
1652 | if (rps_peer->index >= num_mal_peers) | 1682 | if (rps_peer->index >= num_mal_peers) |
1653 | { /* It's useless to ask a malicious peer about a random sample - | 1683 | { /* It's useless to ask a malicious peer about a random sample - |
1654 | it's not sampling */ | 1684 | it's not sampling */ |
1655 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | 1685 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( |
1656 | seed_peers, rps_peer); | 1686 | GNUNET_TIME_UNIT_SECONDS, 2), |
1657 | schedule_missing_requests(rps_peer); | 1687 | seed_peers, rps_peer); |
1658 | } | 1688 | schedule_missing_requests (rps_peer); |
1689 | } | ||
1659 | #endif /* ENABLE_MALICIOUS */ | 1690 | #endif /* ENABLE_MALICIOUS */ |
1660 | } | 1691 | } |
1661 | 1692 | ||
@@ -1664,7 +1695,7 @@ mal_cb(struct RPSPeer *rps_peer) | |||
1664 | ***********************************/ | 1695 | ***********************************/ |
1665 | 1696 | ||
1666 | static void | 1697 | static void |
1667 | churn(void *cls); | 1698 | churn (void *cls); |
1668 | 1699 | ||
1669 | /** | 1700 | /** |
1670 | * @brief Starts churn | 1701 | * @brief Starts churn |
@@ -1678,30 +1709,30 @@ churn(void *cls); | |||
1678 | * @param rps_peer The peer it's called for | 1709 | * @param rps_peer The peer it's called for |
1679 | */ | 1710 | */ |
1680 | static void | 1711 | static void |
1681 | churn_test_cb(struct RPSPeer *rps_peer) | 1712 | churn_test_cb (struct RPSPeer *rps_peer) |
1682 | { | 1713 | { |
1683 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 1714 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
1684 | { | 1715 | { |
1685 | return; | 1716 | return; |
1686 | } | 1717 | } |
1687 | 1718 | ||
1688 | /* Start churn */ | 1719 | /* Start churn */ |
1689 | if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task) | 1720 | if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) |
1690 | { | 1721 | { |
1691 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1692 | "Starting churn task\n"); | 1723 | "Starting churn task\n"); |
1693 | churn_task = GNUNET_SCHEDULER_add_delayed( | 1724 | churn_task = GNUNET_SCHEDULER_add_delayed ( |
1694 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | 1725 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
1695 | churn, | 1726 | churn, |
1696 | NULL); | 1727 | NULL); |
1697 | } | 1728 | } |
1698 | else | 1729 | else |
1699 | { | 1730 | { |
1700 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1731 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1701 | "Not starting churn task\n"); | 1732 | "Not starting churn task\n"); |
1702 | } | 1733 | } |
1703 | 1734 | ||
1704 | schedule_missing_requests(rps_peer); | 1735 | schedule_missing_requests (rps_peer); |
1705 | } | 1736 | } |
1706 | 1737 | ||
1707 | /*********************************** | 1738 | /*********************************** |
@@ -1716,83 +1747,84 @@ churn_test_cb(struct RPSPeer *rps_peer) | |||
1716 | * @param emsg NULL on success; otherwise an error description | 1747 | * @param emsg NULL on success; otherwise an error description |
1717 | */ | 1748 | */ |
1718 | static void | 1749 | static void |
1719 | churn_cb(void *cls, | 1750 | churn_cb (void *cls, |
1720 | struct GNUNET_TESTBED_Operation *op, | 1751 | struct GNUNET_TESTBED_Operation *op, |
1721 | const char *emsg) | 1752 | const char *emsg) |
1722 | { | 1753 | { |
1723 | // FIXME | 1754 | // FIXME |
1724 | struct OpListEntry *entry = cls; | 1755 | struct OpListEntry *entry = cls; |
1725 | 1756 | ||
1726 | (void)op; | 1757 | (void) op; |
1727 | 1758 | ||
1728 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 1759 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
1729 | { | 1760 | { |
1730 | return; | 1761 | return; |
1731 | } | 1762 | } |
1732 | 1763 | ||
1733 | GNUNET_TESTBED_operation_done(entry->op); | 1764 | GNUNET_TESTBED_operation_done (entry->op); |
1734 | if (NULL != emsg) | 1765 | if (NULL != emsg) |
1735 | { | 1766 | { |
1736 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop RPS at a peer\n"); | 1767 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1737 | GNUNET_SCHEDULER_shutdown(); | 1768 | "Failed to start/stop RPS at a peer\n"); |
1738 | return; | 1769 | GNUNET_SCHEDULER_shutdown (); |
1739 | } | 1770 | return; |
1740 | GNUNET_assert(0 != entry->delta); | 1771 | } |
1772 | GNUNET_assert (0 != entry->delta); | ||
1741 | 1773 | ||
1742 | num_peers_online += entry->delta; | 1774 | num_peers_online += entry->delta; |
1743 | 1775 | ||
1744 | if (PEER_GO_OFFLINE == entry->delta) | 1776 | if (PEER_GO_OFFLINE == entry->delta) |
1745 | { /* Peer hopefully just went offline */ | 1777 | { /* Peer hopefully just went offline */ |
1746 | if (GNUNET_YES != rps_peers[entry->index].online) | 1778 | if (GNUNET_YES != rps_peers[entry->index].online) |
1747 | { | 1779 | { |
1748 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1780 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1749 | "peer %s was expected to go offline but is still marked as online\n", | 1781 | "peer %s was expected to go offline but is still marked as online\n", |
1750 | GNUNET_i2s(rps_peers[entry->index].peer_id)); | 1782 | GNUNET_i2s (rps_peers[entry->index].peer_id)); |
1751 | GNUNET_break(0); | 1783 | GNUNET_break (0); |
1752 | } | 1784 | } |
1753 | else | 1785 | else |
1754 | { | 1786 | { |
1755 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1787 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1756 | "peer %s probably went offline as expected\n", | 1788 | "peer %s probably went offline as expected\n", |
1757 | GNUNET_i2s(rps_peers[entry->index].peer_id)); | 1789 | GNUNET_i2s (rps_peers[entry->index].peer_id)); |
1758 | } | ||
1759 | rps_peers[entry->index].online = GNUNET_NO; | ||
1760 | } | 1790 | } |
1791 | rps_peers[entry->index].online = GNUNET_NO; | ||
1792 | } | ||
1761 | 1793 | ||
1762 | else if (PEER_GO_ONLINE < entry->delta) | 1794 | else if (PEER_GO_ONLINE < entry->delta) |
1763 | { /* Peer hopefully just went online */ | 1795 | { /* Peer hopefully just went online */ |
1764 | if (GNUNET_NO != rps_peers[entry->index].online) | 1796 | if (GNUNET_NO != rps_peers[entry->index].online) |
1765 | { | 1797 | { |
1766 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1798 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1767 | "peer %s was expected to go online but is still marked as offline\n", | 1799 | "peer %s was expected to go online but is still marked as offline\n", |
1768 | GNUNET_i2s(rps_peers[entry->index].peer_id)); | 1800 | GNUNET_i2s (rps_peers[entry->index].peer_id)); |
1769 | GNUNET_break(0); | 1801 | GNUNET_break (0); |
1770 | } | 1802 | } |
1771 | else | 1803 | else |
1772 | { | 1804 | { |
1773 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1805 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1774 | "peer %s probably went online as expected\n", | 1806 | "peer %s probably went online as expected\n", |
1775 | GNUNET_i2s(rps_peers[entry->index].peer_id)); | 1807 | GNUNET_i2s (rps_peers[entry->index].peer_id)); |
1776 | if (NULL != cur_test_run.pre_test) | 1808 | if (NULL != cur_test_run.pre_test) |
1777 | { | 1809 | { |
1778 | cur_test_run.pre_test(&rps_peers[entry->index], | 1810 | cur_test_run.pre_test (&rps_peers[entry->index], |
1779 | rps_peers[entry->index].rps_handle); | 1811 | rps_peers[entry->index].rps_handle); |
1780 | schedule_missing_requests(&rps_peers[entry->index]); | 1812 | schedule_missing_requests (&rps_peers[entry->index]); |
1781 | } | 1813 | } |
1782 | } | 1814 | } |
1783 | rps_peers[entry->index].online = GNUNET_YES; | 1815 | rps_peers[entry->index].online = GNUNET_YES; |
1784 | } | 1816 | } |
1785 | else | 1817 | else |
1786 | { | 1818 | { |
1787 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1819 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1788 | "Invalid value for delta: %i\n", entry->delta); | 1820 | "Invalid value for delta: %i\n", entry->delta); |
1789 | GNUNET_break(0); | 1821 | GNUNET_break (0); |
1790 | } | 1822 | } |
1791 | 1823 | ||
1792 | GNUNET_CONTAINER_DLL_remove(oplist_head, oplist_tail, entry); | 1824 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
1793 | rps_peers[entry->index].entry_op_manage = NULL; | 1825 | rps_peers[entry->index].entry_op_manage = NULL; |
1794 | GNUNET_free(entry); | 1826 | GNUNET_free (entry); |
1795 | //if (num_peers_in_round[current_round] == peers_running) | 1827 | // if (num_peers_in_round[current_round] == peers_running) |
1796 | // run_round (); | 1828 | // run_round (); |
1797 | } | 1829 | } |
1798 | 1830 | ||
@@ -1805,52 +1837,53 @@ churn_cb(void *cls, | |||
1805 | * @param prob_go_on_off the probability of the action | 1837 | * @param prob_go_on_off the probability of the action |
1806 | */ | 1838 | */ |
1807 | static void | 1839 | static void |
1808 | manage_service_wrapper(unsigned int i, unsigned int j, | 1840 | manage_service_wrapper (unsigned int i, unsigned int j, |
1809 | enum PEER_ONLINE_DELTA delta, | 1841 | enum PEER_ONLINE_DELTA delta, |
1810 | double prob_go_on_off) | 1842 | double prob_go_on_off) |
1811 | { | 1843 | { |
1812 | struct OpListEntry *entry = NULL; | 1844 | struct OpListEntry *entry = NULL; |
1813 | uint32_t prob; | 1845 | uint32_t prob; |
1814 | 1846 | ||
1815 | /* make sure that management operation is not already scheduled */ | 1847 | /* make sure that management operation is not already scheduled */ |
1816 | if (NULL != rps_peers[j].entry_op_manage) | 1848 | if (NULL != rps_peers[j].entry_op_manage) |
1817 | { | 1849 | { |
1818 | return; | 1850 | return; |
1819 | } | 1851 | } |
1820 | 1852 | ||
1821 | prob = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, | 1853 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1822 | UINT32_MAX); | 1854 | UINT32_MAX); |
1823 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1855 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1824 | "%u. selected peer (%u: %s) is %s.\n", | 1856 | "%u. selected peer (%u: %s) is %s.\n", |
1825 | i, | 1857 | i, |
1826 | j, | 1858 | j, |
1827 | GNUNET_i2s(rps_peers[j].peer_id), | 1859 | GNUNET_i2s (rps_peers[j].peer_id), |
1828 | (PEER_GO_ONLINE == delta) ? "online" : "offline"); | 1860 | (PEER_GO_ONLINE == delta) ? "online" : "offline"); |
1829 | if (prob < prob_go_on_off * UINT32_MAX) | 1861 | if (prob < prob_go_on_off * UINT32_MAX) |
1830 | { | 1862 | { |
1831 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1832 | "%s goes %s\n", | 1864 | "%s goes %s\n", |
1833 | GNUNET_i2s(rps_peers[j].peer_id), | 1865 | GNUNET_i2s (rps_peers[j].peer_id), |
1834 | (PEER_GO_OFFLINE == delta) ? "offline" : "online"); | 1866 | (PEER_GO_OFFLINE == delta) ? "offline" : "online"); |
1835 | 1867 | ||
1836 | if (PEER_GO_OFFLINE == delta) | 1868 | if (PEER_GO_OFFLINE == delta) |
1837 | cancel_pending_req_rep(&rps_peers[j]); | 1869 | cancel_pending_req_rep (&rps_peers[j]); |
1838 | entry = make_oplist_entry(); | 1870 | entry = make_oplist_entry (); |
1839 | entry->delta = delta; | 1871 | entry->delta = delta; |
1840 | entry->index = j; | 1872 | entry->index = j; |
1841 | entry->op = GNUNET_TESTBED_peer_manage_service(NULL, | 1873 | entry->op = GNUNET_TESTBED_peer_manage_service (NULL, |
1842 | testbed_peers[j], | 1874 | testbed_peers[j], |
1843 | "rps", | 1875 | "rps", |
1844 | &churn_cb, | 1876 | &churn_cb, |
1845 | entry, | 1877 | entry, |
1846 | (PEER_GO_OFFLINE == delta) ? 0 : 1); | 1878 | (PEER_GO_OFFLINE == delta) ? |
1847 | rps_peers[j].entry_op_manage = entry; | 1879 | 0 : 1); |
1848 | } | 1880 | rps_peers[j].entry_op_manage = entry; |
1881 | } | ||
1849 | } | 1882 | } |
1850 | 1883 | ||
1851 | 1884 | ||
1852 | static void | 1885 | static void |
1853 | churn(void *cls) | 1886 | churn (void *cls) |
1854 | { | 1887 | { |
1855 | unsigned int i; | 1888 | unsigned int i; |
1856 | unsigned int j; | 1889 | unsigned int j; |
@@ -1860,61 +1893,61 @@ churn(void *cls) | |||
1860 | double portion_go_online; | 1893 | double portion_go_online; |
1861 | double portion_go_offline; | 1894 | double portion_go_offline; |
1862 | 1895 | ||
1863 | (void)cls; | 1896 | (void) cls; |
1864 | 1897 | ||
1865 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 1898 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
1866 | { | 1899 | { |
1867 | return; | 1900 | return; |
1868 | } | 1901 | } |
1869 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1902 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1870 | "Churn function executing\n"); | 1903 | "Churn function executing\n"); |
1871 | 1904 | ||
1872 | churn_task = NULL; /* Should be invalid by now */ | 1905 | churn_task = NULL; /* Should be invalid by now */ |
1873 | 1906 | ||
1874 | /* Compute the probability for an online peer to go offline | 1907 | /* Compute the probability for an online peer to go offline |
1875 | * this round */ | 1908 | * this round */ |
1876 | portion_online = num_peers_online * 1.0 / num_peers; | 1909 | portion_online = num_peers_online * 1.0 / num_peers; |
1877 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1910 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1878 | "Portion online: %f\n", | 1911 | "Portion online: %f\n", |
1879 | portion_online); | 1912 | portion_online); |
1880 | portion_go_online = ((1 - portion_online) * .5 * .66); | 1913 | portion_go_online = ((1 - portion_online) * .5 * .66); |
1881 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1914 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1882 | "Portion that should go online: %f\n", | 1915 | "Portion that should go online: %f\n", |
1883 | portion_go_online); | 1916 | portion_go_online); |
1884 | portion_go_offline = (portion_online + portion_go_online) - .75; | 1917 | portion_go_offline = (portion_online + portion_go_online) - .75; |
1885 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1886 | "Portion that probably goes offline: %f\n", | 1919 | "Portion that probably goes offline: %f\n", |
1887 | portion_go_offline); | 1920 | portion_go_offline); |
1888 | prob_go_offline = portion_go_offline / (portion_online * .5); | 1921 | prob_go_offline = portion_go_offline / (portion_online * .5); |
1889 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1922 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1890 | "Probability of a selected online peer to go offline: %f\n", | 1923 | "Probability of a selected online peer to go offline: %f\n", |
1891 | prob_go_offline); | 1924 | prob_go_offline); |
1892 | 1925 | ||
1893 | permut = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_WEAK, | 1926 | permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, |
1894 | (unsigned int)num_peers); | 1927 | (unsigned int) num_peers); |
1895 | 1928 | ||
1896 | /* Go over 50% randomly chosen peers */ | 1929 | /* Go over 50% randomly chosen peers */ |
1897 | for (i = 0; i < .5 * num_peers; i++) | 1930 | for (i = 0; i < .5 * num_peers; i++) |
1931 | { | ||
1932 | j = permut[i]; | ||
1933 | |||
1934 | /* If online, shut down with certain probability */ | ||
1935 | if (GNUNET_YES == rps_peers[j].online) | ||
1898 | { | 1936 | { |
1899 | j = permut[i]; | 1937 | manage_service_wrapper (i, j, -1, prob_go_offline); |
1900 | |||
1901 | /* If online, shut down with certain probability */ | ||
1902 | if (GNUNET_YES == rps_peers[j].online) | ||
1903 | { | ||
1904 | manage_service_wrapper(i, j, -1, prob_go_offline); | ||
1905 | } | ||
1906 | |||
1907 | /* If offline, restart with certain probability */ | ||
1908 | else if (GNUNET_NO == rps_peers[j].online) | ||
1909 | { | ||
1910 | manage_service_wrapper(i, j, 1, 0.66); | ||
1911 | } | ||
1912 | } | 1938 | } |
1913 | 1939 | ||
1914 | GNUNET_free(permut); | 1940 | /* If offline, restart with certain probability */ |
1941 | else if (GNUNET_NO == rps_peers[j].online) | ||
1942 | { | ||
1943 | manage_service_wrapper (i, j, 1, 0.66); | ||
1944 | } | ||
1945 | } | ||
1915 | 1946 | ||
1916 | churn_task = GNUNET_SCHEDULER_add_delayed( | 1947 | GNUNET_free (permut); |
1917 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | 1948 | |
1949 | churn_task = GNUNET_SCHEDULER_add_delayed ( | ||
1950 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | ||
1918 | churn, | 1951 | churn, |
1919 | NULL); | 1952 | NULL); |
1920 | } | 1953 | } |
@@ -1923,11 +1956,11 @@ churn(void *cls) | |||
1923 | /** | 1956 | /** |
1924 | * Initialise given RPSPeer | 1957 | * Initialise given RPSPeer |
1925 | */ | 1958 | */ |
1926 | static void profiler_init_peer(struct RPSPeer *rps_peer) | 1959 | static void profiler_init_peer (struct RPSPeer *rps_peer) |
1927 | { | 1960 | { |
1928 | rps_peer->num_ids_to_request = cur_test_run.num_requests; | 1961 | rps_peer->num_ids_to_request = cur_test_run.num_requests; |
1929 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n", | 1962 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n", |
1930 | rps_peer->num_ids_to_request); | 1963 | rps_peer->num_ids_to_request); |
1931 | } | 1964 | } |
1932 | 1965 | ||
1933 | 1966 | ||
@@ -1939,9 +1972,9 @@ static void profiler_init_peer(struct RPSPeer *rps_peer) | |||
1939 | * @param recv_peers the received peers | 1972 | * @param recv_peers the received peers |
1940 | */ | 1973 | */ |
1941 | static void | 1974 | static void |
1942 | profiler_reply_handle(void *cls, | 1975 | profiler_reply_handle (void *cls, |
1943 | uint64_t n, | 1976 | uint64_t n, |
1944 | const struct GNUNET_PeerIdentity *recv_peers) | 1977 | const struct GNUNET_PeerIdentity *recv_peers) |
1945 | { | 1978 | { |
1946 | struct RPSPeer *rps_peer; | 1979 | struct RPSPeer *rps_peer; |
1947 | struct RPSPeer *rcv_rps_peer; | 1980 | struct RPSPeer *rcv_rps_peer; |
@@ -1954,53 +1987,53 @@ profiler_reply_handle(void *cls, | |||
1954 | char *file_name_dhr = file_name_dhr_buf; | 1987 | char *file_name_dhr = file_name_dhr_buf; |
1955 | char *file_name_dhru = file_name_dhru_buf; | 1988 | char *file_name_dhru = file_name_dhru_buf; |
1956 | unsigned int i; | 1989 | unsigned int i; |
1957 | struct PendingReply *pending_rep = (struct PendingReply *)cls; | 1990 | struct PendingReply *pending_rep = (struct PendingReply *) cls; |
1958 | 1991 | ||
1959 | pending_rep->req_handle = NULL; | 1992 | pending_rep->req_handle = NULL; |
1960 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n"); | 1993 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n"); |
1961 | rps_peer = pending_rep->rps_peer; | 1994 | rps_peer = pending_rep->rps_peer; |
1962 | (void)GNUNET_asprintf(&file_name, | 1995 | (void) GNUNET_asprintf (&file_name, |
1963 | "/tmp/rps/received_ids-%u", | 1996 | "/tmp/rps/received_ids-%u", |
1964 | rps_peer->index); | 1997 | rps_peer->index); |
1965 | 1998 | ||
1966 | (void)GNUNET_asprintf(&file_name_dh, | 1999 | (void) GNUNET_asprintf (&file_name_dh, |
1967 | "/tmp/rps/diehard_input-%u", | 2000 | "/tmp/rps/diehard_input-%u", |
1968 | rps_peer->index); | 2001 | rps_peer->index); |
1969 | (void)GNUNET_asprintf(&file_name_dhr, | 2002 | (void) GNUNET_asprintf (&file_name_dhr, |
1970 | "/tmp/rps/diehard_input_raw-%u", | 2003 | "/tmp/rps/diehard_input_raw-%u", |
1971 | rps_peer->index); | 2004 | rps_peer->index); |
1972 | (void)GNUNET_asprintf(&file_name_dhru, | 2005 | (void) GNUNET_asprintf (&file_name_dhru, |
1973 | "/tmp/rps/diehard_input_raw_aligned-%u", | 2006 | "/tmp/rps/diehard_input_raw_aligned-%u", |
1974 | rps_peer->index); | 2007 | rps_peer->index); |
1975 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2008 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1976 | "[%s] got %" PRIu64 " peers:\n", | 2009 | "[%s] got %" PRIu64 " peers:\n", |
1977 | GNUNET_i2s(rps_peer->peer_id), | 2010 | GNUNET_i2s (rps_peer->peer_id), |
1978 | n); | 2011 | n); |
1979 | for (i = 0; i < n; i++) | 2012 | for (i = 0; i < n; i++) |
1980 | { | 2013 | { |
1981 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1982 | "%u: %s\n", | 2015 | "%u: %s\n", |
1983 | i, | 2016 | i, |
1984 | GNUNET_i2s(&recv_peers[i])); | 2017 | GNUNET_i2s (&recv_peers[i])); |
1985 | tofile(file_name, | 2018 | tofile (file_name, |
1986 | "%s\n", | 2019 | "%s\n", |
1987 | GNUNET_i2s_full(&recv_peers[i])); | 2020 | GNUNET_i2s_full (&recv_peers[i])); |
1988 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get(peer_map, &recv_peers[i]); | 2021 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]); |
1989 | GNUNET_assert(NULL != rcv_rps_peer); | 2022 | GNUNET_assert (NULL != rcv_rps_peer); |
1990 | tofile(file_name_dh, | 2023 | tofile (file_name_dh, |
1991 | "%" PRIu32 "\n", | 2024 | "%" PRIu32 "\n", |
1992 | (uint32_t)rcv_rps_peer->index); | 2025 | (uint32_t) rcv_rps_peer->index); |
1993 | #ifdef TO_FILE | 2026 | #ifdef TO_FILE |
1994 | to_file_raw(file_name_dhr, | 2027 | to_file_raw (file_name_dhr, |
1995 | (char *)&rcv_rps_peer->index, | 2028 | (char *) &rcv_rps_peer->index, |
1996 | sizeof(uint32_t)); | 2029 | sizeof(uint32_t)); |
1997 | to_file_raw_unaligned(file_name_dhru, | 2030 | to_file_raw_unaligned (file_name_dhru, |
1998 | (char *)&rcv_rps_peer->index, | 2031 | (char *) &rcv_rps_peer->index, |
1999 | sizeof(uint32_t), | 2032 | sizeof(uint32_t), |
2000 | bits_needed); | 2033 | bits_needed); |
2001 | #endif /* TO_FILE */ | 2034 | #endif /* TO_FILE */ |
2002 | } | 2035 | } |
2003 | default_reply_handle(cls, n, recv_peers); | 2036 | default_reply_handle (cls, n, recv_peers); |
2004 | } | 2037 | } |
2005 | 2038 | ||
2006 | 2039 | ||
@@ -2012,10 +2045,10 @@ profiler_reply_handle(void *cls, | |||
2012 | * @param recv_peers the received peers | 2045 | * @param recv_peers the received peers |
2013 | */ | 2046 | */ |
2014 | static void | 2047 | static void |
2015 | profiler_reply_handle_info(void *cls, | 2048 | profiler_reply_handle_info (void *cls, |
2016 | const struct GNUNET_PeerIdentity *recv_peer, | 2049 | const struct GNUNET_PeerIdentity *recv_peer, |
2017 | double probability, | 2050 | double probability, |
2018 | uint32_t num_observed) | 2051 | uint32_t num_observed) |
2019 | { | 2052 | { |
2020 | struct RPSPeer *rps_peer; | 2053 | struct RPSPeer *rps_peer; |
2021 | struct RPSPeer *rcv_rps_peer; | 2054 | struct RPSPeer *rcv_rps_peer; |
@@ -2028,82 +2061,82 @@ profiler_reply_handle_info(void *cls, | |||
2028 | char *file_name_dhr = file_name_dhr_buf; | 2061 | char *file_name_dhr = file_name_dhr_buf; |
2029 | char *file_name_dhru = file_name_dhru_buf; | 2062 | char *file_name_dhru = file_name_dhru_buf; |
2030 | unsigned int i; | 2063 | unsigned int i; |
2031 | struct PendingReply *pending_rep = (struct PendingReply *)cls; | 2064 | struct PendingReply *pending_rep = (struct PendingReply *) cls; |
2032 | 2065 | ||
2033 | pending_rep->req_handle = NULL; | 2066 | pending_rep->req_handle = NULL; |
2034 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n"); | 2067 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n"); |
2035 | rps_peer = pending_rep->rps_peer; | 2068 | rps_peer = pending_rep->rps_peer; |
2036 | (void)GNUNET_asprintf(&file_name, | 2069 | (void) GNUNET_asprintf (&file_name, |
2037 | "/tmp/rps/received_ids-%u", | 2070 | "/tmp/rps/received_ids-%u", |
2038 | rps_peer->index); | 2071 | rps_peer->index); |
2039 | 2072 | ||
2040 | (void)GNUNET_asprintf(&file_name_dh, | 2073 | (void) GNUNET_asprintf (&file_name_dh, |
2041 | "/tmp/rps/diehard_input-%u", | 2074 | "/tmp/rps/diehard_input-%u", |
2042 | rps_peer->index); | 2075 | rps_peer->index); |
2043 | (void)GNUNET_asprintf(&file_name_dhr, | 2076 | (void) GNUNET_asprintf (&file_name_dhr, |
2044 | "/tmp/rps/diehard_input_raw-%u", | 2077 | "/tmp/rps/diehard_input_raw-%u", |
2045 | rps_peer->index); | 2078 | rps_peer->index); |
2046 | (void)GNUNET_asprintf(&file_name_dhru, | 2079 | (void) GNUNET_asprintf (&file_name_dhru, |
2047 | "/tmp/rps/diehard_input_raw_aligned-%u", | 2080 | "/tmp/rps/diehard_input_raw_aligned-%u", |
2048 | rps_peer->index); | 2081 | rps_peer->index); |
2049 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2082 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2050 | "[%s] got peer with info:\n", | 2083 | "[%s] got peer with info:\n", |
2051 | GNUNET_i2s(rps_peer->peer_id)); | 2084 | GNUNET_i2s (rps_peer->peer_id)); |
2052 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2085 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2053 | " %s\n", | 2086 | " %s\n", |
2054 | GNUNET_i2s(recv_peer)); | 2087 | GNUNET_i2s (recv_peer)); |
2055 | tofile(file_name, | 2088 | tofile (file_name, |
2056 | "%s %d %" PRIu32 " \n", | 2089 | "%s %d %" PRIu32 " \n", |
2057 | GNUNET_i2s_full(recv_peer), | 2090 | GNUNET_i2s_full (recv_peer), |
2058 | probability, | 2091 | probability, |
2059 | num_observed); | 2092 | num_observed); |
2060 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get(peer_map, recv_peer); | 2093 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, recv_peer); |
2061 | GNUNET_assert(NULL != rcv_rps_peer); | 2094 | GNUNET_assert (NULL != rcv_rps_peer); |
2062 | tofile(file_name_dh, | 2095 | tofile (file_name_dh, |
2063 | "%" PRIu32 "\n", | 2096 | "%" PRIu32 "\n", |
2064 | (uint32_t)rcv_rps_peer->index); | 2097 | (uint32_t) rcv_rps_peer->index); |
2065 | #ifdef TO_FILE | 2098 | #ifdef TO_FILE |
2066 | to_file_raw(file_name_dhr, | 2099 | to_file_raw (file_name_dhr, |
2067 | (char *)&rcv_rps_peer->index, | 2100 | (char *) &rcv_rps_peer->index, |
2068 | sizeof(uint32_t)); | 2101 | sizeof(uint32_t)); |
2069 | to_file_raw_unaligned(file_name_dhru, | 2102 | to_file_raw_unaligned (file_name_dhru, |
2070 | (char *)&rcv_rps_peer->index, | 2103 | (char *) &rcv_rps_peer->index, |
2071 | sizeof(uint32_t), | 2104 | sizeof(uint32_t), |
2072 | bits_needed); | 2105 | bits_needed); |
2073 | #endif /* TO_FILE */ | 2106 | #endif /* TO_FILE */ |
2074 | default_reply_handle(cls, 1, recv_peer); | 2107 | default_reply_handle (cls, 1, recv_peer); |
2075 | } | 2108 | } |
2076 | 2109 | ||
2077 | 2110 | ||
2078 | static void | 2111 | static void |
2079 | profiler_cb(struct RPSPeer *rps_peer) | 2112 | profiler_cb (struct RPSPeer *rps_peer) |
2080 | { | 2113 | { |
2081 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | 2114 | if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) |
2082 | { | 2115 | { |
2083 | return; | 2116 | return; |
2084 | } | 2117 | } |
2085 | 2118 | ||
2086 | /* Start churn */ | 2119 | /* Start churn */ |
2087 | if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task) | 2120 | if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) |
2088 | { | 2121 | { |
2089 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2090 | "Starting churn task\n"); | 2123 | "Starting churn task\n"); |
2091 | churn_task = GNUNET_SCHEDULER_add_delayed( | 2124 | churn_task = GNUNET_SCHEDULER_add_delayed ( |
2092 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | 2125 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
2093 | churn, | 2126 | churn, |
2094 | NULL); | 2127 | NULL); |
2095 | } | 2128 | } |
2096 | else | 2129 | else |
2097 | { | 2130 | { |
2098 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2099 | "Not starting churn task\n"); | 2132 | "Not starting churn task\n"); |
2100 | } | 2133 | } |
2101 | 2134 | ||
2102 | /* Only request peer ids at one peer. | 2135 | /* Only request peer ids at one peer. |
2103 | * (It's the before-last because last one is target of the focussed attack.) | 2136 | * (It's the before-last because last one is target of the focussed attack.) |
2104 | */ | 2137 | */ |
2105 | if (0 < rps_peer->num_ids_to_request) | 2138 | if (0 < rps_peer->num_ids_to_request) |
2106 | schedule_missing_requests(rps_peer); | 2139 | schedule_missing_requests (rps_peer); |
2107 | } | 2140 | } |
2108 | 2141 | ||
2109 | /** | 2142 | /** |
@@ -2116,29 +2149,29 @@ profiler_cb(struct RPSPeer *rps_peer) | |||
2116 | * #GNUNET_SYSERR to abort iteration with error! | 2149 | * #GNUNET_SYSERR to abort iteration with error! |
2117 | */ | 2150 | */ |
2118 | static int | 2151 | static int |
2119 | file_name_cb(void *cls, const char *filename) | 2152 | file_name_cb (void *cls, const char *filename) |
2120 | { | 2153 | { |
2121 | if (NULL != strstr(filename, "sampler_el")) | 2154 | if (NULL != strstr (filename, "sampler_el")) |
2155 | { | ||
2156 | struct RPS_SamplerElement *s_elem; | ||
2157 | struct GNUNET_CRYPTO_AuthKey auth_key; | ||
2158 | const char *key_char; | ||
2159 | uint32_t i; | ||
2160 | (void) cls; | ||
2161 | |||
2162 | key_char = filename + 20; /* Length of "/tmp/rps/sampler_el-" */ | ||
2163 | tofile (filename, "--------------------------\n"); | ||
2164 | |||
2165 | auth_key = string_to_auth_key (key_char); | ||
2166 | s_elem = RPS_sampler_elem_create (); | ||
2167 | RPS_sampler_elem_set (s_elem, auth_key); | ||
2168 | |||
2169 | for (i = 0; i < num_peers; i++) | ||
2122 | { | 2170 | { |
2123 | struct RPS_SamplerElement *s_elem; | 2171 | RPS_sampler_elem_next (s_elem, &rps_peer_ids[i]); |
2124 | struct GNUNET_CRYPTO_AuthKey auth_key; | ||
2125 | const char *key_char; | ||
2126 | uint32_t i; | ||
2127 | (void)cls; | ||
2128 | |||
2129 | key_char = filename + 20; /* Length of "/tmp/rps/sampler_el-" */ | ||
2130 | tofile(filename, "--------------------------\n"); | ||
2131 | |||
2132 | auth_key = string_to_auth_key(key_char); | ||
2133 | s_elem = RPS_sampler_elem_create(); | ||
2134 | RPS_sampler_elem_set(s_elem, auth_key); | ||
2135 | |||
2136 | for (i = 0; i < num_peers; i++) | ||
2137 | { | ||
2138 | RPS_sampler_elem_next(s_elem, &rps_peer_ids[i]); | ||
2139 | } | ||
2140 | RPS_sampler_elem_destroy(s_elem); | ||
2141 | } | 2172 | } |
2173 | RPS_sampler_elem_destroy (s_elem); | ||
2174 | } | ||
2142 | return GNUNET_OK; | 2175 | return GNUNET_OK; |
2143 | } | 2176 | } |
2144 | 2177 | ||
@@ -2148,17 +2181,17 @@ file_name_cb(void *cls, const char *filename) | |||
2148 | * Compute all perfect samples. | 2181 | * Compute all perfect samples. |
2149 | */ | 2182 | */ |
2150 | static int | 2183 | static int |
2151 | profiler_eval(void) | 2184 | profiler_eval (void) |
2152 | { | 2185 | { |
2153 | #ifdef TO_FILE | 2186 | #ifdef TO_FILE |
2154 | /* Compute perfect sample for each sampler element */ | 2187 | /* Compute perfect sample for each sampler element */ |
2155 | if (-1 == GNUNET_DISK_directory_scan("/tmp/rps/", file_name_cb, NULL)) | 2188 | if (-1 == GNUNET_DISK_directory_scan ("/tmp/rps/", file_name_cb, NULL)) |
2156 | { | 2189 | { |
2157 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Scan of directory failed\n"); | 2190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Scan of directory failed\n"); |
2158 | } | 2191 | } |
2159 | #endif /* TO_FILE */ | 2192 | #endif /* TO_FILE */ |
2160 | 2193 | ||
2161 | return evaluate(); | 2194 | return evaluate (); |
2162 | } | 2195 | } |
2163 | 2196 | ||
2164 | 2197 | ||
@@ -2169,40 +2202,40 @@ profiler_eval(void) | |||
2169 | * | 2202 | * |
2170 | * @return | 2203 | * @return |
2171 | */ | 2204 | */ |
2172 | static int is_in_view(uint32_t a, uint32_t b) | 2205 | static int is_in_view (uint32_t a, uint32_t b) |
2173 | { | 2206 | { |
2174 | uint32_t i; | 2207 | uint32_t i; |
2175 | 2208 | ||
2176 | for (i = 0; i < rps_peers[a].cur_view_count; i++) | 2209 | for (i = 0; i < rps_peers[a].cur_view_count; i++) |
2210 | { | ||
2211 | if (0 == memcmp (rps_peers[b].peer_id, | ||
2212 | &rps_peers[a].cur_view[i], | ||
2213 | sizeof(struct GNUNET_PeerIdentity))) | ||
2177 | { | 2214 | { |
2178 | if (0 == memcmp(rps_peers[b].peer_id, | 2215 | return GNUNET_YES; |
2179 | &rps_peers[a].cur_view[i], | ||
2180 | sizeof(struct GNUNET_PeerIdentity))) | ||
2181 | { | ||
2182 | return GNUNET_YES; | ||
2183 | } | ||
2184 | } | 2216 | } |
2217 | } | ||
2185 | return GNUNET_NO; | 2218 | return GNUNET_NO; |
2186 | } | 2219 | } |
2187 | 2220 | ||
2188 | static uint32_t get_idx_of_pid(const struct GNUNET_PeerIdentity *pid) | 2221 | static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) |
2189 | { | 2222 | { |
2190 | uint32_t i; | 2223 | uint32_t i; |
2191 | 2224 | ||
2192 | for (i = 0; i < num_peers; i++) | 2225 | for (i = 0; i < num_peers; i++) |
2193 | { | 2226 | { |
2194 | if (0 == memcmp(pid, | 2227 | if (0 == memcmp (pid, |
2195 | rps_peers[i].peer_id, | 2228 | rps_peers[i].peer_id, |
2196 | sizeof(struct GNUNET_PeerIdentity))) | 2229 | sizeof(struct GNUNET_PeerIdentity))) |
2197 | { | 2230 | { |
2198 | return i; | 2231 | return i; |
2199 | } | 2232 | } |
2200 | } | 2233 | } |
2201 | //return 0; /* Should not happen - make compiler happy */ | 2234 | // return 0; /* Should not happen - make compiler happy */ |
2202 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2235 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2203 | "No known _PeerIdentity %s!\n", | 2236 | "No known _PeerIdentity %s!\n", |
2204 | GNUNET_i2s_full(pid)); | 2237 | GNUNET_i2s_full (pid)); |
2205 | GNUNET_assert(0); | 2238 | GNUNET_assert (0); |
2206 | } | 2239 | } |
2207 | 2240 | ||
2208 | /** | 2241 | /** |
@@ -2213,20 +2246,20 @@ static uint32_t get_idx_of_pid(const struct GNUNET_PeerIdentity *pid) | |||
2213 | * | 2246 | * |
2214 | * @return | 2247 | * @return |
2215 | */ | 2248 | */ |
2216 | static uint32_t count_containing_views(uint32_t a, uint32_t b) | 2249 | static uint32_t count_containing_views (uint32_t a, uint32_t b) |
2217 | { | 2250 | { |
2218 | uint32_t i; | 2251 | uint32_t i; |
2219 | uint32_t peer_idx; | 2252 | uint32_t peer_idx; |
2220 | uint32_t count = 0; | 2253 | uint32_t count = 0; |
2221 | 2254 | ||
2222 | for (i = 0; i < rps_peers[a].cur_view_count; i++) | 2255 | for (i = 0; i < rps_peers[a].cur_view_count; i++) |
2256 | { | ||
2257 | peer_idx = get_idx_of_pid (&rps_peers[a].cur_view[i]); | ||
2258 | if (GNUNET_YES == is_in_view (peer_idx, b)) | ||
2223 | { | 2259 | { |
2224 | peer_idx = get_idx_of_pid(&rps_peers[a].cur_view[i]); | 2260 | count++; |
2225 | if (GNUNET_YES == is_in_view(peer_idx, b)) | ||
2226 | { | ||
2227 | count++; | ||
2228 | } | ||
2229 | } | 2261 | } |
2262 | } | ||
2230 | return count; | 2263 | return count; |
2231 | } | 2264 | } |
2232 | 2265 | ||
@@ -2236,13 +2269,13 @@ static uint32_t count_containing_views(uint32_t a, uint32_t b) | |||
2236 | * | 2269 | * |
2237 | * @param peer_idx index of the peer that is about to sample | 2270 | * @param peer_idx index of the peer that is about to sample |
2238 | */ | 2271 | */ |
2239 | static void compute_probabilities(uint32_t peer_idx) | 2272 | static void compute_probabilities (uint32_t peer_idx) |
2240 | { | 2273 | { |
2241 | //double probs[num_peers] = { 0 }; | 2274 | // double probs[num_peers] = { 0 }; |
2242 | double probs[num_peers]; | 2275 | double probs[num_peers]; |
2243 | double probs_hist[num_peers]; /* Probability respecting the history */ | 2276 | double probs_hist[num_peers]; /* Probability respecting the history */ |
2244 | size_t probs_as_str_size = (num_peers * 10 + 2) * sizeof(char); | 2277 | size_t probs_as_str_size = (num_peers * 10 + 2) * sizeof(char); |
2245 | char *probs_as_str = GNUNET_malloc(probs_as_str_size); | 2278 | char *probs_as_str = GNUNET_malloc (probs_as_str_size); |
2246 | char *probs_as_str_cpy; | 2279 | char *probs_as_str_cpy; |
2247 | uint32_t i; | 2280 | uint32_t i; |
2248 | double prob_push; | 2281 | double prob_push; |
@@ -2254,143 +2287,144 @@ static void compute_probabilities(uint32_t peer_idx) | |||
2254 | double sum_non_zero_prob = 0; | 2287 | double sum_non_zero_prob = 0; |
2255 | double sum_non_zero_prob_hist = 0; | 2288 | double sum_non_zero_prob_hist = 0; |
2256 | 2289 | ||
2257 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2258 | "Computing probabilities for peer %" PRIu32 "\n", peer_idx); | 2291 | "Computing probabilities for peer %" PRIu32 "\n", peer_idx); |
2259 | /* Firstly without knowledge of old views */ | 2292 | /* Firstly without knowledge of old views */ |
2260 | for (i = 0; i < num_peers; i++) | 2293 | for (i = 0; i < num_peers; i++) |
2261 | { | 2294 | { |
2262 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2263 | "\tfor peer %" PRIu32 ":\n", i); | 2296 | "\tfor peer %" PRIu32 ":\n", i); |
2264 | view_size = rps_peers[i].cur_view_count; | 2297 | view_size = rps_peers[i].cur_view_count; |
2265 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2266 | "\t\tview_size: %" PRIu32 "\n", view_size); | 2299 | "\t\tview_size: %" PRIu32 "\n", view_size); |
2267 | /* For peer i the probability of being sampled is | 2300 | /* For peer i the probability of being sampled is |
2268 | * evenly distributed among all possibly observed peers. */ | 2301 | * evenly distributed among all possibly observed peers. */ |
2269 | /* We could have observed a peer in three cases: | 2302 | /* We could have observed a peer in three cases: |
2270 | * 1. peer sent a push | 2303 | * 1. peer sent a push |
2271 | * 2. peer was contained in a pull reply | 2304 | * 2. peer was contained in a pull reply |
2272 | * 3. peer was in history (sampler) - ignored for now */ | 2305 | * 3. peer was in history (sampler) - ignored for now */ |
2273 | /* 1. Probability of having received a push from peer i */ | 2306 | /* 1. Probability of having received a push from peer i */ |
2274 | if ((GNUNET_YES == is_in_view(i, peer_idx)) && | 2307 | if ((GNUNET_YES == is_in_view (i, peer_idx)) && |
2275 | (1 <= (0.45 * view_size))) | 2308 | (1 <= (0.45 * view_size))) |
2276 | { | 2309 | { |
2277 | if (0 == binom(view_size, 0.45 * view_size)) | 2310 | if (0 == binom (view_size, 0.45 * view_size)) |
2278 | prob_push = 0; | 2311 | prob_push = 0; |
2279 | else | ||
2280 | { | ||
2281 | prob_push = 1.0 * binom(0.45 * view_size, 1) | ||
2282 | / | ||
2283 | binom(view_size, 0.45 * view_size); | ||
2284 | } | ||
2285 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2286 | "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n", | ||
2287 | peer_idx, | ||
2288 | i, | ||
2289 | prob_push); | ||
2290 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2291 | "\t\tposs choices from view: %" PRIu32 ", containing i: %" PRIu32 "\n", | ||
2292 | binom(view_size, 0.45 * view_size), | ||
2293 | binom(0.45 * view_size, 1)); | ||
2294 | } | ||
2295 | else | ||
2296 | { | ||
2297 | prob_push = 0; | ||
2298 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2299 | "\t\t%" PRIu32 " is not in %" PRIu32 "'s view, prob: 0\n", | ||
2300 | peer_idx, | ||
2301 | i); | ||
2302 | } | ||
2303 | /* 2. Probability of peer i being contained in pulls */ | ||
2304 | view_size = rps_peers[peer_idx].cur_view_count; | ||
2305 | cont_views = count_containing_views(peer_idx, i); | ||
2306 | number_of_being_in_pull_events = | ||
2307 | (binom(view_size, 0.45 * view_size) - | ||
2308 | binom(view_size - cont_views, 0.45 * view_size)); | ||
2309 | if (0 != number_of_being_in_pull_events) | ||
2310 | { | ||
2311 | prob_pull = number_of_being_in_pull_events | ||
2312 | / | ||
2313 | (1.0 * binom(view_size, 0.45 * view_size)); | ||
2314 | } | ||
2315 | else | 2312 | else |
2316 | { | 2313 | { |
2317 | prob_pull = 0; | 2314 | prob_push = 1.0 * binom (0.45 * view_size, 1) |
2318 | } | 2315 | / |
2319 | probs[i] = prob_push + prob_pull - (prob_push * prob_pull); | 2316 | binom (view_size, 0.45 * view_size); |
2320 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2317 | } |
2321 | "\t\t%" PRIu32 " has %" PRIu32 " of %" PRIu32 | 2318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2322 | " peers in its view who know %" PRIu32 " prob: %f\n", | 2319 | "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n", |
2323 | peer_idx, | 2320 | peer_idx, |
2324 | cont_views, | 2321 | i, |
2325 | view_size, | 2322 | prob_push); |
2326 | i, | 2323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2327 | prob_pull); | 2324 | "\t\tposs choices from view: %" PRIu32 ", containing i: %" |
2328 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2325 | PRIu32 "\n", |
2329 | "\t\tnumber of possible pull combinations: %" PRIu32 "\n", | 2326 | binom (view_size, 0.45 * view_size), |
2330 | binom(view_size, 0.45 * view_size)); | 2327 | binom (0.45 * view_size, 1)); |
2331 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2328 | } |
2332 | "\t\tnumber of possible pull combinations without %" PRIu32 | 2329 | else |
2333 | ": %" PRIu32 "\n", | 2330 | { |
2334 | i, | 2331 | prob_push = 0; |
2335 | binom(view_size - cont_views, 0.45 * view_size)); | 2332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2336 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2333 | "\t\t%" PRIu32 " is not in %" PRIu32 "'s view, prob: 0\n", |
2337 | "\t\tnumber of possible pull combinations with %" PRIu32 | 2334 | peer_idx, |
2338 | ": %" PRIu32 "\n", | 2335 | i); |
2339 | i, | 2336 | } |
2340 | number_of_being_in_pull_events); | 2337 | /* 2. Probability of peer i being contained in pulls */ |
2341 | 2338 | view_size = rps_peers[peer_idx].cur_view_count; | |
2342 | probs_hist[i] = 0.9 * rps_peers[peer_idx].eval_probs_cache[i] + probs[i]; | 2339 | cont_views = count_containing_views (peer_idx, i); |
2343 | rps_peers[peer_idx].eval_probs_cache[i] = probs_hist[i]; | 2340 | number_of_being_in_pull_events = |
2344 | 2341 | (binom (view_size, 0.45 * view_size) | |
2345 | sum_non_zero_prob += probs[i]; | 2342 | - binom (view_size - cont_views, 0.45 * view_size)); |
2346 | sum_non_zero_prob_hist += probs_hist[i]; | 2343 | if (0 != number_of_being_in_pull_events) |
2347 | } | 2344 | { |
2345 | prob_pull = number_of_being_in_pull_events | ||
2346 | / | ||
2347 | (1.0 * binom (view_size, 0.45 * view_size)); | ||
2348 | } | ||
2349 | else | ||
2350 | { | ||
2351 | prob_pull = 0; | ||
2352 | } | ||
2353 | probs[i] = prob_push + prob_pull - (prob_push * prob_pull); | ||
2354 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2355 | "\t\t%" PRIu32 " has %" PRIu32 " of %" PRIu32 | ||
2356 | " peers in its view who know %" PRIu32 " prob: %f\n", | ||
2357 | peer_idx, | ||
2358 | cont_views, | ||
2359 | view_size, | ||
2360 | i, | ||
2361 | prob_pull); | ||
2362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2363 | "\t\tnumber of possible pull combinations: %" PRIu32 "\n", | ||
2364 | binom (view_size, 0.45 * view_size)); | ||
2365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2366 | "\t\tnumber of possible pull combinations without %" PRIu32 | ||
2367 | ": %" PRIu32 "\n", | ||
2368 | i, | ||
2369 | binom (view_size - cont_views, 0.45 * view_size)); | ||
2370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2371 | "\t\tnumber of possible pull combinations with %" PRIu32 | ||
2372 | ": %" PRIu32 "\n", | ||
2373 | i, | ||
2374 | number_of_being_in_pull_events); | ||
2375 | |||
2376 | probs_hist[i] = 0.9 * rps_peers[peer_idx].eval_probs_cache[i] + probs[i]; | ||
2377 | rps_peers[peer_idx].eval_probs_cache[i] = probs_hist[i]; | ||
2378 | |||
2379 | sum_non_zero_prob += probs[i]; | ||
2380 | sum_non_zero_prob_hist += probs_hist[i]; | ||
2381 | } | ||
2348 | /* normalize */ | 2382 | /* normalize */ |
2349 | if (0 != sum_non_zero_prob) | 2383 | if (0 != sum_non_zero_prob) |
2384 | { | ||
2385 | for (i = 0; i < num_peers; i++) | ||
2350 | { | 2386 | { |
2351 | for (i = 0; i < num_peers; i++) | 2387 | probs[i] = probs[i] * (1.0 / sum_non_zero_prob); |
2352 | { | ||
2353 | probs[i] = probs[i] * (1.0 / sum_non_zero_prob); | ||
2354 | } | ||
2355 | } | 2388 | } |
2389 | } | ||
2356 | if (0 != sum_non_zero_prob_hist) | 2390 | if (0 != sum_non_zero_prob_hist) |
2391 | { | ||
2392 | for (i = 0; i < num_peers; i++) | ||
2357 | { | 2393 | { |
2358 | for (i = 0; i < num_peers; i++) | 2394 | probs_hist[i] = probs_hist[i] * (1.0 / sum_non_zero_prob_hist); |
2359 | { | ||
2360 | probs_hist[i] = probs_hist[i] * (1.0 / sum_non_zero_prob_hist); | ||
2361 | } | ||
2362 | } | 2395 | } |
2396 | } | ||
2363 | 2397 | ||
2364 | /* str repr */ | 2398 | /* str repr */ |
2365 | for (i = 0; i < num_peers; i++) | 2399 | for (i = 0; i < num_peers; i++) |
2366 | { | 2400 | { |
2367 | probs_as_str_cpy = GNUNET_strndup(probs_as_str, probs_as_str_size); | 2401 | probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size); |
2368 | tmp = GNUNET_snprintf(probs_as_str, | 2402 | tmp = GNUNET_snprintf (probs_as_str, |
2369 | probs_as_str_size, | 2403 | probs_as_str_size, |
2370 | "%s %7.6f", probs_as_str_cpy, probs[i]); | 2404 | "%s %7.6f", probs_as_str_cpy, probs[i]); |
2371 | GNUNET_free(probs_as_str_cpy); | 2405 | GNUNET_free (probs_as_str_cpy); |
2372 | GNUNET_assert(0 <= tmp); | 2406 | GNUNET_assert (0 <= tmp); |
2373 | } | 2407 | } |
2374 | 2408 | ||
2375 | to_file_w_len(rps_peers[peer_idx].file_name_probs, | 2409 | to_file_w_len (rps_peers[peer_idx].file_name_probs, |
2376 | probs_as_str_size, | 2410 | probs_as_str_size, |
2377 | probs_as_str); | 2411 | probs_as_str); |
2378 | 2412 | ||
2379 | probs_as_str[0] = '\0'; | 2413 | probs_as_str[0] = '\0'; |
2380 | for (i = 0; i < num_peers; i++) | 2414 | for (i = 0; i < num_peers; i++) |
2381 | { | 2415 | { |
2382 | probs_as_str_cpy = GNUNET_strndup(probs_as_str, probs_as_str_size); | 2416 | probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size); |
2383 | tmp = GNUNET_snprintf(probs_as_str, | 2417 | tmp = GNUNET_snprintf (probs_as_str, |
2384 | probs_as_str_size, | 2418 | probs_as_str_size, |
2385 | "%s %7.6f", probs_as_str_cpy, probs_hist[i]); | 2419 | "%s %7.6f", probs_as_str_cpy, probs_hist[i]); |
2386 | GNUNET_free(probs_as_str_cpy); | 2420 | GNUNET_free (probs_as_str_cpy); |
2387 | GNUNET_assert(0 <= tmp); | 2421 | GNUNET_assert (0 <= tmp); |
2388 | } | 2422 | } |
2389 | 2423 | ||
2390 | to_file_w_len(rps_peers[peer_idx].file_name_probs_hist, | 2424 | to_file_w_len (rps_peers[peer_idx].file_name_probs_hist, |
2391 | probs_as_str_size, | 2425 | probs_as_str_size, |
2392 | probs_as_str); | 2426 | probs_as_str); |
2393 | GNUNET_free(probs_as_str); | 2427 | GNUNET_free (probs_as_str); |
2394 | } | 2428 | } |
2395 | 2429 | ||
2396 | /** | 2430 | /** |
@@ -2402,295 +2436,300 @@ static void compute_probabilities(uint32_t peer_idx) | |||
2402 | * | 2436 | * |
2403 | * @return the number of occurrences | 2437 | * @return the number of occurrences |
2404 | */ | 2438 | */ |
2405 | static uint32_t count_peer_in_views_2(uint32_t peer_idx) | 2439 | static uint32_t count_peer_in_views_2 (uint32_t peer_idx) |
2406 | { | 2440 | { |
2407 | uint32_t i, j; | 2441 | uint32_t i, j; |
2408 | uint32_t count = 0; | 2442 | uint32_t count = 0; |
2409 | 2443 | ||
2410 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ | 2444 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ |
2411 | { | 2445 | { |
2412 | for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */ | 2446 | for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */ |
2413 | { | 2447 | { |
2414 | if (0 == memcmp(rps_peers[peer_idx].peer_id, | 2448 | if (0 == memcmp (rps_peers[peer_idx].peer_id, |
2415 | &rps_peers[i].cur_view[j], | 2449 | &rps_peers[i].cur_view[j], |
2416 | sizeof(struct GNUNET_PeerIdentity))) | 2450 | sizeof(struct GNUNET_PeerIdentity))) |
2417 | { | 2451 | { |
2418 | count++; | 2452 | count++; |
2419 | break; | 2453 | break; |
2420 | } | 2454 | } |
2421 | } | 2455 | } |
2422 | } | 2456 | } |
2423 | rps_peers[peer_idx].count_in_views = count; | 2457 | rps_peers[peer_idx].count_in_views = count; |
2424 | return count; | 2458 | return count; |
2425 | } | 2459 | } |
2426 | 2460 | ||
2427 | static uint32_t cumulated_view_sizes() | 2461 | static uint32_t cumulated_view_sizes () |
2428 | { | 2462 | { |
2429 | uint32_t i; | 2463 | uint32_t i; |
2430 | 2464 | ||
2431 | view_sizes = 0; | 2465 | view_sizes = 0; |
2432 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ | 2466 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ |
2433 | { | 2467 | { |
2434 | view_sizes += rps_peers[i].cur_view_count; | 2468 | view_sizes += rps_peers[i].cur_view_count; |
2435 | } | 2469 | } |
2436 | return view_sizes; | 2470 | return view_sizes; |
2437 | } | 2471 | } |
2438 | 2472 | ||
2439 | static void count_peer_in_views(uint32_t *count_peers) | 2473 | static void count_peer_in_views (uint32_t *count_peers) |
2440 | { | 2474 | { |
2441 | uint32_t i, j; | 2475 | uint32_t i, j; |
2442 | 2476 | ||
2443 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ | 2477 | for (i = 0; i < num_peers; i++) /* Peer in which view is counted */ |
2478 | { | ||
2479 | for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */ | ||
2444 | { | 2480 | { |
2445 | for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */ | 2481 | if (0 == memcmp (rps_peers[i].peer_id, |
2446 | { | 2482 | &rps_peers[i].cur_view[j], |
2447 | if (0 == memcmp(rps_peers[i].peer_id, | 2483 | sizeof(struct GNUNET_PeerIdentity))) |
2448 | &rps_peers[i].cur_view[j], | 2484 | { |
2449 | sizeof(struct GNUNET_PeerIdentity))) | 2485 | count_peers[i]++; |
2450 | { | 2486 | } |
2451 | count_peers[i]++; | ||
2452 | } | ||
2453 | } | ||
2454 | } | 2487 | } |
2488 | } | ||
2455 | } | 2489 | } |
2456 | 2490 | ||
2457 | void compute_diversity() | 2491 | void compute_diversity () |
2458 | { | 2492 | { |
2459 | uint32_t i; | 2493 | uint32_t i; |
2460 | /* ith entry represents the numer of occurrences in other peer's views */ | 2494 | /* ith entry represents the numer of occurrences in other peer's views */ |
2461 | uint32_t *count_peers = GNUNET_new_array(num_peers, uint32_t); | 2495 | uint32_t *count_peers = GNUNET_new_array (num_peers, uint32_t); |
2462 | uint32_t views_total_size; | 2496 | uint32_t views_total_size; |
2463 | double expected; | 2497 | double expected; |
2464 | /* deviation from expected number of peers */ | 2498 | /* deviation from expected number of peers */ |
2465 | double *deviation = GNUNET_new_array(num_peers, double); | 2499 | double *deviation = GNUNET_new_array (num_peers, double); |
2466 | 2500 | ||
2467 | views_total_size = 0; | 2501 | views_total_size = 0; |
2468 | expected = 0; | 2502 | expected = 0; |
2469 | 2503 | ||
2470 | /* For each peer count its representation in other peer's views*/ | 2504 | /* For each peer count its representation in other peer's views*/ |
2471 | for (i = 0; i < num_peers; i++) /* Peer to count */ | 2505 | for (i = 0; i < num_peers; i++) /* Peer to count */ |
2472 | { | 2506 | { |
2473 | views_total_size += rps_peers[i].cur_view_count; | 2507 | views_total_size += rps_peers[i].cur_view_count; |
2474 | count_peer_in_views(count_peers); | 2508 | count_peer_in_views (count_peers); |
2475 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2476 | "Counted representation of %" PRIu32 "th peer [%s]: %" PRIu32 "\n", | 2510 | "Counted representation of %" PRIu32 "th peer [%s]: %" PRIu32 |
2477 | i, | 2511 | "\n", |
2478 | GNUNET_i2s(rps_peers[i].peer_id), | 2512 | i, |
2479 | count_peers[i]); | 2513 | GNUNET_i2s (rps_peers[i].peer_id), |
2480 | } | 2514 | count_peers[i]); |
2481 | 2515 | } | |
2482 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2516 | |
2483 | "size of all views combined: %" PRIu32 "\n", | 2517 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2484 | views_total_size); | 2518 | "size of all views combined: %" PRIu32 "\n", |
2485 | expected = ((double)1 / num_peers) * views_total_size; | 2519 | views_total_size); |
2486 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2520 | expected = ((double) 1 / num_peers) * views_total_size; |
2487 | "Expected number of occurrences of each peer in all views: %f\n", | 2521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2488 | expected); | 2522 | "Expected number of occurrences of each peer in all views: %f\n", |
2523 | expected); | ||
2489 | for (i = 0; i < num_peers; i++) /* Peer to count */ | 2524 | for (i = 0; i < num_peers; i++) /* Peer to count */ |
2490 | { | 2525 | { |
2491 | deviation[i] = expected - count_peers[i]; | 2526 | deviation[i] = expected - count_peers[i]; |
2492 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2493 | "Deviation from expectation: %f\n", deviation[i]); | 2528 | "Deviation from expectation: %f\n", deviation[i]); |
2494 | } | 2529 | } |
2495 | GNUNET_free(count_peers); | 2530 | GNUNET_free (count_peers); |
2496 | GNUNET_free(deviation); | 2531 | GNUNET_free (deviation); |
2497 | } | 2532 | } |
2498 | 2533 | ||
2499 | void print_view_sizes() | 2534 | void print_view_sizes () |
2500 | { | 2535 | { |
2501 | uint32_t i; | 2536 | uint32_t i; |
2502 | 2537 | ||
2503 | for (i = 0; i < num_peers; i++) /* Peer to count */ | 2538 | for (i = 0; i < num_peers; i++) /* Peer to count */ |
2504 | { | 2539 | { |
2505 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2540 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2506 | "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n", | 2541 | "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n", |
2507 | i, | 2542 | i, |
2508 | GNUNET_i2s(rps_peers[i].peer_id), | 2543 | GNUNET_i2s (rps_peers[i].peer_id), |
2509 | rps_peers[i].cur_view_count); | 2544 | rps_peers[i].cur_view_count); |
2510 | } | 2545 | } |
2511 | } | 2546 | } |
2512 | 2547 | ||
2513 | void all_views_updated_cb() | 2548 | void all_views_updated_cb () |
2514 | { | 2549 | { |
2515 | compute_diversity(); | 2550 | compute_diversity (); |
2516 | print_view_sizes(); | 2551 | print_view_sizes (); |
2517 | } | 2552 | } |
2518 | 2553 | ||
2519 | void view_update_cb(void *cls, | 2554 | void view_update_cb (void *cls, |
2520 | uint64_t view_size, | 2555 | uint64_t view_size, |
2521 | const struct GNUNET_PeerIdentity *peers) | 2556 | const struct GNUNET_PeerIdentity *peers) |
2522 | { | 2557 | { |
2523 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2524 | "View was updated (%" PRIu64 ")\n", view_size); | 2559 | "View was updated (%" PRIu64 ")\n", view_size); |
2525 | struct RPSPeer *rps_peer = (struct RPSPeer *)cls; | 2560 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; |
2526 | to_file("/tmp/rps/view_sizes.txt", | 2561 | to_file ("/tmp/rps/view_sizes.txt", |
2527 | "%" PRIu64 " %" PRIu32 "", | 2562 | "%" PRIu64 " %" PRIu32 "", |
2528 | rps_peer->index, | 2563 | rps_peer->index, |
2529 | view_size); | 2564 | view_size); |
2530 | for (uint64_t i = 0; i < view_size; i++) | 2565 | for (uint64_t i = 0; i < view_size; i++) |
2531 | { | 2566 | { |
2532 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2533 | "\t%s\n", GNUNET_i2s(&peers[i])); | 2568 | "\t%s\n", GNUNET_i2s (&peers[i])); |
2534 | } | 2569 | } |
2535 | GNUNET_array_grow(rps_peer->cur_view, | 2570 | GNUNET_array_grow (rps_peer->cur_view, |
2536 | rps_peer->cur_view_count, | 2571 | rps_peer->cur_view_count, |
2537 | view_size); | 2572 | view_size); |
2538 | //*rps_peer->cur_view = *peers; | 2573 | // *rps_peer->cur_view = *peers; |
2539 | GNUNET_memcpy(rps_peer->cur_view, | 2574 | GNUNET_memcpy (rps_peer->cur_view, |
2540 | peers, | 2575 | peers, |
2541 | view_size * sizeof(struct GNUNET_PeerIdentity)); | 2576 | view_size * sizeof(struct GNUNET_PeerIdentity)); |
2542 | to_file("/tmp/rps/count_in_views.txt", | 2577 | to_file ("/tmp/rps/count_in_views.txt", |
2543 | "%" PRIu64 " %" PRIu32 "", | 2578 | "%" PRIu64 " %" PRIu32 "", |
2544 | rps_peer->index, | 2579 | rps_peer->index, |
2545 | count_peer_in_views_2(rps_peer->index)); | 2580 | count_peer_in_views_2 (rps_peer->index)); |
2546 | cumulated_view_sizes(); | 2581 | cumulated_view_sizes (); |
2547 | if (0 != view_size) | 2582 | if (0 != view_size) |
2548 | { | 2583 | { |
2549 | to_file("/tmp/rps/repr.txt", | 2584 | to_file ("/tmp/rps/repr.txt", |
2550 | "%" PRIu64 /* index */ | 2585 | "%" PRIu64 /* index */ |
2551 | " %" PRIu32 /* occurrence in views */ | 2586 | " %" PRIu32 /* occurrence in views */ |
2552 | " %" PRIu32 /* view sizes */ | 2587 | " %" PRIu32 /* view sizes */ |
2553 | " %f" /* fraction of repr in views */ | 2588 | " %f" /* fraction of repr in views */ |
2554 | " %f" /* average view size */ | 2589 | " %f" /* average view size */ |
2555 | " %f" /* prob of occurrence in view slot */ | 2590 | " %f" /* prob of occurrence in view slot */ |
2556 | " %f" "", /* exp frac of repr in views */ | 2591 | " %f" "", /* exp frac of repr in views */ |
2557 | rps_peer->index, | 2592 | rps_peer->index, |
2558 | count_peer_in_views_2(rps_peer->index), | 2593 | count_peer_in_views_2 (rps_peer->index), |
2559 | view_sizes, | 2594 | view_sizes, |
2560 | count_peer_in_views_2(rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */ | 2595 | count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */ |
2561 | view_sizes / (view_size * 1.0), /* average view size */ | 2596 | view_sizes / (view_size * 1.0), /* average view size */ |
2562 | 1.0 / view_size, /* prob of occurrence in view slot */ | 2597 | 1.0 / view_size, /* prob of occurrence in view slot */ |
2563 | (1.0 / view_size) * (view_sizes / view_size) /* expected fraction of repr in views */ | 2598 | (1.0 / view_size) * (view_sizes / view_size) /* expected fraction of repr in views */ |
2564 | ); | 2599 | ); |
2565 | } | 2600 | } |
2566 | compute_probabilities(rps_peer->index); | 2601 | compute_probabilities (rps_peer->index); |
2567 | all_views_updated_cb(); | 2602 | all_views_updated_cb (); |
2568 | } | 2603 | } |
2569 | 2604 | ||
2570 | static void | 2605 | static void |
2571 | pre_profiler(struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) | 2606 | pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) |
2572 | { | 2607 | { |
2573 | rps_peer->file_name_probs = | 2608 | rps_peer->file_name_probs = |
2574 | store_prefix_file_name(rps_peer->index, "probs"); | 2609 | store_prefix_file_name (rps_peer->index, "probs"); |
2575 | rps_peer->file_name_probs_hist = | 2610 | rps_peer->file_name_probs_hist = |
2576 | store_prefix_file_name(rps_peer->index, "probs_hist"); | 2611 | store_prefix_file_name (rps_peer->index, "probs_hist"); |
2577 | GNUNET_RPS_view_request(h, 0, view_update_cb, rps_peer); | 2612 | GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); |
2578 | } | 2613 | } |
2579 | 2614 | ||
2580 | void write_final_stats(void) | 2615 | void write_final_stats (void) |
2581 | { | 2616 | { |
2582 | uint64_t sums[STAT_TYPE_MAX] = { 0 }; | 2617 | uint64_t sums[STAT_TYPE_MAX] = { 0 }; |
2583 | 2618 | ||
2584 | for (uint32_t i = 0; i < num_peers; i++) | 2619 | for (uint32_t i = 0; i < num_peers; i++) |
2585 | { | 2620 | { |
2586 | to_file("/tmp/rps/final_stats.csv", | 2621 | to_file ("/tmp/rps/final_stats.csv", |
2587 | "%" PRIu32 ", " /* index */ | 2622 | "%" PRIu32 ", " /* index */ |
2588 | "%s, %" /* id */ | 2623 | "%s, %" /* id */ |
2589 | PRIu64 ", %" /* rounds */ | 2624 | PRIu64 ", %" /* rounds */ |
2590 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* blocking */ | 2625 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" |
2591 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */ | 2626 | PRIu64 ", %" /* blocking */ |
2592 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */ | 2627 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */ |
2593 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* recv */ | 2628 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */ |
2594 | PRIu64 ", %" /* view size */ | 2629 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" |
2595 | PRIu64 ", %" /* known peers */ | 2630 | PRIu64 ", %" /* recv */ |
2596 | PRIu64 ", %" /* valid peers */ | 2631 | PRIu64 ", %" /* view size */ |
2597 | PRIu64 ", %" /* learned peers */ | 2632 | PRIu64 ", %" /* known peers */ |
2598 | PRIu64 ", %" /* pending online checks */ | 2633 | PRIu64 ", %" /* valid peers */ |
2599 | PRIu64 ", %" /* unrequested pull replies */ | 2634 | PRIu64 ", %" /* learned peers */ |
2600 | PRIu64 ", %" /* peers in push map */ | 2635 | PRIu64 ", %" /* pending online checks */ |
2601 | PRIu64 ", %" /* peers in pull map */ | 2636 | PRIu64 ", %" /* unrequested pull replies */ |
2602 | PRIu64 ", %" /* peers in view */ | 2637 | PRIu64 ", %" /* peers in push map */ |
2603 | PRIu64 "\n" /* view size aim */, | 2638 | PRIu64 ", %" /* peers in pull map */ |
2604 | i, | 2639 | PRIu64 ", %" /* peers in view */ |
2605 | GNUNET_i2s(rps_peers[i].peer_id), | 2640 | PRIu64 "\n" /* view size aim */, |
2606 | rps_peers[i].stats[STAT_TYPE_ROUNDS], | 2641 | i, |
2607 | rps_peers[i].stats[STAT_TYPE_BLOCKS], | 2642 | GNUNET_i2s (rps_peers[i].peer_id), |
2608 | rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH], | 2643 | rps_peers[i].stats[STAT_TYPE_ROUNDS], |
2609 | rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH], | 2644 | rps_peers[i].stats[STAT_TYPE_BLOCKS], |
2610 | rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PULL], | 2645 | rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH], |
2611 | rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL], | 2646 | rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH], |
2612 | rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL], | 2647 | rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PULL], |
2613 | rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND], | 2648 | rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL], |
2614 | rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND_MH], | 2649 | rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL], |
2615 | rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ], | 2650 | rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND], |
2616 | rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ_MH], | 2651 | rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND_MH], |
2617 | rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REP], | 2652 | rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ], |
2618 | rps_peers[i].stats[STAT_TYPE_SENT_PUSH_SEND], | 2653 | rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ_MH], |
2619 | rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ], | 2654 | rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REP], |
2620 | rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ_MH], | 2655 | rps_peers[i].stats[STAT_TYPE_SENT_PUSH_SEND], |
2621 | rps_peers[i].stats[STAT_TYPE_SENT_PULL_REP], | 2656 | rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ], |
2622 | rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND], | 2657 | rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ_MH], |
2623 | rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND_MH], | 2658 | rps_peers[i].stats[STAT_TYPE_SENT_PULL_REP], |
2624 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ], | 2659 | rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND], |
2625 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ_MH], | 2660 | rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND_MH], |
2626 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP_MH], | 2661 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ], |
2627 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP], | 2662 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ_MH], |
2628 | rps_peers[i].stats[STAT_TYPE_VIEW_SIZE], | 2663 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP_MH], |
2629 | rps_peers[i].stats[STAT_TYPE_KNOWN_PEERS], | 2664 | rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP], |
2630 | rps_peers[i].stats[STAT_TYPE_VALID_PEERS], | 2665 | rps_peers[i].stats[STAT_TYPE_VIEW_SIZE], |
2631 | rps_peers[i].stats[STAT_TYPE_LEARND_PEERS], | 2666 | rps_peers[i].stats[STAT_TYPE_KNOWN_PEERS], |
2632 | rps_peers[i].stats[STAT_TYPE_PENDING_ONLINE_CHECKS], | 2667 | rps_peers[i].stats[STAT_TYPE_VALID_PEERS], |
2633 | rps_peers[i].stats[STAT_TYPE_UNREQUESTED_PULL_REPLIES], | 2668 | rps_peers[i].stats[STAT_TYPE_LEARND_PEERS], |
2634 | rps_peers[i].stats[STAT_TYPE_PEERS_IN_PUSH_MAP], | 2669 | rps_peers[i].stats[STAT_TYPE_PENDING_ONLINE_CHECKS], |
2635 | rps_peers[i].stats[STAT_TYPE_PEERS_IN_PULL_MAP], | 2670 | rps_peers[i].stats[STAT_TYPE_UNREQUESTED_PULL_REPLIES], |
2636 | rps_peers[i].stats[STAT_TYPE_PEERS_IN_VIEW], | 2671 | rps_peers[i].stats[STAT_TYPE_PEERS_IN_PUSH_MAP], |
2637 | rps_peers[i].stats[STAT_TYPE_VIEW_SIZE_AIM]); | 2672 | rps_peers[i].stats[STAT_TYPE_PEERS_IN_PULL_MAP], |
2638 | for (enum STAT_TYPE stat_type = STAT_TYPE_ROUNDS; | 2673 | rps_peers[i].stats[STAT_TYPE_PEERS_IN_VIEW], |
2639 | stat_type < STAT_TYPE_MAX; | 2674 | rps_peers[i].stats[STAT_TYPE_VIEW_SIZE_AIM]); |
2640 | stat_type++) | 2675 | for (enum STAT_TYPE stat_type = STAT_TYPE_ROUNDS; |
2641 | { | 2676 | stat_type < STAT_TYPE_MAX; |
2642 | sums[stat_type] += rps_peers[i].stats[stat_type]; | 2677 | stat_type++) |
2643 | } | 2678 | { |
2644 | } | 2679 | sums[stat_type] += rps_peers[i].stats[stat_type]; |
2645 | to_file("/tmp/rps/final_stats.dat", | 2680 | } |
2646 | "SUM %" | 2681 | } |
2647 | PRIu64 " %" /* rounds */ | 2682 | to_file ("/tmp/rps/final_stats.dat", |
2648 | PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" /* blocking */ | 2683 | "SUM %" |
2649 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */ | 2684 | PRIu64 " %" /* rounds */ |
2650 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */ | 2685 | PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 |
2651 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* recv */ | 2686 | " %" /* blocking */ |
2652 | PRIu64 ", %" /* view size */ | 2687 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */ |
2653 | PRIu64 ", %" /* known peers */ | 2688 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */ |
2654 | PRIu64 ", %" /* valid peers */ | 2689 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" |
2655 | PRIu64 ", %" /* learned peers */ | 2690 | PRIu64 ", %" /* recv */ |
2656 | PRIu64 ", %" /* pending online checks */ | 2691 | PRIu64 ", %" /* view size */ |
2657 | PRIu64 ", %" /* unrequested pull replies */ | 2692 | PRIu64 ", %" /* known peers */ |
2658 | PRIu64 ", %" /* peers in push map */ | 2693 | PRIu64 ", %" /* valid peers */ |
2659 | PRIu64 ", %" /* peers in pull map */ | 2694 | PRIu64 ", %" /* learned peers */ |
2660 | PRIu64 ", %" /* peers in view */ | 2695 | PRIu64 ", %" /* pending online checks */ |
2661 | PRIu64 "\n" /* view size aim */, | 2696 | PRIu64 ", %" /* unrequested pull replies */ |
2662 | sums[STAT_TYPE_ROUNDS], | 2697 | PRIu64 ", %" /* peers in push map */ |
2663 | sums[STAT_TYPE_BLOCKS], | 2698 | PRIu64 ", %" /* peers in pull map */ |
2664 | sums[STAT_TYPE_BLOCKS_MANY_PUSH], | 2699 | PRIu64 ", %" /* peers in view */ |
2665 | sums[STAT_TYPE_BLOCKS_NO_PUSH], | 2700 | PRIu64 "\n" /* view size aim */, |
2666 | sums[STAT_TYPE_BLOCKS_NO_PULL], | 2701 | sums[STAT_TYPE_ROUNDS], |
2667 | sums[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL], | 2702 | sums[STAT_TYPE_BLOCKS], |
2668 | sums[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL], | 2703 | sums[STAT_TYPE_BLOCKS_MANY_PUSH], |
2669 | sums[STAT_TYPE_ISSUED_PUSH_SEND], | 2704 | sums[STAT_TYPE_BLOCKS_NO_PUSH], |
2670 | sums[STAT_TYPE_ISSUED_PUSH_SEND_MH], | 2705 | sums[STAT_TYPE_BLOCKS_NO_PULL], |
2671 | sums[STAT_TYPE_ISSUED_PULL_REQ], | 2706 | sums[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL], |
2672 | sums[STAT_TYPE_ISSUED_PULL_REQ_MH], | 2707 | sums[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL], |
2673 | sums[STAT_TYPE_ISSUED_PULL_REP], | 2708 | sums[STAT_TYPE_ISSUED_PUSH_SEND], |
2674 | sums[STAT_TYPE_SENT_PUSH_SEND], | 2709 | sums[STAT_TYPE_ISSUED_PUSH_SEND_MH], |
2675 | sums[STAT_TYPE_SENT_PULL_REQ], | 2710 | sums[STAT_TYPE_ISSUED_PULL_REQ], |
2676 | sums[STAT_TYPE_SENT_PULL_REQ_MH], | 2711 | sums[STAT_TYPE_ISSUED_PULL_REQ_MH], |
2677 | sums[STAT_TYPE_SENT_PULL_REP], | 2712 | sums[STAT_TYPE_ISSUED_PULL_REP], |
2678 | sums[STAT_TYPE_RECV_PUSH_SEND], | 2713 | sums[STAT_TYPE_SENT_PUSH_SEND], |
2679 | sums[STAT_TYPE_RECV_PUSH_SEND_MH], | 2714 | sums[STAT_TYPE_SENT_PULL_REQ], |
2680 | sums[STAT_TYPE_RECV_PULL_REQ], | 2715 | sums[STAT_TYPE_SENT_PULL_REQ_MH], |
2681 | sums[STAT_TYPE_RECV_PULL_REQ_MH], | 2716 | sums[STAT_TYPE_SENT_PULL_REP], |
2682 | sums[STAT_TYPE_RECV_PULL_REP], | 2717 | sums[STAT_TYPE_RECV_PUSH_SEND], |
2683 | sums[STAT_TYPE_RECV_PULL_REP_MH], | 2718 | sums[STAT_TYPE_RECV_PUSH_SEND_MH], |
2684 | sums[STAT_TYPE_VIEW_SIZE], | 2719 | sums[STAT_TYPE_RECV_PULL_REQ], |
2685 | sums[STAT_TYPE_KNOWN_PEERS], | 2720 | sums[STAT_TYPE_RECV_PULL_REQ_MH], |
2686 | sums[STAT_TYPE_VALID_PEERS], | 2721 | sums[STAT_TYPE_RECV_PULL_REP], |
2687 | sums[STAT_TYPE_LEARND_PEERS], | 2722 | sums[STAT_TYPE_RECV_PULL_REP_MH], |
2688 | sums[STAT_TYPE_PENDING_ONLINE_CHECKS], | 2723 | sums[STAT_TYPE_VIEW_SIZE], |
2689 | sums[STAT_TYPE_UNREQUESTED_PULL_REPLIES], | 2724 | sums[STAT_TYPE_KNOWN_PEERS], |
2690 | sums[STAT_TYPE_PEERS_IN_PUSH_MAP], | 2725 | sums[STAT_TYPE_VALID_PEERS], |
2691 | sums[STAT_TYPE_PEERS_IN_PULL_MAP], | 2726 | sums[STAT_TYPE_LEARND_PEERS], |
2692 | sums[STAT_TYPE_PEERS_IN_VIEW], | 2727 | sums[STAT_TYPE_PENDING_ONLINE_CHECKS], |
2693 | sums[STAT_TYPE_VIEW_SIZE_AIM]); | 2728 | sums[STAT_TYPE_UNREQUESTED_PULL_REPLIES], |
2729 | sums[STAT_TYPE_PEERS_IN_PUSH_MAP], | ||
2730 | sums[STAT_TYPE_PEERS_IN_PULL_MAP], | ||
2731 | sums[STAT_TYPE_PEERS_IN_VIEW], | ||
2732 | sums[STAT_TYPE_VIEW_SIZE_AIM]); | ||
2694 | } | 2733 | } |
2695 | 2734 | ||
2696 | /** | 2735 | /** |
@@ -2705,47 +2744,48 @@ void write_final_stats(void) | |||
2705 | * successfully obtained, #GNUNET_SYSERR if not. | 2744 | * successfully obtained, #GNUNET_SYSERR if not. |
2706 | */ | 2745 | */ |
2707 | void | 2746 | void |
2708 | post_test_shutdown_ready_cb(void *cls, | 2747 | post_test_shutdown_ready_cb (void *cls, |
2709 | int success) | 2748 | int success) |
2710 | { | 2749 | { |
2711 | struct STATcls *stat_cls = (struct STATcls *)cls; | 2750 | struct STATcls *stat_cls = (struct STATcls *) cls; |
2712 | struct RPSPeer *rps_peer = stat_cls->rps_peer; | 2751 | struct RPSPeer *rps_peer = stat_cls->rps_peer; |
2713 | 2752 | ||
2714 | rps_peer->h_stat_get[stat_cls->stat_type] = NULL; | 2753 | rps_peer->h_stat_get[stat_cls->stat_type] = NULL; |
2715 | if (GNUNET_OK == success) | 2754 | if (GNUNET_OK == success) |
2716 | { | 2755 | { |
2717 | /* set flag that we we got the value */ | 2756 | /* set flag that we we got the value */ |
2718 | rps_peer->stat_collected_flags |= BIT(stat_cls->stat_type); | 2757 | rps_peer->stat_collected_flags |= BIT (stat_cls->stat_type); |
2719 | } | 2758 | } |
2720 | else | 2759 | else |
2721 | { | 2760 | { |
2722 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2761 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2723 | "Peer %u did not receive statistics value\n", | 2762 | "Peer %u did not receive statistics value\n", |
2724 | rps_peer->index); | 2763 | rps_peer->index); |
2725 | GNUNET_free(stat_cls); | 2764 | GNUNET_free (stat_cls); |
2726 | GNUNET_break(0); | 2765 | GNUNET_break (0); |
2727 | return; | 2766 | return; |
2728 | } | 2767 | } |
2729 | 2768 | ||
2730 | if (NULL != rps_peer->stat_op && | 2769 | if ((NULL != rps_peer->stat_op)&& |
2731 | GNUNET_YES == check_statistics_collect_completed_single_peer(rps_peer)) | 2770 | (GNUNET_YES == check_statistics_collect_completed_single_peer ( |
2732 | { | 2771 | rps_peer)) ) |
2733 | GNUNET_TESTBED_operation_done(rps_peer->stat_op); | 2772 | { |
2734 | } | 2773 | GNUNET_TESTBED_operation_done (rps_peer->stat_op); |
2735 | 2774 | } | |
2736 | write_final_stats(); | 2775 | |
2737 | if (GNUNET_YES == check_statistics_collect_completed()) | 2776 | write_final_stats (); |
2738 | { | 2777 | if (GNUNET_YES == check_statistics_collect_completed ()) |
2739 | //write_final_stats (); | 2778 | { |
2740 | GNUNET_free(stat_cls); | 2779 | // write_final_stats (); |
2741 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2780 | GNUNET_free (stat_cls); |
2742 | "Shutting down\n"); | 2781 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2743 | GNUNET_SCHEDULER_shutdown(); | 2782 | "Shutting down\n"); |
2744 | } | 2783 | GNUNET_SCHEDULER_shutdown (); |
2784 | } | ||
2745 | else | 2785 | else |
2746 | { | 2786 | { |
2747 | GNUNET_free(stat_cls); | 2787 | GNUNET_free (stat_cls); |
2748 | } | 2788 | } |
2749 | } | 2789 | } |
2750 | 2790 | ||
2751 | /** | 2791 | /** |
@@ -2759,76 +2799,76 @@ post_test_shutdown_ready_cb(void *cls, | |||
2759 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | 2799 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
2760 | */ | 2800 | */ |
2761 | int | 2801 | int |
2762 | stat_iterator(void *cls, | 2802 | stat_iterator (void *cls, |
2763 | const char *subsystem, | 2803 | const char *subsystem, |
2764 | const char *name, | 2804 | const char *name, |
2765 | uint64_t value, | 2805 | uint64_t value, |
2766 | int is_persistent) | 2806 | int is_persistent) |
2767 | { | 2807 | { |
2768 | const struct STATcls *stat_cls = (const struct STATcls *)cls; | 2808 | const struct STATcls *stat_cls = (const struct STATcls *) cls; |
2769 | struct RPSPeer *rps_peer = (struct RPSPeer *)stat_cls->rps_peer; | 2809 | struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer; |
2770 | enum STAT_TYPE stat_type; | 2810 | enum STAT_TYPE stat_type; |
2771 | 2811 | ||
2772 | (void)subsystem; | 2812 | (void) subsystem; |
2773 | (void)is_persistent; | 2813 | (void) is_persistent; |
2774 | 2814 | ||
2775 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2815 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2776 | "Got stat value: %s - %" PRIu64 " (%u)\n", | 2816 | "Got stat value: %s - %" PRIu64 " (%u)\n", |
2777 | name, | 2817 | name, |
2778 | value, | 2818 | value, |
2779 | rps_peer->index); | 2819 | rps_peer->index); |
2780 | to_file(rps_peer->file_name_stats, | 2820 | to_file (rps_peer->file_name_stats, |
2781 | "%s: %" PRIu64 "\n", | 2821 | "%s: %" PRIu64 "\n", |
2782 | name, | 2822 | name, |
2783 | value); | 2823 | value); |
2784 | stat_type = stat_str_2_type(name); | 2824 | stat_type = stat_str_2_type (name); |
2785 | GNUNET_assert(STAT_TYPE_ROUNDS <= stat_type && | 2825 | GNUNET_assert (STAT_TYPE_ROUNDS <= stat_type && |
2786 | STAT_TYPE_MAX > stat_type); | 2826 | STAT_TYPE_MAX > stat_type); |
2787 | rps_peer->stats[stat_type] = value; | 2827 | rps_peer->stats[stat_type] = value; |
2788 | return GNUNET_OK; | 2828 | return GNUNET_OK; |
2789 | } | 2829 | } |
2790 | 2830 | ||
2791 | 2831 | ||
2792 | void | 2832 | void |
2793 | post_profiler(struct RPSPeer *rps_peer) | 2833 | post_profiler (struct RPSPeer *rps_peer) |
2794 | { | 2834 | { |
2795 | if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) | 2835 | if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) |
2796 | { | 2836 | { |
2797 | return; | 2837 | return; |
2798 | } | 2838 | } |
2799 | 2839 | ||
2800 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2840 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2801 | "Going to request statistic values with mask 0x%" PRIx32 "\n", | 2841 | "Going to request statistic values with mask 0x%" PRIx32 "\n", |
2802 | cur_test_run.stat_collect_flags); | 2842 | cur_test_run.stat_collect_flags); |
2803 | 2843 | ||
2804 | struct STATcls *stat_cls; | 2844 | struct STATcls *stat_cls; |
2805 | uint32_t stat_type; | 2845 | uint32_t stat_type; |
2806 | for (stat_type = STAT_TYPE_ROUNDS; | 2846 | for (stat_type = STAT_TYPE_ROUNDS; |
2807 | stat_type < STAT_TYPE_MAX; | 2847 | stat_type < STAT_TYPE_MAX; |
2808 | stat_type++) | 2848 | stat_type++) |
2809 | { | 2849 | { |
2810 | if (BIT(stat_type) & cur_test_run.stat_collect_flags) | 2850 | if (BIT (stat_type) & cur_test_run.stat_collect_flags) |
2811 | { | 2851 | { |
2812 | stat_cls = GNUNET_malloc(sizeof(struct STATcls)); | 2852 | stat_cls = GNUNET_malloc (sizeof(struct STATcls)); |
2813 | stat_cls->rps_peer = rps_peer; | 2853 | stat_cls->rps_peer = rps_peer; |
2814 | stat_cls->stat_type = stat_type; | 2854 | stat_cls->stat_type = stat_type; |
2815 | rps_peer->file_name_stats = | 2855 | rps_peer->file_name_stats = |
2816 | store_prefix_file_name(rps_peer->peer_id, "stats"); | 2856 | store_prefix_file_name (rps_peer->peer_id, "stats"); |
2817 | rps_peer->h_stat_get[stat_type] = | 2857 | rps_peer->h_stat_get[stat_type] = |
2818 | GNUNET_STATISTICS_get(rps_peer->stats_h, | 2858 | GNUNET_STATISTICS_get (rps_peer->stats_h, |
2819 | "rps", | 2859 | "rps", |
2820 | stat_type_strings [stat_type], | 2860 | stat_type_strings [stat_type], |
2821 | post_test_shutdown_ready_cb, | 2861 | post_test_shutdown_ready_cb, |
2822 | stat_iterator, | 2862 | stat_iterator, |
2823 | (struct STATcls *)stat_cls); | 2863 | (struct STATcls *) stat_cls); |
2824 | GNUNET_assert(NULL != rps_peer->h_stat_get); | 2864 | GNUNET_assert (NULL != rps_peer->h_stat_get); |
2825 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2865 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2826 | "Requested statistics for %s (peer %" PRIu32 ")\n", | 2866 | "Requested statistics for %s (peer %" PRIu32 ")\n", |
2827 | stat_type_strings [stat_type], | 2867 | stat_type_strings [stat_type], |
2828 | rps_peer->index); | 2868 | rps_peer->index); |
2829 | } | 2869 | } |
2830 | } | 2870 | } |
2831 | GNUNET_free(rps_peer->eval_probs_cache); | 2871 | GNUNET_free (rps_peer->eval_probs_cache); |
2832 | } | 2872 | } |
2833 | 2873 | ||
2834 | 2874 | ||
@@ -2850,100 +2890,104 @@ post_profiler(struct RPSPeer *rps_peer) | |||
2850 | * failed | 2890 | * failed |
2851 | */ | 2891 | */ |
2852 | static void | 2892 | static void |
2853 | test_run(void *cls, | 2893 | test_run (void *cls, |
2854 | struct GNUNET_TESTBED_RunHandle *h, | 2894 | struct GNUNET_TESTBED_RunHandle *h, |
2855 | unsigned int n_peers, | 2895 | unsigned int n_peers, |
2856 | struct GNUNET_TESTBED_Peer **peers, | 2896 | struct GNUNET_TESTBED_Peer **peers, |
2857 | unsigned int links_succeeded, | 2897 | unsigned int links_succeeded, |
2858 | unsigned int links_failed) | 2898 | unsigned int links_failed) |
2859 | { | 2899 | { |
2860 | unsigned int i; | 2900 | unsigned int i; |
2861 | struct OpListEntry *entry; | 2901 | struct OpListEntry *entry; |
2862 | 2902 | ||
2863 | (void)cls; | 2903 | (void) cls; |
2864 | (void)h; | 2904 | (void) h; |
2865 | (void)links_failed; | 2905 | (void) links_failed; |
2866 | 2906 | ||
2867 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); | 2907 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); |
2868 | 2908 | ||
2869 | /* Check whether we timed out */ | 2909 | /* Check whether we timed out */ |
2870 | if (n_peers != num_peers || | 2910 | if ((n_peers != num_peers)|| |
2871 | NULL == peers || | 2911 | (NULL == peers) || |
2872 | 0 == links_succeeded) | 2912 | (0 == links_succeeded) ) |
2873 | { | 2913 | { |
2874 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Going down due to args (eg. timeout)\n"); | 2914 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2875 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\tn_peers: %u\n", n_peers); | 2915 | "Going down due to args (eg. timeout)\n"); |
2876 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n", num_peers); | 2916 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tn_peers: %u\n", n_peers); |
2877 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers); | 2917 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n", |
2878 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n", links_succeeded); | 2918 | num_peers); |
2879 | ok = 1; | 2919 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers); |
2880 | GNUNET_SCHEDULER_shutdown(); | 2920 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n", |
2881 | return; | 2921 | links_succeeded); |
2882 | } | 2922 | ok = 1; |
2923 | GNUNET_SCHEDULER_shutdown (); | ||
2924 | return; | ||
2925 | } | ||
2883 | 2926 | ||
2884 | 2927 | ||
2885 | /* Initialize peers */ | 2928 | /* Initialize peers */ |
2886 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "going to initialise peers\n"); | 2929 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "going to initialise peers\n"); |
2887 | testbed_peers = peers; | 2930 | testbed_peers = peers; |
2888 | num_peers_online = 0; | 2931 | num_peers_online = 0; |
2889 | for (i = 0; i < num_peers; i++) | 2932 | for (i = 0; i < num_peers; i++) |
2890 | { | 2933 | { |
2891 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "initialising %u\n", i); | 2934 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "initialising %u\n", i); |
2892 | entry = make_oplist_entry(); | 2935 | entry = make_oplist_entry (); |
2893 | entry->index = i; | 2936 | entry->index = i; |
2894 | rps_peers[i].index = i; | 2937 | rps_peers[i].index = i; |
2895 | if (NULL != cur_test_run.init_peer) | 2938 | if (NULL != cur_test_run.init_peer) |
2896 | cur_test_run.init_peer(&rps_peers[i]); | 2939 | cur_test_run.init_peer (&rps_peers[i]); |
2897 | if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) | 2940 | if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) |
2898 | { | 2941 | { |
2899 | rps_peers->cur_view_count = 0; | 2942 | rps_peers->cur_view_count = 0; |
2900 | rps_peers->cur_view = NULL; | 2943 | rps_peers->cur_view = NULL; |
2901 | } | 2944 | } |
2902 | entry->op = GNUNET_TESTBED_peer_get_information(peers[i], | 2945 | entry->op = GNUNET_TESTBED_peer_get_information (peers[i], |
2903 | GNUNET_TESTBED_PIT_IDENTITY, | 2946 | GNUNET_TESTBED_PIT_IDENTITY, |
2904 | &info_cb, | 2947 | &info_cb, |
2905 | entry); | 2948 | entry); |
2906 | } | 2949 | } |
2907 | 2950 | ||
2908 | /* Bring peers up */ | 2951 | /* Bring peers up */ |
2909 | GNUNET_assert(num_peers == n_peers); | 2952 | GNUNET_assert (num_peers == n_peers); |
2910 | for (i = 0; i < n_peers; i++) | 2953 | for (i = 0; i < n_peers; i++) |
2911 | { | 2954 | { |
2912 | rps_peers[i].index = i; | 2955 | rps_peers[i].index = i; |
2913 | rps_peers[i].op = | 2956 | rps_peers[i].op = |
2914 | GNUNET_TESTBED_service_connect(&rps_peers[i], | 2957 | GNUNET_TESTBED_service_connect (&rps_peers[i], |
2915 | peers[i], | 2958 | peers[i], |
2916 | "rps", | 2959 | "rps", |
2917 | &rps_connect_complete_cb, | 2960 | &rps_connect_complete_cb, |
2918 | &rps_peers[i], | 2961 | &rps_peers[i], |
2919 | &rps_connect_adapter, | 2962 | &rps_connect_adapter, |
2920 | &rps_disconnect_adapter, | 2963 | &rps_disconnect_adapter, |
2921 | &rps_peers[i]); | 2964 | &rps_peers[i]); |
2922 | /* Connect all peers to statistics service */ | 2965 | /* Connect all peers to statistics service */ |
2923 | if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics) | 2966 | if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics) |
2924 | { | 2967 | { |
2925 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2968 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2926 | "Connecting to statistics service\n"); | 2969 | "Connecting to statistics service\n"); |
2927 | rps_peers[i].stat_op = | 2970 | rps_peers[i].stat_op = |
2928 | GNUNET_TESTBED_service_connect(NULL, | 2971 | GNUNET_TESTBED_service_connect (NULL, |
2929 | peers[i], | 2972 | peers[i], |
2930 | "statistics", | 2973 | "statistics", |
2931 | stat_complete_cb, | 2974 | stat_complete_cb, |
2932 | &rps_peers[i], | 2975 | &rps_peers[i], |
2933 | &stat_connect_adapter, | 2976 | &stat_connect_adapter, |
2934 | &stat_disconnect_adapter, | 2977 | &stat_disconnect_adapter, |
2935 | &rps_peers[i]); | 2978 | &rps_peers[i]); |
2936 | } | 2979 | } |
2937 | } | 2980 | } |
2938 | 2981 | ||
2939 | if (NULL != churn_task) | 2982 | if (NULL != churn_task) |
2940 | GNUNET_SCHEDULER_cancel(churn_task); | 2983 | GNUNET_SCHEDULER_cancel (churn_task); |
2941 | post_test_task = GNUNET_SCHEDULER_add_delayed(duration, &post_test_op, NULL); | 2984 | post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op, NULL); |
2942 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n", timeout.rel_value_us / 1000000); | 2985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n", |
2943 | shutdown_task = GNUNET_SCHEDULER_add_delayed(timeout, | 2986 | timeout.rel_value_us / 1000000); |
2944 | &trigger_shutdown, | 2987 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, |
2945 | NULL); | 2988 | &trigger_shutdown, |
2946 | GNUNET_SCHEDULER_add_shutdown(shutdown_op, NULL); | 2989 | NULL); |
2990 | GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL); | ||
2947 | } | 2991 | } |
2948 | 2992 | ||
2949 | 2993 | ||
@@ -2954,26 +2998,26 @@ test_run(void *cls, | |||
2954 | * @param argv unused | 2998 | * @param argv unused |
2955 | */ | 2999 | */ |
2956 | static void | 3000 | static void |
2957 | run(void *cls, | 3001 | run (void *cls, |
2958 | char *const *args, | 3002 | char *const *args, |
2959 | const char *cfgfile, | 3003 | const char *cfgfile, |
2960 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 3004 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
2961 | { | 3005 | { |
2962 | //int ret_value; | 3006 | // int ret_value; |
2963 | (void)cls; | 3007 | (void) cls; |
2964 | (void)args; | 3008 | (void) args; |
2965 | (void)cfgfile; | 3009 | (void) cfgfile; |
2966 | 3010 | ||
2967 | /* Defaults for tests */ | 3011 | /* Defaults for tests */ |
2968 | churn_task = NULL; | 3012 | churn_task = NULL; |
2969 | 3013 | ||
2970 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); | 3014 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); |
2971 | cur_test_run.name = "test-rps-profiler"; | 3015 | cur_test_run.name = "test-rps-profiler"; |
2972 | if (0 == num_peers) | 3016 | if (0 == num_peers) |
2973 | num_peers = 10; | 3017 | num_peers = 10; |
2974 | mal_type = 3; | 3018 | mal_type = 3; |
2975 | cur_test_run.init_peer = profiler_init_peer; | 3019 | cur_test_run.init_peer = profiler_init_peer; |
2976 | //cur_test_run.pre_test = mal_pre; | 3020 | // cur_test_run.pre_test = mal_pre; |
2977 | cur_test_run.pre_test = pre_profiler; | 3021 | cur_test_run.pre_test = pre_profiler; |
2978 | cur_test_run.main_test = profiler_cb; | 3022 | cur_test_run.main_test = profiler_cb; |
2979 | cur_test_run.reply_handle = profiler_reply_handle; | 3023 | cur_test_run.reply_handle = profiler_reply_handle; |
@@ -2982,104 +3026,105 @@ run(void *cls, | |||
2982 | cur_test_run.request_interval = 2; | 3026 | cur_test_run.request_interval = 2; |
2983 | if (0 == cur_test_run.num_requests) | 3027 | if (0 == cur_test_run.num_requests) |
2984 | cur_test_run.num_requests = 5; | 3028 | cur_test_run.num_requests = 5; |
2985 | //cur_test_run.have_churn = HAVE_CHURN; | 3029 | // cur_test_run.have_churn = HAVE_CHURN; |
2986 | cur_test_run.have_churn = HAVE_NO_CHURN; | 3030 | cur_test_run.have_churn = HAVE_NO_CHURN; |
2987 | cur_test_run.have_quick_quit = HAVE_QUICK_QUIT; | 3031 | cur_test_run.have_quick_quit = HAVE_QUICK_QUIT; |
2988 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; | 3032 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; |
2989 | cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) | | 3033 | cur_test_run.stat_collect_flags = BIT (STAT_TYPE_ROUNDS) |
2990 | BIT(STAT_TYPE_BLOCKS) | | 3034 | | BIT (STAT_TYPE_BLOCKS) |
2991 | BIT(STAT_TYPE_BLOCKS_MANY_PUSH) | | 3035 | | BIT (STAT_TYPE_BLOCKS_MANY_PUSH) |
2992 | BIT(STAT_TYPE_BLOCKS_NO_PUSH) | | 3036 | | BIT (STAT_TYPE_BLOCKS_NO_PUSH) |
2993 | BIT(STAT_TYPE_BLOCKS_NO_PULL) | | 3037 | | BIT (STAT_TYPE_BLOCKS_NO_PULL) |
2994 | BIT(STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL) | | 3038 | | BIT (STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL) |
2995 | BIT(STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL) | | 3039 | | BIT (STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL) |
2996 | BIT(STAT_TYPE_ISSUED_PUSH_SEND) | | 3040 | | BIT (STAT_TYPE_ISSUED_PUSH_SEND) |
2997 | BIT(STAT_TYPE_ISSUED_PUSH_SEND_MH) | | 3041 | | BIT (STAT_TYPE_ISSUED_PUSH_SEND_MH) |
2998 | BIT(STAT_TYPE_ISSUED_PULL_REQ) | | 3042 | | BIT (STAT_TYPE_ISSUED_PULL_REQ) |
2999 | BIT(STAT_TYPE_ISSUED_PULL_REQ_MH) | | 3043 | | BIT (STAT_TYPE_ISSUED_PULL_REQ_MH) |
3000 | BIT(STAT_TYPE_ISSUED_PULL_REP) | | 3044 | | BIT (STAT_TYPE_ISSUED_PULL_REP) |
3001 | BIT(STAT_TYPE_SENT_PUSH_SEND) | | 3045 | | BIT (STAT_TYPE_SENT_PUSH_SEND) |
3002 | BIT(STAT_TYPE_SENT_PULL_REQ) | | 3046 | | BIT (STAT_TYPE_SENT_PULL_REQ) |
3003 | BIT(STAT_TYPE_SENT_PULL_REQ_MH) | | 3047 | | BIT (STAT_TYPE_SENT_PULL_REQ_MH) |
3004 | BIT(STAT_TYPE_SENT_PULL_REP) | | 3048 | | BIT (STAT_TYPE_SENT_PULL_REP) |
3005 | BIT(STAT_TYPE_RECV_PUSH_SEND) | | 3049 | | BIT (STAT_TYPE_RECV_PUSH_SEND) |
3006 | BIT(STAT_TYPE_RECV_PUSH_SEND_MH) | | 3050 | | BIT (STAT_TYPE_RECV_PUSH_SEND_MH) |
3007 | BIT(STAT_TYPE_RECV_PULL_REQ) | | 3051 | | BIT (STAT_TYPE_RECV_PULL_REQ) |
3008 | BIT(STAT_TYPE_RECV_PULL_REQ_MH) | | 3052 | | BIT (STAT_TYPE_RECV_PULL_REQ_MH) |
3009 | BIT(STAT_TYPE_RECV_PULL_REP) | | 3053 | | BIT (STAT_TYPE_RECV_PULL_REP) |
3010 | BIT(STAT_TYPE_RECV_PULL_REP_MH) | | 3054 | | BIT (STAT_TYPE_RECV_PULL_REP_MH) |
3011 | BIT(STAT_TYPE_VIEW_SIZE) | | 3055 | | BIT (STAT_TYPE_VIEW_SIZE) |
3012 | BIT(STAT_TYPE_KNOWN_PEERS) | | 3056 | | BIT (STAT_TYPE_KNOWN_PEERS) |
3013 | BIT(STAT_TYPE_VALID_PEERS) | | 3057 | | BIT (STAT_TYPE_VALID_PEERS) |
3014 | BIT(STAT_TYPE_LEARND_PEERS) | | 3058 | | BIT (STAT_TYPE_LEARND_PEERS) |
3015 | BIT(STAT_TYPE_PENDING_ONLINE_CHECKS) | | 3059 | | BIT (STAT_TYPE_PENDING_ONLINE_CHECKS) |
3016 | BIT(STAT_TYPE_UNREQUESTED_PULL_REPLIES) | | 3060 | | BIT (STAT_TYPE_UNREQUESTED_PULL_REPLIES) |
3017 | BIT(STAT_TYPE_PEERS_IN_PUSH_MAP) | | 3061 | | BIT (STAT_TYPE_PEERS_IN_PUSH_MAP) |
3018 | BIT(STAT_TYPE_PEERS_IN_PULL_MAP) | | 3062 | | BIT (STAT_TYPE_PEERS_IN_PULL_MAP) |
3019 | BIT(STAT_TYPE_PEERS_IN_VIEW) | | 3063 | | BIT (STAT_TYPE_PEERS_IN_VIEW) |
3020 | BIT(STAT_TYPE_VIEW_SIZE_AIM); | 3064 | | BIT (STAT_TYPE_VIEW_SIZE_AIM); |
3021 | cur_test_run.have_collect_view = COLLECT_VIEW; | 3065 | cur_test_run.have_collect_view = COLLECT_VIEW; |
3022 | 3066 | ||
3023 | /* 'Clean' directory */ | 3067 | /* 'Clean' directory */ |
3024 | (void)GNUNET_DISK_directory_remove("/tmp/rps/"); | 3068 | (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); |
3025 | GNUNET_DISK_directory_create("/tmp/rps/"); | 3069 | GNUNET_DISK_directory_create ("/tmp/rps/"); |
3026 | if (0 == duration.rel_value_us) | 3070 | if (0 == duration.rel_value_us) |
3071 | { | ||
3072 | if (0 == timeout.rel_value_us) | ||
3027 | { | 3073 | { |
3028 | if (0 == timeout.rel_value_us) | 3074 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); |
3029 | { | 3075 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3030 | duration = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90); | 3076 | (90 * 1.2) |
3031 | timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 3077 | + (0.01 * num_peers)); |
3032 | (90 * 1.2) + | ||
3033 | (0.01 * num_peers)); | ||
3034 | } | ||
3035 | else | ||
3036 | { | ||
3037 | duration = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | ||
3038 | (timeout.rel_value_us / 1000000) | ||
3039 | * 0.75); | ||
3040 | } | ||
3041 | } | 3078 | } |
3042 | else | 3079 | else |
3043 | { | 3080 | { |
3044 | if (0 == timeout.rel_value_us) | 3081 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3045 | { | 3082 | (timeout.rel_value_us / 1000000) |
3046 | timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 3083 | * 0.75); |
3047 | ((duration.rel_value_us / 1000000) | ||
3048 | * 1.2) + (0.01 * num_peers)); | ||
3049 | } | ||
3050 | } | 3084 | } |
3051 | GNUNET_assert(duration.rel_value_us < timeout.rel_value_us); | 3085 | } |
3052 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3086 | else |
3053 | "duration is %lus\n", | 3087 | { |
3054 | duration.rel_value_us / 1000000); | 3088 | if (0 == timeout.rel_value_us) |
3055 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3089 | { |
3056 | "timeout is %lus\n", | 3090 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3057 | timeout.rel_value_us / 1000000); | 3091 | ((duration.rel_value_us |
3092 | / 1000000) | ||
3093 | * 1.2) + (0.01 * num_peers)); | ||
3094 | } | ||
3095 | } | ||
3096 | GNUNET_assert (duration.rel_value_us < timeout.rel_value_us); | ||
3097 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3098 | "duration is %lus\n", | ||
3099 | duration.rel_value_us / 1000000); | ||
3100 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3101 | "timeout is %lus\n", | ||
3102 | timeout.rel_value_us / 1000000); | ||
3058 | 3103 | ||
3059 | /* Compute number of bits for representing largest peer id */ | 3104 | /* Compute number of bits for representing largest peer id */ |
3060 | for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++) | 3105 | for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++) |
3061 | ; | 3106 | ; |
3062 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3063 | "Need %u bits to represent %" PRIu32 " peers\n", | 3108 | "Need %u bits to represent %" PRIu32 " peers\n", |
3064 | bits_needed, | 3109 | bits_needed, |
3065 | num_peers); | 3110 | num_peers); |
3066 | 3111 | ||
3067 | rps_peers = GNUNET_new_array(num_peers, struct RPSPeer); | 3112 | rps_peers = GNUNET_new_array (num_peers, struct RPSPeer); |
3068 | peer_map = GNUNET_CONTAINER_multipeermap_create(num_peers, GNUNET_NO); | 3113 | peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO); |
3069 | rps_peer_ids = GNUNET_new_array(num_peers, struct GNUNET_PeerIdentity); | 3114 | rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity); |
3070 | if ((2 == mal_type) || | 3115 | if ((2 == mal_type) || |
3071 | (3 == mal_type)) | 3116 | (3 == mal_type)) |
3072 | target_peer = &rps_peer_ids[num_peers - 2]; | 3117 | target_peer = &rps_peer_ids[num_peers - 2]; |
3073 | 3118 | ||
3074 | ok = 1; | 3119 | ok = 1; |
3075 | GNUNET_TESTBED_run(NULL, | 3120 | GNUNET_TESTBED_run (NULL, |
3076 | cfg, | 3121 | cfg, |
3077 | num_peers, | 3122 | num_peers, |
3078 | 0, /* event mask */ | 3123 | 0, /* event mask */ |
3079 | NULL, | 3124 | NULL, |
3080 | NULL, | 3125 | NULL, |
3081 | &test_run, | 3126 | &test_run, |
3082 | NULL); | 3127 | NULL); |
3083 | } | 3128 | } |
3084 | 3129 | ||
3085 | /** | 3130 | /** |
@@ -3090,69 +3135,72 @@ run(void *cls, | |||
3090 | * @return 0 on success | 3135 | * @return 0 on success |
3091 | */ | 3136 | */ |
3092 | int | 3137 | int |
3093 | main(int argc, char *argv[]) | 3138 | main (int argc, char *argv[]) |
3094 | { | 3139 | { |
3095 | int ret_value; | 3140 | int ret_value; |
3096 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 3141 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
3097 | GNUNET_GETOPT_option_uint('n', | 3142 | GNUNET_GETOPT_option_uint ('n', |
3098 | "num-peers", | 3143 | "num-peers", |
3099 | "COUNT", | 3144 | "COUNT", |
3100 | gettext_noop("number of peers to start"), | 3145 | gettext_noop ("number of peers to start"), |
3101 | &num_peers), | 3146 | &num_peers), |
3102 | GNUNET_GETOPT_option_relative_time('d', | 3147 | GNUNET_GETOPT_option_relative_time ('d', |
3103 | "duration", | 3148 | "duration", |
3104 | "DURATION", | 3149 | "DURATION", |
3105 | gettext_noop("duration of the profiling"), | 3150 | gettext_noop ( |
3106 | &duration), | 3151 | "duration of the profiling"), |
3107 | GNUNET_GETOPT_option_relative_time('t', | 3152 | &duration), |
3108 | "timeout", | 3153 | GNUNET_GETOPT_option_relative_time ('t', |
3109 | "TIMEOUT", | 3154 | "timeout", |
3110 | gettext_noop("timeout for the profiling"), | 3155 | "TIMEOUT", |
3111 | &timeout), | 3156 | gettext_noop ( |
3112 | GNUNET_GETOPT_option_uint('r', | 3157 | "timeout for the profiling"), |
3113 | "num-requests", | 3158 | &timeout), |
3114 | "COUNT", | 3159 | GNUNET_GETOPT_option_uint ('r', |
3115 | gettext_noop("number of PeerIDs to request"), | 3160 | "num-requests", |
3116 | &cur_test_run.num_requests), | 3161 | "COUNT", |
3162 | gettext_noop ("number of PeerIDs to request"), | ||
3163 | &cur_test_run.num_requests), | ||
3117 | GNUNET_GETOPT_OPTION_END | 3164 | GNUNET_GETOPT_OPTION_END |
3118 | }; | 3165 | }; |
3119 | 3166 | ||
3120 | unsetenv("XDG_DATA_HOME"); | 3167 | unsetenv ("XDG_DATA_HOME"); |
3121 | unsetenv("XDG_CONFIG_HOME"); | 3168 | unsetenv ("XDG_CONFIG_HOME"); |
3122 | //if (GNUNET_OK != | 3169 | // if (GNUNET_OK != |
3123 | // GNUNET_STRINGS_get_utf8_args (argc, argv, | 3170 | // GNUNET_STRINGS_get_utf8_args (argc, argv, |
3124 | // &argc, &argv)) | 3171 | // &argc, &argv)) |
3125 | // return 2; | 3172 | // return 2; |
3126 | ret_value = 0; | 3173 | ret_value = 0; |
3127 | if (GNUNET_OK != | 3174 | if (GNUNET_OK != |
3128 | GNUNET_PROGRAM_run(argc, | 3175 | GNUNET_PROGRAM_run (argc, |
3129 | argv, | 3176 | argv, |
3130 | "gnunet-rps-profiler", | 3177 | "gnunet-rps-profiler", |
3131 | gettext_noop("Measure quality and performance of the RPS service."), | 3178 | gettext_noop ( |
3132 | options, | 3179 | "Measure quality and performance of the RPS service."), |
3133 | &run, | 3180 | options, |
3134 | NULL)) | 3181 | &run, |
3135 | { | 3182 | NULL)) |
3136 | ret_value = 1; | 3183 | { |
3137 | } | 3184 | ret_value = 1; |
3185 | } | ||
3138 | if (0 != ret_value) | 3186 | if (0 != ret_value) |
3139 | { | 3187 | { |
3140 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 3188 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3141 | "Test did not run successfully!\n"); | 3189 | "Test did not run successfully!\n"); |
3142 | } | 3190 | } |
3143 | else | 3191 | else |
3144 | { | 3192 | { |
3145 | ret_value = cur_test_run.eval_cb(); | 3193 | ret_value = cur_test_run.eval_cb (); |
3146 | if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) | 3194 | if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) |
3147 | { | 3195 | { |
3148 | GNUNET_array_grow(rps_peers->cur_view, | 3196 | GNUNET_array_grow (rps_peers->cur_view, |
3149 | rps_peers->cur_view_count, | 3197 | rps_peers->cur_view_count, |
3150 | 0); | 3198 | 0); |
3151 | } | 3199 | } |
3152 | GNUNET_free(rps_peers); | 3200 | GNUNET_free (rps_peers); |
3153 | GNUNET_free(rps_peer_ids); | 3201 | GNUNET_free (rps_peer_ids); |
3154 | GNUNET_CONTAINER_multipeermap_destroy(peer_map); | 3202 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); |
3155 | } | 3203 | } |
3156 | return ret_value; | 3204 | return ret_value; |
3157 | } | 3205 | } |
3158 | 3206 | ||