Simulation script for tests with random rearrangement: use a random generator that lets us control the seed. Set the seed to the Cooja simulation seed.
This commit is contained in:
parent
196d64aa66
commit
7f8ff9d9af
@ -544,7 +544,7 @@ make receiver-node.cooja TARGET=cooja</commands>
|
||||
}
|
||||

|
||||
function getRandom(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
return r.nextFloat() * (max - min) + min;
|
||||
}
|
||||

|
||||
// From: http://bost.ocks.org/mike/shuffle/
|
||||
@ -555,7 +555,7 @@ function shuffle(array) {
|
||||
while (m) {
|
||||

|
||||
// Pick a remaining element…
|
||||
i = Math.floor(Math.random() * m--);
|
||||
i = Math.floor(r.nextFloat() * m--);
|
||||

|
||||
// And swap it with the current element.
|
||||
t = array[m];
|
||||
@ -571,6 +571,7 @@ GENERATE_MSG(1200000, 'randomize-nodes');
|
||||
GENERATE_MSG(2400000, 'randomize-nodes');
|
||||
GENERATE_MSG(3600000, 'randomize-nodes');
|
||||

|
||||
var r = new java.util.Random(sim.getRandomSeed());
|
||||
var numForwarders = 20;
|
||||
var forwardIDStart = 4;
|
||||
packetsReceived = [];
|
||||
|
@ -544,7 +544,7 @@ make receiver-node.cooja TARGET=cooja</commands>
|
||||
}
|
||||

|
||||
function getRandom(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
return r.nextFloat() * (max - min) + min;
|
||||
}
|
||||

|
||||
// From: http://bost.ocks.org/mike/shuffle/
|
||||
@ -555,7 +555,7 @@ function shuffle(array) {
|
||||
while (m) {
|
||||

|
||||
// Pick a remaining element…
|
||||
i = Math.floor(Math.random() * m--);
|
||||
i = Math.floor(r.nextFloat() * m--);
|
||||

|
||||
// And swap it with the current element.
|
||||
t = array[m];
|
||||
@ -571,6 +571,7 @@ GENERATE_MSG(1200000, 'randomize-nodes');
|
||||
GENERATE_MSG(2400000, 'randomize-nodes');
|
||||
GENERATE_MSG(3600000, 'randomize-nodes');
|
||||

|
||||
var r = new java.util.Random(sim.getRandomSeed());
|
||||
var numForwarders = 20;
|
||||
var forwardIDStart = 4;
|
||||
packetsReceived = [];
|
||||
|
Loading…
Reference in New Issue
Block a user