Fix User#generateBandwidth change packetSize name to PACKET_SIZE
This commit is contained in:
parent
82c7ed700d
commit
22eead040f
@ -1,14 +1,14 @@
|
|||||||
package fr.ntr;
|
package fr.ntr;
|
||||||
|
|
||||||
public class Packets {
|
public class Packets {
|
||||||
static final int packetSize = 100;
|
static final int PACKET_SIZE = 100;
|
||||||
private int startTimeSending;
|
private int startTimeSending;
|
||||||
private int endTimeSending;
|
private int endTimeSending;
|
||||||
private int durationSending;
|
private int durationSending;
|
||||||
private int bitsNumberRemaining;
|
private int bitsNumberRemaining;
|
||||||
|
|
||||||
public Packets(int startTimeSending){
|
public Packets(int startTimeSending){
|
||||||
this.bitsNumberRemaining = packetSize;
|
this.bitsNumberRemaining = PACKET_SIZE;
|
||||||
this.startTimeSending = startTimeSending;
|
this.startTimeSending = startTimeSending;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,16 +26,14 @@ public class User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void generateBandwidth() {
|
public void generateBandwidth() {
|
||||||
|
|
||||||
for(int y = 0; y < bandwidthTable[0].length; y++) {
|
for(int y = 0; y < bandwidthTable[0].length; y++) {
|
||||||
double rand = this.random.nextDouble();
|
double rand = this.random.nextDouble();
|
||||||
for(int x = 0; x < bandwidthTable.length; x++) {
|
double h = 1 * Math.sqrt(-2 * Math.log(1 - rand));
|
||||||
double h = 1 * Math.sqrt(-2 * Math.log(1 - rand));
|
double gain = h * h * Math.pow(10, rand * 1/10) * Math.pow(1 / this.distance, 3.5);
|
||||||
double gain = h * h * Math.pow(10, rand * 1/10) * Math.pow(1 / this.distance, 3.5);
|
double spectralEfficiency = (20 * gain) / (15000 * (3.9*Math.pow(10, -21)));
|
||||||
double spectralEfficiency = (20 * gain) / (15000 * (3.9*Math.pow(10, -21)));
|
double mkn = Math.log(1 + spectralEfficiency) / Math.log(2);
|
||||||
double mkn = Math.log(1 + spectralEfficiency) / Math.log(2);
|
this.bandwidthTable[0][y] = mkn;
|
||||||
this.bandwidthTable[x][y] = mkn;
|
this.bandwidthTable[1][y] = mkn;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,9 +52,9 @@ public class User {
|
|||||||
}
|
}
|
||||||
// On calcule le nombre de paquets qu'on peut transmettre
|
// On calcule le nombre de paquets qu'on peut transmettre
|
||||||
int bitsToSend = random.nextInt(2 * mbis);
|
int bitsToSend = random.nextInt(2 * mbis);
|
||||||
int nbPacketsToSend = bitsToSend / Packets.packetSize;
|
int nbPacketsToSend = bitsToSend / Packets.PACKET_SIZE;
|
||||||
// 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 = bitsToSend % Packets.packetSize;
|
this.leftForNextSource = bitsToSend % Packets.PACKET_SIZE;
|
||||||
// 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));
|
||||||
|
Reference in New Issue
Block a user