From 63a330d317a9edf6b3443d579e7f03c46b64a8ed Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 18 May 2022 14:23:13 -0700 Subject: [PATCH] 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 --- minindn/apps/nfd.py | 2 +- minindn/helpers/ndn_routing_helper.py | 18 ++++++++++++++---- minindn/helpers/nfdc.py | 4 +++- requirements.txt | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/minindn/apps/nfd.py b/minindn/apps/nfd.py index 2b6a959..90a36b8 100644 --- a/minindn/apps/nfd.py +++ b/minindn/apps/nfd.py @@ -72,4 +72,4 @@ class Nfd(Application): def start(self): Application.start(self, 'nfd --config {}'.format(self.confFile), logfile=self.logFile) - Minindn.sleep(2) + Minindn.sleep(0.5) 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 json 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 @@ class NdnRoutingHelper(object): 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' diff --git a/requirements.txt b/requirements.txt index 5c0596f..6e2edbd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ python-igraph setuptools -tqdm \ No newline at end of file +tqdm +joblib