Vince Lehman | b8b1806 | 2015-07-14 13:07:22 -0500 | [diff] [blame] | 1 | # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | # |
| 3 | # Copyright (C) 2015 The University of Memphis, |
| 4 | # Arizona Board of Regents, |
| 5 | # Regents of the University of California. |
| 6 | # |
| 7 | # This file is part of Mini-NDN. |
| 8 | # See AUTHORS.md for a complete list of Mini-NDN authors and contributors. |
| 9 | # |
| 10 | # Mini-NDN is free software: you can redistribute it and/or modify |
| 11 | # it under the terms of the GNU General Public License as published by |
| 12 | # the Free Software Foundation, either version 3 of the License, or |
| 13 | # (at your option) any later version. |
| 14 | # |
| 15 | # Mini-NDN is distributed in the hope that it will be useful, |
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | # GNU General Public License for more details. |
| 19 | # |
| 20 | # You should have received a copy of the GNU General Public License |
| 21 | # along with Mini-NDN, e.g., in COPYING.md file. |
| 22 | # If not, see <http://www.gnu.org/licenses/>. |
| 23 | # |
| 24 | # This file incorporates work covered by the following copyright and |
| 25 | # permission notice: |
| 26 | # |
| 27 | # Mininet 2.2.1 License |
| 28 | # |
| 29 | # Copyright (c) 2013-2015 Open Networking Laboratory |
| 30 | # Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of |
| 31 | # The Leland Stanford Junior University |
| 32 | # |
| 33 | # Original authors: Bob Lantz and Brandon Heller |
| 34 | # |
| 35 | # We are making Mininet available for public use and benefit with the |
| 36 | # expectation that others will use, modify and enhance the Software and |
| 37 | # contribute those enhancements back to the community. However, since we |
| 38 | # would like to make the Software available for broadest use, with as few |
| 39 | # restrictions as possible permission is hereby granted, free of charge, to |
| 40 | # any person obtaining a copy of this Software to deal in the Software |
| 41 | # under the copyrights without restriction, including without limitation |
| 42 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 43 | # and/or sell copies of the Software, and to permit persons to whom the |
| 44 | # Software is furnished to do so, subject to the following conditions: |
| 45 | # |
| 46 | # The above copyright notice and this permission notice shall be included |
| 47 | # in all copies or substantial portions of the Software. |
| 48 | # |
| 49 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 50 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 51 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 52 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 53 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 54 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 55 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 56 | # |
| 57 | # The name and trademarks of copyright holder(s) may NOT be used in |
| 58 | # advertising or publicity pertaining to the Software or any derivatives |
| 59 | # without specific, written prior permission. |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 60 | |
| 61 | from mininet.topo import Topo |
| 62 | from mininet.net import Mininet |
| 63 | from mininet.log import setLogLevel, output, info |
| 64 | from mininet.cli import CLI |
| 65 | from mininet.link import TCLink |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 66 | from mininet.util import ipStr, ipParse |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 67 | |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 68 | |
| 69 | from ndn import ExperimentManager |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 70 | from ndn.ndn_host import NdnHost, CpuLimitedNdnHost |
Vince Lehman | fbd47c9 | 2015-10-14 16:00:06 -0500 | [diff] [blame] | 71 | from ndn.conf_parser import parse_hosts, parse_switches, parse_links |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 72 | |
| 73 | import os.path, time |
| 74 | import optparse |
| 75 | import datetime |
ashu | 01b62f7 | 2015-03-12 15:16:11 -0500 | [diff] [blame] | 76 | from os.path import expanduser |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 77 | import sys |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 78 | |
| 79 | from ndn.nlsr import Nlsr, NlsrConfigGenerator |
ashu | 34c3ee0 | 2015-03-25 14:41:14 -0500 | [diff] [blame] | 80 | from ndn.nfd import Nfd |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 81 | |
Vince Lehman | e9f116d | 2015-07-15 10:40:21 -0500 | [diff] [blame] | 82 | VERSION_NUMBER = "0.1.0" |
| 83 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 84 | def printExperimentNames(option, opt, value, parser): |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 85 | experimentNames = ExperimentManager.getExperimentNames() |
| 86 | |
| 87 | print "Mini-NDN experiments:" |
| 88 | for experiment in experimentNames: |
| 89 | print " %s" % experiment |
| 90 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 91 | sys.exit() |
| 92 | |
Vince Lehman | e9f116d | 2015-07-15 10:40:21 -0500 | [diff] [blame] | 93 | def printVersion(option, opt, value, parser): |
| 94 | print "Mini-NDN v%s" % VERSION_NUMBER |
| 95 | sys.exit() |
| 96 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 97 | class ProgramOptions: |
| 98 | def __init__(self): |
| 99 | self.ctime = 60 |
| 100 | self.experimentName = None |
| 101 | self.nFaces = 3 |
| 102 | self.templateFile = "minindn.conf" |
| 103 | self.hr = False |
| 104 | self.isCliEnabled = True |
| 105 | self.nPings = 300 |
| 106 | self.testbed = False |
Ashlesh Gawande | 1b66369 | 2015-10-14 16:38:10 -0500 | [diff] [blame] | 107 | self.workDir = "/tmp" |
Ashlesh Gawande | d829bfc | 2015-10-14 16:38:10 -0500 | [diff] [blame^] | 108 | self.resultDir = None |
| 109 | |
| 110 | def createResultsDir(resultDir, faces, hr): |
| 111 | if faces == 0: |
| 112 | faces = "all" |
| 113 | |
| 114 | if hr: |
| 115 | routingType = "/hr/" |
| 116 | else: |
| 117 | routingType = "/ls/" |
| 118 | |
| 119 | resultDir = "%s/%s/faces-%s" % (str(resultDir), routingType, str(faces)) |
| 120 | resultDir = os.path.abspath(resultDir) |
| 121 | |
| 122 | if not os.path.isdir(resultDir): |
| 123 | os.makedirs(resultDir) |
| 124 | else: |
| 125 | print("Results directory (%s) already exists!" % resultDir) |
| 126 | sys.exit(1); |
| 127 | |
| 128 | print "Results will be stored at: %s" % resultDir |
| 129 | return resultDir |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 130 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 131 | def parse_args(): |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 132 | usage = """Usage: minindn [template_file] [ -t | --testbed ] |
Ashlesh Gawande | 20f7076 | 2015-06-17 15:18:19 -0500 | [diff] [blame] | 133 | If no template_file is given, ndn_utils/default-topology.conf (given sample file) |
| 134 | will be used. |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 135 | If --testbed is used, minindn will run the NDN Project Testbed. |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 136 | """ |
| 137 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 138 | parser = optparse.OptionParser(usage) |
| 139 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 140 | parser.add_option("--ctime", action="store", dest="ctime", type="int", default=60, |
| 141 | help="Specify convergence time for the topology (Default: 60 seconds)") |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 142 | |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 143 | parser.add_option("--experiment", action="store", dest="experiment", |
| 144 | help="Runs the specified experiment") |
| 145 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 146 | parser.add_option("--faces", action="store", dest="faces", type="int", default=3, |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 147 | help="Specify number of faces 0-60") |
| 148 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 149 | parser.add_option("--hr", action="store_true", dest="hr", default=False, |
| 150 | help="--hr is used to turn on hyperbolic routing") |
| 151 | |
| 152 | parser.add_option("--list-experiments", action="callback", callback=printExperimentNames, |
| 153 | help="Lists the names of all available experiments") |
| 154 | |
| 155 | parser.add_option("--no-cli", action="store_false", dest="isCliEnabled", default=True, |
| 156 | help="Run experiments and exit without showing the command line interface") |
| 157 | |
| 158 | parser.add_option("--nPings", action="store", dest="nPings", type="int", default=300, |
| 159 | help="Number of pings to perform between each node in the experiment") |
| 160 | |
| 161 | parser.add_option("-t", "--testbed", action="store_true", dest="testbed", default=False, |
| 162 | help="instantiates NDN Testbed") |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 163 | |
Ashlesh Gawande | 1b66369 | 2015-10-14 16:38:10 -0500 | [diff] [blame] | 164 | parser.add_option("--work-dir", action="store", dest="workDir", default="/tmp", |
| 165 | help="Specify the working directory; default is /tmp") |
| 166 | |
Ashlesh Gawande | d829bfc | 2015-10-14 16:38:10 -0500 | [diff] [blame^] | 167 | parser.add_option("--result-dir", action="store", dest="resultDir", default=None, |
| 168 | help="Specify the full path destination folder where experiment results will be moved") |
| 169 | |
Vince Lehman | e9f116d | 2015-07-15 10:40:21 -0500 | [diff] [blame] | 170 | parser.add_option('--version', '-V', action='callback', callback=printVersion, |
| 171 | help='Displays version information') |
| 172 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 173 | (args, arg) = parser.parse_args() |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 174 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 175 | options = ProgramOptions() |
| 176 | options.ctime = args.ctime |
| 177 | options.experimentName = args.experiment |
| 178 | options.nFaces = args.faces |
| 179 | options.hr = args.hr |
| 180 | options.isCliEnabled = args.isCliEnabled |
| 181 | options.nPings = args.nPings |
| 182 | options.testbed = args.testbed |
Ashlesh Gawande | 1b66369 | 2015-10-14 16:38:10 -0500 | [diff] [blame] | 183 | options.workDir = args.workDir |
Ashlesh Gawande | d829bfc | 2015-10-14 16:38:10 -0500 | [diff] [blame^] | 184 | options.resultDir = args.resultDir |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 185 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 186 | if options.experimentName is not None and options.experimentName not in ExperimentManager.getExperimentNames(): |
| 187 | print("No experiment named %s" % options.experimentName) |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 188 | sys.exit() |
| 189 | |
Ashlesh Gawande | d829bfc | 2015-10-14 16:38:10 -0500 | [diff] [blame^] | 190 | if options.experimentName is not None and options.resultDir is None: |
| 191 | print "No results folder specified; experiment results will remain in the working directory" |
| 192 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 193 | if len(arg) == 0 or len(arg) > 2: |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 194 | options.templateFile = '' |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 195 | else: |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 196 | options.templateFile = arg[0] |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 197 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 198 | return options |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 199 | |
| 200 | class NdnTopo(Topo): |
Ashlesh Gawande | 1b66369 | 2015-10-14 16:38:10 -0500 | [diff] [blame] | 201 | def __init__(self, conf_arq, workDir, **opts): |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 202 | Topo.__init__(self, **opts) |
| 203 | |
| 204 | global hosts_conf |
| 205 | global links_conf |
| 206 | hosts_conf = parse_hosts(conf_arq) |
Vince Lehman | fbd47c9 | 2015-10-14 16:00:06 -0500 | [diff] [blame] | 207 | switches_conf = parse_switches(conf_arq) |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 208 | links_conf = parse_links(conf_arq) |
| 209 | |
| 210 | self.isTCLink = False |
| 211 | self.isLimited = False |
| 212 | |
| 213 | for host in hosts_conf: |
| 214 | if host.cpu != None and self.isLimited != True: |
| 215 | self.isLimited = True |
Ashlesh Gawande | 1b66369 | 2015-10-14 16:38:10 -0500 | [diff] [blame] | 216 | self.addHost(host.name, app=host.app, params=host.uri_tuples, cpu=host.cpu,cores=host.cores,cache=host.cache, workdir=workDir) |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 217 | |
Vince Lehman | fbd47c9 | 2015-10-14 16:00:06 -0500 | [diff] [blame] | 218 | for switch in switches_conf: |
| 219 | self.addSwitch(switch.name) |
| 220 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 221 | for link in links_conf: |
| 222 | if len(link.linkDict) == 0: |
| 223 | self.addLink(link.h1, link.h2) |
| 224 | else: |
| 225 | self.addLink(link.h1, link.h2, **link.linkDict) |
| 226 | self.isTCLink = True |
| 227 | |
| 228 | info('Parse of ' + conf_arq + ' done.\n') |
| 229 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 230 | def execute(options): |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 231 | "Create a network based on template_file" |
| 232 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 233 | template_file = options.templateFile |
Ashlesh Gawande | 20f7076 | 2015-06-17 15:18:19 -0500 | [diff] [blame] | 234 | install_dir='/usr/local/etc/mini-ndn/' |
| 235 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 236 | if template_file == '': |
Ashlesh Gawande | 20f7076 | 2015-06-17 15:18:19 -0500 | [diff] [blame] | 237 | template_file = install_dir + 'default-topology.conf' |
| 238 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 239 | if options.testbed: |
Ashlesh Gawande | 20f7076 | 2015-06-17 15:18:19 -0500 | [diff] [blame] | 240 | template_file = install_dir + 'minindn.testbed.conf' |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 241 | |
| 242 | if os.path.exists(template_file) == False: |
Ashlesh Gawande | 20f7076 | 2015-06-17 15:18:19 -0500 | [diff] [blame] | 243 | info('No template file given and default template file cannot be found. Exiting...\n') |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 244 | quit() |
Ashlesh Gawande | 20f7076 | 2015-06-17 15:18:19 -0500 | [diff] [blame] | 245 | |
Vince Lehman | 498625b | 2015-10-21 14:25:24 -0500 | [diff] [blame] | 246 | # Update nfd.conf file used by Mini-NDN to match the currently installed version of NFD |
| 247 | nfdConfFile = "%s/nfd.conf" % install_dir |
| 248 | os.system("sudo cp /usr/local/etc/ndn/nfd.conf.sample %s" % nfdConfFile) |
| 249 | os.system("sudo sed -i \'s|default_level [A-Z]*$|default_level $LOG_LEVEL|g\' %s" % nfdConfFile) |
| 250 | |
Ashlesh Gawande | d829bfc | 2015-10-14 16:38:10 -0500 | [diff] [blame^] | 251 | if options.resultDir is not None: |
| 252 | options.resultDir = createResultsDir(options.resultDir, options.nFaces, options.hr) |
| 253 | |
Ashlesh Gawande | 1b66369 | 2015-10-14 16:38:10 -0500 | [diff] [blame] | 254 | topo = NdnTopo(template_file, options.workDir) |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 255 | |
| 256 | t = datetime.datetime.now() |
| 257 | |
| 258 | if topo.isTCLink == True and topo.isLimited == True: |
| 259 | net = Mininet(topo,host=CpuLimitedNdnHost,link=TCLink) |
| 260 | elif topo.isTCLink == True and topo.isLimited == False: |
| 261 | net = Mininet(topo,host=NdnHost,link=TCLink) |
| 262 | elif topo.isTCLink == False and topo.isLimited == True: |
| 263 | net = Mininet(topo,host=CpuLimitedNdnHost) |
| 264 | else: |
| 265 | net = Mininet(topo,host=NdnHost) |
| 266 | |
| 267 | t2 = datetime.datetime.now() |
| 268 | |
| 269 | delta = t2 - t |
| 270 | |
| 271 | info('Setup time: ' + str(delta.seconds) + '\n') |
| 272 | |
| 273 | net.start() |
| 274 | |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 275 | # Giving proper IPs to intf so neighbor nodes can communicate |
| 276 | # This is one way of giving connectivity, another way could be |
| 277 | # to insert a switch between each pair of neighbors |
| 278 | ndnNetBase = "1.0.0.0" |
| 279 | interfaces = [] |
| 280 | for host in net.hosts: |
| 281 | for intf in host.intfList(): |
| 282 | link = intf.link |
| 283 | node1, node2 = link.intf1.node, link.intf2.node |
Vince Lehman | fbd47c9 | 2015-10-14 16:00:06 -0500 | [diff] [blame] | 284 | |
| 285 | if node1 in net.switches or node2 in net.switches: |
| 286 | print "%s or %s is a switch" % (node1.name, node2.name) |
| 287 | continue |
| 288 | |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 289 | if link.intf1 not in interfaces and link.intf2 not in interfaces: |
| 290 | interfaces.append(link.intf1) |
| 291 | interfaces.append(link.intf2) |
| 292 | node1.setIP(ipStr(ipParse(ndnNetBase) + 1) + '/30', intf=link.intf1) |
| 293 | node2.setIP(ipStr(ipParse(ndnNetBase) + 2) + '/30', intf=link.intf2) |
| 294 | ndnNetBase = ipStr(ipParse(ndnNetBase) + 4) |
| 295 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 296 | nodes = "" # Used later to check prefix name in checkFIB |
| 297 | |
| 298 | # NLSR initialization |
| 299 | for host in net.hosts: |
| 300 | nodes += str(host.name) + "," |
| 301 | |
| 302 | conf = next(x for x in hosts_conf if x.name == host.name) |
| 303 | host.nlsrParameters = conf.nlsrParameters |
| 304 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 305 | if options.nFaces is not None: |
| 306 | host.nlsrParameters["max-faces-per-prefix"] = options.nFaces |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 307 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 308 | if options.hr is True: |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 309 | host.nlsrParameters["hyperbolic-state"] = "on" |
| 310 | |
| 311 | # Generate NLSR configuration file |
ashu | 2ad32e2 | 2015-05-29 13:37:40 -0500 | [diff] [blame] | 312 | configGenerator = NlsrConfigGenerator(host) |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 313 | configGenerator.createConfigFile() |
| 314 | |
| 315 | # Start NLSR |
ashu | 34c3ee0 | 2015-03-25 14:41:14 -0500 | [diff] [blame] | 316 | host.nlsr = Nlsr(host) |
| 317 | host.nlsr.start() |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 318 | |
| 319 | nodes = nodes[0:-1] |
| 320 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 321 | for host in net.hosts: |
| 322 | if 'app' in host.params: |
Ashlesh Gawande | 557cb84 | 2015-07-01 15:39:44 -0500 | [diff] [blame] | 323 | if host.params['app'] != '': |
| 324 | app = host.params['app'] |
| 325 | print "Starting " + app + " on node " + host.name |
| 326 | print(host.cmd(app)) |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 327 | |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 328 | # Load experiment |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 329 | experimentName = options.experimentName |
| 330 | |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 331 | if experimentName is not None: |
| 332 | print "Loading experiment: %s" % experimentName |
| 333 | |
| 334 | experimentArgs = { |
| 335 | "net": net, |
| 336 | "nodes": nodes, |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 337 | "ctime": options.ctime, |
| 338 | "nPings": options.nPings, |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 339 | "strategy": Nfd.STRATEGY_BEST_ROUTE_V3 |
| 340 | } |
| 341 | |
| 342 | experiment = ExperimentManager.create(experimentName, experimentArgs) |
| 343 | |
| 344 | if experiment is not None: |
| 345 | experiment.start() |
| 346 | else: |
| 347 | print "ERROR: Experiment '%s' does not exist" % experimentName |
| 348 | return |
| 349 | |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 350 | if options.isCliEnabled is True: |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 351 | CLI(net) |
| 352 | |
| 353 | net.stop() |
| 354 | |
Ashlesh Gawande | d829bfc | 2015-10-14 16:38:10 -0500 | [diff] [blame^] | 355 | if options.resultDir is not None: |
| 356 | print("Moving results to %s" % options.resultDir) |
| 357 | os.system("sudo mv /%s/* %s" % (options.workDir, options.resultDir)) |
| 358 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 359 | if __name__ == '__main__': |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 360 | |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 361 | hosts_conf = [] |
| 362 | links_conf = [] |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 363 | |
| 364 | options = parse_args() |
ashu | ef3490b | 2015-02-17 11:01:04 -0600 | [diff] [blame] | 365 | |
| 366 | setLogLevel('info') |
Vince Lehman | 194be24 | 2015-10-15 18:01:42 -0500 | [diff] [blame] | 367 | execute(options) |