Wip maj roundRobin
This commit is contained in:
parent
b9eb223e64
commit
7a83bb134c
@ -1,5 +1,9 @@
|
|||||||
package fr.ntr.scheduler;
|
package fr.ntr.scheduler;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import fr.ntr.AccessPoint;
|
||||||
|
import fr.ntr.ResourceBlock;
|
||||||
import fr.ntr.User;
|
import fr.ntr.User;
|
||||||
|
|
||||||
|
|
||||||
@ -25,18 +29,22 @@ public class RoundRobin extends Scheduler {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void scheduling() {
|
public void scheduling() {
|
||||||
|
//selection aleatoire du premier utilisateur
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
index = random.nextInt(users.size()-1);
|
index = random.nextInt(users.size()-1);
|
||||||
|
|
||||||
|
//Pour chaque time slot et sous porteuses
|
||||||
for (int Ts = 0; Ts < AccessPoint.getTimeSlotNb(); Ts++) {
|
for (int Ts = 0; Ts < AccessPoint.getTimeSlotNb(); Ts++) {
|
||||||
for(int Sp = 0; Sp < AccessPoint.getSubCarrierNb(); Sp++) {
|
for(int Sp = 0; Sp < AccessPoint.getSubCarrierNb(); Sp++) {
|
||||||
|
|
||||||
if (users.get(index).getPacketsToSend() == null) {
|
if (users.get(index).getPacketsToSend() == null) {
|
||||||
users.remove(index);
|
users.remove(index);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
//sub the packet send need Set packet
|
||||||
|
users.get(index).getPacketsToSend();
|
||||||
}
|
}
|
||||||
frame[Ts][Sp].setUser(UserSelection(Ts, Sp, users));
|
frame[Ts][Sp].setUser(UserSelection(Ts, Sp, users));
|
||||||
|
|
||||||
//AccessPoint.setFrame[Ts][Sp]();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,11 +54,15 @@ public class RoundRobin extends Scheduler {
|
|||||||
* Return the user in function of TS and SP selected
|
* Return the user in function of TS and SP selected
|
||||||
*/
|
*/
|
||||||
private User UserSelection(int Ts, int Sp, List<User> Users) {
|
private User UserSelection(int Ts, int Sp, List<User> Users) {
|
||||||
for (int i = 0; i < Ts; i++) {
|
|
||||||
for (int j = 0; j < Sp; j++) {
|
|
||||||
index++;
|
//for (int i = 0; i < Ts; i++) {
|
||||||
}
|
// for (int j = 0; j < Sp; j++) {
|
||||||
}
|
// index++;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
index = Ts * Sp;
|
||||||
return Users.get(index%(Users.size() - 1));
|
return Users.get(index%(Users.size() - 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user