nfd: add option to set CS size
Don't append NFD logs b/w runs
Re-factor NFD start from ndn_host.py to bin/minindn
refs: #4469, #4508
Change-Id: I43f594a3353bb92101a0281a4561999cd8406707
diff --git a/bin/minindn b/bin/minindn
index 930314f..116fcf5 100755
--- a/bin/minindn
+++ b/bin/minindn
@@ -130,6 +130,7 @@
self.tunnelType = None
self.faceType = "udp"
self.arbArgs = {}
+ self.csSize = 65536
def createResultsDir(resultDir, faces, rType):
if faces == 0:
@@ -154,7 +155,7 @@
# nargs='?' required here since optional argument
parser.add_argument('tempfile', nargs='?', default=INSTALL_DIR + 'default-topology.conf',
- help="If no template_file is given, ndn_utils/default-topology.conf (given sample file) will be used.")
+ help="If no template_file is given, topologies/default-topology.conf (given sample file) will be used.")
parser.add_argument("--ctime", type=int, default=60,
help="Specify convergence time for the topology (Default: 60 seconds)")
@@ -215,6 +216,9 @@
parser.add_argument("--face-type", dest='faceType', default='udp', choices=['udp', 'tcp'])
+ parser.add_argument("--cs-size", dest='csSize', type=int, default=65536,
+ help="Set CS size in NFD's conf file")
+
args, unknownArgs = parser.parse_known_args()
unknownArgsList = []
@@ -245,6 +249,7 @@
options.tunnelType = args.tunnelType
options.placeList = args.placeList
options.faceType = args.faceType
+ options.csSize = args.csSize
for k in args.__dict__:
if k in unknownArgsList:
@@ -402,6 +407,12 @@
node2.setIP(ipStr(ipParse(ndnNetBase) + 2) + '/30', intf=link.intf2)
ndnNetBase = ipStr(ipParse(ndnNetBase) + 4)
+ time.sleep(2)
+ info('Starting NFD on nodes\n')
+ for host in net.hosts:
+ host.nfd = Nfd(host, options.csSize)
+ host.nfd.start()
+
if options.isNlsrEnabled is True:
# NLSR Security
@@ -409,6 +420,7 @@
Nlsr.createKeysAndCertificates(net, options.workDir)
# NLSR initialization
+ info('Starting NLSR on nodes\n')
for host in net.hosts:
conf = next(x for x in hosts_conf if x.name == host.name)
host.nlsrParameters = conf.nlsrParameters
diff --git a/install.sh b/install.sh
index 37eeeea..9a331a8 100755
--- a/install.sh
+++ b/install.sh
@@ -204,10 +204,10 @@
install_dir="/usr/local/etc/mini-ndn/"
sudo mkdir -p "$install_dir"
- sudo cp ndn_utils/topologies/default-topology.conf "$install_dir"
- sudo cp ndn_utils/topologies/minindn.caida.conf "$install_dir"
- sudo cp ndn_utils/topologies/minindn.ucla.conf "$install_dir"
- sudo cp ndn_utils/topologies/minindn.testbed.conf "$install_dir"
+ sudo cp topologies/default-topology.conf "$install_dir"
+ sudo cp topologies/minindn.caida.conf "$install_dir"
+ sudo cp topologies/minindn.ucla.conf "$install_dir"
+ sudo cp topologies/minindn.testbed.conf "$install_dir"
sudo python setup.py clean --all install
}
diff --git a/ndn/ndn_application.py b/ndn/ndn_application.py
index 7720734..dd9100e 100644
--- a/ndn/ndn_application.py
+++ b/ndn/ndn_application.py
@@ -43,7 +43,7 @@
self.isRunning = True
def stop(self):
- if self.isRunning:
- self.node.cmd("sudo kill %s" % self.processId)
+ if self.isRunning and self.processId != "":
+ self.node.cmd("sudo kill {}".format(self.processId))
self.isRunning = False
diff --git a/ndn/ndn_host.py b/ndn/ndn_host.py
index 7c727ab..7596f5f 100644
--- a/ndn/ndn_host.py
+++ b/ndn/ndn_host.py
@@ -100,8 +100,7 @@
self.cmd("mkdir -p %s" % self.homeFolder)
self.cmd("cd %s" % self.homeFolder)
- self.nfd = Nfd(self)
- self.nfd.start()
+ self.nfd = None
self.peerList = {}
@@ -116,7 +115,8 @@
def terminate(self):
"Stop node."
- self.nfd.stop()
+ if self.nfd is not None:
+ self.nfd.stop()
Host.terminate(self)
class CpuLimitedNdnHost(CPULimitedHost, NdnHostCommon):
@@ -134,8 +134,7 @@
self.cmd("mkdir -p %s" % self.homeFolder)
self.cmd("cd %s" % self.homeFolder)
- self.nfd = Nfd(self)
- self.nfd.start()
+ self.nfd = None
self.peerList = {}
@@ -150,8 +149,9 @@
def terminate(self):
"Stop node."
- self.nfd.stop()
- Host.terminate(self)
+ if self.nfd is not None:
+ self.nfd.stop()
+ CPULimitedHost.terminate(self)
class RemoteNdnHost(RemoteMixin, NdnHost):
"A node on a remote server"
diff --git a/ndn/nfd.py b/ndn/nfd.py
index 880d248..09e28d5 100644
--- a/ndn/nfd.py
+++ b/ndn/nfd.py
@@ -24,12 +24,11 @@
import time, sys, os
from ndn.ndn_application import NdnApplication
-
class Nfd(NdnApplication):
STRATEGY_BEST_ROUTE = "best-route"
STRATEGY_NCC = "ncc"
- def __init__(self, node):
+ def __init__(self, node, csSize):
NdnApplication.__init__(self, node)
self.logLevel = node.params["params"].get("nfd-log-level", "INFO")
@@ -55,6 +54,9 @@
# Open the conf file and change socket file name
node.cmd("infoedit -f {} -s face_system.unix.path -v /var/run/{}.sock".format(self.confFile, node.name))
+ # Set CS size
+ node.cmd("infoedit -f {} -s tables.cs_max_packets -v {}".format(self.confFile, csSize))
+
# Make NDN folder
node.cmd("sudo mkdir {}".format(self.ndnFolder))
@@ -68,7 +70,7 @@
node.cmd("ndnsec-keygen /localhost/operator | ndnsec-install-cert -")
def start(self):
- NdnApplication.start(self, "setsid nfd --config {} >> {} 2>&1 &".format(self.confFile, self.logFile))
+ NdnApplication.start(self, "setsid nfd --config {} > {} 2>&1 &".format(self.confFile, self.logFile))
time.sleep(2)
def setStrategy(self, name, strategy):
diff --git a/ndn_utils/topologies/default-topology.conf b/topologies/default-topology.conf
similarity index 100%
rename from ndn_utils/topologies/default-topology.conf
rename to topologies/default-topology.conf
diff --git a/ndn_utils/topologies/minindn.caida.conf b/topologies/minindn.caida.conf
similarity index 100%
rename from ndn_utils/topologies/minindn.caida.conf
rename to topologies/minindn.caida.conf
diff --git a/ndn_utils/topologies/minindn.testbed.conf b/topologies/minindn.testbed.conf
similarity index 100%
rename from ndn_utils/topologies/minindn.testbed.conf
rename to topologies/minindn.testbed.conf
diff --git a/ndn_utils/topologies/minindn.ucla.conf b/topologies/minindn.ucla.conf
similarity index 100%
rename from ndn_utils/topologies/minindn.ucla.conf
rename to topologies/minindn.ucla.conf