From 2c5d1d2e94e83d6bd53a704a6c4cad01bed2df5b Mon Sep 17 00:00:00 2001 From: Tr1xt4n Date: Tue, 28 Mar 2023 08:32:26 +0200 Subject: [PATCH] +delay --- src/main/java/fr/ntr/AccessPoint.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 5e92b91..e658633 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -58,7 +58,7 @@ public class AccessPoint { Files.deleteIfExists(Paths.get("export", this.users.size() + ".csv")); new File("export").mkdir(); this.outputDataFile = new FileOutputStream("export" + File.separator + this.users.size() + ".csv", true); - outputDataFile.write("tick;x;y;user;bandwidth;\n".getBytes()); + outputDataFile.write("tick;x;y;user;bandwidth;delay\n".getBytes()); } catch(IOException e) { System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage()); System.exit(1); @@ -102,11 +102,20 @@ public class AccessPoint { } private void analyseData(int tick) throws IOException { + double delayAverrage = 0.0; + double total = 0.0; + for(User u: this.users){ + List packets = u.getPacketsSent(); + for (Packets p: packets){ + total += p.getDurationSending(); + } + } + delayAverrage = total/this.users.size(); for(int i = 0; i < frame.length; i++) { for(int j = 0; j < frame[i].length; j++) { ResourceBlock ur = frame[i][j]; if(ur.getUser() != null) { - String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";\n"); + String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverrage +";\n"); try{ outputDataFile.write(data.getBytes()); }catch(IOException e){