génération des paquets
This commit is contained in:
parent
545f230437
commit
b9eb223e64
@ -58,16 +58,24 @@ public class AccessPoint {
|
|||||||
* Génération du débit et des paquets
|
* Génération du débit et des paquets
|
||||||
*/
|
*/
|
||||||
private void init(int nbUsers, int ticks) {
|
private void init(int nbUsers, int ticks) {
|
||||||
double n = 200;
|
int n = 200;
|
||||||
double timeInterval = 50;
|
int timeInterval = 50 + new Random().nextInt(50);
|
||||||
|
|
||||||
|
// 2 groupes d'utilisateurs, proches et éloignés
|
||||||
double[] distance = { 200d, 1000d };
|
double[] distance = { 200d, 1000d };
|
||||||
for (int i = 0; i < distance.length; i++) {
|
for (int i = 0; i < distance.length; i++) {
|
||||||
for(int j = 0; j < nbUsers; j++){
|
for(int j = 0; j < nbUsers; j++){
|
||||||
User user = new User(distance[i], timeSlotNb, subCarrierNb);
|
User user = new User(distance[i], timeSlotNb, subCarrierNb);
|
||||||
user.generateBandwidth();
|
|
||||||
if(ticks % timeInterval){
|
|
||||||
n = user.createPackets(n);
|
|
||||||
|
|
||||||
|
// On regénère le tableau de débits toutes les 50 ms
|
||||||
|
if(ticks % 50 == 0){
|
||||||
|
user.generateBandwidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
// On regénère les sources toutes les 50-100 ms
|
||||||
|
if(ticks % timeInterval == 0){
|
||||||
|
n = user.createPackets(n);
|
||||||
|
timeInterval = 50 + new Random().nextInt(51);
|
||||||
}
|
}
|
||||||
this.users.add(user);
|
this.users.add(user);
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,14 @@ public class User {
|
|||||||
private final double[][] bandwidthTable;
|
private final double[][] bandwidthTable;
|
||||||
private final List<Packets> packetsToSend;
|
private final List<Packets> packetsToSend;
|
||||||
private final List<Packets> packetsSent;
|
private final List<Packets> packetsSent;
|
||||||
|
private int leftForNextSource;
|
||||||
|
|
||||||
public User(double distance, int timeSlotNb, int subCarrierNb) {
|
public User(double distance, int timeSlotNb, int subCarrierNb) {
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
this.bandwidthTable = new double[timeSlotNb][subCarrierNb];
|
this.bandwidthTable = new double[timeSlotNb][subCarrierNb];
|
||||||
this.packetsToSend = new ArrayList<>();
|
this.packetsToSend = new ArrayList<>();
|
||||||
this.packetsSent = new ArrayList<>();
|
this.packetsSent = new ArrayList<>();
|
||||||
|
this.leftForNextSource = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateBandwidth() {
|
public void generateBandwidth() {
|
||||||
@ -32,9 +33,15 @@ public class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPackets(double m) {
|
public int createPackets(int m) {
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
double mbis = random.nextDouble() * (2 * m);
|
int mbis = (int) random.nextDouble() * (2 * m);
|
||||||
|
int nbPacketsToSend = mbis / Packets.packetSize;
|
||||||
|
this.leftForNextSource = mbis % Packets.packetSize;
|
||||||
|
for(int i = 0; i < nbPacketsToSend; i++){
|
||||||
|
this.packetsToSend.add(new Packets(i, i, i)); // Voir pour les valeurs du contructeur Packets
|
||||||
|
}
|
||||||
|
return mbis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user