Create faces in NFD for each neighbor of NLSR
Add option to specify whether to use TCP or UDP face in nlsr.conf
refs: #4144, #4146
Change-Id: Ida40aef80bea0e5bcb7392e446aaefce0bea9b66
diff --git a/bin/minindn b/bin/minindn
index c6fc1f8..b6831af 100755
--- a/bin/minindn
+++ b/bin/minindn
@@ -124,6 +124,7 @@
self.guided = None
self.placer = None
self.tunnelType = None
+ self.faceType = "udp"
def createResultsDir(resultDir, faces, hr):
if faces == 0:
@@ -206,6 +207,8 @@
parser.add_argument("--tunnel-type", dest="tunnelType", default='ssh',
choices=['ssh', 'gre'])
+ parser.add_argument("--face-type", dest='faceType', default='udp', choices=['udp', 'tcp'])
+
args = parser.parse_args()
options = ProgramOptions()
@@ -226,6 +229,7 @@
options.placement = args.placement
options.tunnelType = args.tunnelType
options.placeList = args.placeList
+ options.faceType = args.faceType
if options.experimentName is not None and options.experimentName not in ExperimentManager.getExperimentNames():
print("No experiment named %s" % options.experimentName)
@@ -401,11 +405,11 @@
host.nlsrParameters["hyperbolic-state"] = "on"
# Generate NLSR configuration file
- configGenerator = NlsrConfigGenerator(host, options.nlsrSecurity)
+ configGenerator = NlsrConfigGenerator(host, options.nlsrSecurity, options.faceType)
configGenerator.createConfigFile()
# Start NLSR
- host.nlsr = Nlsr(host)
+ host.nlsr = Nlsr(host, configGenerator.neighborIPs, options.faceType)
host.nlsr.start()
for host in net.hosts:
diff --git a/ndn/experiments/experiment.py b/ndn/experiments/experiment.py
index f5f4118..a13c774 100644
--- a/ndn/experiments/experiment.py
+++ b/ndn/experiments/experiment.py
@@ -109,6 +109,7 @@
def recoverNode(self, host):
print("Bringing %s up" % host.name)
host.nfd.start()
+ host.nlsr.createFaces()
host.nlsr.start()
host.nfd.setStrategy("/ndn/", self.strategy)
host.cmd("ndnpingserver /ndn/" + str(host) + "-site/" + str(host) + " > ping-server &")
diff --git a/ndn/nlsr.py b/ndn/nlsr.py
index 54a6a3c..1d4150c 100644
--- a/ndn/nlsr.py
+++ b/ndn/nlsr.py
@@ -36,19 +36,29 @@
NETWORK="/ndn/"
class Nlsr(NdnApplication):
- def __init__(self, node):
+ def __init__(self, node, neighbors, faceType):
NdnApplication.__init__(self, node)
+ self.node = node
+ self.neighbors = neighbors
+ self.faceType = faceType
self.routerName = "/%sC1.Router/cs/%s" % ('%', node.name)
self.confFile = "%s/nlsr.conf" % node.homeFolder
# Make directory for log file
self.logDir = "%s/log" % node.homeFolder
- node.cmd("mkdir %s" % self.logDir)
+ self.node.cmd("mkdir %s" % self.logDir)
+
+ # Create faces in NFD
+ self.createFaces()
def start(self):
NdnApplication.start(self, "nlsr -f {} > /dev/null 2>&1 &".format(self.confFile))
time.sleep(1)
+ def createFaces(self):
+ for ip in self.neighbors:
+ self.node.cmd("nfdc face create {}://{} permanent".format(self.faceType, ip))
+
@staticmethod
def createKey(host, name, outputFile):
host.cmd("ndnsec-keygen {} > {}".format(name, outputFile))
@@ -133,9 +143,10 @@
ROUTING_LINK_STATE = "ls"
ROUTING_HYPERBOLIC = "hr"
- def __init__(self, node, isSecurityEnabled):
+ def __init__(self, node, isSecurityEnabled, faceType):
self.node = node
self.isSecurityEnabled = isSecurityEnabled
+ self.faceType = faceType
parameters = node.nlsrParameters
@@ -144,6 +155,7 @@
self.hyperRadius = parameters.get("radius", 0.0)
self.hyperAngle = parameters.get("angle", 0.0)
self.logLevel = parameters.get("nlsr-log-level", "DEBUG")
+ self.neighborIPs = []
def createConfigFile(self):
@@ -207,10 +219,13 @@
linkCost = intf.params.get("delay", "10ms").replace("ms", "")
+ # To be used later to create faces
+ self.neighborIPs.append(ip)
+
neighbors += "neighbor\n"
neighbors += "{\n"
neighbors += " name " + NETWORK + other.name + "-site/%C1.Router/cs/" + other.name + "\n"
- neighbors += " face-uri udp://" + str(ip) + "\n"
+ neighbors += " face-uri {}://{}\n".format(self.faceType, ip)
neighbors += " link-cost " + linkCost + "\n"
neighbors += "}\n"