fix allocation

This commit is contained in:
Tr1xt4n 2023-03-31 11:42:01 +02:00
parent 077ef9aca8
commit b3201ff7a5
2 changed files with 11 additions and 2 deletions

View File

@ -49,7 +49,7 @@ public class User {
if(timeInterval == 0) { if(timeInterval == 0) {
timeInterval = random.nextInt(2, 102); timeInterval = random.nextInt(2, 102);
// On tire un nombre entre 0 et 2 * m // On tire un nombre entre 0 et 2 * m
mbis = random.nextInt(1, 2 * m + 1) ; mbis = random.nextInt(0, 2 * m + 1) ;
} }
// On calcule le nombre de paquets qu'on peut transmettre // On calcule le nombre de paquets qu'on peut transmettre

View File

@ -16,8 +16,17 @@ public abstract class Scheduler {
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp, int ticks) { protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp, int ticks) {
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) { if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1); Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);
if(p.getBitsNumberRemaining() > 0){ if(p.getBitsNumberRemaining() >= 0){
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]); p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
if(p.getBitsNumberRemaining() <= 0) {
if(ticks == 0){
p.setDurationSending(1);
}else {
p.setDurationSending(ticks);
}
userMax.getPacketsSent().add(p);
userMax.getPacketsToSend().remove(p);
}
} else { } else {
if(ticks == 0){ if(ticks == 0){
p.setDurationSending(1); p.setDurationSending(1);