diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index b5a6b2c..105d7c3 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -33,6 +33,8 @@ public class AccessPoint { */ private final double min, max; + private Random random = new Random(); + public AccessPoint(Scheduler scheduler, ResourceBlock[][] frame, List users, int timeSlotNb, int subCarrierNb, double min, double max) { this.min = min; @@ -65,7 +67,6 @@ public class AccessPoint { private void updateBandwidth(int ticks) { int n = 200; - Random random = new Random(); int timeInterval = 50 + random.nextInt(51); for(User user : users) { // On régénère le tableau de débits toutes les 50 ms diff --git a/src/main/java/fr/ntr/User.java b/src/main/java/fr/ntr/User.java index 5669f95..dce601b 100644 --- a/src/main/java/fr/ntr/User.java +++ b/src/main/java/fr/ntr/User.java @@ -12,6 +12,8 @@ public class User { private final List packetsSent; private int leftForNextSource; + private Random random = new Random(); + public User(double distance, int timeSlotNb, int subCarrierNb) { this.distance = distance; this.bandwidthTable = new double[timeSlotNb][subCarrierNb]; @@ -21,7 +23,7 @@ public class User { } public void generateBandwidth() { - double random = Math.random(); + double random = this.random.nextDouble(); for(int i = 0; i < bandwidthTable.length; i++) { for(int j = 0; j < bandwidthTable[i].length; j++) { double h = 1 * Math.sqrt(-2 * Math.log(1 - random));