aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <16000511@e105m10.istic.univ-rennes1.fr>2016-03-29 11:37:18 +0200
committerLoic Guegan <16000511@e105m10.istic.univ-rennes1.fr>2016-03-29 11:37:18 +0200
commit04c6618a68d48f8c095bcf692110de3085e98040 (patch)
tree3782eec8e0fa20166f6826599461142f3587d9c3
parentfa261c3042b3fce1cc88cea3b67381bae9f7c747 (diff)
Test
-rw-r--r--main/Main.java7
-rw-r--r--structure/Grid.java37
2 files changed, 25 insertions, 19 deletions
diff --git a/main/Main.java b/main/Main.java
index b843336..0fea318 100644
--- a/main/Main.java
+++ b/main/Main.java
@@ -20,13 +20,14 @@ 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();
-
+ gr.update();
+ /*
// Update Graph
while(true){
@@ -39,7 +40,7 @@ public class Main {
g.buildEdgeWithRandomWeigth();
System.out.println("Update !");
gr.update();
- }
+ }*/
}
}
diff --git a/structure/Grid.java b/structure/Grid.java
index e5db1ef..00c3b52 100644
--- a/structure/Grid.java
+++ b/structure/Grid.java
@@ -12,6 +12,7 @@ public class Grid {
private ArrayList<Router> routers=new ArrayList<>();
private ArrayList<ArrayList<Integer>> links=new ArrayList<>();
+ private int[] pMoy={50,59,92,50,4,8,6,13,7,1,51,6};
private int bestLink;
private Protocol protocol;
@@ -33,10 +34,9 @@ public class Grid {
this.routers.add(new Router());
}
-
+
this.buildEdgeWithRandomWeigth();
- this.buildPath();
this.protocol=protocol;
@@ -87,29 +87,34 @@ public class Grid {
public void buildEdgeWithRandomWeigth(){
+ //Build fixed link
+ this.buildPath();
+
+
+
// First line
- this.buildLinkWithRandomWeight(routers.get(0), routers.get(1));
- this.buildLinkWithRandomWeight(routers.get(1), routers.get(2));
+ this.buildLinkWithRandomWeight(routers.get(0), routers.get(1), 1);
+ this.buildLinkWithRandomWeight(routers.get(1), routers.get(2),1);
// Second line
- this.buildLinkWithRandomWeight(routers.get(3), routers.get(4));
- this.buildLinkWithRandomWeight(routers.get(4), routers.get(5));
+ this.buildLinkWithRandomWeight(routers.get(3), routers.get(4),69);
+ this.buildLinkWithRandomWeight(routers.get(4), routers.get(5),20);
// Third line
- this.buildLinkWithRandomWeight(routers.get(6), routers.get(7));
- this.buildLinkWithRandomWeight(routers.get(7), routers.get(8));
+ this.buildLinkWithRandomWeight(routers.get(6), routers.get(7),23);
+ this.buildLinkWithRandomWeight(routers.get(7), routers.get(8),54);
// First column
- this.buildLinkWithRandomWeight(routers.get(0), routers.get(3));
- this.buildLinkWithRandomWeight(routers.get(3), routers.get(6));
+ this.buildLinkWithRandomWeight(routers.get(0), routers.get(3),14);
+ this.buildLinkWithRandomWeight(routers.get(3), routers.get(6),11);
// Second column
- this.buildLinkWithRandomWeight(routers.get(1), routers.get(4));
- this.buildLinkWithRandomWeight(routers.get(4), routers.get(7));
+ this.buildLinkWithRandomWeight(routers.get(1), routers.get(4),33);
+ this.buildLinkWithRandomWeight(routers.get(4), routers.get(7),22);
// Third column
- this.buildLinkWithRandomWeight(routers.get(2), routers.get(5));
- this.buildLinkWithRandomWeight(routers.get(5), routers.get(8));
+ this.buildLinkWithRandomWeight(routers.get(2), routers.get(5),11);
+ this.buildLinkWithRandomWeight(routers.get(5), routers.get(8),47);
}
@@ -172,8 +177,8 @@ public class Grid {
}
- private void buildLinkWithRandomWeight(Router router1, Router router2){
- router1.buildLink(router2, rand.nextInt(this.maxWeight));
+ private void buildLinkWithRandomWeight(Router router1, Router router2, int pMoy){
+ router1.buildLink(router2, rand.nextInt(pMoy));
}