diff --git a/build.gradle b/build.gradle index 4b8b89a..e154be0 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ plugins { } run { - args = ["10000", "20"] + args = ["10000", "40"] } application { diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index e752838..edd06d7 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -24,11 +24,10 @@ public class AccessPoint { cell1.updateBandwidth(ticks); cell2.updateBandwidth(ticks); - for(int ts = 0; ts < 2; ts++) { - for (int sp = 0; sp < 100; sp++) { - cell1.preScheduling(); - cell2.preScheduling(); - + cell1.preScheduling(); + cell2.preScheduling(); + for(int ts = 0; ts < Cell.getTimeSlotNb(); ts++) { + for (int sp = 0; sp < Cell.getSubCarrierNb(); sp++) { User user1 = cell1.schedule(ticks, ts, sp); User user2 = cell2.schedule(ticks, ts, sp); if(user1 == user2 && user1 != null) { diff --git a/src/main/java/fr/ntr/Cell.java b/src/main/java/fr/ntr/Cell.java index 30c3673..9ba7bb8 100644 --- a/src/main/java/fr/ntr/Cell.java +++ b/src/main/java/fr/ntr/Cell.java @@ -76,18 +76,19 @@ public class Cell { public void consumeResource(int tick, int ts, int sp) { ResourceBlock rb = frame[ts][sp]; User user = rb.getUser(); - Packets p = user.getPacketsToSend().get(user.getPacketsToSend().size()-1); - p.decreaseBitsNumberRemaining((int) user.getBandwidthTable()[ts][sp]); - if(p.getBitsNumberRemaining() <= 0) { - if(tick == 0){ - p.setDurationSending(1); - }else { - p.setDurationSending(tick); + if(user != null && !user.getPacketsToSend().isEmpty()) { + Packets p = user.getPacketsToSend().get(0); + p.decreaseBitsNumberRemaining((int) rb.getBandwidth()); + if(p.getBitsNumberRemaining() <= 0) { + if(tick == 0){ + p.setDurationSending(1); + }else { + p.setDurationSending(tick); + } + user.getPacketsSent().add(p); + user.getPacketsToSend().remove(p); } - user.getPacketsSent().add(p); - user.getPacketsToSend().remove(p); } - } public void analyseData(int tick) throws IOException { diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index aa66e12..1f615c1 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -110,7 +110,8 @@ public class Main { System.exit(1); } } - executor.close(); + executor.close(); + System.out.println("Executor closed"); } 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 20bca04..f553fc4 100644 --- a/src/main/java/fr/ntr/scheduler/RoundRobin.java +++ b/src/main/java/fr/ntr/scheduler/RoundRobin.java @@ -25,7 +25,6 @@ public class RoundRobin extends Scheduler { */ @Override public User scheduling(int ticks, int ts, int sp) { - if(userCopy.isEmpty()) { return null; } @@ -36,7 +35,7 @@ public class RoundRobin extends Scheduler { @Override public void postScheduling(User userSelected) { - if(!userSelected.getPacketsToSend().isEmpty()) + if(userSelected != null && !userSelected.getPacketsToSend().isEmpty()) userCopy.add(userSelected); } diff --git a/src/main/java/fr/ntr/scheduler/Scheduler.java b/src/main/java/fr/ntr/scheduler/Scheduler.java index 78376a4..3d30a88 100644 --- a/src/main/java/fr/ntr/scheduler/Scheduler.java +++ b/src/main/java/fr/ntr/scheduler/Scheduler.java @@ -21,17 +21,6 @@ public abstract class Scheduler { public void allocateRessource(User userMax, int ts, int sp, int ticks) { if (userMax != null && !userMax.getPacketsToSend().isEmpty()) { - /* Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1); - p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]); - if(p.getBitsNumberRemaining() <= 0) { - if(ticks == 0){ - p.setDurationSending(1); - }else { - p.setDurationSending(ticks); - } - userMax.getPacketsSent().add(p); - userMax.getPacketsToSend().remove(p); - } */ myFrame[ts][sp].setUser(userMax); myFrame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]); }