Move duplicate block

This commit is contained in:
Quentin Legot 2023-03-24 11:51:08 +01:00
parent 9f2178ed49
commit cb7150e444
5 changed files with 16 additions and 18 deletions

View File

@ -80,14 +80,14 @@ public class AccessPoint {
private void updateBandwidth(int ticks) { private void updateBandwidth(int ticks) {
int n = 200; int n = 200;
int timeInterval = 50 + random.nextInt(51); int timeInterval = Math.max(1, random.nextInt(51)); // avoid div by 0
for(User user : users) { for(User user : users) {
// On régé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){ if(ticks % 50 == 0){
user.generateBandwidth(); user.generateBandwidth();
} }
// On régénère les sources toutes les 50-100 ms // On régénère les sources toutes les 0-50 ms
if(ticks % timeInterval == 0){ if(ticks % timeInterval == 0){
timeInterval = 50 + random.nextInt(51); timeInterval = 50 + random.nextInt(51);
n = user.createPackets(n, ticks); n = user.createPackets(n, ticks);

View File

@ -18,16 +18,10 @@ public class MaxSNR extends Scheduler {
@Override @Override
public void scheduling() { public void scheduling() {
User userMax = null;
for(int ts = 0; ts < 2; ts++){ for(int ts = 0; ts < 2; ts++){
for(int sp = 0; sp < 100; sp++){ for(int sp = 0; sp < 100; sp++){
userMax = selectionUtilisateur(sp, ts, users); User userMax = selectionUtilisateur(sp, ts, users);
if (userMax.getPacketsToSend().size() != 0) { allocateRessource(userMax, frame, ts, sp);
userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0));
userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0));
frame[ts][sp].setUser(userMax);
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
}
} }
} }
} }

View File

@ -34,12 +34,7 @@ public class ProportionalFair extends Scheduler {
for(int ts = 0; ts < 2; ts++){ for(int ts = 0; ts < 2; ts++){
for(int sp = 0; sp < 100; sp++){ for(int sp = 0; sp < 100; sp++){
selectedUser = selectionUtilisateur(ts, sp, users, averageBandwiths); selectedUser = selectionUtilisateur(ts, sp, users, averageBandwiths);
if (selectedUser != null && !selectedUser.getPacketsToSend().isEmpty()) { allocateRessource(selectedUser, frame, ts, sp);
selectedUser.getPacketsSent().add(selectedUser.getPacketsToSend().get(0));
selectedUser.getPacketsToSend().remove(selectedUser.getPacketsToSend().get(0));
frame[ts][sp].setUser(selectedUser);
frame[ts][sp].setBandwidth(selectedUser.getBandwidthTable()[ts][sp]);
}
} }
} }
} }

View File

@ -36,7 +36,7 @@ public class RoundRobin extends Scheduler {
//Pour chaque time slot et sous porteuses //Pour chaque time slot et sous porteuses
for (int Ts = 0; Ts < AccessPoint.getTimeSlotNb(); Ts++) { for (int Ts = 0; Ts < AccessPoint.getTimeSlotNb(); Ts++) {
for(int Sp = 0; Sp < AccessPoint.getSubCarrierNb(); Sp++) { for(int Sp = 0; Sp < AccessPoint.getSubCarrierNb(); Sp++) {
if (users.get(index).getPacketsToSend().size() != 0) { if (!users.get(index).getPacketsToSend().isEmpty()) {
// on enlève le packet transmis de la liste // on enlève le packet transmis de la liste
// TODO Verify sub the packet send need Set packet // TODO Verify sub the packet send need Set packet
users.get(index).getPacketsSent().add(users.get(index).getPacketsToSend().get(0)); users.get(index).getPacketsSent().add(users.get(index).getPacketsToSend().get(0));

View File

@ -1,5 +1,8 @@
package fr.ntr.scheduler; package fr.ntr.scheduler;
import fr.ntr.ResourceBlock;
import fr.ntr.User;
public abstract class Scheduler { public abstract class Scheduler {
/** /**
@ -8,7 +11,13 @@ public abstract class Scheduler {
* Return * Return
*/ */
public abstract void scheduling(); public abstract void scheduling();
protected void TraitementDonnees() {
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp) {
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0));
userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0));
frame[ts][sp].setUser(userMax);
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
}
} }
} }