This commit is contained in:
Quentin Legot 2023-03-10 08:50:28 +01:00
parent 01b82d7ef4
commit 26c1871490
2 changed files with 14 additions and 9 deletions

View File

@ -61,7 +61,7 @@ public class AccessPoint {
for(int i = 0; i < nbUsers; i++){
Random random = new Random();
double randomDist = this.min + random.nextDouble() * (this.max - this.min);
User user = new User(randomDist);
User user = new User(randomDist, timeSlotNb, subCarrierNb);
user.generateBandwidth();
user.createPackets();
this.users.add(user);
@ -87,4 +87,5 @@ public class AccessPoint {
public int getFrameSize(){
return this.timeSlotNb * this.subCarrierNb;
}
}

View File

@ -10,21 +10,25 @@ public class User {
private final List<Packets> packetsToSend;
private final List<Packets> packetsSent;
public User(double distance) {
public User(double distance, int timeSlotNb, int subCarrierNb) {
this.distance = distance;
this.bandwidthTable = new double[1][1]; // TODO: 03/03/2023 Changer valeurs
this.bandwidthTable = new double[timeSlotNb][subCarrierNb];
this.packetsToSend = new ArrayList<>();
this.packetsSent = new ArrayList<>();
}
public void generateBandwidth() {
double X = Math.random();
double h = 8 * Math.sqrt(-2 * Math.log(1 - X));
double gain = h * Math.pow(10, X*8/10) * Math.pow(1/this.distance, 3.5);
double spectralEfficacity = (43 * gain)/(15000*(-174));
double mkn = Math.log1p(spectralEfficacity);
this.bandwidthTable[][] = mkn; // Voir comment remplir le tableau
double random = Math.random();
for(int i = 0; i < bandwidthTable.length; i++) {
for(int j = 0; j < bandwidthTable[i].length; j++) {
double h = 8 * Math.sqrt(-2 * Math.log(1 - random));
double gain = h * Math.pow(10, random*8/10) * Math.pow(1/this.distance, 3.5);
double spectralEfficiency = (43 * gain)/(15000*(-174));
double mkn = Math.log1p(spectralEfficiency);
this.bandwidthTable[i][j] = mkn;
}
}
}
public void createPackets() {