2023-03-03 10:38:35 +01:00
|
|
|
package fr.ntr;
|
|
|
|
|
2023-03-03 12:12:18 +01:00
|
|
|
import java.util.ArrayList;
|
2023-03-03 11:28:16 +01:00
|
|
|
import java.util.List;
|
2023-03-06 17:48:22 +01:00
|
|
|
import java.util.Random;
|
2023-03-03 11:28:16 +01:00
|
|
|
|
|
|
|
import fr.ntr.scheduler.Scheduler;
|
|
|
|
|
2023-03-03 10:38:35 +01:00
|
|
|
public class AccessPoint {
|
2023-03-03 11:28:16 +01:00
|
|
|
private List<User> users;
|
|
|
|
private Scheduler scheduler;
|
2023-03-03 11:47:53 +01:00
|
|
|
/**
|
|
|
|
* nombre de slots
|
|
|
|
*/
|
|
|
|
private static int timeSlotNb;
|
|
|
|
/**
|
2023-03-10 08:19:07 +01:00
|
|
|
* Nombre de sous-porteuses
|
2023-03-03 11:47:53 +01:00
|
|
|
*/
|
|
|
|
private static int subCarrierNb;
|
|
|
|
/**
|
|
|
|
* trame
|
|
|
|
*/
|
|
|
|
private ResourceBlock[][] frame;
|
|
|
|
/**
|
2023-03-10 08:19:07 +01:00
|
|
|
* Reste pour la prochaine source
|
2023-03-03 11:47:53 +01:00
|
|
|
*/
|
|
|
|
private double leftForNextSource;
|
2023-03-06 17:48:22 +01:00
|
|
|
/**
|
2023-03-10 08:19:07 +01:00
|
|
|
* Portée minimum et maximum de l'antenne
|
2023-03-06 17:48:22 +01:00
|
|
|
*/
|
|
|
|
private final double min, max;
|
2023-03-03 11:28:16 +01:00
|
|
|
|
|
|
|
|
2023-03-06 17:48:22 +01:00
|
|
|
public AccessPoint(Scheduler scheduler, double min, double max) {
|
|
|
|
this.min = min;
|
|
|
|
this.max = max;
|
2023-03-10 08:19:07 +01:00
|
|
|
this.users = new ArrayList<>();
|
2023-03-03 11:28:16 +01:00
|
|
|
this.scheduler = scheduler;
|
2023-03-03 12:12:18 +01:00
|
|
|
this.frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
2023-03-03 11:28:16 +01:00
|
|
|
}
|
|
|
|
|
2023-03-06 17:48:22 +01:00
|
|
|
/**
|
|
|
|
* Lancer la simulation
|
|
|
|
* @param duration
|
|
|
|
*/
|
|
|
|
public void startSimulation(int duration, int nbUsers){
|
|
|
|
for(int ticks = 0; ticks < duration; ++ticks){
|
|
|
|
// Simulation
|
|
|
|
reset();
|
|
|
|
init(nbUsers);
|
|
|
|
schedule();
|
|
|
|
// traite les données et les enregistre dans un fichier
|
|
|
|
analyseData();
|
|
|
|
}
|
2023-03-03 11:28:16 +01:00
|
|
|
}
|
|
|
|
|
2023-03-03 12:12:18 +01:00
|
|
|
/**
|
|
|
|
* Génération du débit et des paquets
|
|
|
|
*/
|
2023-03-06 17:48:22 +01:00
|
|
|
private void init(int nbUsers){
|
|
|
|
for(int i = 0; i < nbUsers; i++){
|
|
|
|
Random random = new Random();
|
|
|
|
double randomDist = this.min + random.nextDouble() * (this.max - this.min);
|
2023-03-10 08:50:28 +01:00
|
|
|
User user = new User(randomDist, timeSlotNb, subCarrierNb);
|
2023-03-06 17:48:22 +01:00
|
|
|
user.generateBandwidth();
|
|
|
|
user.createPackets();
|
|
|
|
this.users.add(user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void schedule(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void analyseData(){
|
|
|
|
|
2023-03-03 11:28:16 +01:00
|
|
|
}
|
|
|
|
|
2023-03-06 17:48:22 +01:00
|
|
|
private void plotData(){
|
2023-03-03 11:28:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void reset(){
|
|
|
|
|
|
|
|
}
|
2023-03-03 12:12:18 +01:00
|
|
|
|
|
|
|
public int getFrameSize(){
|
|
|
|
return this.timeSlotNb * this.subCarrierNb;
|
|
|
|
}
|
2023-03-10 08:50:28 +01:00
|
|
|
|
2023-03-03 10:38:35 +01:00
|
|
|
}
|