performance improvements
Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5a
diff --git a/minindn/helpers/ndn_routing_helper.py b/minindn/helpers/ndn_routing_helper.py
index c2d1013..93b196f 100644
--- a/minindn/helpers/ndn_routing_helper.py
+++ b/minindn/helpers/ndn_routing_helper.py
@@ -33,7 +33,6 @@
import json
import operator
from collections import defaultdict
-from tqdm import tqdm
from joblib import Parallel, delayed
from mininet.log import info, debug, error, warn
@@ -298,7 +297,7 @@
info('Creating faces and adding routes to FIB\n')
res = Parallel(n_jobs=-1, require='sharedmem',
- prefer="threads")(delayed(self.addNodeRoutes)(host) for host in tqdm(self.net.hosts))
+ prefer="threads", verbose=1)(delayed(self.addNodeRoutes)(host) for host in self.net.hosts)
info('Processed all the routes to NFD\n')
@@ -309,8 +308,8 @@
:param Node node: Node from net object
"""
neighborIPs = self.getNeighbor(node)
- self.createFaces(node, neighborIPs)
- self.routeAdd(node, neighborIPs)
+ neighborFaces = self.createFaces(node, neighborIPs)
+ self.routeAdd(node, neighborFaces)
def addOrigin(self, nodes, prefix):
"""
@@ -348,10 +347,15 @@
self.calculateNPossibleRoutes(nFaces=1)
def createFaces(self, node, neighborIPs):
- for ip in neighborIPs.values():
- nfdc.createFace(node, ip, self.faceType)
+ neighborFaces = {}
+ for k, ip in neighborIPs.items():
+ faceID = nfdc.createFace(node, ip, self.faceType)
+ if not isinstance(faceID, str): raise ValueError(faceID)
+ neighborFaces[k] = faceID
+ return neighborFaces
- def routeAdd(self, node, neighborIPs):
+
+ def routeAdd(self, node, neighborFaces):
"""
Add route from a node to its neighbors for each prefix/s advertised by destination node
@@ -367,8 +371,7 @@
prefixes = [defaultPrefix] + self.namePrefixes[destination]
for prefix in prefixes:
# Register routes to all the available destination name prefix/s
- faceID = nfdc.createFace(node, neighborIPs[nextHop])
- nfdc.registerRoute(node, prefix, faceID, cost=cost)
+ nfdc.registerRoute(node, prefix, neighborFaces[nextHop], cost=cost)
@staticmethod
def getNeighbor(node):
# Nodes to IP mapping
diff --git a/minindn/helpers/nfdc.py b/minindn/helpers/nfdc.py
index 50c005b..9468d8b 100644
--- a/minindn/helpers/nfdc.py
+++ b/minindn/helpers/nfdc.py
@@ -21,12 +21,12 @@
# along with Mini-NDN, e.g., in COPYING.md file.
# If not, see <http://www.gnu.org/licenses/>.
-from mininet.log import debug
+from mininet.log import debug, warn
from minindn.minindn import Minindn
# 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
+SLEEP_TIME = 0.0015
class Nfdc(object):
STRATEGY_ASF = 'asf'
@@ -89,6 +89,7 @@
if "face-created" in output or (allowExisting and "face-exists" in output):
faceID = output.split(" ")[1][3:]
return faceID
+ warn("["+ node.name + "] Face register failed: " + output)
return -1
@staticmethod
@@ -102,7 +103,9 @@
@staticmethod
def setStrategy(node, namePrefix, strategy):
cmd = 'nfdc strategy set {} ndn:/localhost/nfd/strategy/{}'.format(namePrefix, strategy)
- debug(node.cmd(cmd))
+ out = node.cmd(cmd)
+ if out.find('error') != -1:
+ warn("[" + node.name + "] Error on strategy set out: " + out)
Minindn.sleep(SLEEP_TIME)
@staticmethod
@@ -124,4 +127,4 @@
if "faceid=" not in output:
return -1
faceId = output.split(" ")[0][7:]
- return faceId
\ No newline at end of file
+ return faceId