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
diff --git a/minindn/helpers/nfdc.py b/minindn/helpers/nfdc.py
index 9e1e184..50c005b 100644
--- a/minindn/helpers/nfdc.py
+++ b/minindn/helpers/nfdc.py
@@ -24,7 +24,9 @@
from mininet.log import debug
from minindn.minindn import Minindn
-SLEEP_TIME = 0.2
+# If needed (e.g. to speed up the process), use a smaller (or larger value)
+# based on your machines resource (CPU, memory)
+SLEEP_TIME = 0.1
class Nfdc(object):
STRATEGY_ASF = 'asf'