Merge branch 'master' of gitlab.istic.univ-rennes1.fr:18008147/ntr
This commit is contained in:
commit
f91c300a2a
@ -1,6 +1,5 @@
|
||||
package fr.ntr;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@ -42,7 +41,6 @@ public class AccessPoint {
|
||||
|
||||
/**
|
||||
* Lancer la simulation
|
||||
*
|
||||
* @param duration
|
||||
*/
|
||||
public void startSimulation(int duration, int nbUsers) {
|
||||
@ -62,7 +60,7 @@ public class AccessPoint {
|
||||
private void init(int nbUsers) {
|
||||
double[] distance = { 200d, 500d };
|
||||
for (int i = 0; i < nbUsers; i++) {
|
||||
User user = new User(distance[i]);
|
||||
User user = new User(distance[i], timeSlotNb, subCarrierNb);
|
||||
user.generateBandwidth();
|
||||
user.createPackets();
|
||||
this.users.add(user);
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user