calcul temps de transmission de chaque paquet
This commit is contained in:
parent
b5691cb6d0
commit
6c51709f53
@ -66,7 +66,7 @@ public class AccessPoint {
|
||||
|
||||
// On regénère les sources toutes les 50-100 ms
|
||||
if(ticks % timeInterval == 0){
|
||||
n = user.createPackets(n);
|
||||
n = user.createPackets(n, ticks);
|
||||
timeInterval = 50 + new Random().nextInt(51);
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,39 @@ package fr.ntr;
|
||||
|
||||
public class Packets {
|
||||
static final int packetSize = 100;
|
||||
private int creationTime;
|
||||
private int startTimeSending;
|
||||
private int endTimeSending;
|
||||
private int durationSending;
|
||||
private double bitsNumberRemaining;
|
||||
|
||||
public Packets(int creationTime, int endTimeSending, double bitsNumberRemaining){
|
||||
this.creationTime = creationTime;
|
||||
this.endTimeSending = endTimeSending;
|
||||
this.bitsNumberRemaining = bitsNumberRemaining;
|
||||
public Packets(int startTimeSending){
|
||||
this.startTimeSending = startTimeSending;
|
||||
}
|
||||
|
||||
public int getStartTimeSending() {
|
||||
return startTimeSending;
|
||||
}
|
||||
|
||||
public void setStartTimeSending(int startTimeSending) {
|
||||
this.startTimeSending = startTimeSending;
|
||||
}
|
||||
|
||||
public int getEndTimeSending() {
|
||||
return endTimeSending;
|
||||
}
|
||||
|
||||
public void setEndTimeSending(int endTimeSending) {
|
||||
this.endTimeSending = endTimeSending;
|
||||
}
|
||||
|
||||
public void setDurationSending(){
|
||||
int durationSending = endTimeSending - startTimeSending;
|
||||
this.durationSending = durationSending;
|
||||
}
|
||||
|
||||
public int getDurationSending() {
|
||||
return durationSending;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -32,23 +32,35 @@ public class User {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int createPackets(int m) {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param m
|
||||
* @param ticks qui va définir le temps auquel a été créé un paquet
|
||||
* @return
|
||||
*/
|
||||
public int createPackets(int m, int ticks) {
|
||||
Random random = new Random();
|
||||
int mbis = (int) random.nextDouble() * (2 * m);
|
||||
// On tire un nombre entre 0 et 2 * m
|
||||
int mbis = random.nextInt(2 * (m + this.leftForNextSource));
|
||||
// On calcule le nombre de paquets qu'on peut transmettre
|
||||
int nbPacketsToSend = mbis / Packets.packetSize;
|
||||
// On conserve le nombre de bits restants pour la prochaine génération
|
||||
this.leftForNextSource = mbis % Packets.packetSize;
|
||||
// On crée les paquets
|
||||
for(int i = 0; i < nbPacketsToSend; i++){
|
||||
this.packetsToSend.add(new Packets(i, i, i)); // Voir pour les valeurs du contructeur Packets
|
||||
this.packetsToSend.add(new Packets(ticks));
|
||||
}
|
||||
return mbis;
|
||||
}
|
||||
|
||||
/**
|
||||
* calculDélai
|
||||
* calcul délais de transmission des paquets
|
||||
*/
|
||||
public double calculateLatency() {
|
||||
return 0d;
|
||||
public void computeTimeSending() {
|
||||
for(Packets p : packetsToSend){
|
||||
p.setDurationSending();
|
||||
}
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
|
Reference in New Issue
Block a user