performance improvements
Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5a
This commit is contained in:
1 parent
edd777fdfc
commit
86647794f8
2 files changed
+19
-13
No files matched your search
@@ -33,7 +33,6 @@ from math import sin, cos, sinh, cosh, acos, acosh
|
||||
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 @@ class NdnRoutingHelper(object):
|
||||
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 @@ class NdnRoutingHelper(object):
|
||||
: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 @@ class NdnRoutingHelper(object):
|
||||
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 @@ class NdnRoutingHelper(object):
|
||||
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
|
||||
|
||||
@@ -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 @@ class Nfdc(object):
|
||||
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 @@ class Nfdc(object):
|
||||
@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 @@ class Nfdc(object):
|
||||
if "faceid=" not in output:
|
||||
return -1
|
||||
faceId = output.split(" ")[0][7:]
|
||||
return faceId
|
||||
return faceId
|
||||
Reference in new issue
Block a user