From 22eead040f9f2e34d43e92a79c76bc3e965af112 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Fri, 31 Mar 2023 08:50:26 +0200 Subject: [PATCH] Fix User#generateBandwidth change packetSize name to PACKET_SIZE --- src/main/java/fr/ntr/Packets.java | 4 ++-- src/main/java/fr/ntr/User.java | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/ntr/Packets.java b/src/main/java/fr/ntr/Packets.java index 35b0460..f6c5a74 100644 --- a/src/main/java/fr/ntr/Packets.java +++ b/src/main/java/fr/ntr/Packets.java @@ -1,14 +1,14 @@ package fr.ntr; public class Packets { - static final int packetSize = 100; + static final int PACKET_SIZE = 100; private int startTimeSending; private int endTimeSending; private int durationSending; private int bitsNumberRemaining; public Packets(int startTimeSending){ - this.bitsNumberRemaining = packetSize; + this.bitsNumberRemaining = PACKET_SIZE; this.startTimeSending = startTimeSending; } diff --git a/src/main/java/fr/ntr/User.java b/src/main/java/fr/ntr/User.java index f0e10ba..e932b04 100644 --- a/src/main/java/fr/ntr/User.java +++ b/src/main/java/fr/ntr/User.java @@ -26,16 +26,14 @@ public class User { } public void generateBandwidth() { - for(int y = 0; y < bandwidthTable[0].length; y++) { double rand = this.random.nextDouble(); - for(int x = 0; x < bandwidthTable.length; x++) { - double h = 1 * Math.sqrt(-2 * Math.log(1 - rand)); - double gain = h * h * Math.pow(10, rand * 1/10) * Math.pow(1 / this.distance, 3.5); - double spectralEfficiency = (20 * gain) / (15000 * (3.9*Math.pow(10, -21))); - double mkn = Math.log(1 + spectralEfficiency) / Math.log(2); - this.bandwidthTable[x][y] = mkn; - } + double h = 1 * Math.sqrt(-2 * Math.log(1 - rand)); + double gain = h * h * Math.pow(10, rand * 1/10) * Math.pow(1 / this.distance, 3.5); + double spectralEfficiency = (20 * gain) / (15000 * (3.9*Math.pow(10, -21))); + double mkn = Math.log(1 + spectralEfficiency) / Math.log(2); + this.bandwidthTable[0][y] = mkn; + this.bandwidthTable[1][y] = mkn; } } @@ -54,9 +52,9 @@ public class User { } // On calcule le nombre de paquets qu'on peut transmettre int bitsToSend = random.nextInt(2 * mbis); - int nbPacketsToSend = bitsToSend / Packets.packetSize; + int nbPacketsToSend = bitsToSend / Packets.PACKET_SIZE; // On conserve le nombre de bits restants pour la prochaine génération - this.leftForNextSource = bitsToSend % Packets.packetSize; + this.leftForNextSource = bitsToSend % Packets.PACKET_SIZE; // On crée les paquets for(int i = 0; i < nbPacketsToSend; i++) { this.packetsToSend.add(new Packets(ticks));