**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/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()