average
This commit is contained in:
parent
671ccd2b18
commit
71464a15d7
@ -57,6 +57,11 @@ public class AccessPoint {
|
||||
}
|
||||
}
|
||||
|
||||
int totalBits = 0;
|
||||
for(User u: this.users){
|
||||
totalBits += u.totalbits;
|
||||
}
|
||||
System.out.println("total bits / nb users = "+ (((float)totalBits)/this.users.size()/10_000));
|
||||
}
|
||||
|
||||
private void updateBandwidth(int ticks) {
|
||||
|
@ -65,13 +65,14 @@ public class Main {
|
||||
private static List<User> generateUsers(int nbUsers, int timeSlotNb, int subCarrierNb) {
|
||||
List<User> users = new ArrayList<>();
|
||||
// 2 groupes d'utilisateurs, proches et éloignés
|
||||
double[] distance = { 200d, 1000d };
|
||||
double[] distance = { 200d, 400d };
|
||||
for (double v : distance) {
|
||||
for (int j = 0; j < nbUsers; j++) {
|
||||
User user = new User(v, timeSlotNb, subCarrierNb);
|
||||
users.add(user);
|
||||
}
|
||||
}
|
||||
|
||||
return users;
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ public class User {
|
||||
private int leftForNextSource;
|
||||
private int timeInterval = 1;
|
||||
|
||||
public int totalbits = 0;
|
||||
|
||||
private int mbis;
|
||||
|
||||
private final Random random = new Random();
|
||||
@ -45,13 +47,17 @@ public class User {
|
||||
public void createPackets(int m, int ticks) {
|
||||
timeInterval--;
|
||||
if(timeInterval == 0) {
|
||||
timeInterval = random.nextInt(50, 101);
|
||||
timeInterval = random.nextInt(2, 102);
|
||||
// On tire un nombre entre 0 et 2 * m
|
||||
mbis = random.nextInt(1, 2 * m + 1) ;
|
||||
|
||||
}
|
||||
// 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;
|
||||
// On conserve le nombre de bits restants pour la prochaine génération
|
||||
this.leftForNextSource = bitsToSend % Packets.PACKET_SIZE;
|
||||
|
@ -1,4 +1,6 @@
|
||||
package fr.ntr.scheduler;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
@ -26,6 +28,7 @@ public class RoundRobin extends Scheduler {
|
||||
@Override
|
||||
public void scheduling(int ticks) {
|
||||
List<User> userCopy = users.stream().filter(u -> !u.getPacketsToSend().isEmpty()).collect(Collectors.toList());
|
||||
Collections.shuffle(userCopy);
|
||||
|
||||
//Pour chaque time slot et sous porteuses
|
||||
loop: for (int ts = 0; ts < AccessPoint.getTimeSlotNb(); ts++) {
|
||||
|
Reference in New Issue
Block a user