Add interference
This commit is contained in:
parent
de59bc8047
commit
d534f3f61b
@ -30,11 +30,9 @@ public class AccessPoint {
|
|||||||
for (int sp = 0; sp < Cell.getSubCarrierNb(); sp++) {
|
for (int sp = 0; sp < Cell.getSubCarrierNb(); sp++) {
|
||||||
User user1 = cell1.schedule(ticks, ts, sp);
|
User user1 = cell1.schedule(ticks, ts, sp);
|
||||||
User user2 = cell2.schedule(ticks, ts, sp);
|
User user2 = cell2.schedule(ticks, ts, sp);
|
||||||
if(user1 == user2 && user1 != null) {
|
boolean haveInterference = user1 == user2 && user1 != null;
|
||||||
computeInterference(user1, ts, sp);
|
cell1.consumeResource(ticks, ts, sp, haveInterference);
|
||||||
}
|
cell2.consumeResource(ticks, ts, sp, haveInterference);
|
||||||
cell1.consumeResource(ticks, ts, sp);
|
|
||||||
cell2.consumeResource(ticks, ts, sp);
|
|
||||||
|
|
||||||
cell1.postScheduling(user1);
|
cell1.postScheduling(user1);
|
||||||
cell2.postScheduling(user2);
|
cell2.postScheduling(user2);
|
||||||
@ -44,15 +42,11 @@ public class AccessPoint {
|
|||||||
// traite les données et les enregistre dans un fichier
|
// traite les données et les enregistre dans un fichier
|
||||||
try {
|
try {
|
||||||
cell1.analyseData(ticks);
|
cell1.analyseData(ticks);
|
||||||
//cell2.analyseData(ticks);
|
cell2.analyseData(ticks);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Can't export data");
|
System.out.println("Can't export data");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeInterference(User user, int ts, int sp) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -73,11 +73,12 @@ public class Cell {
|
|||||||
return scheduler.scheduling(tick, ts, sp);
|
return scheduler.scheduling(tick, ts, sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void consumeResource(int tick, int ts, int sp) {
|
public void consumeResource(int tick, int ts, int sp, boolean haveInterference) {
|
||||||
ResourceBlock rb = frame[ts][sp];
|
ResourceBlock rb = frame[ts][sp];
|
||||||
User user = rb.getUser();
|
User user = rb.getUser();
|
||||||
if(user != null && !user.getPacketsToSend().isEmpty()) {
|
if(user != null && !user.getPacketsToSend().isEmpty()) {
|
||||||
Packets p = user.getPacketsToSend().get(0);
|
Packets p = user.getPacketsToSend().get(0);
|
||||||
|
rb.setBandwidth(updateBandwidth(haveInterference, rb));
|
||||||
p.decreaseBitsNumberRemaining((int) rb.getBandwidth());
|
p.decreaseBitsNumberRemaining((int) rb.getBandwidth());
|
||||||
if(p.getBitsNumberRemaining() <= 0) {
|
if(p.getBitsNumberRemaining() <= 0) {
|
||||||
if(tick == 0){
|
if(tick == 0){
|
||||||
@ -91,6 +92,19 @@ public class Cell {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double updateBandwidth(boolean haveInterference, ResourceBlock rb) {
|
||||||
|
if(haveInterference) {
|
||||||
|
if(rb.getUser().getDistance() < 200d) {
|
||||||
|
// User proche
|
||||||
|
return rb.getBandwidth() / 2;
|
||||||
|
}
|
||||||
|
// User loin
|
||||||
|
return rb.getBandwidth() / 4;
|
||||||
|
} else {
|
||||||
|
return rb.getBandwidth();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void analyseData(int tick) throws IOException {
|
public void analyseData(int tick) throws IOException {
|
||||||
double delayAverage = 0.0;
|
double delayAverage = 0.0;
|
||||||
int nbPacketsSent = 0;
|
int nbPacketsSent = 0;
|
||||||
|
Reference in New Issue
Block a user