No need to store host names, make network name a constant
refs: #3958, #3972 Change-Id: I16e5b94174dd47913d7d93a22708fb41061a762c
This commit is contained in:
1 parent
95789ccc5e
commit
f6a610bd2e
3 files changed
+11
-16
No files matched your search
@@ -385,16 +385,12 @@ def execute(options):
|
||||
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 @@ def execute(options):
|
||||
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 @@ def execute(options):
|
||||
|
||||
experimentArgs = {
|
||||
"net": net,
|
||||
"nodes": nodes,
|
||||
"ctime": options.ctime,
|
||||
"nPings": options.nPings,
|
||||
"strategy": Nfd.STRATEGY_BEST_ROUTE,
|
||||
|
||||
@@ -31,7 +31,6 @@ class Experiment:
|
||||
|
||||
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 @@ class Experiment:
|
||||
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
|
||||
|
||||
|
||||
+7
-5
@@ -32,6 +32,8 @@ import os
|
||||
import textwrap
|
||||
from subprocess import call
|
||||
|
||||
NETWORK="/ndn/"
|
||||
|
||||
class Nlsr(NdnApplication):
|
||||
def __init__(self, node):
|
||||
NdnApplication.__init__(self, node)
|
||||
@@ -66,7 +68,7 @@ class Nlsr(NdnApplication):
|
||||
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 @@ class Nlsr(NdnApplication):
|
||||
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 @@ class NlsrConfigGenerator:
|
||||
|
||||
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 @@ class NlsrConfigGenerator:
|
||||
|
||||
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 @@ class NlsrConfigGenerator:
|
||||
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user