This commit is contained in:
Tr1xt4n 2023-03-28 08:32:26 +02:00
parent a7f93da59a
commit 2c5d1d2e94

View File

@ -58,7 +58,7 @@ public class AccessPoint {
Files.deleteIfExists(Paths.get("export", this.users.size() + ".csv")); Files.deleteIfExists(Paths.get("export", this.users.size() + ".csv"));
new File("export").mkdir(); new File("export").mkdir();
this.outputDataFile = new FileOutputStream("export" + File.separator + this.users.size() + ".csv", true); 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) { } catch(IOException e) {
System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage()); System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage());
System.exit(1); System.exit(1);
@ -102,11 +102,20 @@ public class AccessPoint {
} }
private void analyseData(int tick) throws IOException { private void analyseData(int tick) throws IOException {
double delayAverrage = 0.0;
double total = 0.0;
for(User u: this.users){
List<Packets> 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 i = 0; i < frame.length; i++) {
for(int j = 0; j < frame[i].length; j++) { for(int j = 0; j < frame[i].length; j++) {
ResourceBlock ur = frame[i][j]; ResourceBlock ur = frame[i][j];
if(ur.getUser() != null) { 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{ try{
outputDataFile.write(data.getBytes()); outputDataFile.write(data.getBytes());
}catch(IOException e){ }catch(IOException e){