modification to use cluster version

Change-Id: Iaf169507577deba20d548348532a2e0b91a03249
refs: #3652
diff --git a/bin/minindn b/bin/minindn
index 9eca39c..950dc05 100755
--- a/bin/minindn
+++ b/bin/minindn
@@ -1,6 +1,6 @@
 # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 #
-# Copyright (C) 2015-2016, The University of Memphis,
+# Copyright (C) 2015-2017, The University of Memphis,
 #                          Arizona Board of Regents,
 #                          Regents of the University of California.
 #
@@ -24,9 +24,9 @@
 # This file incorporates work covered by the following copyright and
 # permission notice:
 #
-#   Mininet 2.2.1 License
+#   Mininet 2.3.0d1 License
 #
-#   Copyright (c) 2013-2015 Open Networking Laboratory
+#   Copyright (c) 2013-2016 Open Networking Laboratory
 #   Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
 #   The Leland Stanford Junior University
 #
@@ -65,10 +65,15 @@
 from mininet.link import TCLink
 from mininet.util import ipStr, ipParse
 
+from mininet.examples.cluster import MininetCluster, RoundRobinPlacer, ClusterCleanup
+from mininet.examples.clustercli import ClusterCLI
 
 from ndn import ExperimentManager
-from ndn.ndn_host import NdnHost, CpuLimitedNdnHost
+from ndn.ndn_host import NdnHost, CpuLimitedNdnHost, RemoteNdnHost
 from ndn.conf_parser import parse_hosts, parse_switches, parse_links
+from ndn.remote_ndn_link import RemoteNdnLink, RemoteGRENdnLink
+from ndn.placer import GuidedPlacer, PopulatePlacement
+from ndn.util import ssh, scp
 
 import os.path, time
 import shutil
@@ -78,6 +83,9 @@
 import sys
 import signal
 from subprocess import call
+import glob
+from functools import partial
+import re
 
 from ndn.nlsr import Nlsr, NlsrConfigGenerator
 from ndn.nfd import Nfd
@@ -112,6 +120,11 @@
         self.workDir = "/tmp"
         self.resultDir = None
         self.pctTraffic = 1.0
+        self.cluster = None
+        self.servers = None
+        self.guided = None
+        self.placer = None
+        self.tunnelType = None
 
 def createResultsDir(resultDir, faces, hr):
     if faces == 0:
@@ -181,6 +194,19 @@
     parser.add_argument('--version', '-V', action='version', version='%(prog)s ' + VERSION_NUMBER,
                         help='Displays version information')
 
+    parser.add_argument("--cluster", metavar='localhost,server2,...',
+                        help="Run cluster edition")
+
+    parser.add_argument("--placement", default='guided',
+                        choices=['roundRobin', 'guided'])
+
+    parser.add_argument("--place-list", dest="placeList",
+                        help="""Provide corresponding number of nodes (comma separated) to put on
+                        each node respectively of --cluster when guided placement is used""")
+
+    parser.add_argument("--tunnel-type", dest="tunnelType", default='ssh',
+                        choices=['ssh', 'gre'])
+
     args = parser.parse_args()
 
     options = ProgramOptions()
@@ -197,6 +223,10 @@
     options.workDir = args.workDir
     options.resultDir = args.resultDir
     options.pctTraffic = args.pctTraffic
+    options.cluster = args.cluster
+    options.placement = args.placement
+    options.tunnelType = args.tunnelType
+    options.placeList = args.placeList
 
     if options.experimentName is not None and options.experimentName not in ExperimentManager.getExperimentNames():
         print("No experiment named %s" % options.experimentName)
@@ -205,6 +235,33 @@
     if options.experimentName is not None and options.resultDir is None:
         print("No results folder specified; experiment results will remain in the working directory")
 
+    if options.cluster is not None:
+        servers = options.cluster.split(',')
+        for server in servers:
+            ClusterCleanup.add(server)
+        options.servers = servers
+
+        if options.placement == "roundRobin":
+            options.placement = RoundRobinPlacer
+        elif options.placement == "guided":
+            if options.placeList is None or not re.match("^[0-9,]+$", options.placeList):
+                print("Please specify correctly how many nodes you want to place on each node!")
+                sys.exit(1)
+            else:
+                try:
+                    options.placeList = map(int, options.placeList.split(","))
+                except ValueError:
+                    print("Please specify the nodes correctly, no comma at the beginning/end!")
+                    sys.exit(1)
+
+                PopulatePlacement(options.placeList)
+                options.placement = GuidedPlacer
+
+        if options.tunnelType == "ssh":
+            options.tunnelType = RemoteNdnLink
+        else:
+            options.tunnelType = RemoteGRENdnLink
+
     return options
 
 class NdnTopo(Topo):
@@ -247,6 +304,17 @@
         info('Template file cannot be found. Exiting...\n')
         sys.exit(1)
 
+    if options.cluster is not None and options.placement == GuidedPlacer:
+        num_nodes = 0
+        with open(options.templateFile, 'r') as topo:
+            for line in topo:
+                if ': _' in line:
+                    num_nodes += 1
+
+        if sum(options.placeList) != num_nodes:
+            print("Placement list sum is not equal to number of nodes!")
+            sys.exit(1)
+
     # Use nfd.conf as default configuration for NFD, else use the sample
 
     nfdConfFile = "%s/nfd.conf" % INSTALL_DIR
@@ -259,6 +327,17 @@
 
     call(["sudo", "sed", "-i", 's|default_level [A-Z]*$|default_level $LOG_LEVEL|g', nfdConfFile])
 
+    # Copy nfd.conf to remote hosts - this assumes that NDN versions across
+    # the cluster are at least compatible if not the same
+    if options.cluster is not None:
+        for server in options.servers:
+            if server != "localhost":
+                login = "mininet@%s" % server
+                src = nfdConfFile
+                dst = "%s:/tmp/nfd.conf" % (login)
+                scp(src, dst)
+                ssh(login, "sudo cp /tmp/nfd.conf %s" % src)
+
     if options.resultDir is not None:
         options.resultDir = createResultsDir(options.resultDir, options.nFaces, options.hr)
 
@@ -269,11 +348,15 @@
     if topo.isTCLink == True and topo.isLimited == True:
         net = Mininet(topo,host=CpuLimitedNdnHost,link=TCLink)
     elif topo.isTCLink == True and topo.isLimited == False:
-        net = Mininet(topo,host=NdnHost,link=TCLink)
+        if options.cluster is not None:
+            mn = partial(MininetCluster, servers=options.servers, placement=options.placement)
+            net = mn(topo=topo, host=RemoteNdnHost, link=options.tunnelType)
+        else:
+            net = Mininet(topo, host=NdnHost, link=TCLink)
     elif topo.isTCLink == False and topo.isLimited == True:
-        net = Mininet(topo,host=CpuLimitedNdnHost)
+        net = Mininet(topo, host=CpuLimitedNdnHost)
     else:
-        net = Mininet(topo,host=NdnHost)
+        net = Mininet(topo, host=NdnHost)
 
     t2 = datetime.datetime.now()
 
@@ -369,7 +452,16 @@
 
     if options.resultDir is not None:
         print("Moving results to %s" % options.resultDir)
-        os.system("sudo mv /%s/* %s" % (options.workDir, options.resultDir))
+        for file in glob.glob('%s/*' % options.workDir):
+            shutil.move(file, options.resultDir)
+        if options.cluster is not None:
+            for server in options.servers:
+                if server != "localhost":
+                    login = "mininet@%s" % server
+                    src = "%s:%s/*" % (login, options.workDir)
+                    dst = options.resultDir
+                    scp(src, dst)
+            print("Please clean work directories of other machines before running the cluster again")
 
 def signal_handler(signal, frame):
     print('Cleaning up...')
diff --git a/docs/CLUSTER.md b/docs/CLUSTER.md
new file mode 100644
index 0000000..e1e52ad
--- /dev/null
+++ b/docs/CLUSTER.md
@@ -0,0 +1,25 @@
+Mini-NDN cluster edition
+========================
+
+Mini-NDN cluster edition uses the experimental Mininet cluster edition.
+**Make sure that you can run the Mininet cluster edition by following
+[these instructions](https://github.com/mininet/mininet/wiki/Cluster-Edition-Prototype)**.
+Mini-NDN will use the "mininet" username created in Mininet cluster edition setup.
+
+## Mini-NDN cluster options
+
+To run Mini-NDN cluster on `localhost` and another server `server1` with
+the guided node placement strategy (default), the following command can be used:
+
+    sudo minindn --cluster=localhost,server1 --place-list=1,3
+
+Note that `place-list` specifies the number of nodes to be placed on the corresponding servers
+of the cluster.
+In the example, one node will be placed on `localhost` and three nodes on `server1`.
+Unless specified, the default 4 node topology is used.
+Another placement can be `roundRobin` placement algorithm from Mininet.
+This does not require a place-list.
+
+    sudo minindn --cluster=localhost,server1 --placement roundRobin
+
+By default the tunnel type used is SSH, but GRE tunnel can be specified by `--tunnel-type=gre`
diff --git a/install.sh b/install.sh
index 87dc96e..a474c23 100755
--- a/install.sh
+++ b/install.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 # -*- Mode:bash; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 #
-# Copyright (C) 2015-2016, The University of Memphis,
+# Copyright (C) 2015-2017, The University of Memphis,
 #                          Arizona Board of Regents,
 #                          Regents of the University of California.
 #
@@ -25,9 +25,9 @@
 # This file incorporates work covered by the following copyright and
 # permission notice:
 #
-#   Mininet 2.2.1 License
+#   Mininet 2.3.0d1 License
 #
-#   Copyright (c) 2013-2015 Open Networking Laboratory
+#   Copyright (c) 2013-2016 Open Networking Laboratory
 #   Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
 #   The Leland Stanford Junior University
 #
@@ -214,7 +214,6 @@
 
     sudo mkdir -p "$install_dir"
     sudo cp ndn_utils/client.conf.sample "$install_dir"
-    sudo cp ndn_utils/nlsr.conf "$install_dir"
     sudo cp ndn_utils/topologies/default-topology.conf "$install_dir"
     sudo cp ndn_utils/topologies/minindn.testbed.conf "$install_dir"
     sudo python setup.py install
diff --git a/ndn/ndn_host.py b/ndn/ndn_host.py
index 70d2ffb..7c727ab 100644
--- a/ndn/ndn_host.py
+++ b/ndn/ndn_host.py
@@ -1,6 +1,6 @@
 # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 #
-# Copyright (C) 2015-2016, The University of Memphis,
+# Copyright (C) 2015-2017, The University of Memphis,
 #                          Arizona Board of Regents,
 #                          Regents of the University of California.
 #
@@ -24,9 +24,9 @@
 # This file incorporates work covered by the following copyright and
 # permission notice:
 #
-#   Mininet 2.2.1 License
+#   Mininet 2.3.0d1 License
 #
-#   Copyright (c) 2013-2015 Open Networking Laboratory
+#   Copyright (c) 2013-2016 Open Networking Laboratory
 #   Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
 #   The Leland Stanford Junior University
 #
@@ -59,6 +59,8 @@
 #   without specific, written prior permission.
 
 from mininet.node import CPULimitedHost, Host, Node
+from mininet.examples.cluster import RemoteMixin
+
 from ndn.nfd import Nfd
 
 class NdnHostCommon():
@@ -150,3 +152,7 @@
         "Stop node."
         self.nfd.stop()
         Host.terminate(self)
+
+class RemoteNdnHost(RemoteMixin, NdnHost):
+    "A node on a remote server"
+    pass
diff --git a/ndn/nlsr.py b/ndn/nlsr.py
index 43176b4..3a4b522 100644
--- a/ndn/nlsr.py
+++ b/ndn/nlsr.py
@@ -1,6 +1,6 @@
 # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 #
-# Copyright (C) 2015-2016, The University of Memphis,
+# Copyright (C) 2015-2017, The University of Memphis,
 #                          Arizona Board of Regents,
 #                          Regents of the University of California.
 #
@@ -22,12 +22,15 @@
 # If not, see <http://www.gnu.org/licenses/>.
 
 from mininet.clean import sh
+from mininet.examples.cluster import RemoteMixin
 
 from ndn.ndn_application import NdnApplication
+from ndn.util import ssh, scp
 
-import os
 import shutil
+import os
 import textwrap
+from subprocess import call
 
 class Nlsr(NdnApplication):
     def __init__(self, node):
@@ -60,7 +63,7 @@
         securityDir = "{}/security".format(workDir)
 
         if not os.path.exists(securityDir):
-                os.mkdir(securityDir)
+            os.mkdir(securityDir)
 
         # Create root certificate
         rootName = "/ndn"
@@ -71,8 +74,12 @@
         for host in net.hosts:
             nodeSecurityFolder = "{}/security".format(host.homeFolder)
 
-            if not os.path.exists(nodeSecurityFolder):
-                os.mkdir(nodeSecurityFolder)
+            host.cmd("mkdir -p %s" % nodeSecurityFolder)
+
+            # Create temp folders for remote nodes on this machine (localhost) to store site.key file
+            # from RemoteNodes
+            if not os.path.exists(nodeSecurityFolder) and isinstance(host, RemoteMixin) and host.isRemote:
+                os.makedirs(nodeSecurityFolder)
 
             shutil.copyfile("{}/root.cert".format(securityDir), "{}/root.cert".format(nodeSecurityFolder))
 
@@ -82,8 +89,25 @@
             siteCertFile = "{}/site.cert".format(nodeSecurityFolder)
             Nlsr.createKey(host, siteName, siteKeyFile)
 
+            # Copy siteKeyFile from remote for ndnsec-certgen
+            if isinstance(host, RemoteMixin) and host.isRemote:
+                login = "mininet@{}".format(host.server)
+                src = "{}:{}".format(login, siteKeyFile)
+                dst = siteKeyFile
+                scp(src, dst)
+
             # Root key is in root namespace, must sign site key and then install on host
             sh("ndnsec-certgen -N {} -s {} -p {} {} > {}".format(siteName, rootName, siteName, siteKeyFile, siteCertFile))
+
+            # Copy root.cert and site.cert from localhost to remote host
+            if isinstance(host, RemoteMixin) and host.isRemote:
+                login = "mininet@{}".format(host.server)
+                src = "{}/site.cert".format(nodeSecurityFolder)
+                src2 = "{}/root.cert".format(nodeSecurityFolder)
+                dst = "{}:/tmp/".format(login)
+                scp(src, src2, dst)
+                host.cmd("mv /tmp/*.cert {}".format(nodeSecurityFolder))
+
             host.cmd("ndnsec-cert-install -f {}".format(siteCertFile))
 
             # Create operator certificate
@@ -106,7 +130,6 @@
     ROUTING_HYPERBOLIC = "hr"
 
     def __init__(self, node, isSecurityEnabled):
-        node.cmd("sudo cp /usr/local/etc/mini-ndn/nlsr.conf nlsr.conf")
         self.node = node
         self.isSecurityEnabled = isSecurityEnabled
 
@@ -120,30 +143,29 @@
 
     def createConfigFile(self):
 
-        filePath = "%s/nlsr.conf" % self.node.homeFolder
+        tmp_conf = "/tmp/nlsr.conf"
 
-        configFile = open(filePath, 'r')
-        oldContent = configFile.read()
+        configFile = open(tmp_conf, 'w')
+        configFile.write(self.__getConfig())
         configFile.close()
 
-        newContent = oldContent.replace("$GENERAL_SECTION", self.__getGeneralSection())
-        newContent = newContent.replace("$NEIGHBORS_SECTION", self.__getNeighborsSection())
-        newContent = newContent.replace("$HYPERBOLIC_SECTION", self.__getHyperbolicSection())
-        newContent = newContent.replace("$FIB_SECTION", self.__getFibSection())
-        newContent = newContent.replace("$ADVERTISING_SECTION", self.__getAdvertisingSection())
-        newContent = newContent.replace("$SECURITY_SECTION", self.__getSecuritySection())
+        # If this node is a remote node scp the nlsr.conf file to its /tmp/nlsr.conf
+        if isinstance(self.node, RemoteMixin) and self.node.isRemote:
+            login = "mininet@%s" % self.node.server
+            src = tmp_conf
+            dst = "%s:%s" % (login, tmp_conf)
+            scp(src, dst)
 
-        configFile = open(filePath, 'w')
-        configFile.write(newContent)
-        configFile.close()
+        # Copy nlsr.conf to home folder
+        self.node.cmd("mv %s nlsr.conf" % tmp_conf)
 
     def __getConfig(self):
 
-        config =  self.__getGeneralSection()
-        config += self.__getNeighborsSection()
-        config += self.__getHyperbolicSection()
-        config += self.__getFibSection()
-        config += self.__getAdvertisingSection()
+        config  = self.__getGeneralSection() + "\n"
+        config += self.__getNeighborsSection() + "\n"
+        config += self.__getHyperbolicSection() + "\n"
+        config += self.__getFibSection() + "\n"
+        config += self.__getAdvertisingSection() + "\n"
         config += self.__getSecuritySection()
 
         return config
diff --git a/ndn/placer.py b/ndn/placer.py
new file mode 100644
index 0000000..ba521b8
--- /dev/null
+++ b/ndn/placer.py
@@ -0,0 +1,87 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2017, 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/>.
+#
+# This file incorporates work covered by the following copyright and
+# permission notice:
+#
+#   Mininet 2.3.0d1 License
+#
+#   Copyright (c) 2013-2016 Open Networking Laboratory
+#   Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
+#   The Leland Stanford Junior University
+#
+#   Original authors: Bob Lantz and Brandon Heller
+#
+#   We are making Mininet available for public use and benefit with the
+#   expectation that others will use, modify and enhance the Software and
+#   contribute those enhancements back to the community. However, since we
+#   would like to make the Software available for broadest use, with as few
+#   restrictions as possible permission is hereby granted, free of charge, to
+#   any person obtaining a copy of this Software to deal in the Software
+#   under the copyrights without restriction, including without limitation
+#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#   and/or sell copies of the Software, and to permit persons to whom the
+#   Software is furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included
+#   in all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+#   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+#   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+#   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+#   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+#   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+#   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+#   The name and trademarks of copyright holder(s) may NOT be used in
+#   advertising or publicity pertaining to the Software or any derivatives
+#   without specific, written prior permission.
+
+from mininet.examples.cluster import Placer
+
+nodePlace = []
+
+class PopulatePlacement():
+    def __init__( self, placeList ):
+        global nodePlace
+        nodePlace = placeList
+
+class GuidedPlacer( Placer ):
+    "Guided placement"
+    def __init__( self, *args, **kwargs ):
+        Placer.__init__( self, *args, **kwargs )
+        self.count = 0
+
+    def place( self, nodename ):
+        assert nodename  #please pylint
+        while(True):
+            global nodePlace
+            if nodePlace[self.count] != 0:
+                nodePlace[self.count] -= 1
+                # args[self.count] is not zero, hence return the server at that position
+                # so that if args[0] is 7 and servers[0] is Europa then place 7 nodes on Europa
+                return self.servers[self.count]
+            else:
+                # while makes sure we go back to the if after this
+                self.count += 1
diff --git a/ndn/remote_ndn_link.py b/ndn/remote_ndn_link.py
new file mode 100644
index 0000000..6dd64f3
--- /dev/null
+++ b/ndn/remote_ndn_link.py
@@ -0,0 +1,90 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2017, 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/>.
+#
+# This file incorporates work covered by the following copyright and
+# permission notice:
+#
+#   Mininet 2.3.0d1 License
+#
+#   Copyright (c) 2013-2016 Open Networking Laboratory
+#   Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
+#   The Leland Stanford Junior University
+#
+#   Original authors: Bob Lantz and Brandon Heller
+#
+#   We are making Mininet available for public use and benefit with the
+#   expectation that others will use, modify and enhance the Software and
+#   contribute those enhancements back to the community. However, since we
+#   would like to make the Software available for broadest use, with as few
+#   restrictions as possible permission is hereby granted, free of charge, to
+#   any person obtaining a copy of this Software to deal in the Software
+#   under the copyrights without restriction, including without limitation
+#   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#   and/or sell copies of the Software, and to permit persons to whom the
+#   Software is furnished to do so, subject to the following conditions:
+#
+#   The above copyright notice and this permission notice shall be included
+#   in all copies or substantial portions of the Software.
+#
+#   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+#   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+#   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+#   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+#   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+#   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+#   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+#   The name and trademarks of copyright holder(s) may NOT be used in
+#   advertising or publicity pertaining to the Software or any derivatives
+#   without specific, written prior permission.
+
+from mininet.link import TCLink
+from mininet.examples.cluster import RemoteLink, RemoteGRELink
+
+class RemoteNdnLink( TCLink, RemoteLink ):
+    "A RemoteLink is a link between nodes which may be on different servers"
+
+    def __init__( self, node1, node2, **kwargs ):
+        """Initialize a RemoteLink
+           see Link() for parameters"""
+        # Create links on remote node
+        self.node1 = node1
+        self.node2 = node2
+        self.tunnel = None
+        kwargs.setdefault( 'params1', {} )
+        kwargs.setdefault( 'params2', {} )
+        self.cmd = None  # satisfy pylint
+        TCLink.__init__( self, node1, node2, **kwargs )
+
+class RemoteGRENdnLink( TCLink, RemoteGRELink ):
+    def __init__(self, node1, node2, **kwargs):
+        """Initialize a RemoteLink
+           see Link() for parameters"""
+        # Create links on remote node
+        self.node1 = node1
+        self.node2 = node2
+        self.tunnel = None
+        kwargs.setdefault( 'params1', {} )
+        kwargs.setdefault( 'params2', {} )
+        self.cmd = None  # satisfy pylint
+        TCLink.__init__( self, node1, node2, **kwargs )
diff --git a/ndn/util.py b/ndn/util.py
new file mode 100644
index 0000000..19a5356
--- /dev/null
+++ b/ndn/util.py
@@ -0,0 +1,39 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2017, 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 subprocess import call
+
+sshbase = [ 'ssh', '-q', '-t', '-i/home/mininet/.ssh/id_rsa' ]
+scpbase = [ 'scp', '-i', '/home/mininet/.ssh/id_rsa' ]
+devnull = open('/dev/null', 'w')
+
+def ssh(login, cmd):
+    rcmd = sshbase + [login, cmd]
+    call(rcmd, stdout=devnull, stderr=devnull)
+
+def scp(*args):
+    tmp = []
+    for arg in args:
+        tmp.append(arg)
+    rcmd = scpbase + tmp
+    call(rcmd, stdout=devnull, stderr=devnull)
diff --git a/ndn_utils/nlsr.conf b/ndn_utils/nlsr.conf
deleted file mode 100644
index 492ee0d..0000000
--- a/ndn_utils/nlsr.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-; the general section contains all the general settings for router
-
-$GENERAL_SECTION
-
-; the neighbors section contains the configuration for router's neighbors and hello's behavior
-
-$NEIGHBORS_SECTION
-
-; the hyperbolic section contains the configuration settings of enabling a router to calculate
-; routing table using [hyperbolic routing table calculation](http://arxiv.org/abs/0805.1266) method
-
-$HYPERBOLIC_SECTION
-
-
-; the fib section is used to configure fib entry's type to ndn FIB updated by NLSR
-
-$FIB_SECTION
-
-; the advertising section contains the configuration settings of the name prefixes
-; hosted by this router
-
-$ADVERTISING_SECTION
-
-$SECURITY_SECTION