Calcul délai paquet
This commit is contained in:
parent
e7b9f75035
commit
c06ada9679
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user