Fix plr50.c:
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Thu, 18 Aug 2011 15:14:21 +0000 (17:14 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Thu, 18 Aug 2011 15:14:21 +0000 (17:14 +0200)
 - Allow specifying a seed (and seed to a default), for repeatable results
 - Fix PLR formula - was inverted

src/nepi/testbeds/planetlab/scripts/plr50.c

index 7332783..b573c73 100644 (file)
@@ -5,11 +5,16 @@ static int plr = 50;
 
 int init(const char* args)
 {
-    sscanf(args, "plr=%d", &plr);
+    int seed;
+    int rv;
+    seed = 1234;
+    rv = sscanf(args, "plr=%d,seed=%d", &plr, &seed);
+    srand(seed);
+    return rv;
 }
 
 int accept_packet(const char* packet, int direction)
 {
-    return (direction != 0) || (rand() > (RAND_MAX*100/plr));
+    return (direction != 0) || (rand() > (RAND_MAX/100*plr));
 }