**breaking** mini-ndn: re-design

refs: #5062

Everything is now done through examples like Mininet.
bin/minindn no longer provided as a binary installed in the system
bin/minindnedit GUI: will no longer be maintained
Remove cluster edition, will be re-introduced later

Change-Id: Id4ef137cb2a04d1b0dd24d01941757363bbf7d26
diff --git a/examples/ip_rounting_experiment.py b/examples/ip_rounting_experiment.py
new file mode 100644
index 0000000..a6a82c0
--- /dev/null
+++ b/examples/ip_rounting_experiment.py
@@ -0,0 +1,53 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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 mininet.log import setLogLevel, info
+
+from minindn.minindn import Minindn
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+from minindn.helpers.ip_routing_helper import IPRoutingHelper
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    Minindn.cleanUp()
+    Minindn.verifyDependencies()
+
+    ndn = Minindn()
+
+    ndn.start()
+
+    info('Starting NFD on nodes\n')
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    info('Starting NLSR on nodes\n')
+    nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr)
+
+    # Calculate all routes for IP routing
+    IPRoutingHelper.calcAllRoutes(ndn.net)
+    info("IP routes configured, start ping\n")
+
+    ndn.net.pingAll()
+
+    ndn.net.stop()
diff --git a/examples/mnndn.py b/examples/mnndn.py
new file mode 100644
index 0000000..d989633
--- /dev/null
+++ b/examples/mnndn.py
@@ -0,0 +1,49 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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 mininet.log import setLogLevel, info
+
+from minindn.minindn import Minindn
+from minindn.util import MiniNDNCLI
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    Minindn.cleanUp()
+    Minindn.verifyDependencies()
+
+    ndn = Minindn()
+
+    ndn.start()
+
+    info('Starting NFD on nodes\n')
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    info('Starting NLSR on nodes\n')
+    nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr)
+
+    MiniNDNCLI(ndn.net)
+
+    ndn.stop()
diff --git a/examples/nlsr/advertised-delayed-start.py b/examples/nlsr/advertised-delayed-start.py
new file mode 100644
index 0000000..8856fbd
--- /dev/null
+++ b/examples/nlsr/advertised-delayed-start.py
@@ -0,0 +1,79 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+import sys
+
+from mininet.log import setLogLevel, info
+from mininet.topo import Topo
+
+from minindn.minindn import Minindn
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+
+from nlsr_common import getParser
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    topo = Topo()
+    h1 = topo.addHost('h1')
+    h2 = topo.addHost('h2')
+    topo.addLink(h1, h2, delay='10ms')
+
+    ndn = Minindn(parser=getParser(), topo=topo)
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    nlsrs = AppManager(ndn, [], Nlsr)
+
+    host1 = ndn.net.hosts[0]
+    nlsrs.startOnNode(host1, security=args.security, faceType=args.faceType,
+                      nFaces=args.faces, routingType=args.routingType)
+
+
+    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 = ndn.net.hosts[1]
+    nlsrs.startOnNode(host2, security=args.security, faceType=args.faceType,
+                      nFaces=args.faces, routingType=args.routingType)
+
+    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))
+        ndn.stop()
+        sys.exit(1)
+
+    ndn.stop()
diff --git a/examples/nlsr/delayed_start.py b/examples/nlsr/delayed_start.py
new file mode 100644
index 0000000..59b2f54
--- /dev/null
+++ b/examples/nlsr/delayed_start.py
@@ -0,0 +1,64 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+
+from mininet.log import setLogLevel, info
+
+from minindn.minindn import Minindn
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+from minindn.helpers.experiment import Experiment
+
+from nlsr_common import getParser
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    ndn = Minindn(parser=getParser())
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    nlsrs = AppManager(ndn, [], Nlsr)
+
+    i = 1
+    info('Starting NLSR on nodes\n')
+    for host in ndn.net.hosts:
+        nlsrs.startOnNode(host, security=args.security, sync=args.sync, faceType=args.faceType,
+                          nFaces=args.faces, routingType=args.routingType)
+
+        # Wait 1/2 minute between starting NLSRs
+        # Wait 1 hour before starting last NLSR
+        if i == len(ndn.net.hosts) - 1:
+            info('Sleeping 1 hour before starting last NLSR\n')
+            time.sleep(3600)
+        else:
+            time.sleep(30)
+        i += 1
+
+    Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
+
+    ndn.stop()
diff --git a/examples/nlsr/mcn_failure.py b/examples/nlsr/mcn_failure.py
new file mode 100644
index 0000000..1bd0449
--- /dev/null
+++ b/examples/nlsr/mcn_failure.py
@@ -0,0 +1,90 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+
+from mininet.log import setLogLevel, info
+
+from minindn.minindn import Minindn
+from minindn.util import MiniNDNCLI
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+from minindn.helpers.experiment import Experiment
+from minindn.helpers.nfdc import Nfdc
+from minindn.helpers.ndnpingclient import NDNPingClient
+
+from nlsr_common import getParser
+
+def mcnFailure(ndn, nfds, nlsrs, args):
+    Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
+    if args.nPings != 0:
+        Experiment.setupPing(ndn.net.hosts, Nfdc.STRATEGY_BEST_ROUTE)
+        pingedDict = Experiment.startPctPings(ndn.net, args.nPings, args.pctTraffic)
+
+    PING_COLLECTION_TIME_BEFORE_FAILURE = 60
+    PING_COLLECTION_TIME_AFTER_RECOVERY = 120
+
+    time.sleep(PING_COLLECTION_TIME_BEFORE_FAILURE)
+
+    mcn = max(ndn.net.hosts, key=lambda host: len(host.intfNames()))
+
+    info('Bringing down node {}\n'.format(mcn.name))
+    nlsrs[mcn.name].stop()
+    nfds[mcn.name].stop()
+
+    time.sleep(args.ctime)
+
+    info('Bringing up node {}\n'.format(mcn.name))
+    nfds[mcn.name].start()
+    nlsrs[mcn.name].start()
+
+    # Restart pings
+    if args.nPings != 0:
+        Experiment.setupPing([mcn], Nfdc.STRATEGY_BEST_ROUTE)
+        for nodeToPing in pingedDict[mcn]:
+            NDNPingClient.ping(mcn, nodeToPing, PING_COLLECTION_TIME_AFTER_RECOVERY)
+
+        time.sleep(PING_COLLECTION_TIME_AFTER_RECOVERY)
+
+    Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    ndn = Minindn(parser=getParser())
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync,
+                       security=args.security, faceType=args.faceType,
+                       nFaces=args.faces, routingType=args.routingType)
+
+    mcnFailure(ndn, nfds, nlsrs, args)
+
+    if args.isCliEnabled:
+        MiniNDNCLI(ndn.net)
+
+    ndn.stop()
diff --git a/examples/nlsr/multiple_failure.py b/examples/nlsr/multiple_failure.py
new file mode 100644
index 0000000..48d1afd
--- /dev/null
+++ b/examples/nlsr/multiple_failure.py
@@ -0,0 +1,109 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+
+from mininet.log import setLogLevel, info
+
+from minindn.minindn import Minindn
+from minindn.util import MiniNDNCLI
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+from minindn.helpers.experiment import Experiment
+from minindn.helpers.nfdc import Nfdc
+from minindn.helpers.ndnpingclient import NDNPingClient
+
+from nlsr_common import getParser
+
+def multipleFailure(ndn, nfds, nlsrs, args):
+
+    Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
+    Experiment.setupPing(ndn.net.hosts, Nfdc.STRATEGY_BEST_ROUTE)
+
+    PING_COLLECTION_TIME_BEFORE_FAILURE = 60
+    FAILURE_INTERVAL = 60
+    RECOVERY_INTERVAL = 60
+
+    # This is the number of pings required to make it through the full experiment
+    nInitialPings = (PING_COLLECTION_TIME_BEFORE_FAILURE +
+                     len(ndn.net.hosts) * (FAILURE_INTERVAL + RECOVERY_INTERVAL))
+    print('Scheduling with {} initial pings'.format(nInitialPings))
+
+    pingedDict = Experiment.startPctPings(ndn.net, nInitialPings, args.pctTraffic)
+    time.sleep(PING_COLLECTION_TIME_BEFORE_FAILURE)
+
+    nNodesRemainingToFail = len(ndn.net.hosts)
+
+    for host in ndn.net.hosts:
+        # Fail the node
+        info('Bringing down node {}\n'.format(host.name))
+        nlsrs[host.name].stop()
+        nfds[host.name].stop()
+
+        # Stay in failure state for FAILURE_INTERVAL seconds
+        time.sleep(FAILURE_INTERVAL)
+
+        # Bring the node back up
+        start_time = time.time()
+        info('Bringing up node {}\n'.format(host.name))
+        nfds[host.name].start()
+        nlsrs[host.name].start()
+        Experiment.setupPing([host], Nfdc.STRATEGY_BEST_ROUTE)
+
+        recovery_time = int(time.time() - start_time)
+
+        # Number of pings required to reach the end of the test
+        nNodesRemainingToFail -= 1
+        nPings = ((RECOVERY_INTERVAL - recovery_time) +
+                  nNodesRemainingToFail * (FAILURE_INTERVAL + RECOVERY_INTERVAL))
+
+        info('Scheduling with {} remaining pings\n'.format(nPings))
+
+        # Restart pings
+        for nodeToPing in pingedDict[host]:
+            NDNPingClient.ping(host, nodeToPing, nPings)
+
+        time.sleep(RECOVERY_INTERVAL - recovery_time)
+
+    #Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    ndn = Minindn(parser=getParser())
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync,
+                       security=args.security, faceType=args.faceType,
+                       nFaces=args.faces, routingType=args.routingType)
+
+    multipleFailure(ndn, nfds, nlsrs, args)
+
+    if args.isCliEnabled:
+        MiniNDNCLI(ndn.net)
+
+    ndn.stop()
diff --git a/examples/nlsr/nlsr_common.py b/examples/nlsr/nlsr_common.py
new file mode 100644
index 0000000..5ec7f7c
--- /dev/null
+++ b/examples/nlsr/nlsr_common.py
@@ -0,0 +1,57 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import argparse
+
+def getParser():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--ctime', type=int, default=60,
+                        help='Specify convergence time for the topology (Default: 60 seconds)')
+
+    parser.add_argument('--faces', type=int, default=3,
+                        help='Specify number of max faces per prefix for NLSR 0-60')
+
+    parser.add_argument('--routing', dest='routingType', default='link-state',
+                        choices=['link-state', 'hr', 'dry'],
+                        help='''Choose routing type, dry = link-state is used
+                                but hr is calculated for comparision.''')
+
+    parser.add_argument('--sync', dest='sync', default='psync',
+                        choices=['chronosync', 'psync'],
+                        help='choose the sync protocol to be used by NLSR.')
+
+    parser.add_argument('--security', action='store_true', dest='security',
+                        help='Enables NLSR security')
+
+    parser.add_argument('--face-type', dest='faceType', default='udp', choices=['udp', 'tcp'])
+
+    parser.add_argument('--no-cli', action='store_false', dest='isCliEnabled',
+                        help='Run experiments and exit without showing the command line interface')
+
+    parser.add_argument('--pct-traffic', dest='pctTraffic', type=float, default=1.0,
+                        help='Specify the percentage of nodes each node should ping')
+
+    parser.add_argument('--nPings', type=int, default=300,
+                        help='Number of pings to perform between each node in the experiment')
+
+    return parser
diff --git a/examples/nlsr/pingall.py b/examples/nlsr/pingall.py
new file mode 100644
index 0000000..002ace0
--- /dev/null
+++ b/examples/nlsr/pingall.py
@@ -0,0 +1,63 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+
+from mininet.log import setLogLevel
+
+from minindn.minindn import Minindn
+from minindn.util import MiniNDNCLI
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+from minindn.helpers.experiment import Experiment
+from minindn.helpers.nfdc import Nfdc
+
+from nlsr_common import getParser
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    ndn = Minindn(parser=getParser())
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync,
+                       security=args.security, faceType=args.faceType,
+                       nFaces=args.faces, routingType=args.routingType,
+                       logLevel='ndn.*=TRACE:nlsr.*=TRACE')
+
+    Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=False)
+
+    if args.nPings != 0:
+        Experiment.setupPing(ndn.net.hosts, Nfdc.STRATEGY_BEST_ROUTE)
+        Experiment.startPctPings(ndn.net, args.nPings, args.pctTraffic)
+
+        time.sleep(args.nPings + 10)
+
+    if args.isCliEnabled:
+        MiniNDNCLI(ndn.net)
+
+    ndn.stop()
diff --git a/examples/nlsr/prefix_propogation.py b/examples/nlsr/prefix_propogation.py
new file mode 100644
index 0000000..7ea027c
--- /dev/null
+++ b/examples/nlsr/prefix_propogation.py
@@ -0,0 +1,84 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+
+from mininet.log import setLogLevel, info
+
+from minindn.minindn import Minindn
+from minindn.util import MiniNDNCLI
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.apps.nlsr import Nlsr
+from minindn.helpers.experiment import Experiment
+
+from nlsr_common import getParser
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    ndn = Minindn(parser=getParser())
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+    nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync,
+                       security=args.security, faceType=args.faceType,
+                       nFaces=args.faces, routingType=args.routingType)
+
+    Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
+
+    firstNode = ndn.net.hosts[0]
+
+    if args.security:
+        firstNode.cmd('ndnsec-set-default /ndn/{}-site/%C1.Operator/op'.format(firstNode.name))
+
+    info('Testing advertise\n')
+    firstNode.cmd('nlsrc advertise /testPrefix')
+    time.sleep(30)
+
+    for host in ndn.net.hosts:
+        if host.name != firstNode.name:
+            if (int(host.cmd('nfdc fib | grep testPrefix | wc -l')) != 1 or
+               int(host.cmd('nlsrc status | grep testPrefix | wc -l')) != 1):
+                info('Advertise test failed\n')
+                ndn.stop()
+                sys.exit(1)
+
+    info('Testing withdraw\n')
+    firstNode.cmd('nlsrc withdraw /testPrefix')
+    time.sleep(30)
+
+    for host in ndn.net.hosts:
+        if host.name != firstNode.name:
+            if (int(host.cmd('nfdc fib | grep testPrefix | wc -l')) != 0 or
+               int(host.cmd('nlsrc status | grep testPrefix | wc -l')) != 0):
+                info('Withdraw test failed\n')
+                ndn.stop()
+                sys.exit(1)
+
+    if args.isCliEnabled:
+        MiniNDNCLI(ndn.net)
+
+    ndn.stop()
diff --git a/examples/psync/full_sync.py b/examples/psync/full_sync.py
new file mode 100644
index 0000000..1a54a73
--- /dev/null
+++ b/examples/psync/full_sync.py
@@ -0,0 +1,81 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+import sys
+
+from mininet.log import setLogLevel, info
+
+from minindn.minindn import Minindn
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.helpers.nfdc import Nfdc
+
+def registerRouteToAllNeighbors(ndn, host, syncPrefix):
+    for node in ndn.net.hosts:
+        for neighbor in node.connectionsTo(host):
+            ip = node.IP(neighbor[0])
+            Nfdc.createFace(host, ip)
+            Nfdc.registerRoute(host, syncPrefix, ip)
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    ndn = Minindn()
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+
+    syncPrefix = "/sync"
+    numUserPrefixesPerNode = 2
+    maxUpdatesPerUserPrefixPerNode = 3
+
+    for host in ndn.net.hosts:
+        Nfdc.setStrategy(host, syncPrefix, Nfdc.STRATEGY_MULTICAST)
+        registerRouteToAllNeighbors(ndn, host, syncPrefix)
+
+    info('Starting psync-full-sync on all the nodes\n')
+    for host in ndn.net.hosts:
+        host.cmd('export NDN_LOG=examples.FullSyncApp=INFO')
+        host.cmd('psync-full-sync {} {} {} {} &> psync.logs &'
+                 .format(syncPrefix, host.name, numUserPrefixesPerNode,
+                         maxUpdatesPerUserPrefixPerNode))
+
+    info('Sleeping 5 minutes for convergence\n')
+    # Estimated time for 4 node default topology
+    time.sleep(300)
+
+    totalUpdates = int(host.cmd('grep -r Update {}/*/psync.logs | wc -l'
+                                .format(args.workDir)))
+
+    expectedUpdates = (maxUpdatesPerUserPrefixPerNode *
+                      len(ndn.net.hosts) * (len(ndn.net.hosts) - 1) * numUserPrefixesPerNode)
+
+    if totalUpdates == expectedUpdates:
+        info('PSync full sync has successfully converged.\n')
+    else:
+        info('PSync full sync convergence was not successful. Exiting...\n')
+        ndn.stop()
+        sys.exit(1)
diff --git a/examples/psync/partial_sync.py b/examples/psync/partial_sync.py
new file mode 100644
index 0000000..13f2761
--- /dev/null
+++ b/examples/psync/partial_sync.py
@@ -0,0 +1,67 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import time
+import sys
+
+from mininet.log import setLogLevel, info
+from mininet.topo import Topo
+
+from minindn.minindn import Minindn
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    topo = Topo()
+    topo.addHost('h1')
+
+    ndn = Minindn(topo=topo)
+    args = ndn.args
+
+    ndn.start()
+
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+
+    host1 = ndn.net.hosts[0]
+    host1.cmd('export NDN_LOG=examples.PartialSyncProducerApp=INFO')
+    host1.cmd('psync-producer /sync /{} 10 1 &> producer.log &'.format(host1.name))
+    time.sleep(1)
+
+    host1.cmd('export NDN_LOG=examples.PartialSyncConsumerApp=INFO:$NDN_LOG')
+    host1.cmd('psync-consumer /sync 5 &> consumer.log &')
+
+    info('Sleeping 90 seconds for convergence\n')
+    time.sleep(90)
+
+    consumerSubs = int(host1.cmd('cat consumer.log | grep -c Subscribing'))
+    consumerUpdates = int(host1.cmd('cat consumer.log | grep -c Update'))
+    producerPublish = int(host1.cmd('cat producer.log | grep -c Publish'))
+
+    if consumerSubs == 5 and consumerUpdates == 5 and producerPublish == 10:
+        info('PSync partial sync has successfully converged.\n')
+    else:
+        info('PSync partial sync convergence was not successful. Exiting...\n')
+        ndn.stop()
+        sys.exit(1)
diff --git a/examples/static_routing_experiment.py b/examples/static_routing_experiment.py
new file mode 100644
index 0000000..a5d9b04
--- /dev/null
+++ b/examples/static_routing_experiment.py
@@ -0,0 +1,100 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2019, 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/>.
+
+import argparse
+import sys
+
+from mininet.log import setLogLevel, info
+from mininet.topo import Topo
+
+from minindn.minindn import Minindn
+from minindn.util import MiniNDNCLI
+from minindn.apps.app_manager import AppManager
+from minindn.apps.nfd import Nfd
+from minindn.helpers.ndn_routing_helper import NdnRoutingHelper
+
+if __name__ == '__main__':
+    setLogLevel('info')
+
+    Minindn.cleanUp()
+    Minindn.verifyDependencies()
+
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--face-type', dest='faceType', default='udp', choices=['udp', 'tcp'])
+    parser.add_argument('--routing', dest='routingType', default='link-state',
+                         choices=['link-state', 'hr', 'dry'],
+                         help='''Choose routing type, dry = link-state is used
+                                 but hr is calculated for comparision.''')
+
+    '''
+    Experiment run with default topology, test cases won't work with other topologies
+                          # With calculateNPossibleRoutes,
+            10            # routing = hr, N = All, from A, 3 routes needs to added to NFD.
+        a +++++++ b       # a - b  -- cost 10
+        +         +       # a - c  -- cost 10
+     10 +         + 10    # a - d  -- cost 20
+        +         +       # Same goes for B being a source.
+        c         d       #
+    '''
+    topo = Topo()
+    a = topo.addHost('a')
+    b = topo.addHost('b')
+    c = topo.addHost('c')
+    d = topo.addHost('d')
+    topo.addLink(a, b, delay='10ms')
+    topo.addLink(a, c, delay='10ms')
+    topo.addLink(b, d, delay='10ms')
+
+    ndn = Minindn(parser=parser, topo=topo)
+
+    ndn.start()
+
+    info('Starting NFD on nodes\n')
+    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
+
+    info('Adding static routes to NFD\n')
+    grh = NdnRoutingHelper(ndn.net, ndn.args.faceType, ndn.args.routingType)
+    # For all host, pass ndn.net.hosts or a list, [ndn.net['a'], ..] or [ndn.net.hosts[0],.]
+    grh.addOrigin([ndn.net['a']], ["/abc"])
+    grh.calculateNPossibleRoutes()
+
+    '''
+    prefix "/abc" is advertise from node A, it should be reachable from all other nodes.
+    '''
+    routesFromA = ndn.net['a'].cmd("nfdc route | grep -v '/localhost/nfd'")
+    if '/ndn/b-site/b' not in routesFromA or \
+       '/ndn/c-site/c' not in routesFromA or \
+       '/ndn/d-site/d' not in routesFromA:
+        info("Route addition failed\n")
+
+    routesToPrefix = ndn.net['b'].cmd("nfdc fib | grep '/abc'")
+    if '/abc' not in routesToPrefix:
+        info("Missing route to advertised prefix, Route addition failed\n")
+        ndn.net.stop()
+        sys.exit(1)
+
+    info('Route addition to NFD completed\n')
+
+    MiniNDNCLI(ndn.net)
+
+    ndn.stop()