Add startup experiments for NLSR and current testbed topology

refs: #4785

Change-Id: I957b8c229ed0696b2f3fca9445f9f27274b0e197
diff --git a/ndn/nlsr.py b/ndn/apps/nlsr.py
similarity index 87%
rename from ndn/nlsr.py
rename to ndn/apps/nlsr.py
index 98efc78..7d55a21 100644
--- a/ndn/nlsr.py
+++ b/ndn/apps/nlsr.py
@@ -23,10 +23,11 @@
 
 from mininet.clean import sh
 from mininet.examples.cluster import RemoteMixin
+from mininet.log import info
 
 from ndn.ndn_application import NdnApplication
 from ndn.util import ssh, scp, copyExistentFile
-from apps.nfdc import Nfdc
+from ndn.apps.nfdc import Nfdc
 
 import shutil
 import os
@@ -37,11 +38,11 @@
 NETWORK="/ndn/"
 
 class Nlsr(NdnApplication):
-    def __init__(self, node, neighbors, faceType):
+    def __init__(self, node, options):
         NdnApplication.__init__(self, node)
+        self.config = NlsrConfigGenerator(node, options)
+
         self.node = node
-        self.neighbors = neighbors
-        self.faceType = faceType
         self.routerName = "/{}C1.Router/cs/{}".format('%', node.name)
         self.confFile = "{}/nlsr.conf".format(node.homeFolder)
 
@@ -49,17 +50,14 @@
         self.logDir = "{}/log".format(node.homeFolder)
         self.node.cmd("mkdir {}".format(self.logDir))
 
-        # Create faces in NFD
-        self.createFaces()
-
-    def start(self):
-        self.node.cmd("export NDN_LOG=nlsr.*={}".format(self.node.nlsrParameters.get("nlsr-log-level", "DEBUG")))
+    def start(self, sleepTime = 1):
+        self.node.cmd("export NDN_LOG=nlsr.*={}".format(self.node.params["params"].get("nlsr-log-level", "DEBUG")))
         NdnApplication.start(self, "nlsr -f {} > log/nlsr.log 2>&1 &".format(self.confFile))
-        time.sleep(1)
+        time.sleep(sleepTime)
 
     def createFaces(self):
-        for ip in self.neighbors:
-            Nfdc.createFace(self.node, ip, self.faceType, isPermanent=True)
+        for ip in self.config.neighborIPs:
+            Nfdc.createFace(self.node, ip, self.config.faceType, isPermanent=True)
 
     @staticmethod
     def createKey(host, name, outputFile):
@@ -142,22 +140,36 @@
     ROUTING_LINK_STATE = "ls"
     ROUTING_HYPERBOLIC = "hr"
 
-    def __init__(self, node, isSecurityEnabled, faceType):
+    def __init__(self, node, options):
         self.node = node
-        self.isSecurityEnabled = isSecurityEnabled
-        self.faceType = faceType
+        self.isSecurityEnabled = options.nlsrSecurity
+        self.faceType = options.faceType
         self.infocmd = "infoedit -f nlsr.conf"
 
-        parameters = node.nlsrParameters
+        parameters = node.params["params"]
 
-        self.nFaces = parameters.get("max-faces-per-prefix", 3)
-        self.hyperbolicState = parameters.get("hyperbolic-state", "off")
+        self.nFaces = options.nFaces
+        if options.routingType == "hr":
+            self.hyperbolicState = "on"
+        elif options.routingType == "dry":
+            self.hyperbolicState = "dry-run"
+        else:
+            self.hyperbolicState = "off"
         self.hyperRadius = parameters.get("radius", 0.0)
         self.hyperAngle = parameters.get("angle", 0.0)
+
+        if ((self.hyperbolicState == "on" or self.hyperbolicState == "dry-run") and
+            (self.hyperRadius == 0.0 or self.hyperAngle == 0.0)):
+                info('Hyperbolic coordinates in topology file are either missing or misconfigured.')
+                info('Check that each node has one radius value and one or two angle value(s).')
+                sys.exit(1)
+
         self.neighborIPs = []
         possibleConfPaths = ["/usr/local/etc/ndn/nlsr.conf.sample", "/etc/ndn/nlsr.conf.sample"]
         copyExistentFile(node, possibleConfPaths, "{}/nlsr.conf".format(self.node.homeFolder))
 
+        self.createConfigFile()
+
     def createConfigFile(self):
 
         self.__editGeneralSection()
@@ -192,7 +204,7 @@
 
                 linkCost = intf.params.get("delay", "10ms").replace("ms", "")
 
-                # To be used later to create faces
+                Nfdc.createFace(self.node, ip, self.faceType, isPermanent=True)
                 self.neighborIPs.append(ip)
 
                 self.node.cmd("{} -a neighbors.neighbor \
diff --git a/ndn/conf_parser.py b/ndn/conf_parser.py
index 85fda2b..a2f63a1 100644
--- a/ndn/conf_parser.py
+++ b/ndn/conf_parser.py
@@ -66,25 +66,14 @@
     def __init__(self, name, app='', params='', cpu=None, cores=None, cache=None):
         self.name = name
         self.app = app
-        self.uri_tuples = params
         self.params = params
         self.cpu = cpu
         self.cores = cores
         self.cache = cache
 
-        # For now assume leftovers are NLSR configuration parameters
-        self.nlsrParameters = params
-
     def __repr__(self):
-        return 'Name: '    + self.name + \
-               ' App: '    + self.app + \
-               ' URIS: '   + str(self.uri_tuples) + \
-               ' CPU: '    + str(self.cpu) + \
-               ' Cores: '  + str(self.cores) + \
-               ' Cache: '  + str(self.cache) + \
-               ' Radius: ' + str(self.radius) + \
-               ' Angle: '  + str(self.angle) + \
-               ' NLSR Parameters: ' + self.nlsrParameters
+        return " Name: {} App: {} Params: {} CPU: {} Cores: {} Cores: {} Cache: {}" \
+               .format(self.name, self.app, self.params, self.cpu, self.cores, self.cache)
 
 class confNdnSwitch:
     def __init__(self, name):
@@ -98,7 +87,7 @@
         self.linkDict = linkDict
 
     def __repr__(self):
-        return 'h1: ' + self.h1 + ' h2: ' + self.h2 + ' params: ' + str(self.linkDict)
+        return "h1: {} h2: {} params: {}".format(self.h1, self.h2, self.linkDict)
 
 def parse_hosts(conf_arq):
     'Parse hosts section from the conf file.'
@@ -109,16 +98,16 @@
 
     items = config.items('nodes')
 
-        #makes a first-pass read to hosts section to find empty host sections
+    # makes a first-pass read to hosts section to find empty host sections
     for item in items:
         name = item[0]
         rest = item[1].split()
         if len(rest) == 0:
             config.set('nodes', name, '_')
-        #updates 'items' list
+    # updates 'items' list
     items = config.items('nodes')
 
-        #makes a second-pass read to hosts section to properly add hosts
+    # makes a second-pass read to hosts section to properly add hosts
     for item in items:
 
         name = item[0]
@@ -203,4 +192,4 @@
         elif line == "[links]\n":
             linkSectionFlag = True
 
-    return links
\ No newline at end of file
+    return links
diff --git a/ndn/experiment_manager.py b/ndn/experiment_manager.py
index 1275a96..0be9f92 100644
--- a/ndn/experiment_manager.py
+++ b/ndn/experiment_manager.py
@@ -38,7 +38,7 @@
 
     def loadModules(self):
         currentDir = os.path.dirname(__file__)
-        experimentDir = "%s/%s" % (currentDir, "experiments")
+        experimentDir = "{}/{}".format(currentDir, "experiments")
         experimentModule = "ndn.experiments"
 
         # Import and register experiments
@@ -46,13 +46,17 @@
             for filename in files:
                 if filename.endswith(".py") and filename != "__init__.py":
                     module = filename.replace(".py", "")
-                    __import__("%s.%s" % (experimentModule, module))
+                    subdir = os.path.basename(root)
+                    if subdir == "experiments":
+                        __import__("{}.{}".format(experimentModule, module))
+                    else:
+                        __import__("{}.{}.{}".format(experimentModule, subdir, module))
 
     def register(self, name, experimentClass):
         if name not in self.experiments:
             self.experiments[name] = experimentClass
         else:
-            raise _ExperimentManager.Error("Experiment '%s' has already been registered" % name)
+            raise _ExperimentManager.Error("Experiment '{}' has already been registered".format(name))
 
     def create(self, name, args):
         if name in self.experiments:
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")
diff --git a/ndn/util.py b/ndn/util.py
index 159a8e8..0398453 100644
--- a/ndn/util.py
+++ b/ndn/util.py
@@ -55,3 +55,28 @@
     prompt = 'mini-ndn> '
     def __init__(self, mininet, stdin=sys.stdin, script=None):
         CLI.__init__(self, mininet, stdin=sys.stdin, script=None)
+
+class ProgramOptions:
+    def __init__(self):
+        self.ctime = 60
+        self.experimentName = None
+        self.nFaces = 3
+        self.templateFile = "minindn.conf"
+        self.routingType = "link-state"
+        self.isNlsrEnabled = True
+        self.isCliEnabled = True
+        self.nlsrSecurity = False
+        self.nPings = 300
+        self.testbed = False
+        self.workDir = "/tmp/minindn"
+        self.resultDir = None
+        self.pctTraffic = 1.0
+        self.cluster = None
+        self.servers = None
+        self.guided = None
+        self.placer = None
+        self.tunnelType = None
+        self.faceType = "udp"
+        self.arguments = None
+        self.csSize = 65536
+        self.strategy = "best-route"
\ No newline at end of file