aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/Main.java39
-rw-r--r--resources/Graph.pngbin0 -> 31584 bytes
-rw-r--r--structure/Grid.java58
-rw-r--r--structure/MyGraph.java3
4 files changed, 61 insertions, 39 deletions
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();
+ 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();
}
- g.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
--- /dev/null
+++ b/resources/Graph.png
Binary files 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<Router> routers=new ArrayList<>();
- private ArrayList<ArrayList<Integer>> links=new ArrayList<>();
+ public ArrayList<ArrayList<Integer>> 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<Integer,Integer> 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<Integer> link){
+ public int getMaxBottleneck(ArrayList<Integer> link){
int max=this.getWeigthOfLink(link.get(0), link.get(1));
for(int j=1;j<link.size()-1;j++){
int currentMax=this.getWeigthOfLink(link.get(j), link.get(j+1));
@@ -286,11 +294,12 @@ public class Grid {
* @return the bestLinkByProtocol
*/
public int getBestLinkByProtocol() {
+
if(this.protocol==Protocol.CUSTOM){
this.counterCUSTOM--;
if(this.counterCUSTOM==0){
this.bestLink=this.getBestLinkIndex();
- this.counterCUSTOM=5;
+ this.counterCUSTOM=2;
}
}
@@ -299,6 +308,9 @@ public class Grid {
+ public int getDebitMoy(){
+ return this.debitTotal/this.nbmesure;
+ }
diff --git a/structure/MyGraph.java b/structure/MyGraph.java
index 1c2dc0f..be9e504 100644
--- a/structure/MyGraph.java
+++ b/structure/MyGraph.java
@@ -147,13 +147,14 @@ public class MyGraph extends SingleGraph{
}
+
if(this.grid.getBestLinkByProtocol()==this.grid.getBestLinkIndex()){
this.success++;
}
else{
this.miss++;
}
- System.out.println("Success = " + this.success + " Miss = " + this.miss + " try number :"+(this.success+this.miss)) ;
+ //System.out.println("Success = " + this.success + " Miss = " + this.miss + " try number :"+(this.success+this.miss)) ;
//Build bestLink
this.showBestLink();