Merge remote-tracking branch 'origin/master'

This commit is contained in:
iboyeau 2023-03-17 10:48:03 +01:00
commit ef528d2367
5 changed files with 30 additions and 12 deletions

View File

@ -31,12 +31,14 @@ public class AccessPoint {
private final double min, max; 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.min = min;
this.max = max; this.max = max;
this.users = new ArrayList<>(); this.users = new ArrayList<>();
this.scheduler = scheduler; this.scheduler = scheduler;
this.frame = new ResourceBlock[timeSlotNb][subCarrierNb]; this.frame = frame;
this.timeSlotNb = timeSlotNb;
this.subCarrierNb = subCarrierNb;
} }
/** /**
@ -57,17 +59,18 @@ public class AccessPoint {
private void updateBandwidth(int ticks) { private void updateBandwidth(int ticks) {
int n = 200; int n = 200;
int timeInterval = 50 + new Random().nextInt(50); Random random = new Random();
int timeInterval = 50 + random.nextInt(51);
for(User user : users) { 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){ if(ticks % 50 == 0){
user.generateBandwidth(); 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){ if(ticks % timeInterval == 0){
n = user.createPackets(n); n = user.createPackets(n);
timeInterval = 50 + new Random().nextInt(51); timeInterval = 50 + random.nextInt(51);
} }
} }
} }

View File

@ -1,11 +1,11 @@
package fr.ntr; package fr.ntr;
import fr.ntr.scheduler.RoundRobin; import fr.ntr.scheduler.RoundRobin;
import fr.ntr.scheduler.Scheduler;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
//TODO ajouter accès à AccessPoint
if(args.length == 2) { if(args.length == 2) {
int numberOfTicks; // Nombre de ticks de la simulation -> durée de la simulation int numberOfTicks; // Nombre de ticks de la simulation -> durée de la simulation
@ -19,8 +19,12 @@ public class Main {
System.exit(1); System.exit(1);
return; return;
} }
//TODO : change timeSlotNb and subCarrierNb
AccessPoint accessPoint = new AccessPoint(new RoundRobin("round robin", 0), 0, 50); 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); accessPoint.startSimulation(numberOfTicks, maximumLoad);
} else { } else {
System.err.println("Please give launch arguments"); System.err.println("Please give launch arguments");

View File

@ -35,11 +35,11 @@ public class User {
public int createPackets(int m) { public int createPackets(int m) {
Random random = new Random(); Random random = new Random();
int mbis = (int) random.nextDouble() * (2 * m); int mbis = random.nextInt(2 * m);
int nbPacketsToSend = mbis / Packets.packetSize; int nbPacketsToSend = mbis / Packets.packetSize;
this.leftForNextSource = mbis % Packets.packetSize; this.leftForNextSource = mbis % Packets.packetSize;
for(int i = 0; i < nbPacketsToSend; i++){ 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; return mbis;
} }

View File

@ -1,18 +1,28 @@
package fr.ntr.scheduler; package fr.ntr.scheduler;
import java.util.List; import java.util.List;
import fr.ntr.ResourceBlock;
import fr.ntr.User; import fr.ntr.User;
public class MaxSNR extends Scheduler { public class MaxSNR extends Scheduler {
private List<User> users; private List<User> users;
private ResourceBlock[][] frame;
@Override @Override
public void scheduling() { public void scheduling() {
User userMax = null; 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); 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));
} }
} }
} }

View File

@ -15,9 +15,10 @@ public class RoundRobin extends Scheduler {
private List<User> users; private List<User> users;
private ResourceBlock[][] frame; private ResourceBlock[][] frame;
public RoundRobin(String name, int index) { public RoundRobin(String name, int index, ResourceBlock[][] frame) {
this.name = name; this.name = name;
this.index = index; this.index = index;
this.frame = frame;
} }
/** /**