Fix analyzeData and createPackets

This commit is contained in:
Quentin Legot 2023-03-17 12:08:19 +01:00
parent 8c784dd231
commit 590f0e49b9
4 changed files with 12 additions and 3 deletions

3
.gitignore vendored
View File

@ -5,4 +5,5 @@
build
bin/
.idea
.project
.project
data.csv

View File

@ -106,7 +106,6 @@ public class AccessPoint {
for(int j = 0; j < frame[i].length; j++) {
ResourceBlock ur = frame[i][j];
String data = (i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";\n");
System.out.println("data: " + data);
file.write(data.getBytes());
}
}
@ -119,6 +118,11 @@ public class AccessPoint {
private void reset() {
// TODO insert new UR
for(int i = 0; i < timeSlotNb; i++) {
for(int j = 0; j < subCarrierNb; j++) {
frame[i][j] = new ResourceBlock(0);
}
}
}
public int getFrameSize() {

View File

@ -5,7 +5,11 @@ public class ResourceBlock {
private double bandwidth;
public ResourceBlock (User user, double bandwidth) {
this(bandwidth);
this.user = user;
}
public ResourceBlock(double bandwidth) {
this.bandwidth = bandwidth;
}

View File

@ -44,7 +44,7 @@ public class User {
public int createPackets(int m, int ticks) {
Random random = new Random();
// On tire un nombre entre 0 et 2 * m
int mbis = random.nextInt(2 * (m + this.leftForNextSource));
int mbis = m == 0 ? 0 : random.nextInt(2 * (m + this.leftForNextSource));
// On calcule le nombre de paquets qu'on peut transmettre
int nbPacketsToSend = mbis / Packets.packetSize;
// On conserve le nombre de bits restants pour la prochaine génération