fix allocation
This commit is contained in:
parent
077ef9aca8
commit
b3201ff7a5
@ -49,7 +49,7 @@ public class User {
|
||||
if(timeInterval == 0) {
|
||||
timeInterval = random.nextInt(2, 102);
|
||||
// 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
|
||||
|
@ -16,8 +16,17 @@ public abstract class Scheduler {
|
||||
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp, int ticks) {
|
||||
if (userMax != null && !userMax.getPacketsToSend().isEmpty()) {
|
||||
Packets p = userMax.getPacketsToSend().get(userMax.getPacketsToSend().size()-1);
|
||||
if(p.getBitsNumberRemaining() > 0){
|
||||
if(p.getBitsNumberRemaining() >= 0){
|
||||
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 {
|
||||
if(ticks == 0){
|
||||
p.setDurationSending(1);
|
||||
|
Reference in New Issue
Block a user