diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 7e3a7f2..15c481d 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -61,7 +61,7 @@ public class AccessPoint { for(int i = 0; i < nbUsers; i++){ Random random = new Random(); double randomDist = this.min + random.nextDouble() * (this.max - this.min); - User user = new User(randomDist); + User user = new User(randomDist, timeSlotNb, subCarrierNb); user.generateBandwidth(); user.createPackets(); this.users.add(user); @@ -87,4 +87,5 @@ public class AccessPoint { public int getFrameSize(){ return this.timeSlotNb * this.subCarrierNb; } + } diff --git a/src/main/java/fr/ntr/User.java b/src/main/java/fr/ntr/User.java index 9e30065..54581d4 100644 --- a/src/main/java/fr/ntr/User.java +++ b/src/main/java/fr/ntr/User.java @@ -10,21 +10,25 @@ public class User { private final List packetsToSend; private final List packetsSent; - public User(double distance) { + public User(double distance, int timeSlotNb, int subCarrierNb) { this.distance = distance; - this.bandwidthTable = new double[1][1]; // TODO: 03/03/2023 Changer valeurs + this.bandwidthTable = new double[timeSlotNb][subCarrierNb]; this.packetsToSend = new ArrayList<>(); this.packetsSent = new ArrayList<>(); } public void generateBandwidth() { - double X = Math.random(); - double h = 8 * Math.sqrt(-2 * Math.log(1 - X)); - double gain = h * Math.pow(10, X*8/10) * Math.pow(1/this.distance, 3.5); - double spectralEfficacity = (43 * gain)/(15000*(-174)); - double mkn = Math.log1p(spectralEfficacity); - this.bandwidthTable[][] = mkn; // Voir comment remplir le tableau + double random = Math.random(); + for(int i = 0; i < bandwidthTable.length; i++) { + for(int j = 0; j < bandwidthTable[i].length; j++) { + double h = 8 * Math.sqrt(-2 * Math.log(1 - random)); + double gain = h * Math.pow(10, random*8/10) * Math.pow(1/this.distance, 3.5); + double spectralEfficiency = (43 * gain)/(15000*(-174)); + double mkn = Math.log1p(spectralEfficiency); + this.bandwidthTable[i][j] = mkn; + } + } } public void createPackets() {