Add static routes to NFDs in parallel
This allows setting up static routing in large
topologies in a reasonable time. Some timer values
are also reduced, seems to work fine to me
Change-Id: I112cfd216615a100db6dc18182db40ba614d83e6
diff --git a/minindn/helpers/ndn_routing_helper.py b/minindn/helpers/ndn_routing_helper.py
index 6eeb40d..c2d1013 100644
--- a/minindn/helpers/ndn_routing_helper.py
+++ b/minindn/helpers/ndn_routing_helper.py
@@ -34,6 +34,7 @@
import operator
from collections import defaultdict
from tqdm import tqdm
+from joblib import Parallel, delayed
from mininet.log import info, debug, error, warn
from minindn.helpers.nfdc import Nfdc as nfdc
@@ -295,13 +296,22 @@
def globalRoutingHelperHandler(self):
info('Creating faces and adding routes to FIB\n')
- for host in tqdm(self.net.hosts):
- neighborIPs = self.getNeighbor(host)
- self.createFaces(host, neighborIPs)
- self.routeAdd(host, neighborIPs)
+
+ res = Parallel(n_jobs=-1, require='sharedmem',
+ prefer="threads")(delayed(self.addNodeRoutes)(host) for host in tqdm(self.net.hosts))
info('Processed all the routes to NFD\n')
+ def addNodeRoutes(self, node):
+ """
+ Create faces to neighbors and add all routes for one node
+
+ :param Node node: Node from net object
+ """
+ neighborIPs = self.getNeighbor(node)
+ self.createFaces(node, neighborIPs)
+ self.routeAdd(node, neighborIPs)
+
def addOrigin(self, nodes, prefix):
"""
Add prefix/s as origin on node/s