Merge branch 'master' into ajout_cellule
This commit is contained in:
commit
06f3e82c4a
@ -90,7 +90,7 @@ public class Main {
|
|||||||
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
||||||
List<User> users = new ArrayList<>();
|
List<User> users = new ArrayList<>();
|
||||||
// 2 groupes d'utilisateurs, proches et éloignés
|
// 2 groupes d'utilisateurs, proches et éloignés
|
||||||
double[] distance = { 200d, 1000d };
|
double[] distance = { 200d, 400d };
|
||||||
for (double v : distance) {
|
for (double v : distance) {
|
||||||
for (int j = 0; j < nbUsers; j++) {
|
for (int j = 0; j < nbUsers; j++) {
|
||||||
User user = new User(v, timeSlotNb, subCarrierNb);
|
User user = new User(v, timeSlotNb, subCarrierNb);
|
||||||
|
@ -13,6 +13,8 @@ public class User {
|
|||||||
private int leftForNextSource;
|
private int leftForNextSource;
|
||||||
private int timeInterval = 1;
|
private int timeInterval = 1;
|
||||||
|
|
||||||
|
public int totalbits = 0;
|
||||||
|
|
||||||
private int mbis;
|
private int mbis;
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
@ -45,13 +47,17 @@ public class User {
|
|||||||
public void createPackets(int m, int ticks) {
|
public void createPackets(int m, int ticks) {
|
||||||
timeInterval--;
|
timeInterval--;
|
||||||
if(timeInterval == 0) {
|
if(timeInterval == 0) {
|
||||||
timeInterval = 50 + random.nextInt(51);
|
timeInterval = 50 + random.nextInt(52);
|
||||||
// On tire un nombre entre 0 et 2 * m
|
// On tire un nombre entre 0 et 2 * m
|
||||||
mbis = 1 + random.nextInt(2 * m + 1) ;
|
mbis = random.nextInt(2 * m + 1) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
// On calcule le nombre de paquets qu'on peut transmettre
|
// On calcule le nombre de paquets qu'on peut transmettre
|
||||||
int bitsToSend = random.nextInt(2 * mbis + 1) + this.leftForNextSource;
|
int bitsToSend = random.nextInt(2 * mbis + 1);
|
||||||
|
this.totalbits += bitsToSend;
|
||||||
|
// totalbits/duree (200)
|
||||||
|
// somme total bits/duree (linéaire)
|
||||||
|
bitsToSend+=this.leftForNextSource;
|
||||||
int nbPacketsToSend = bitsToSend / Packets.PACKET_SIZE;
|
int nbPacketsToSend = bitsToSend / Packets.PACKET_SIZE;
|
||||||
// On conserve le nombre de bits restants pour la prochaine génération
|
// On conserve le nombre de bits restants pour la prochaine génération
|
||||||
this.leftForNextSource = bitsToSend % Packets.PACKET_SIZE;
|
this.leftForNextSource = bitsToSend % Packets.PACKET_SIZE;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.ntr.scheduler;
|
package fr.ntr.scheduler;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import fr.ntr.Cell;
|
import fr.ntr.Cell;
|
||||||
@ -26,6 +26,7 @@ public class RoundRobin extends Scheduler {
|
|||||||
@Override
|
@Override
|
||||||
public void scheduling(int ticks) {
|
public void scheduling(int ticks) {
|
||||||
List<User> userCopy = users.stream().filter(u -> !u.getPacketsToSend().isEmpty()).collect(Collectors.toList());
|
List<User> userCopy = users.stream().filter(u -> !u.getPacketsToSend().isEmpty()).collect(Collectors.toList());
|
||||||
|
Collections.shuffle(userCopy);
|
||||||
|
|
||||||
//Pour chaque time slot et sous porteuses
|
//Pour chaque time slot et sous porteuses
|
||||||
loop: for (int ts = 0; ts < Cell.getTimeSlotNb(); ts++) {
|
loop: for (int ts = 0; ts < Cell.getTimeSlotNb(); ts++) {
|
||||||
|
@ -15,9 +15,18 @@ 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(0);
|
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);
|
||||||
@ -31,4 +40,4 @@ public abstract class Scheduler {
|
|||||||
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user