No need to store host names, make network name a constant
refs: #3958, #3972
Change-Id: I16e5b94174dd47913d7d93a22708fb41061a762c
diff --git a/bin/minindn b/bin/minindn
index 13ee300..d0ff5ef 100755
--- a/bin/minindn
+++ b/bin/minindn
@@ -385,16 +385,12 @@
node2.setIP(ipStr(ipParse(ndnNetBase) + 2) + '/30', intf=link.intf2)
ndnNetBase = ipStr(ipParse(ndnNetBase) + 4)
- nodes = "" # Used later to check prefix name in checkFIB
-
# NLSR Security
if options.nlsrSecurity is True:
Nlsr.createKeysAndCertificates(net, options.workDir)
# NLSR initialization
for host in net.hosts:
- nodes += str(host.name) + ","
-
conf = next(x for x in hosts_conf if x.name == host.name)
host.nlsrParameters = conf.nlsrParameters
@@ -412,8 +408,6 @@
host.nlsr = Nlsr(host)
host.nlsr.start()
- nodes = nodes[0:-1]
-
for host in net.hosts:
if 'app' in host.params:
if host.params['app'] != '':
@@ -429,7 +423,6 @@
experimentArgs = {
"net": net,
- "nodes": nodes,
"ctime": options.ctime,
"nPings": options.nPings,
"strategy": Nfd.STRATEGY_BEST_ROUTE,
diff --git a/ndn/experiments/experiment.py b/ndn/experiments/experiment.py
index d13f088..0b917c2 100644
--- a/ndn/experiments/experiment.py
+++ b/ndn/experiments/experiment.py
@@ -31,7 +31,6 @@
def __init__(self, args):
self.net = args["net"]
- self.nodes = args["nodes"]
self.convergenceTime = args["ctime"]
self.nPings = args["nPings"]
self.strategy = args["strategy"]
@@ -74,9 +73,10 @@
statusRouter = host.cmd("nfdc fib list | grep site/%C1.Router/cs/")
statusPrefix = host.cmd("nfdc fib list | grep ndn | grep site | grep -v Router")
didNodeConverge = True
- for node in self.nodes.split(","):
- if ( ("/ndn/" + node + "-site/%C1.Router/cs/" + node) not in statusRouter or
- str(host) != node and ("/ndn/" + node + "-site/" + node) not in statusPrefix ):
+ for node in self.net.hosts:
+ # Node has its own router name in the fib list, but not name prefix
+ if ( ("/ndn/" + node.name + "-site/%C1.Router/cs/" + node.name) not in statusRouter or
+ host.name != node.name and ("/ndn/" + node.name + "-site/" + node.name) not in statusPrefix ):
didNodeConverge = False
didNlsrConverge = False
diff --git a/ndn/nlsr.py b/ndn/nlsr.py
index 0e22361..ab8c1dd 100644
--- a/ndn/nlsr.py
+++ b/ndn/nlsr.py
@@ -32,6 +32,8 @@
import textwrap
from subprocess import call
+NETWORK="/ndn/"
+
class Nlsr(NdnApplication):
def __init__(self, node):
NdnApplication.__init__(self, node)
@@ -66,7 +68,7 @@
os.mkdir(securityDir)
# Create root certificate
- rootName = "/ndn"
+ rootName = NETWORK
sh("ndnsec-keygen {} > {}/root.keys".format(rootName, securityDir))
sh("ndnsec-certgen -N {} -p {} {}/root.keys > {}/root.cert".format(rootName, rootName, securityDir, securityDir))
@@ -84,7 +86,7 @@
shutil.copyfile("{}/root.cert".format(securityDir), "{}/root.cert".format(nodeSecurityFolder))
# Create site certificate
- siteName = "/ndn/{}-site".format(host.name)
+ siteName = "{}{}-site".format(NETWORK, host.name)
siteKeyFile = "{}/site.keys".format(nodeSecurityFolder)
siteCertFile = "{}/site.cert".format(nodeSecurityFolder)
Nlsr.createKey(host, siteName, siteKeyFile)
@@ -176,7 +178,7 @@
general = "general\n"
general += "{\n"
- general += " network /ndn/\n"
+ general += " network {}\n".format(NETWORK)
general += " site /{}-site\n".format(self.node.name)
general += " router /%C1.Router/cs/" + self.node.name + "\n"
general += " log-level " + self.logLevel + "\n"
@@ -207,7 +209,7 @@
neighbors += "neighbor\n"
neighbors += "{\n"
- neighbors += " name /ndn/" + other.name + "-site/%C1.Router/cs/" + other.name + "\n"
+ neighbors += " name " + NETWORK + other.name + "-site/%C1.Router/cs/" + other.name + "\n"
neighbors += " face-uri udp://" + str(ip) + "\n"
neighbors += " link-cost " + linkCost + "\n"
neighbors += "}\n"
@@ -240,7 +242,7 @@
advertising = "advertising\n"
advertising += "{\n"
- advertising += " prefix /ndn/" + self.node.name + "-site/" + self.node.name + "\n"
+ advertising += " prefix "+ NETWORK + self.node.name + "-site/" + self.node.name + "\n"
advertising += "}\n"
return advertising