Final fix of User#createPackets
This commit is contained in:
parent
d6d54dbd84
commit
4c2d0ccf50
@ -11,7 +11,7 @@ plugins {
|
||||
}
|
||||
|
||||
run {
|
||||
args = ["10000", "50"]
|
||||
args = ["10000", "17"]
|
||||
}
|
||||
|
||||
application {
|
||||
|
@ -13,6 +13,8 @@ public class User {
|
||||
private int leftForNextSource;
|
||||
private int timeInterval = 1;
|
||||
|
||||
private int mbis;
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
public User(double distance, int timeSlotNb, int subCarrierNb) {
|
||||
@ -47,18 +49,18 @@ public class User {
|
||||
if(timeInterval == 0) {
|
||||
timeInterval = random.nextInt(50, 101);
|
||||
// On tire un nombre entre 0 et 2 * m
|
||||
int mbis = random.nextInt(1, 2 * m) + this.leftForNextSource;
|
||||
// On calcule le nombre de paquets qu'on peut transmettre
|
||||
int bitsToSend = random.nextInt(2 * mbis);
|
||||
int nbPacketsToSend = bitsToSend / Packets.packetSize;
|
||||
// On conserve le nombre de bits restants pour la prochaine génération
|
||||
this.leftForNextSource = bitsToSend % Packets.packetSize;
|
||||
// On crée les paquets
|
||||
for(int i = 0; i < nbPacketsToSend; i++) {
|
||||
this.packetsToSend.add(new Packets(ticks));
|
||||
}
|
||||
}
|
||||
mbis = random.nextInt(1, 2 * m) + this.leftForNextSource;
|
||||
|
||||
}
|
||||
// On calcule le nombre de paquets qu'on peut transmettre
|
||||
int bitsToSend = random.nextInt(2 * mbis);
|
||||
int nbPacketsToSend = bitsToSend / Packets.packetSize;
|
||||
// On conserve le nombre de bits restants pour la prochaine génération
|
||||
this.leftForNextSource = bitsToSend % Packets.packetSize;
|
||||
// On crée les paquets
|
||||
for(int i = 0; i < nbPacketsToSend; i++) {
|
||||
this.packetsToSend.add(new Packets(ticks));
|
||||
}
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
|
Reference in New Issue
Block a user