From c06ada967977aa48b876bde96dbd40919c94cb3f Mon Sep 17 00:00:00 2001 From: Remi Boure Date: Fri, 24 Mar 2023 12:12:18 +0100 Subject: [PATCH] =?UTF-8?q?Calcul=20d=C3=A9lai=20paquet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/fr/ntr/AccessPoint.java | 19 ++++++++++++++++--- src/main/java/fr/ntr/Packets.java | 17 ++++++++++++----- src/main/java/fr/ntr/User.java | 9 --------- src/main/java/fr/ntr/scheduler/MaxSNR.java | 16 +++++++++++++--- src/main/java/fr/ntr/scheduler/Scheduler.java | 2 +- 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index c8955c7..14df64a 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -68,7 +68,8 @@ public class AccessPoint { // Simulation reset(); updateBandwidth(ticks); - schedule(); + schedule(ticks); + computePacketDelay(ticks); // traite les données et les enregistre dans un fichier try { analyseData(ticks); @@ -76,6 +77,7 @@ public class AccessPoint { System.out.println("Can't export data"); } } + } private void updateBandwidth(int ticks) { @@ -95,8 +97,8 @@ public class AccessPoint { } } - private void schedule() { - scheduler.scheduling(); + private void schedule(int ticks) { + scheduler.scheduling(ticks); } private void analyseData(int tick) throws IOException { @@ -126,6 +128,17 @@ public class AccessPoint { } } + private void computePacketDelay(int ticks){ + for(int i = 0; i < this.users.size(); i++){ + User u = this.users.get(i); + if(!u.getPacketsToSend().isEmpty()){ + for(Packets p : u.getPacketsToSend()){ + + } + } + } + } + public ResourceBlock[][] getFrame() { return frame; } diff --git a/src/main/java/fr/ntr/Packets.java b/src/main/java/fr/ntr/Packets.java index 01e1602..16b2cb3 100644 --- a/src/main/java/fr/ntr/Packets.java +++ b/src/main/java/fr/ntr/Packets.java @@ -5,12 +5,16 @@ public class Packets { private int startTimeSending; private int endTimeSending; private int durationSending; - private double bitsNumberRemaining; + private int bitsNumberRemaining; public Packets(int startTimeSending){ this.startTimeSending = startTimeSending; } + public double getBitsNumberRemaining() { + return bitsNumberRemaining; + } + public int getStartTimeSending() { return startTimeSending; } @@ -24,17 +28,20 @@ public class Packets { } public void setEndTimeSending(int endTimeSending) { - this.endTimeSending = endTimeSending; + this.endTimeSending = endTimeSending+1; } - public void setDurationSending(){ - int durationSending = endTimeSending - startTimeSending; - this.durationSending = durationSending; + public void setDurationSending(int ticks){ + this.durationSending = ticks - startTimeSending; } public int getDurationSending() { return durationSending; } + public void decreaseBitsNumberRemaining(int d) { + this.bitsNumberRemaining -= d; + } + } \ No newline at end of file diff --git a/src/main/java/fr/ntr/User.java b/src/main/java/fr/ntr/User.java index ec7e659..e6b2a36 100644 --- a/src/main/java/fr/ntr/User.java +++ b/src/main/java/fr/ntr/User.java @@ -57,15 +57,6 @@ public class User { return mbis; } - /** - * Calcul délais de transmission des paquets - */ - public void computeTimeSending() { - for(Packets p : packetsToSend){ - p.setDurationSending(); - } - } - public double getDistance() { return distance; } diff --git a/src/main/java/fr/ntr/scheduler/MaxSNR.java b/src/main/java/fr/ntr/scheduler/MaxSNR.java index 2d55916..a76961e 100644 --- a/src/main/java/fr/ntr/scheduler/MaxSNR.java +++ b/src/main/java/fr/ntr/scheduler/MaxSNR.java @@ -1,6 +1,7 @@ package fr.ntr.scheduler; import java.util.List; +import fr.ntr.Packets; import fr.ntr.ResourceBlock; import fr.ntr.User; @@ -17,16 +18,25 @@ public class MaxSNR extends Scheduler { } @Override - public void scheduling() { + public void scheduling(int ticks) { User userMax = null; for(int ts = 0; ts < 2; ts++){ for(int sp = 0; sp < 100; sp++){ userMax = selectionUtilisateur(sp, ts, users); if (userMax.getPacketsToSend().size() != 0) { - userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0)); - userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0)); + Packets p = userMax.getPacketsToSend().get(0); + userMax.getPacketsSent().add(p); + if(p.getDurationSending() != 0){ + if(p.getBitsNumberRemaining() > 0){ + p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]); + } else { + p.setDurationSending(ticks); + } + } + userMax.getPacketsToSend().remove(p); frame[ts][sp].setUser(userMax); frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]); + } } } diff --git a/src/main/java/fr/ntr/scheduler/Scheduler.java b/src/main/java/fr/ntr/scheduler/Scheduler.java index e21432d..1a1c104 100644 --- a/src/main/java/fr/ntr/scheduler/Scheduler.java +++ b/src/main/java/fr/ntr/scheduler/Scheduler.java @@ -7,7 +7,7 @@ public abstract class Scheduler { * Rempli la trame avec les utilisateurs * Return */ - public abstract void scheduling(); + public abstract void scheduling(int ticks); protected void TraitementDonnees() { }