blob: 0398453efbe859b59f1ccb851c25a31830e556ac [file] [log] [blame]
Ashlesh Gawandef5f304b2016-06-16 16:42:41 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
Alexander Lane9944cf52018-05-17 12:16:50 -05003# Copyright (C) 2015-2018, The University of Memphis,
Ashlesh Gawandef5f304b2016-06-16 16:42:41 -05004# 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
24from subprocess import call
Ashlesh Gawande95789cc2017-02-27 12:38:04 -060025from mininet.cli import CLI
26import sys
Alexander Lane4fa88812018-05-23 12:56:52 -050027from os.path import isfile
Ashlesh Gawandef5f304b2016-06-16 16:42:41 -050028
29sshbase = [ 'ssh', '-q', '-t', '-i/home/mininet/.ssh/id_rsa' ]
30scpbase = [ 'scp', '-i', '/home/mininet/.ssh/id_rsa' ]
31devnull = open('/dev/null', 'w')
32
33def ssh(login, cmd):
34 rcmd = sshbase + [login, cmd]
35 call(rcmd, stdout=devnull, stderr=devnull)
36
37def scp(*args):
38 tmp = []
39 for arg in args:
40 tmp.append(arg)
41 rcmd = scpbase + tmp
42 call(rcmd, stdout=devnull, stderr=devnull)
Ashlesh Gawande95789cc2017-02-27 12:38:04 -060043
Alexander Lane4fa88812018-05-23 12:56:52 -050044def copyExistentFile(node, fileList, destination):
45 for file in fileList:
46 if isfile(file):
47 node.cmd("cp {} {}".format(file, destination))
48 break
49 if not isfile(destination):
50 fileName = destination.split("/")[-1]
51 raise IOError("{} not found in expected directory.".format(fileName))
52
53
Ashlesh Gawande95789cc2017-02-27 12:38:04 -060054class MiniNDNCLI(CLI):
55 prompt = 'mini-ndn> '
56 def __init__(self, mininet, stdin=sys.stdin, script=None):
57 CLI.__init__(self, mininet, stdin=sys.stdin, script=None)
Ashlesh Gawande27b5e1b2018-08-06 17:47:15 -050058
59class ProgramOptions:
60 def __init__(self):
61 self.ctime = 60
62 self.experimentName = None
63 self.nFaces = 3
64 self.templateFile = "minindn.conf"
65 self.routingType = "link-state"
66 self.isNlsrEnabled = True
67 self.isCliEnabled = True
68 self.nlsrSecurity = False
69 self.nPings = 300
70 self.testbed = False
71 self.workDir = "/tmp/minindn"
72 self.resultDir = None
73 self.pctTraffic = 1.0
74 self.cluster = None
75 self.servers = None
76 self.guided = None
77 self.placer = None
78 self.tunnelType = None
79 self.faceType = "udp"
80 self.arguments = None
81 self.csSize = 65536
82 self.strategy = "best-route"