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
reset();
updateBandwidth(ticks);
schedule();
schedule(ticks);
computePacketDelay(ticks);
// traite les données et les enregistre dans un fichier
try {
analyseData(ticks);
@ -76,6 +77,7 @@ public class AccessPoint {
System.out.println("Can't export data");
}
}
}
private void updateBandwidth(int ticks) {
@ -95,8 +97,8 @@ public class AccessPoint {
}
}
private void schedule() {
scheduler.scheduling();
private void schedule(int ticks) {
scheduler.scheduling(ticks);
}
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() {
return frame;
}

View File

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

View File

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

View File

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

View File

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