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){