Add startup experiments for NLSR and current testbed topology
refs: #4785
Change-Id: I957b8c229ed0696b2f3fca9445f9f27274b0e197
diff --git a/ndn/experiments/arguments_experiment.py b/ndn/experiments/arguments_experiment.py
index e7ed6f9..6baacd5 100644
--- a/ndn/experiments/arguments_experiment.py
+++ b/ndn/experiments/arguments_experiment.py
@@ -1,10 +1,36 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2018, The University of Memphis,
+# Arizona Board of Regents,
+# Regents of the University of California.
+#
+# This file is part of Mini-NDN.
+# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
+#
+# Mini-NDN is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Mini-NDN is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Mini-NDN, e.g., in COPYING.md file.
+# If not, see <http://www.gnu.org/licenses/>.
+
from ndn.experiments.experiment import Experiment
class ArgumentsExperiment(Experiment):
def __init__(self, args):
Experiment.__init__(self, args)
- self.ds = self.arguments.ds
- self.logging = self.arguments.logging
+ self.ds = self.options.arguments.ds
+ self.logging = self.options.arguments.logging
+
+ def start(self):
+ pass
def setup(self):
pass
diff --git a/ndn/experiments/convergence_experiment.py b/ndn/experiments/convergence_experiment.py
deleted file mode 100644
index f95da58..0000000
--- a/ndn/experiments/convergence_experiment.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-#
-# Copyright (C) 2015-2018, The University of Memphis,
-# Arizona Board of Regents,
-# Regents of the University of California.
-#
-# This file is part of Mini-NDN.
-# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
-#
-# Mini-NDN is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Mini-NDN is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Mini-NDN, e.g., in COPYING.md file.
-# If not, see <http://www.gnu.org/licenses/>.
-
-from ndn.experiments.experiment import Experiment
-
-class ConvergenceExperiment(Experiment):
-
- def __init__(self, args):
- Experiment.__init__(self, args)
-
- def setup(self):
- self.checkConvergence()
-
- def run(self):
- pass
-
-Experiment.register("convergence", ConvergenceExperiment)
diff --git a/ndn/experiments/experiment.py b/ndn/experiments/experiment.py
index 347655d..8a2f49c 100644
--- a/ndn/experiments/experiment.py
+++ b/ndn/experiments/experiment.py
@@ -23,46 +23,71 @@
import time
import sys
-from ndn.apps.ndn_ping_client import NDNPingClient
from itertools import cycle
+from mininet.log import info
+
from ndn import ExperimentManager
from ndn.apps.nfdc import Nfdc
+from ndn.apps.nlsr import Nlsr, NlsrConfigGenerator
+from ndn.apps.ndn_ping_client import NDNPingClient
+
class Experiment:
def __init__(self, args):
self.net = args["net"]
- self.convergenceTime = args["ctime"]
- self.nPings = args["nPings"]
- self.strategy = args["strategy"]
- self.pctTraffic = args["pctTraffic"]
- self.nlsrSecurity = args["nlsrSecurity"]
- self.arguments = args["arguments"]
+ self.options = args["options"]
# Used to restart pings on the recovered node if any
self.pingedDict = {}
+ def afterNfdStart(self):
+ pass
+
def start(self):
+ self.afterNfdStart()
+ if self.options.isNlsrEnabled is True:
+ self.startNlsr()
self.setup()
self.run()
def setup(self):
for host in self.net.hosts:
# Set strategy
- Nfdc.setStrategy(host, "/ndn/", self.strategy)
+ Nfdc.setStrategy(host, "/ndn/", self.options.strategy)
# Start ping server
- host.cmd("ndnpingserver /ndn/{}-site/{} > ping-server &".format(host, host))
+ host.cmd("ndnpingserver /ndn/{}-site/{} > ping-server &".format(host.name, host.name))
# Create folder to store ping data
host.cmd("mkdir ping-data")
- self.checkConvergence()
+ def startNlsr(self, checkConvergence = True):
+ # NLSR Security
+ if self.options.nlsrSecurity is True:
+ Nlsr.createKeysAndCertificates(self.net, self.options.workDir)
+
+ # NLSR initialization
+ info('Starting NLSR on nodes\n')
+ for host in self.net.hosts:
+ host.nlsr = Nlsr(host, self.options)
+ host.nlsr.start()
+
+ for host in self.net.hosts:
+ nlsrStatus = host.cmd("ps -g | grep 'nlsr -f {}/[n]lsr.conf'".format(host.homeFolder))
+ if not host.nlsr.isRunning or not nlsrStatus:
+ print("NLSR on host {} is not running. Printing log file and exiting...".format(host.name))
+ print(host.cmd("tail {}/log/nlsr.log".format(host.homeFolder)))
+ self.net.stop()
+ sys.exit(1)
+
+ if checkConvergence:
+ self.checkConvergence()
def checkConvergence(self, convergenceTime = None):
if convergenceTime is None:
- convergenceTime = self.convergenceTime
+ convergenceTime = self.options.ctime
# Wait for convergence time period
print "Waiting " + str(convergenceTime) + " seconds for convergence..."
@@ -79,8 +104,8 @@
didNodeConverge = True
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 ):
+ if ( ("/ndn/{}-site/%C1.Router/cs/{}".format(node.name, node.name)) not in statusRouter or
+ host.name != node.name and ("/ndn/{}-site/{}".format(node.name, node.name)) not in statusPrefix ):
didNodeConverge = False
didNlsrConverge = False
@@ -98,23 +123,23 @@
for other in self.net.hosts:
# Do not ping self
if host.name != other.name:
- NDNPingClient.ping(host, other, self.nPings)
+ NDNPingClient.ping(host, other, self.options.nPings)
def failNode(self, host):
- print("Bringing %s down" % host.name)
+ print("Bringing {} down".format(host.name))
host.nfd.stop()
def recoverNode(self, host):
- print("Bringing %s up" % host.name)
+ print("Bringing {} up".format(host.name))
host.nfd.start()
host.nlsr.createFaces()
host.nlsr.start()
- Nfdc.setStrategy(host, "/ndn/", self.strategy)
- host.cmd("ndnpingserver /ndn/{}-site/{} > ping-server &".format(host, host))
+ Nfdc.setStrategy(host, "/ndn/", self.options.strategy)
+ host.cmd("ndnpingserver /ndn/{}-site/{} > ping-server &".format(host.name, host.name))
def startPctPings(self):
- nNodesToPing = int(round(len(self.net.hosts)*self.pctTraffic))
- print "Each node will ping %d node(s)" % nNodesToPing
+ nNodesToPing = int(round(len(self.net.hosts) * self.options.pctTraffic))
+ print "Each node will ping {} node(s)".format(nNodesToPing)
# Temporarily store all the nodes being pinged by a particular node
nodesPingedList = []
@@ -133,7 +158,7 @@
# Do not ping self
if host.name != other.name:
- NDNPingClient.ping(host, other, self.nPings)
+ NDNPingClient.ping(host, other, self.options.nPings)
nodesPingedList.append(other)
# Always increment because in 100% case a node should not ping itself
@@ -144,4 +169,4 @@
@staticmethod
def register(name, experimentClass):
- ExperimentManager.register(name, experimentClass)
\ No newline at end of file
+ ExperimentManager.register(name, experimentClass)
diff --git a/ndn/experiments/mcn_failure_convergence_experiment.py b/ndn/experiments/mcn_failure_convergence_experiment.py
deleted file mode 100644
index 376d91f..0000000
--- a/ndn/experiments/mcn_failure_convergence_experiment.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-#
-# Copyright (C) 2015-2018, The University of Memphis,
-# Arizona Board of Regents,
-# Regents of the University of California.
-#
-# This file is part of Mini-NDN.
-# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
-#
-# Mini-NDN is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Mini-NDN is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Mini-NDN, e.g., in COPYING.md file.
-# If not, see <http://www.gnu.org/licenses/>.
-
-from ndn.experiments.experiment import Experiment
-from ndn.experiments.mcn_failure_experiment import MCNFailureExperiment
-
-import time
-
-class MCNFailureConvergenceExperiment(MCNFailureExperiment):
-
- def __init__(self, args):
- MCNFailureExperiment.__init__(self, args)
-
- def run(self):
- mostConnectedNode = self.getMostConnectedNode()
-
- # After the pings are scheduled, collect pings for 1 minute
- time.sleep(self.PING_COLLECTION_TIME_BEFORE_FAILURE)
-
- # Bring down MCN
- self.failNode(mostConnectedNode)
-
- # MCN is down for 2 minutes
- time.sleep(120)
-
- # Bring MCN back up
- self.recoverNode(mostConnectedNode)
-
- self.checkConvergence()
-
-Experiment.register("mcn-failure-convergence", MCNFailureConvergenceExperiment)
diff --git a/ndn/experiments/nlsr/__init__.py b/ndn/experiments/nlsr/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ndn/experiments/nlsr/__init__.py
diff --git a/ndn/experiments/nlsr/advertise-delayed-start.py b/ndn/experiments/nlsr/advertise-delayed-start.py
new file mode 100644
index 0000000..cbd8ac8
--- /dev/null
+++ b/ndn/experiments/nlsr/advertise-delayed-start.py
@@ -0,0 +1,73 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2018, The University of Memphis,
+# Arizona Board of Regents,
+# Regents of the University of California.
+#
+# This file is part of Mini-NDN.
+# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
+#
+# Mini-NDN is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Mini-NDN is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Mini-NDN, e.g., in COPYING.md file.
+# If not, see <http://www.gnu.org/licenses/>.
+
+from ndn.experiments.experiment import Experiment
+from ndn.apps.nlsr import Nlsr, NlsrConfigGenerator
+
+from mininet.log import info
+
+import time, sys
+
+class AdvertiseDelayedStartExperiment(Experiment):
+ '''Tests Name LSA data segmentation'''
+
+ def __init__(self, args):
+ Experiment.__init__(self, args)
+
+ def setup(self):
+ pass
+
+ def run(self):
+ pass
+
+ def startNlsr(self, checkConvergence = True):
+ # NLSR Security
+ if self.options.nlsrSecurity is True:
+ Nlsr.createKeysAndCertificates(self.net, self.options.workDir)
+
+ host1 = self.net.hosts[0]
+ host1.nlsr = Nlsr(host1, self.options)
+ host1.nlsr.start()
+
+ expectedTotalCount = 500
+ for i in range(0, expectedTotalCount):
+ host1.cmd("nlsrc advertise /long/name/to/exceed/max/packet/size/host1/{}".format(i))
+
+ time.sleep(60)
+
+ host2 = self.net.hosts[1]
+ host2.nlsr = Nlsr(host2, self.options)
+ host2.nlsr.start()
+
+ time.sleep(60)
+
+ advertiseCount = int(host2.cmd("nfdc fib | grep host1 | wc -l"))
+ info(advertiseCount)
+ if advertiseCount == expectedTotalCount:
+ info('\nSuccessfully advertised {} prefixes\n'.format(expectedTotalCount))
+ else:
+ info('\nAdvertising {} prefixes failed. Exiting...\n'.format(expectedTotalCount))
+ self.net.stop()
+ sys.exit(1)
+
+Experiment.register("advertise-delayed-start", AdvertiseDelayedStartExperiment)
diff --git a/ndn/experiments/nlsr/delayed-start.py b/ndn/experiments/nlsr/delayed-start.py
new file mode 100644
index 0000000..e995c50
--- /dev/null
+++ b/ndn/experiments/nlsr/delayed-start.py
@@ -0,0 +1,66 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2018, The University of Memphis,
+# Arizona Board of Regents,
+# Regents of the University of California.
+#
+# This file is part of Mini-NDN.
+# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
+#
+# Mini-NDN is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Mini-NDN is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Mini-NDN, e.g., in COPYING.md file.
+# If not, see <http://www.gnu.org/licenses/>.
+
+from ndn.experiments.experiment import Experiment
+from ndn.apps.nlsr import Nlsr, NlsrConfigGenerator
+
+from mininet.log import info
+
+import time
+
+class NlsrDelayedStartExperiment(Experiment):
+
+ def __init__(self, args):
+ Experiment.__init__(self, args)
+
+ def setup(self):
+ pass
+
+ def run(self):
+ pass
+
+ def startNlsr(self, checkConvergence = True):
+ # NLSR Security
+ if self.options.nlsrSecurity is True:
+ Nlsr.createKeysAndCertificates(self.net, self.options.workDir)
+
+ i = 1
+ # NLSR initialization
+ info('Starting NLSR on nodes\n')
+ for host in self.net.hosts:
+ host.nlsr = Nlsr(host, self.options)
+ host.nlsr.start()
+
+ # Wait 1/2 minute between starting NLSRs
+ # Wait 1 hour before starting last NLSR
+ if i == len(self.net.hosts) - 1:
+ info('Sleeping 1 hour before starting last NLSR')
+ time.sleep(3600)
+ else:
+ time.sleep(30)
+ i += 1
+
+ if checkConvergence:
+ self.checkConvergence()
+
+Experiment.register("nlsr-delayed-start", NlsrDelayedStartExperiment)
diff --git a/ndn/experiments/failure_experiment.py b/ndn/experiments/nlsr/failure_experiment.py
similarity index 97%
rename from ndn/experiments/failure_experiment.py
rename to ndn/experiments/nlsr/failure_experiment.py
index a27b0a6..783bac4 100644
--- a/ndn/experiments/failure_experiment.py
+++ b/ndn/experiments/nlsr/failure_experiment.py
@@ -22,7 +22,6 @@
# If not, see <http://www.gnu.org/licenses/>.
from ndn.experiments.experiment import Experiment
-from ndn.nlsr import Nlsr
from ndn.apps.ndn_ping_client import NDNPingClient
import time
@@ -30,7 +29,7 @@
class FailureExperiment(Experiment):
def __init__(self, args):
- args["nPings"] = 300
+ args["options"].nPings = 300
Experiment.__init__(self, args)
self.PING_COLLECTION_TIME_BEFORE_FAILURE = 60
diff --git a/ndn/experiments/mcn_failure_experiment.py b/ndn/experiments/nlsr/mcn_failure_experiment.py
similarity index 66%
rename from ndn/experiments/mcn_failure_experiment.py
rename to ndn/experiments/nlsr/mcn_failure_experiment.py
index 62bdcab..cd448cc 100644
--- a/ndn/experiments/mcn_failure_experiment.py
+++ b/ndn/experiments/nlsr/mcn_failure_experiment.py
@@ -29,7 +29,6 @@
class MCNFailureExperiment(Experiment):
def __init__(self, args):
- args["nPings"] = 300
Experiment.__init__(self, args)
self.PING_COLLECTION_TIME_BEFORE_FAILURE = 60
@@ -37,13 +36,18 @@
def getMostConnectedNode(self):
mcn = max(self.net.hosts, key=lambda host: len(host.intfNames()))
- print "The most connected node is: %s" % mcn.name
+ print "The most connected node is: {}".format(mcn.name)
return mcn
+ def setup(self):
+ if self.options.nPings != 0:
+ Experiment.setup(self)
+
def run(self):
mostConnectedNode = self.getMostConnectedNode()
- self.startPctPings()
+ if self.options.nPings != 0:
+ self.startPctPings()
# After the pings are scheduled, collect pings for 1 minute
time.sleep(self.PING_COLLECTION_TIME_BEFORE_FAILURE)
@@ -52,16 +56,24 @@
self.failNode(mostConnectedNode)
# MCN is down for 2 minutes
- time.sleep(120)
+ time.sleep(int(self.options.arguments.waitTime))
# Bring MCN back up
self.recoverNode(mostConnectedNode)
# Restart pings
- for nodeToPing in self.pingedDict[mostConnectedNode]:
- NDNPingClient.ping(mostConnectedNode, nodeToPing, self.PING_COLLECTION_TIME_AFTER_RECOVERY)
+ if self.options.nPings != 0:
+ for nodeToPing in self.pingedDict[mostConnectedNode]:
+ NDNPingClient.ping(mostConnectedNode, nodeToPing, self.PING_COLLECTION_TIME_AFTER_RECOVERY)
- # Collect pings for more seconds after MCN is up
- time.sleep(self.PING_COLLECTION_TIME_AFTER_RECOVERY)
+ # Collect pings for more seconds after MCN is up
+ time.sleep(self.PING_COLLECTION_TIME_AFTER_RECOVERY)
+ else:
+ self.checkConvergence()
-Experiment.register("failure-mcn", MCNFailureExperiment)
+ @staticmethod
+ def parseArguments(parser):
+ parser.add_argument("--wait-time", dest="waitTime", default="120",
+ help="[Experiment] Generic wait time for experiment use")
+
+Experiment.register("mcn-failure", MCNFailureExperiment)
diff --git a/ndn/experiments/multiple_failure_experiment.py b/ndn/experiments/nlsr/multiple_failure_experiment.py
similarity index 89%
rename from ndn/experiments/multiple_failure_experiment.py
rename to ndn/experiments/nlsr/multiple_failure_experiment.py
index 6b4ce6b..efbba60 100644
--- a/ndn/experiments/multiple_failure_experiment.py
+++ b/ndn/experiments/nlsr/multiple_failure_experiment.py
@@ -22,7 +22,6 @@
# If not, see <http://www.gnu.org/licenses/>.
from ndn.experiments.experiment import Experiment
-from ndn.nlsr import Nlsr
from ndn.apps.ndn_ping_client import NDNPingClient
import time
@@ -38,12 +37,11 @@
# This is the number of pings required to make it through the full experiment
nInitialPings = (self.PING_COLLECTION_TIME_BEFORE_FAILURE +
- len(args["net"].hosts)*(self.FAILURE_INTERVAL + self.RECOVERY_INTERVAL))
- print("Scheduling with %s initial pings" % nInitialPings)
-
- args["nPings"] = nInitialPings
+ len(args["net"].hosts) * (self.FAILURE_INTERVAL + self.RECOVERY_INTERVAL))
+ print("Scheduling with {} initial pings".format(nInitialPings))
Experiment.__init__(self, args)
+ self.options.nPings = nInitialPings
def run(self):
self.startPctPings()
@@ -71,7 +69,7 @@
nPings = ((self.RECOVERY_INTERVAL - recovery_time) +
nNodesRemainingToFail*(self.FAILURE_INTERVAL + self.RECOVERY_INTERVAL))
- print("Scheduling with %s remaining pings" % nPings)
+ print("Scheduling with {} remaining pings".format(nPings))
# Restart pings
for nodeToPing in self.pingedDict[host]:
diff --git a/ndn/experiments/pingall_experiment.py b/ndn/experiments/nlsr/pingall_experiment.py
similarity index 82%
rename from ndn/experiments/pingall_experiment.py
rename to ndn/experiments/nlsr/pingall_experiment.py
index cad27e2..56a70bd 100644
--- a/ndn/experiments/pingall_experiment.py
+++ b/ndn/experiments/nlsr/pingall_experiment.py
@@ -31,12 +31,19 @@
Experiment.__init__(self, args)
self.COLLECTION_PERIOD_BUFFER = 10
- print "Using %f traffic" % self.pctTraffic
+ print "Using {} traffic".format(self.options.pctTraffic)
+
+ def setup(self):
+ if self.options.nPings != 0:
+ Experiment.setup(self)
def run(self):
+ if self.options.nPings == 0:
+ return
+
self.startPctPings()
# For pingall experiment sleep for the number of pings + some offset
- time.sleep(self.nPings + self.COLLECTION_PERIOD_BUFFER)
+ time.sleep(self.options.nPings + self.COLLECTION_PERIOD_BUFFER)
Experiment.register("pingall", PingallExperiment)
diff --git a/ndn/experiments/prefix_propogation.py b/ndn/experiments/nlsr/prefix_propogation.py
similarity index 98%
rename from ndn/experiments/prefix_propogation.py
rename to ndn/experiments/nlsr/prefix_propogation.py
index a4f83b3..ae8301a 100644
--- a/ndn/experiments/prefix_propogation.py
+++ b/ndn/experiments/nlsr/prefix_propogation.py
@@ -36,7 +36,7 @@
def run(self):
firstNode = self.net.hosts[0]
- if self.nlsrSecurity:
+ if self.options.nlsrSecurity:
firstNode.cmd("ndnsec-set-default /ndn/{}-site/%C1.Operator/op".format(firstNode.name))
print("Testing advertise")