diff --git a/main/Main.java b/main/Main.java index c9bdd24..3023069 100644 --- a/main/Main.java +++ b/main/Main.java @@ -20,27 +20,36 @@ public class Main { public static void main(String[] args) { - Grid g=new Grid(Grid.Protocol.DSDV); + //Grid g=new Grid(Grid.Protocol.AODV); // Build Graph for graphstream - MyGraph gr=new MyGraph("Routage Oportuniste", g); - gr.display(); + //MyGraph gr=new MyGraph("Routage Oportuniste", g); + //gr.display(); //gr.update(); - - // Update Graph - while(true){ - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - g.buildEdgeWithRandomWeigth(); - System.out.println("Update !"); - gr.update(); - } + for(int j=0;j<20;j++){ + Grid g=new Grid(Grid.Protocol.AODV); + Grid g2=new Grid(Grid.Protocol.DSDV); + Grid g3=new Grid(Grid.Protocol.CUSTOM); + // Update Graph + for(int i=0;i<100;i++){ + /*try { + Thread.sleep(10000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + g.buildEdgeWithRandomWeigth(); + g2.buildEdgeWithRandomWeigth(); + g3.buildEdgeWithRandomWeigth(); + + //System.out.println("Update !"); + //gr.update(); + } + + System.out.println("AODV :"+g.getDebitMoy() + " DSDV :"+g2.getDebitMoy()+" CUSTOM :"+g3.getDebitMoy()); + } } } diff --git a/resources/Graph.png b/resources/Graph.png new file mode 100644 index 0000000..a4adf57 Binary files /dev/null and b/resources/Graph.png differ diff --git a/structure/Grid.java b/structure/Grid.java index 73c034e..08dd305 100644 --- a/structure/Grid.java +++ b/structure/Grid.java @@ -10,7 +10,7 @@ public class Grid { } private ArrayList routers=new ArrayList<>(); - private ArrayList> links=new ArrayList<>(); + public ArrayList> links=new ArrayList<>(); private int[] pMoy={50,59,92,50,4,8,6,13,7,1,51,6}; @@ -20,7 +20,7 @@ public class Grid { private Random rand = new Random(); private final int maxWeight=100; - + int debitTotal=0,nbmesure=0; @@ -38,18 +38,20 @@ public class Grid { this.buildEdgeWithRandomWeigth(); //Build fixed link - this.buildPath(); + //this.buildPath(); this.protocol=protocol; switch(protocol){ - case AODV: + case DSDV: this.bestLink=this.getBestLinkIndex(); break; - case DSDV: case CUSTOM: + this.bestLink=this.getBestLinkIndex(); + break; + case AODV: HashMap currentBestLink=new HashMap<>(); - for(int i=0;i<1000;i++){ + for(int i=0;i<100;i++){ int current=this.getBestLinkIndex(); if(currentBestLink.containsKey(current)){ currentBestLink.put(current, currentBestLink.get(current)+1); @@ -73,11 +75,11 @@ public class Grid { maxId=entryId; } - System.out.println("Id : "+ entryId + " max "+ entry); + //System.out.println("Id : "+ entryId + " max "+ entry); } this.bestLink=maxId; - System.out.println("Retenu :"+maxId); + // System.out.println("Retenu :"+maxId); break; @@ -89,32 +91,38 @@ public class Grid { public void buildEdgeWithRandomWeigth(){ - + // First line - this.buildLinkWithRandomWeight(routers.get(0), routers.get(1), 1); - this.buildLinkWithRandomWeight(routers.get(1), routers.get(2),1); + this.buildLinkWithRandomWeight(routers.get(0), routers.get(1), 100); + this.buildLinkWithRandomWeight(routers.get(1), routers.get(2),100); // Second line - this.buildLinkWithRandomWeight(routers.get(3), routers.get(4),69); - this.buildLinkWithRandomWeight(routers.get(4), routers.get(5),20); + this.buildLinkWithRandomWeight(routers.get(3), routers.get(4),100); + this.buildLinkWithRandomWeight(routers.get(4), routers.get(5),50); // Third line - this.buildLinkWithRandomWeight(routers.get(6), routers.get(7),23); - this.buildLinkWithRandomWeight(routers.get(7), routers.get(8),54); + this.buildLinkWithRandomWeight(routers.get(6), routers.get(7),100); + this.buildLinkWithRandomWeight(routers.get(7), routers.get(8),60); // First column - this.buildLinkWithRandomWeight(routers.get(0), routers.get(3),14); - this.buildLinkWithRandomWeight(routers.get(3), routers.get(6),11); + this.buildLinkWithRandomWeight(routers.get(0), routers.get(3),80); + this.buildLinkWithRandomWeight(routers.get(3), routers.get(6),100); // Second column - this.buildLinkWithRandomWeight(routers.get(1), routers.get(4),33); - this.buildLinkWithRandomWeight(routers.get(4), routers.get(7),22); + this.buildLinkWithRandomWeight(routers.get(1), routers.get(4),100); + this.buildLinkWithRandomWeight(routers.get(4), routers.get(7),10); // Third column - this.buildLinkWithRandomWeight(routers.get(2), routers.get(5),11); - this.buildLinkWithRandomWeight(routers.get(5), routers.get(8),47); + this.buildLinkWithRandomWeight(routers.get(2), routers.get(5),100); + this.buildLinkWithRandomWeight(routers.get(5), routers.get(8),100); + + this.buildPath(); + + //System.out.println(this.links.get(this.getBestLinkByProtocol())); + this.debitTotal+=this.getMaxBottleneck(this.links.get(this.getBestLinkByProtocol())); + this.nbmesure++; } @@ -199,7 +207,7 @@ public class Grid { } - private int getMaxBottleneck(ArrayList link){ + public int getMaxBottleneck(ArrayList link){ int max=this.getWeigthOfLink(link.get(0), link.get(1)); for(int j=1;j