From ebba05aa0ac3a5797410e66dbc8c21d189c04a76 Mon Sep 17 00:00:00 2001 From: Loris Date: Tue, 28 Mar 2023 08:59:16 +0200 Subject: [PATCH] added interference simulation in startSimulation() --- src/main/java/fr/ntr/AccessPoint.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 71a6a59..f77f4f5 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -47,6 +47,32 @@ public class AccessPoint { cell2.updateBandwidth(ticks); cell1.schedule(); cell2.schedule(); + + //simulation des interférences + ResourceBlock[][] frameCell1 = cell1.getFrame(); + ResourceBlock[][] frameCell2 = cell2.getFrame(); + + for (int k = 0; k > frameCell1.length; k++ ) { + for (int l = 0; l < frameCell1[k].length; l++) { + //interférences si les deux cellules parlent au même UE sur le même time slot + User user1 = frameCell1[k][l].getUser(); + User user2 = frameCell2[k][l].getUser(); + if (user1 == user2) { + double bandwidth1 = frameCell1[k][l].getBandwidth(); + double bandwidth2 = frameCell2[k][l].getBandwidth(); + //2 cas: utilisateur proche ou loin + if (user1.getDistance() > 200d) { + frameCell1[k][l].setBandwidth(bandwidth1 / 2); + frameCell2[k][l].setBandwidth(bandwidth2 / 2); + } + else { + frameCell1[k][l].setBandwidth(bandwidth1 / 4); + frameCell2[k][l].setBandwidth(bandwidth2 / 4); + } + } + } + } + // traite les données et les enregistre dans un fichier /* try {