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:
Simon Duquennoy 2017-11-04 17:55:31 +01:00
parent 196d64aa66
commit 7f8ff9d9af
2 changed files with 6 additions and 4 deletions

View File

@ -544,7 +544,7 @@ make receiver-node.cooja TARGET=cooja</commands>
}&#xD;
&#xD;
function getRandom(min, max) {&#xD;
return Math.random() * (max - min) + min;&#xD;
return r.nextFloat() * (max - min) + min;&#xD;
}&#xD;
&#xD;
// From: http://bost.ocks.org/mike/shuffle/&#xD;
@ -555,7 +555,7 @@ function shuffle(array) {&#xD;
while (m) {&#xD;
&#xD;
// Pick a remaining element…&#xD;
i = Math.floor(Math.random() * m--);&#xD;
i = Math.floor(r.nextFloat() * m--);&#xD;
&#xD;
// And swap it with the current element.&#xD;
t = array[m];&#xD;
@ -571,6 +571,7 @@ GENERATE_MSG(1200000, 'randomize-nodes');&#xD;
GENERATE_MSG(2400000, 'randomize-nodes');&#xD;
GENERATE_MSG(3600000, 'randomize-nodes');&#xD;
&#xD;
var r = new java.util.Random(sim.getRandomSeed());&#xD;
var numForwarders = 20;&#xD;
var forwardIDStart = 4;&#xD;
packetsReceived = [];&#xD;

View File

@ -544,7 +544,7 @@ make receiver-node.cooja TARGET=cooja</commands>
}&#xD;
&#xD;
function getRandom(min, max) {&#xD;
return Math.random() * (max - min) + min;&#xD;
return r.nextFloat() * (max - min) + min;&#xD;
}&#xD;
&#xD;
// From: http://bost.ocks.org/mike/shuffle/&#xD;
@ -555,7 +555,7 @@ function shuffle(array) {&#xD;
while (m) {&#xD;
&#xD;
// Pick a remaining element…&#xD;
i = Math.floor(Math.random() * m--);&#xD;
i = Math.floor(r.nextFloat() * m--);&#xD;
&#xD;
// And swap it with the current element.&#xD;
t = array[m];&#xD;
@ -571,6 +571,7 @@ GENERATE_MSG(1200000, 'randomize-nodes');&#xD;
GENERATE_MSG(2400000, 'randomize-nodes');&#xD;
GENERATE_MSG(3600000, 'randomize-nodes');&#xD;
&#xD;
var r = new java.util.Random(sim.getRandomSeed());&#xD;
var numForwarders = 20;&#xD;
var forwardIDStart = 4;&#xD;
packetsReceived = [];&#xD;