First fix of User#createPackets
This commit is contained in:
parent
aa9ea15beb
commit
d6d54dbd84
@ -48,7 +48,6 @@ def delay() -> np.ndarray:
|
|||||||
for x in d:
|
for x in d:
|
||||||
delays[nb, 0] = int(nb_users)
|
delays[nb, 0] = int(nb_users)
|
||||||
delays[nb, 1] = float(x)
|
delays[nb, 1] = float(x)
|
||||||
print(float(x))
|
|
||||||
nb += 1
|
nb += 1
|
||||||
return delays
|
return delays
|
||||||
|
|
||||||
@ -60,7 +59,6 @@ delays.sort(axis=0)
|
|||||||
# Data for plotting
|
# Data for plotting
|
||||||
averages.sort(axis=0)
|
averages.sort(axis=0)
|
||||||
|
|
||||||
#print(averages)
|
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
ax.scatter(averages[:, 0], averages[:, 1])
|
ax.scatter(averages[:, 0], averages[:, 1])
|
||||||
|
|
||||||
|
@ -25,17 +25,12 @@ public class AccessPoint {
|
|||||||
* trame
|
* trame
|
||||||
*/
|
*/
|
||||||
private ResourceBlock[][] frame;
|
private ResourceBlock[][] frame;
|
||||||
/**
|
|
||||||
* Reste pour la prochaine source
|
|
||||||
*/
|
|
||||||
private double leftForNextSource;
|
|
||||||
/**
|
/**
|
||||||
* Portée minimum et maximum de l'antenne
|
* Portée minimum et maximum de l'antenne
|
||||||
*/
|
*/
|
||||||
private final double min, max;
|
private final double min, max;
|
||||||
|
|
||||||
private Random random = new Random();
|
|
||||||
|
|
||||||
private FileOutputStream outputDataFile;
|
private FileOutputStream outputDataFile;
|
||||||
|
|
||||||
|
|
||||||
@ -80,19 +75,15 @@ public class AccessPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateBandwidth(int ticks) {
|
private void updateBandwidth(int ticks) {
|
||||||
int n = 200;
|
int m = 200;
|
||||||
int timeInterval = Math.max(1, random.nextInt(51)); // avoid div by 0
|
|
||||||
for(User user : users) {
|
for(User user : users) {
|
||||||
|
// On régénère les sources toutes les 50-100 ms
|
||||||
|
user.createPackets(m, ticks);
|
||||||
// On régénère le tableau de débits toutes les 50 ms
|
// On régénère le tableau de débits toutes les 50 ms
|
||||||
if(ticks % 50 == 0){
|
if(ticks % 50 == 0){
|
||||||
user.generateBandwidth();
|
user.generateBandwidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
// On régénère les sources toutes les 0-50 ms
|
|
||||||
if(ticks % timeInterval == 0){
|
|
||||||
timeInterval = Math.max(1, random.nextInt(51));
|
|
||||||
n = user.createPackets(n, ticks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ public class User {
|
|||||||
private final List<Packets> packetsToSend;
|
private final List<Packets> packetsToSend;
|
||||||
private final List<Packets> packetsSent;
|
private final List<Packets> packetsSent;
|
||||||
private int leftForNextSource;
|
private int leftForNextSource;
|
||||||
|
private int timeInterval = 1;
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
|
|
||||||
@ -40,20 +41,24 @@ public class User {
|
|||||||
*
|
*
|
||||||
* @param m
|
* @param m
|
||||||
* @param ticks qui va définir le temps auquel a été créé un paquet
|
* @param ticks qui va définir le temps auquel a été créé un paquet
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public int createPackets(int m, int ticks) {
|
public void createPackets(int m, int ticks) {
|
||||||
|
timeInterval--;
|
||||||
|
if(timeInterval == 0) {
|
||||||
|
timeInterval = random.nextInt(50, 101);
|
||||||
// On tire un nombre entre 0 et 2 * m
|
// On tire un nombre entre 0 et 2 * m
|
||||||
int mbis = m == 0 ? 0 : random.nextInt(2 * (m + this.leftForNextSource));
|
int mbis = random.nextInt(1, 2 * m) + this.leftForNextSource;
|
||||||
// On calcule le nombre de paquets qu'on peut transmettre
|
// On calcule le nombre de paquets qu'on peut transmettre
|
||||||
int nbPacketsToSend = mbis / Packets.packetSize;
|
int bitsToSend = random.nextInt(2 * mbis);
|
||||||
|
int nbPacketsToSend = bitsToSend / Packets.packetSize;
|
||||||
// On conserve le nombre de bits restants pour la prochaine génération
|
// On conserve le nombre de bits restants pour la prochaine génération
|
||||||
this.leftForNextSource = mbis % Packets.packetSize;
|
this.leftForNextSource = bitsToSend % Packets.packetSize;
|
||||||
// On crée les paquets
|
// On crée les paquets
|
||||||
for(int i = 0; i < nbPacketsToSend; i++) {
|
for(int i = 0; i < nbPacketsToSend; i++) {
|
||||||
this.packetsToSend.add(new Packets(ticks));
|
this.packetsToSend.add(new Packets(ticks));
|
||||||
}
|
}
|
||||||
return mbis;
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDistance() {
|
public double getDistance() {
|
||||||
|
Reference in New Issue
Block a user