Calcul délai paquet

This commit is contained in:
Remi Boure 2023-03-24 12:12:18 +01:00
parent e7b9f75035
commit c06ada9679
5 changed files with 42 additions and 21 deletions

View File

@ -68,7 +68,8 @@ public class AccessPoint {
// Simulation // Simulation
reset(); reset();
updateBandwidth(ticks); updateBandwidth(ticks);
schedule(); schedule(ticks);
computePacketDelay(ticks);
// traite les données et les enregistre dans un fichier // traite les données et les enregistre dans un fichier
try { try {
analyseData(ticks); analyseData(ticks);
@ -76,6 +77,7 @@ public class AccessPoint {
System.out.println("Can't export data"); System.out.println("Can't export data");
} }
} }
} }
private void updateBandwidth(int ticks) { private void updateBandwidth(int ticks) {
@ -95,8 +97,8 @@ public class AccessPoint {
} }
} }
private void schedule() { private void schedule(int ticks) {
scheduler.scheduling(); scheduler.scheduling(ticks);
} }
private void analyseData(int tick) throws IOException { private void analyseData(int tick) throws IOException {
@ -126,6 +128,17 @@ public class AccessPoint {
} }
} }
private void computePacketDelay(int ticks){
for(int i = 0; i < this.users.size(); i++){
User u = this.users.get(i);
if(!u.getPacketsToSend().isEmpty()){
for(Packets p : u.getPacketsToSend()){
}
}
}
}
public ResourceBlock[][] getFrame() { public ResourceBlock[][] getFrame() {
return frame; return frame;
} }

View File

@ -5,12 +5,16 @@ public class Packets {
private int startTimeSending; private int startTimeSending;
private int endTimeSending; private int endTimeSending;
private int durationSending; private int durationSending;
private double bitsNumberRemaining; private int bitsNumberRemaining;
public Packets(int startTimeSending){ public Packets(int startTimeSending){
this.startTimeSending = startTimeSending; this.startTimeSending = startTimeSending;
} }
public double getBitsNumberRemaining() {
return bitsNumberRemaining;
}
public int getStartTimeSending() { public int getStartTimeSending() {
return startTimeSending; return startTimeSending;
} }
@ -24,17 +28,20 @@ public class Packets {
} }
public void setEndTimeSending(int endTimeSending) { public void setEndTimeSending(int endTimeSending) {
this.endTimeSending = endTimeSending; this.endTimeSending = endTimeSending+1;
} }
public void setDurationSending(){ public void setDurationSending(int ticks){
int durationSending = endTimeSending - startTimeSending; this.durationSending = ticks - startTimeSending;
this.durationSending = durationSending;
} }
public int getDurationSending() { public int getDurationSending() {
return durationSending; return durationSending;
} }
public void decreaseBitsNumberRemaining(int d) {
this.bitsNumberRemaining -= d;
}
} }

View File

@ -57,15 +57,6 @@ public class User {
return mbis; return mbis;
} }
/**
* Calcul délais de transmission des paquets
*/
public void computeTimeSending() {
for(Packets p : packetsToSend){
p.setDurationSending();
}
}
public double getDistance() { public double getDistance() {
return distance; return distance;
} }

View File

@ -1,6 +1,7 @@
package fr.ntr.scheduler; package fr.ntr.scheduler;
import java.util.List; import java.util.List;
import fr.ntr.Packets;
import fr.ntr.ResourceBlock; import fr.ntr.ResourceBlock;
import fr.ntr.User; import fr.ntr.User;
@ -17,16 +18,25 @@ public class MaxSNR extends Scheduler {
} }
@Override @Override
public void scheduling() { public void scheduling(int ticks) {
User userMax = null; User userMax = null;
for(int ts = 0; ts < 2; ts++){ for(int ts = 0; ts < 2; ts++){
for(int sp = 0; sp < 100; sp++){ for(int sp = 0; sp < 100; sp++){
userMax = selectionUtilisateur(sp, ts, users); userMax = selectionUtilisateur(sp, ts, users);
if (userMax.getPacketsToSend().size() != 0) { if (userMax.getPacketsToSend().size() != 0) {
userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0)); Packets p = userMax.getPacketsToSend().get(0);
userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0)); userMax.getPacketsSent().add(p);
if(p.getDurationSending() != 0){
if(p.getBitsNumberRemaining() > 0){
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
} else {
p.setDurationSending(ticks);
}
}
userMax.getPacketsToSend().remove(p);
frame[ts][sp].setUser(userMax); frame[ts][sp].setUser(userMax);
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]); frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
} }
} }
} }

View File

@ -7,7 +7,7 @@ public abstract class Scheduler {
* Rempli la trame avec les utilisateurs * Rempli la trame avec les utilisateurs
* Return * Return
*/ */
public abstract void scheduling(); public abstract void scheduling(int ticks);
protected void TraitementDonnees() { protected void TraitementDonnees() {
} }