aboutsummaryrefslogtreecommitdiff
path: root/structure/Grid.java
diff options
context:
space:
mode:
Diffstat (limited to 'structure/Grid.java')
-rw-r--r--structure/Grid.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/structure/Grid.java b/structure/Grid.java
index d075196..e929f5d 100644
--- a/structure/Grid.java
+++ b/structure/Grid.java
@@ -6,14 +6,15 @@ import java.util.Map.Entry;
public class Grid {
public enum Protocol {
- AODV, DSDV
+ AODV, DSDV, CUSTOM
}
private ArrayList<Router> grid=new ArrayList<>();
private ArrayList<ArrayList<Integer>> links=new ArrayList<>();
private int bestLinkByProtocol;
-
+ private Protocol protocolChoose;
+ private int counterCUSTOM=5;
private Random rand = new Random();
private final int maxWeight=100;
@@ -31,13 +32,14 @@ public class Grid {
this.buildRandomLink();
this.buildLinks();
-
+ this.protocolChoose=protocol;
+
switch(protocol){
case AODV:
this.bestLinkByProtocol=this.getBestLinkIndex();
break;
- case DSDV:
-
+ case DSDV:
+ case CUSTOM:
HashMap<Integer,Integer> currentBestLink=new HashMap<>();
for(int i=0;i<10000;i++){
int current=this.getBestLinkIndex();
@@ -69,7 +71,10 @@ public class Grid {
this.bestLinkByProtocol=maxId;
System.out.println("Retenu :"+maxId);
break;
+
+
}
+
}
@@ -269,6 +274,14 @@ public class Grid {
* @return the bestLinkByProtocol
*/
public int getBestLinkByProtocol() {
+ if(this.protocolChoose==Protocol.CUSTOM){
+ this.counterCUSTOM--;
+ if(this.counterCUSTOM==0){
+ this.bestLinkByProtocol=this.getBestLinkIndex();
+ this.counterCUSTOM=5;
+ }
+
+ }
return bestLinkByProtocol;
}