Test
This commit is contained in:
parent
fa261c3042
commit
04c6618a68
2 changed files with 25 additions and 19 deletions
|
@ -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();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue