Compute average delays
This commit is contained in:
parent
3a438472d0
commit
6442356450
@ -102,20 +102,21 @@ public class AccessPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void analyseData(int tick) throws IOException {
|
private void analyseData(int tick) throws IOException {
|
||||||
double delayAverrage = 0.0;
|
double delayAverage = 0.0;
|
||||||
double total = 0.0;
|
int nbPacketsSent = 0;
|
||||||
for(User u: this.users){
|
for(User u: this.users){
|
||||||
List<Packets> packets = u.getPacketsSent();
|
List<Packets> packets = u.getPacketsSent();
|
||||||
|
nbPacketsSent += packets.size();
|
||||||
for (Packets p: packets){
|
for (Packets p: packets){
|
||||||
total += p.getDurationSending();
|
delayAverage += p.getDurationSending();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delayAverrage = total/this.users.size();
|
delayAverage = delayAverage/nbPacketsSent;
|
||||||
for(int i = 0; i < frame.length; i++) {
|
for(int i = 0; i < frame.length; i++) {
|
||||||
for(int j = 0; j < frame[i].length; j++) {
|
for(int j = 0; j < frame[i].length; j++) {
|
||||||
ResourceBlock ur = frame[i][j];
|
ResourceBlock ur = frame[i][j];
|
||||||
if(ur.getUser() != null) {
|
if(ur.getUser() != null) {
|
||||||
String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverrage +";\n");
|
String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverage +";\n");
|
||||||
try{
|
try{
|
||||||
outputDataFile.write(data.getBytes());
|
outputDataFile.write(data.getBytes());
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
|
@ -22,26 +22,13 @@ public class MaxSNR extends Scheduler {
|
|||||||
User userMax = null;
|
User userMax = null;
|
||||||
for(int ts = 0; ts < 2; ts++){
|
for(int ts = 0; ts < 2; ts++){
|
||||||
for(int sp = 0; sp < 100; sp++){
|
for(int sp = 0; sp < 100; sp++){
|
||||||
userMax = selectionUtilisateur(sp, ts, users);
|
userMax = userSelection(ts, sp, users);
|
||||||
if (userMax.getPacketsToSend().size() != 0) {
|
allocateRessource(userMax, frame, ts, sp, ticks);
|
||||||
Packets p = userMax.getPacketsToSend().get(0);
|
|
||||||
userMax.getPacketsSent().add(p);
|
|
||||||
if(p.getBitsNumberRemaining() > 0){
|
|
||||||
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
|
|
||||||
} else {
|
|
||||||
p.setDurationSending(ticks);
|
|
||||||
}
|
|
||||||
|
|
||||||
userMax.getPacketsToSend().remove(p);
|
|
||||||
frame[ts][sp].setUser(userMax);
|
|
||||||
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private User selectionUtilisateur(int sp, int ts, List<User> Users) {
|
private User userSelection(int ts, int sp, List<User> Users) {
|
||||||
double MaxSnr = 0.0;
|
double MaxSnr = 0.0;
|
||||||
User userMax = null;
|
User userMax = null;
|
||||||
for(User u: Users){
|
for(User u: Users){
|
||||||
|
@ -32,16 +32,15 @@ public class ProportionalFair extends Scheduler {
|
|||||||
avg = avg / (bandwidthTable.length * bandwidthTable[0].length);
|
avg = avg / (bandwidthTable.length * bandwidthTable[0].length);
|
||||||
averageBandwiths.add(avg);
|
averageBandwiths.add(avg);
|
||||||
}
|
}
|
||||||
User selectedUser;
|
|
||||||
for(int ts = 0; ts < 2; ts++){
|
for(int ts = 0; ts < 2; ts++){
|
||||||
for(int sp = 0; sp < 100; sp++){
|
for(int sp = 0; sp < 100; sp++){
|
||||||
selectedUser = selectionUtilisateur(ts, sp, users, averageBandwiths);
|
User selectedUser = userSelection(ts, sp, users, averageBandwiths);
|
||||||
allocateRessource(selectedUser, frame, ts, sp);
|
allocateRessource(selectedUser, frame, ts, sp, ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private User selectionUtilisateur(int ts, int sp, List<User> users, List<Double> averageBandwiths) {
|
private User userSelection(int ts, int sp, List<User> users, List<Double> averageBandwiths) {
|
||||||
double PF = 0.0;
|
double PF = 0.0;
|
||||||
User selectedUser = null;
|
User selectedUser = null;
|
||||||
for(int i = 0; i < users.size(); i++){
|
for(int i = 0; i < users.size(); i++){
|
||||||
|
@ -34,19 +34,10 @@ public class RoundRobin extends Scheduler {
|
|||||||
index = random.nextInt(users.size());
|
index = random.nextInt(users.size());
|
||||||
|
|
||||||
//Pour chaque time slot et sous porteuses
|
//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().isEmpty()) {
|
User userSelected = userSelection(ts, sp, users);
|
||||||
// on enlève le packet transmis de la liste
|
allocateRessource(userSelected, frame, ts, sp, ticks);
|
||||||
// TODO Verify sub the packet send need Set packet
|
|
||||||
users.get(index).getPacketsSent().add(users.get(index).getPacketsToSend().get(0));
|
|
||||||
users.get(index).getPacketsToSend().remove(users.get(index).getPacketsToSend().get(0));
|
|
||||||
//on ajoute l'utilisateur a la frame
|
|
||||||
User user = UserSelection(Ts, Sp, users);
|
|
||||||
frame[Ts][Sp].setUser(user);
|
|
||||||
frame[Ts][Sp].setBandwidth(user.getBandwidthTable()[Ts][Sp]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,10 +46,10 @@ public class RoundRobin extends Scheduler {
|
|||||||
* Entry Time slot (int), Sous porteuse(int), and users ( List<User>)
|
* Entry Time slot (int), Sous porteuse(int), and users ( List<User>)
|
||||||
* 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) {
|
||||||
//compte le nombre de bloc attribue
|
//compte le nombre de bloc attribue
|
||||||
for (int i = 0; i < Ts; i++){
|
for (int i = 0; i < ts; i++){
|
||||||
for (int j = 0; j < Sp; j++) {
|
for (int j = 0; j < sp; j++) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.ntr.scheduler;
|
package fr.ntr.scheduler;
|
||||||
|
|
||||||
|
import fr.ntr.Packets;
|
||||||
import fr.ntr.ResourceBlock;
|
import fr.ntr.ResourceBlock;
|
||||||
import fr.ntr.User;
|
import fr.ntr.User;
|
||||||
|
|
||||||
@ -12,10 +13,20 @@ public abstract class Scheduler {
|
|||||||
*/
|
*/
|
||||||
public abstract void scheduling(int ticks);
|
public abstract void scheduling(int ticks);
|
||||||
|
|
||||||
protected void allocateRessource(User userMax, ResourceBlock[][] frame, int ts, int sp) {
|
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()) {
|
||||||
userMax.getPacketsSent().add(userMax.getPacketsToSend().get(0));
|
Packets p = userMax.getPacketsToSend().get(0);
|
||||||
userMax.getPacketsToSend().remove(userMax.getPacketsToSend().get(0));
|
if(p.getBitsNumberRemaining() > 0){
|
||||||
|
p.decreaseBitsNumberRemaining((int) userMax.getBandwidthTable()[ts][sp]);
|
||||||
|
} else {
|
||||||
|
if(ticks == 0){
|
||||||
|
p.setDurationSending(1);
|
||||||
|
}else {
|
||||||
|
p.setDurationSending(ticks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userMax.getPacketsSent().add(p);
|
||||||
|
userMax.getPacketsToSend().remove(p);
|
||||||
frame[ts][sp].setUser(userMax);
|
frame[ts][sp].setUser(userMax);
|
||||||
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
frame[ts][sp].setBandwidth(userMax.getBandwidthTable()[ts][sp]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user