From cb0ad20d89d9ca34c4b6e74f501d4a129486351c Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Fri, 17 Mar 2023 10:29:36 +0100 Subject: [PATCH 1/3] Fix createPackets --- src/main/java/fr/ntr/AccessPoint.java | 9 +++++---- src/main/java/fr/ntr/User.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 01ac564..1a79222 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -57,17 +57,18 @@ public class AccessPoint { private void updateBandwidth(int ticks) { int n = 200; - int timeInterval = 50 + new Random().nextInt(50); + Random random = new Random(); + int timeInterval = 50 + random.nextInt(51); for(User user : users) { - // On regénère le tableau de débits toutes les 50 ms + // On régénère le tableau de débits toutes les 50 ms if(ticks % 50 == 0){ user.generateBandwidth(); } - // On regénère les sources toutes les 50-100 ms + // On régénère les sources toutes les 50-100 ms if(ticks % timeInterval == 0){ n = user.createPackets(n); - timeInterval = 50 + new Random().nextInt(51); + timeInterval = 50 + random.nextInt(51); } } } diff --git a/src/main/java/fr/ntr/User.java b/src/main/java/fr/ntr/User.java index 8d62352..84861da 100644 --- a/src/main/java/fr/ntr/User.java +++ b/src/main/java/fr/ntr/User.java @@ -35,11 +35,11 @@ public class User { public int createPackets(int m) { Random random = new Random(); - int mbis = (int) random.nextDouble() * (2 * m); + int mbis = random.nextInt(2 * m); int nbPacketsToSend = mbis / Packets.packetSize; this.leftForNextSource = mbis % Packets.packetSize; for(int i = 0; i < nbPacketsToSend; i++){ - this.packetsToSend.add(new Packets(i, i, i)); // Voir pour les valeurs du contructeur Packets + this.packetsToSend.add(new Packets(i, i, i)); // Voir pour les valeurs du constructeur Packets } return mbis; } From e89eefa529b6e18edf0aabbcf4090c0a7edf91fb Mon Sep 17 00:00:00 2001 From: Tr1xt4n Date: Fri, 17 Mar 2023 10:42:51 +0100 Subject: [PATCH 2/3] maj MAXSnr --- src/main/java/fr/ntr/scheduler/MaxSNR.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/fr/ntr/scheduler/MaxSNR.java b/src/main/java/fr/ntr/scheduler/MaxSNR.java index c346bfd..0fc7211 100644 --- a/src/main/java/fr/ntr/scheduler/MaxSNR.java +++ b/src/main/java/fr/ntr/scheduler/MaxSNR.java @@ -1,18 +1,28 @@ package fr.ntr.scheduler; import java.util.List; +import fr.ntr.ResourceBlock; import fr.ntr.User; public class MaxSNR extends Scheduler { private List users; + private ResourceBlock[][] frame; + @Override public void scheduling() { 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() == null) { + users.remove(userMax); + }else{ + //sub the packet send need Set packet + userMax.getPacketsToSend(); + } + frame[ts][sp].setUser(selectionUtilisateur(sp, ts, users)); } } } From cdbb056bed8a23f054f8a1a1b94a499913718bc4 Mon Sep 17 00:00:00 2001 From: Loris Date: Fri, 17 Mar 2023 10:45:55 +0100 Subject: [PATCH 3/3] Main instancie frame et le donne au scheduler et AccessPoint --- src/main/java/fr/ntr/AccessPoint.java | 6 ++++-- src/main/java/fr/ntr/Main.java | 10 +++++++--- src/main/java/fr/ntr/scheduler/RoundRobin.java | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 1a79222..8592b0f 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -31,12 +31,14 @@ public class AccessPoint { private final double min, max; - public AccessPoint(Scheduler scheduler, double min, double max) { + public AccessPoint(Scheduler scheduler, ResourceBlock[][] frame, int timeSlotNb, int subCarrierNb, double min, double max) { this.min = min; this.max = max; this.users = new ArrayList<>(); this.scheduler = scheduler; - this.frame = new ResourceBlock[timeSlotNb][subCarrierNb]; + this.frame = frame; + this.timeSlotNb = timeSlotNb; + this.subCarrierNb = subCarrierNb; } /** diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index 3796cd7..e72e29d 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -1,11 +1,11 @@ package fr.ntr; import fr.ntr.scheduler.RoundRobin; +import fr.ntr.scheduler.Scheduler; public class Main { public static void main(String[] args) { - //TODO ajouter accès à AccessPoint if(args.length == 2) { int numberOfTicks; // Nombre de ticks de la simulation -> durée de la simulation @@ -19,8 +19,12 @@ public class Main { System.exit(1); return; } - - AccessPoint accessPoint = new AccessPoint(new RoundRobin("round robin", 0), 0, 50); + //TODO : change timeSlotNb and subCarrierNb + int timeSlotNb = 0; + int subCarrierNb = 0; + ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; + Scheduler scheduler = new RoundRobin("round robin", 0, frame); + AccessPoint accessPoint = new AccessPoint(scheduler, frame, timeSlotNb, subCarrierNb, 0, 50); accessPoint.startSimulation(numberOfTicks, maximumLoad); } else { System.err.println("Please give launch arguments"); diff --git a/src/main/java/fr/ntr/scheduler/RoundRobin.java b/src/main/java/fr/ntr/scheduler/RoundRobin.java index 163e1c0..f2ff2b1 100644 --- a/src/main/java/fr/ntr/scheduler/RoundRobin.java +++ b/src/main/java/fr/ntr/scheduler/RoundRobin.java @@ -15,9 +15,10 @@ public class RoundRobin extends Scheduler { private List users; private ResourceBlock[][] frame; - public RoundRobin(String name, int index) { + public RoundRobin(String name, int index, ResourceBlock[][] frame) { this.name = name; this.index = index; + this.frame = frame; } /**