code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def linearBandwidthTest( lengths ): "Check bandwidth at various lengths along a switch chain." results = {} switchCount = max( lengths ) hostCount = switchCount + 1 switches = { 'reference user': UserSwitch, 'Open vSwitch kernel': OVSKernelSwitch } # UserSwitch is horribly s...
Check bandwidth at various lengths along a switch chain.
linearBandwidthTest
python
mininet/mininet
examples/linearbandwidth.py
https://github.com/mininet/mininet/blob/master/examples/linearbandwidth.py
BSD-3-Clause
def start( self, controllers ): "Start and set management IP address" # Call superclass constructor UserSwitch.start( self, controllers ) # Set Switch IP address if self.switchIP is not None: if not self.inNamespace: self.cmd( 'ifconfig', self, self.sw...
Start and set management IP address
start
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def quit( self ): "Stop our network, if any, then quit." self.stop() Frame.quit( self )
Stop our network, if any, then quit.
quit
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def createCanvas( self ): "Create and return our scrolling canvas frame." f = Frame( self ) canvas = Canvas( f, width=self.cwidth, height=self.cheight, bg=self.bg ) # Scroll bars xbar = Scrollbar( f, orient='horizontal', command=canvas.xview ) y...
Create and return our scrolling canvas frame.
createCanvas
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def updateScrollRegion( self ): "Update canvas scroll region to hold everything." bbox = self.canvas.bbox( 'all' ) if bbox is not None: self.canvas.configure( scrollregion=( 0, 0, bbox[ 2 ], bbox[ 3 ] ) )
Update canvas scroll region to hold everything.
updateScrollRegion
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def canvasx( self, x_root ): "Convert root x coordinate to canvas coordinate." c = self.canvas return c.canvasx( x_root ) - c.winfo_rootx()
Convert root x coordinate to canvas coordinate.
canvasx
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def canvasy( self, y_root ): "Convert root y coordinate to canvas coordinate." c = self.canvas return c.canvasy( y_root ) - c.winfo_rooty()
Convert root y coordinate to canvas coordinate.
canvasy
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def activate( self, toolName ): "Activate a tool and press its button." # Adjust button appearance if self.active: self.buttons[ self.active ].configure( relief='raised' ) self.buttons[ toolName ].configure( relief='sunken' ) # Activate dynamic bindings self.a...
Activate a tool and press its button.
activate
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def createToolbar( self ): "Create and return our toolbar frame." toolbar = Frame( self ) # Tools for tool in self.tools: cmd = partial( self.activate, tool ) b = Button( toolbar, text=tool, font=self.smallFont, command=cmd) if tool in self.images: ...
Create and return our toolbar frame.
createToolbar
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def addNode( self, node, nodeNum, x, y, name=None): "Add a new node to our canvas." if node == 'Switch': self.switchCount += 1 if node == 'Host': self.hostCount += 1 if node == 'Controller': self.controllerCount += 1 if name is None: ...
Add a new node to our canvas.
addNode
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def convertJsonUnicode(self, text): "Some part of Mininet don't like Unicode" unicode = globals().get( 'unicode', str ) if isinstance(text, dict): return {self.convertJsonUnicode(key): self.convertJsonUnicode(value) for key, value in text.items()} if isinstance(text, list): ...
Some part of Mininet don't like Unicode
convertJsonUnicode
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def findItem( self, x, y ): "Find items at a location in our canvas." items = self.canvas.find_overlapping( x, y, x, y ) if len( items ) == 0: return None else: return items[ 0 ]
Find items at a location in our canvas.
findItem
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def clickController( self, event ): "Add a new Controller to our canvas." self.newNode( 'Controller', event )
Add a new Controller to our canvas.
clickController
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def clickHost( self, event ): "Add a new host to our canvas." self.newNode( 'Host', event )
Add a new host to our canvas.
clickHost
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def clickLegacyRouter( self, event ): "Add a new switch to our canvas." self.newNode( 'LegacyRouter', event )
Add a new switch to our canvas.
clickLegacyRouter
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def dragNetLink( self, event ): "Drag a link's endpoint to another node." if self.link is None: return # Since drag starts in widget, we use root coords x = self.canvasx( event.x_root ) y = self.canvasy( event.y_root ) c = self.canvas c.coords( self.li...
Drag a link's endpoint to another node.
dragNetLink
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def releaseNetLink( self, _event ): "Give up on the current link." if self.link is not None: self.canvas.delete( self.link ) self.linkWidget = self.linkItem = self.link = None
Give up on the current link.
releaseNetLink
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def createNodeBindings( self ): "Create a set of bindings for nodes." bindings = { '<ButtonPress-1>': self.clickNode, '<B1-Motion>': self.dragNode, '<ButtonRelease-1>': self.releaseNode, '<Enter>': self.enterNode, '<Leave>': self.leaveNode ...
Create a set of bindings for nodes.
createNodeBindings
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def selectItem( self, item ): "Select an item and remember old selection." self.lastSelection = self.selection self.selection = item
Select an item and remember old selection.
selectItem
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def selectNode( self, event ): "Select the node that was clicked on." item = self.widgetToItem.get( event.widget, None ) self.selectItem( item )
Select the node that was clicked on.
selectNode
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def dragNodeAround( self, event ): "Drag a node around on the canvas." c = self.canvas # Convert global to local coordinates; # Necessary since x, y are widget-relative x = self.canvasx( event.x_root ) y = self.canvasy( event.y_root ) w = event.widget # Ad...
Drag a node around on the canvas.
dragNodeAround
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def deleteNode( self, item ): "Delete node (and its links) from model." widget = self.itemToWidget[ item ] tags = self.canvas.gettags(item) if 'Controller' in tags: # remove from switch controller lists for searchwidget, searchitem in self.widgetToItem.items(): ...
Delete node (and its links) from model.
deleteNode
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def pathCheck( *args, **kwargs ): "Make sure each program in *args can be found in $PATH." moduleName = kwargs.get( 'moduleName', 'it' ) for arg in args: if not quietRun( 'which ' + arg ): showerror(title="Error", message= 'Cannot find required e...
Make sure each program in *args can be found in $PATH.
pathCheck
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def build( self ): "Build network based on our topology." dpctl = None if len(self.appPrefs['dpctl']) > 0: dpctl = int(self.appPrefs['dpctl']) net = Mininet( topo=None, listenPort=dpctl, build=False, ipBase...
Build network based on our topology.
build
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def xterm( self, _ignore=None ): "Make an xterm when a button is pressed." if ( self.selection is None or self.net is None or self.selection not in self.itemToWidget ): return name = self.itemToWidget[ self.selection ][ 'text' ] if name not in self.n...
Make an xterm when a button is pressed.
xterm
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def parseArgs( self ): """Parse command-line args and return options object. returns: opts parse options dict""" if '--custom' in sys.argv: index = sys.argv.index( '--custom' ) if len( sys.argv ) > index + 1: filename = sys.argv[ index + 1 ] ...
Parse command-line args and return options object. returns: opts parse options dict
parseArgs
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def parseCustomFile( self, fileName ): "Parse custom file and add params before parsing cmd-line options." customs = {} if os.path.isfile( fileName ): with open( fileName, 'r' ) as f: exec( f.read() ) # pylint: disable=exec-used for name, val in customs.i...
Parse custom file and add params before parsing cmd-line options.
parseCustomFile
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def miniEditImages(): "Create and return images for MiniEdit." # Image data. Git will be unhappy. However, the alternative # is to keep track of separate binary files, which is also # unappealing. return { 'Select': BitmapImage( file='/usr/include/X11/bitmaps/left_ptr' ), ...
Create and return images for MiniEdit.
miniEditImages
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def addDictOption( opts, choicesDict, default, name, helpStr=None ): """Convenience function to add choices dicts to OptionParser. opts: OptionParser instance choicesDict: dictionary of valid choices, must include default default: default choice key name: long option name help: st...
Convenience function to add choices dicts to OptionParser. opts: OptionParser instance choicesDict: dictionary of valid choices, must include default default: default choice key name: long option name help: string
addDictOption
python
mininet/mininet
examples/miniedit.py
https://github.com/mininet/mininet/blob/master/examples/miniedit.py
BSD-3-Clause
def attach( self, intf ): "Attach an interface and set its port" port = self.ports[ intf ] if port: if self.isOldOVS(): self.cmd( 'ovs-vsctl add-port', self, intf ) else: self.cmd( 'ovs-vsctl add-port', self, intf, ...
Attach an interface and set its port
attach
python
mininet/mininet
examples/mobility.py
https://github.com/mininet/mininet/blob/master/examples/mobility.py
BSD-3-Clause
def renameIntf( self, intf, newname='' ): "Rename an interface (to its canonical name)" intf.ifconfig( 'down' ) if not newname: newname = '%s-eth%d' % ( self.name, self.ports[ intf ] ) intf.cmd( 'ip link set', intf, 'name', newname ) del self.nameToIntf[ intf.name ] ...
Rename an interface (to its canonical name)
renameIntf
python
mininet/mininet
examples/mobility.py
https://github.com/mininet/mininet/blob/master/examples/mobility.py
BSD-3-Clause
def moveIntf( self, intf, switch, port=None, rename=True ): "Move one of our interfaces to another switch" self.detach( intf ) self.delIntf( intf ) switch.addIntf( intf, port=port, rename=rename ) switch.attach( intf )
Move one of our interfaces to another switch
moveIntf
python
mininet/mininet
examples/mobility.py
https://github.com/mininet/mininet/blob/master/examples/mobility.py
BSD-3-Clause
def printConnections( switches ): "Compactly print connected nodes to each switch" for sw in switches: output( '%s: ' % sw ) for intf in sw.intfList(): link = intf.link if link: intf1, intf2 = link.intf1, link.intf2 remote = intf1 if intf1....
Compactly print connected nodes to each switch
printConnections
python
mininet/mininet
examples/mobility.py
https://github.com/mininet/mininet/blob/master/examples/mobility.py
BSD-3-Clause
def moveHost( host, oldSwitch, newSwitch, newPort=None ): "Move a host from old switch to new switch" hintf, sintf = host.connectionsTo( oldSwitch )[ 0 ] oldSwitch.moveIntf( sintf, newSwitch, port=newPort ) return hintf, sintf
Move a host from old switch to new switch
moveHost
python
mininet/mininet
examples/mobility.py
https://github.com/mininet/mininet/blob/master/examples/mobility.py
BSD-3-Clause
def runMultiLink(): "Create and run multiple link network" topo = simpleMultiLinkTopo( n=2 ) net = Mininet( topo=topo, waitConnected=True ) net.start() CLI( net ) net.stop()
Create and run multiple link network
runMultiLink
python
mininet/mininet
examples/multilink.py
https://github.com/mininet/mininet/blob/master/examples/multilink.py
BSD-3-Clause
def chunks( items, n ): "Divide list l into chunks of size n - thanks Stackoverflow" return [ items[ i: i + n ] for i in range( 0, len( items ), n ) ]
Divide list l into chunks of size n - thanks Stackoverflow
chunks
python
mininet/mininet
examples/multiping.py
https://github.com/mininet/mininet/blob/master/examples/multiping.py
BSD-3-Clause
def startpings( host, targetips ): "Tell host to repeatedly ping targets" targetips = ' '.join( targetips ) # Simple ping loop cmd = ( 'while true; do ' ' for ip in %s; do ' % targetips + ' echo -n %s "->" $ip ' % host.IP() + ' `ping -c1 -w 1 $ip | grep packets` ...
Tell host to repeatedly ping targets
startpings
python
mininet/mininet
examples/multiping.py
https://github.com/mininet/mininet/blob/master/examples/multiping.py
BSD-3-Clause
def multiping( netsize, chunksize, seconds): "Ping subsets of size chunksize in net of size netsize" # Create network and identify subnets topo = SingleSwitchTopo( netsize ) net = Mininet( topo=topo, waitConnected=True ) net.start() hosts = net.hosts subnets = chunks( hosts, chunksize ) ...
Ping subsets of size chunksize in net of size netsize
multiping
python
mininet/mininet
examples/multiping.py
https://github.com/mininet/mininet/blob/master/examples/multiping.py
BSD-3-Clause
def monitorFiles( outfiles, seconds, timeoutms ): "Monitor set of files and return [(host, line)...]" devnull = open( '/dev/null', 'w' ) # pylint: disable=consider-using-with tails, fdToFile, fdToHost = {}, {}, {} for h, outfile in outfiles.items(): tail = Popen( # pylint: disable=consider-usi...
Monitor set of files and return [(host, line)...]
monitorFiles
python
mininet/mininet
examples/multipoll.py
https://github.com/mininet/mininet/blob/master/examples/multipoll.py
BSD-3-Clause
def monitorTest( N=3, seconds=3 ): "Run pings and monitor multiple hosts" topo = SingleSwitchTopo( N ) net = Mininet( topo, waitConnected=True ) net.start() hosts = net.hosts info( "Starting test...\n" ) server = hosts[ 0 ] outfiles, errfiles = {}, {} for h in hosts: # Create...
Run pings and monitor multiple hosts
monitorTest
python
mininet/mininet
examples/multipoll.py
https://github.com/mininet/mininet/blob/master/examples/multipoll.py
BSD-3-Clause
def ifconfigTest( net ): "Run ifconfig on all hosts in net." hosts = net.hosts for host in hosts: info( host.cmd( 'ifconfig' ) )
Run ifconfig on all hosts in net.
ifconfigTest
python
mininet/mininet
examples/multitest.py
https://github.com/mininet/mininet/blob/master/examples/multitest.py
BSD-3-Clause
def run(): "Create network and run the CLI" topo = InternetTopo() net = Mininet(topo=topo, waitConnected=True ) net.start() CLI(net) net.stop()
Create network and run the CLI
run
python
mininet/mininet
examples/natnet.py
https://github.com/mininet/mininet/blob/master/examples/natnet.py
BSD-3-Clause
def testPortNumbering(): """Test port numbering: Create a network with 5 hosts (using Mininet's mid-level API) and check that implicit and explicit port numbering works as expected.""" net = Mininet( controller=Controller, waitConnected=True ) info( '*** Adding controller\n' ) ne...
Test port numbering: Create a network with 5 hosts (using Mininet's mid-level API) and check that implicit and explicit port numbering works as expected.
testPortNumbering
python
mininet/mininet
examples/numberedports.py
https://github.com/mininet/mininet/blob/master/examples/numberedports.py
BSD-3-Clause
def monitorhosts( hosts=5 ): "Start a bunch of pings and monitor them using popen" mytopo = SingleSwitchTopo( hosts ) net = Mininet( topo=mytopo, waitConnected=True ) net.start() # Start a bunch of pings popens = {} last = net.hosts[ -1 ] for host in net.hosts: popens[ host ] = h...
Start a bunch of pings and monitor them using popen
monitorhosts
python
mininet/mininet
examples/popen.py
https://github.com/mininet/mininet/blob/master/examples/popen.py
BSD-3-Clause
def pmonitorTest( N=3, seconds=10 ): "Run pings and monitor multiple hosts using pmonitor" topo = SingleSwitchTopo( N ) net = Mininet( topo, waitConnected=True ) net.start() hosts = net.hosts info( "Starting test...\n" ) server = hosts[ 0 ] popens = {} for h in hosts: popens[...
Run pings and monitor multiple hosts using pmonitor
pmonitorTest
python
mininet/mininet
examples/popenpoll.py
https://github.com/mininet/mininet/blob/master/examples/popenpoll.py
BSD-3-Clause
def scratchNet( cname='controller', cargs='-v ptcp:' ): "Create network from scratch using Open vSwitch." info( "*** Creating nodes\n" ) controller = Node( 'c0', inNamespace=False ) switch = Node( 's0', inNamespace=False ) h0 = Node( 'h0' ) h1 = Node( 'h1' ) info( "*** Creating links\n" ) ...
Create network from scratch using Open vSwitch.
scratchNet
python
mininet/mininet
examples/scratchnet.py
https://github.com/mininet/mininet/blob/master/examples/scratchnet.py
BSD-3-Clause
def linkIntfs( node1, node2 ): "Create link from node1 to node2 and return intfs" link = Link( node1, node2 ) return link.intf1, link.intf2
Create link from node1 to node2 and return intfs
linkIntfs
python
mininet/mininet
examples/scratchnetuser.py
https://github.com/mininet/mininet/blob/master/examples/scratchnetuser.py
BSD-3-Clause
def scratchNetUser( cname='controller', cargs='ptcp:' ): "Create network from scratch using user switch." # It's not strictly necessary for the controller and switches # to be in separate namespaces. For performance, they probably # should be in the root namespace. However, it's interesting to # se...
Create network from scratch using user switch.
scratchNetUser
python
mininet/mininet
examples/scratchnetuser.py
https://github.com/mininet/mininet/blob/master/examples/scratchnetuser.py
BSD-3-Clause
def perfTest( lossy=True ): "Create network and run simple performance test" topo = SingleSwitchTopo( n=4, lossy=lossy ) net = Mininet( topo=topo, host=CPULimitedHost, link=TCLink, autoStaticArp=True ) net.start() info( "Dumping host connections\n" ) dumpNod...
Create network and run simple performance test
perfTest
python
mininet/mininet
examples/simpleperf.py
https://github.com/mininet/mininet/blob/master/examples/simpleperf.py
BSD-3-Clause
def TreeNet( depth=1, fanout=2, **kwargs ): "Convenience function for creating tree networks." topo = TreeTopo( depth, fanout ) return Mininet( topo, waitConnected=True, **kwargs )
Convenience function for creating tree networks.
TreeNet
python
mininet/mininet
examples/sshd.py
https://github.com/mininet/mininet/blob/master/examples/sshd.py
BSD-3-Clause
def connectToRootNS( network, switch, ip, routes ): """Connect hosts to root namespace via switch. Starts network. network: Mininet() network object switch: switch to connect to root namespace ip: IP address for root namespace node routes: host networks to route to""" # Create a node in ...
Connect hosts to root namespace via switch. Starts network. network: Mininet() network object switch: switch to connect to root namespace ip: IP address for root namespace node routes: host networks to route to
connectToRootNS
python
mininet/mininet
examples/sshd.py
https://github.com/mininet/mininet/blob/master/examples/sshd.py
BSD-3-Clause
def sshd( network, cmd='/usr/sbin/sshd', opts='-D', ip='10.123.123.1/32', routes=None, switch=None ): """Start a network, connect it to root ns, and run sshd on all hosts. ip: root-eth0 IP address in root namespace (10.123.123.1/32) routes: Mininet host networks to route to (10.0/24) ...
Start a network, connect it to root ns, and run sshd on all hosts. ip: root-eth0 IP address in root namespace (10.123.123.1/32) routes: Mininet host networks to route to (10.0/24) switch: Mininet switch to connect to root namespace (s1)
sshd
python
mininet/mininet
examples/sshd.py
https://github.com/mininet/mininet/blob/master/examples/sshd.py
BSD-3-Clause
def treePing64(): "Run ping test on 64-node tree networks." results = {} switches = { 'reference user': UserSwitch, 'Open vSwitch kernel': OVSKernelSwitch } for name, switch in switches.items(): info( "*** Testing", name, "datapath\n" ) network = TreeNet( depth=2, fano...
Run ping test on 64-node tree networks.
treePing64
python
mininet/mininet
examples/treeping64.py
https://github.com/mininet/mininet/blob/master/examples/treeping64.py
BSD-3-Clause
def config( self, vlan=100, **params ): """Configure VLANHost according to (optional) parameters: vlan: VLAN ID for default interface""" r = super( VLANHost, self ).config( **params ) intf = self.defaultIntf() # remove IP from default, "physical" interface self.cmd( ...
Configure VLANHost according to (optional) parameters: vlan: VLAN ID for default interface
config
python
mininet/mininet
examples/vlanhost.py
https://github.com/mininet/mininet/blob/master/examples/vlanhost.py
BSD-3-Clause
def exampleAllHosts( vlan ): """Simple example of how VLANHost can be used in a script""" # This is where the magic happens... host = partial( VLANHost, vlan=vlan ) # vlan (type: int): VLAN ID to be used by all hosts # Start a basic network using our VLANHost topo = SingleSwitchTopo( k=2 ) ...
Simple example of how VLANHost can be used in a script
exampleAllHosts
python
mininet/mininet
examples/vlanhost.py
https://github.com/mininet/mininet/blob/master/examples/vlanhost.py
BSD-3-Clause
def runTests( testDir, verbosity=1 ): "discover and run all tests in testDir" # ensure root and cleanup before starting tests ensureRoot() cleanup() # discover all tests in testDir testSuite = unittest.defaultTestLoader.discover( testDir ) # run tests success = MininetTestRunner( verbosi...
discover and run all tests in testDir
runTests
python
mininet/mininet
examples/test/runner.py
https://github.com/mininet/mininet/blob/master/examples/test/runner.py
BSD-3-Clause
def connected( self ): "Log into ssh server, check banner, then exit" p = pexpect.spawn( 'ssh 10.0.0.1 -o ConnectTimeout=1 ' '-o StrictHostKeyChecking=no ' '-i /tmp/ssh/test_rsa exit' ) while True: index = p.expect( self.opts ) ...
Log into ssh server, check banner, then exit
connected
python
mininet/mininet
examples/test/test_baresshd.py
https://github.com/mininet/mininet/blob/master/examples/test/test_baresshd.py
BSD-3-Clause
def testSSH( self ): "Simple test to verify that we can ssh into h1" result = False # try to connect up to 3 times; sshd can take a while to start result = self.connected() self.assertTrue( result )
Simple test to verify that we can ssh into h1
testSSH
python
mininet/mininet
examples/test/test_baresshd.py
https://github.com/mininet/mininet/blob/master/examples/test/test_baresshd.py
BSD-3-Clause
def testCreateFile( self ): "Create a file, a.txt, in the first private directory and verify" fileName = 'a.txt' directory = self.directories[ 0 ] path = directory + '/' + fileName self.net.sendline( 'h1 touch %s; ls %s' % ( path, directory ) ) index = self.net.expect( [ ...
Create a file, a.txt, in the first private directory and verify
testCreateFile
python
mininet/mininet
examples/test/test_bind.py
https://github.com/mininet/mininet/blob/master/examples/test/test_bind.py
BSD-3-Clause
def testIsolation( self ): "Create a file in two hosts and verify that contents are different" fileName = 'b.txt' directory = self.directories[ 0 ] path = directory + '/' + fileName contents = { 'h1' : '1', 'h2' : '2' } # Verify file doesn't exist, then write private copy...
Create a file in two hosts and verify that contents are different
testIsolation
python
mininet/mininet
examples/test/test_bind.py
https://github.com/mininet/mininet/blob/master/examples/test/test_bind.py
BSD-3-Clause
def connectedTest( self, name, cmap ): "Verify that switches are connected to the controller specified by cmap" p = pexpect.spawn( 'python -m %s' % name ) p.expect( self.prompt ) # but first a simple ping test p.sendline( 'pingall' ) p.expect ( '(\d+)% dropped' ) ...
Verify that switches are connected to the controller specified by cmap
connectedTest
python
mininet/mininet
examples/test/test_controllers.py
https://github.com/mininet/mininet/blob/master/examples/test/test_controllers.py
BSD-3-Clause
def testPingall( self ): "Simple pingall test that verifies 0% packet drop in data network" p = pexpect.spawn( 'python -m mininet.examples.controlnet', logfile=stdout) p.expect( self.prompt ) p.sendline( 'pingall' ) p.expect ( '(\d+)% dropped' ) percent = int( p.match.gro...
Simple pingall test that verifies 0% packet drop in data network
testPingall
python
mininet/mininet
examples/test/test_controlnet.py
https://github.com/mininet/mininet/blob/master/examples/test/test_controlnet.py
BSD-3-Clause
def testFailover( self ): "Kill controllers and verify that switch, s1, fails over properly" count = 1 p = pexpect.spawn( 'python -m mininet.examples.controlnet', logfile=stdout ) p.expect( self.prompt ) lp = pexpect.spawn( 'tail -f /tmp/s1-ofp.log', logfile=stdout ) lp.e...
Kill controllers and verify that switch, s1, fails over properly
testFailover
python
mininet/mininet
examples/test/test_controlnet.py
https://github.com/mininet/mininet/blob/master/examples/test/test_controlnet.py
BSD-3-Clause
def testCPU( self ): "Verify that CPU utilization is monotonically decreasing for each scheduler" p = pexpect.spawn( 'python -m mininet.examples.cpu', timeout=300 ) # matches each line from results( shown above ) opts = [ '([a-z]+)\t([\d\.]+)%\t([\d\.e\+]+)', pexpect.EOF...
Verify that CPU utilization is monotonically decreasing for each scheduler
testCPU
python
mininet/mininet
examples/test/test_cpu.py
https://github.com/mininet/mininet/blob/master/examples/test/test_cpu.py
BSD-3-Clause
def testEmptyNet( self ): "Run simple CLI tests: pingall (verify 0% drop) and iperf (sanity)" p = pexpect.spawn( 'python -m mininet.examples.emptynet' ) p.expect( self.prompt ) # pingall test p.sendline( 'pingall' ) p.expect ( '(\d+)% dropped' ) percent = int( p.m...
Run simple CLI tests: pingall (verify 0% drop) and iperf (sanity)
testEmptyNet
python
mininet/mininet
examples/test/test_emptynet.py
https://github.com/mininet/mininet/blob/master/examples/test/test_emptynet.py
BSD-3-Clause
def testLocalPing( self ): "Verify connectivity between virtual hosts using pingall" p = pexpect.spawn( 'python -m mininet.examples.hwintf %s' % self.n0.intf() ) p.expect( self.prompt ) p.sendline( 'pingall' ) p.expect ( '(\d+)% dropped' ) percent = int( p.match.group( 1 ...
Verify connectivity between virtual hosts using pingall
testLocalPing
python
mininet/mininet
examples/test/test_hwintf.py
https://github.com/mininet/mininet/blob/master/examples/test/test_hwintf.py
BSD-3-Clause
def testExternalPing( self ): "Verify connnectivity between virtual host and virtual-physical 'external' host " p = pexpect.spawn( 'python -m mininet.examples.hwintf %s' % self.n0.intf() ) p.expect( self.prompt ) # test ping external to internal expectStr = '(\d+) packets transmi...
Verify connnectivity between virtual host and virtual-physical 'external' host
testExternalPing
python
mininet/mininet
examples/test/test_hwintf.py
https://github.com/mininet/mininet/blob/master/examples/test/test_hwintf.py
BSD-3-Clause
def testLinearBandwidth( self ): "Verify that bandwidth is monotonically decreasing as # of hops increases" p = pexpect.spawn( 'python -m mininet.examples.linearbandwidth' ) count = 0 opts = [ '\*\*\* Linear network results', '(\d+)\s+([\d\.]+) (.bits)', ...
Verify that bandwidth is monotonically decreasing as # of hops increases
testLinearBandwidth
python
mininet/mininet
examples/test/test_linearbandwidth.py
https://github.com/mininet/mininet/blob/master/examples/test/test_linearbandwidth.py
BSD-3-Clause
def testTTL( self ): "Verify that the TTL is decremented" p = pexpect.spawn( 'python -m mininet.examples.linuxrouter' ) p.expect( self.prompt ) p.sendline( 'h1 ping -c 1 h2' ) p.expect ( 'ttl=(\d+)' ) ttl = int( p.match.group( 1 ) ) if p.match else -1 p.expect( se...
Verify that the TTL is decremented
testTTL
python
mininet/mininet
examples/test/test_linuxrouter.py
https://github.com/mininet/mininet/blob/master/examples/test/test_linuxrouter.py
BSD-3-Clause
def testMobility( self ): "Run the example and verify its 4 ping results" cmd = 'python -m mininet.examples.mobility 2>&1' grep = ' | grep -c " 0% dropped" ' result = check_output( cmd + grep, shell=True ) assert int( result ) == 4
Run the example and verify its 4 ping results
testMobility
python
mininet/mininet
examples/test/test_mobility.py
https://github.com/mininet/mininet/blob/master/examples/test/test_mobility.py
BSD-3-Clause
def testMultiPing( self ): """Verify that each target is pinged at least once, and that pings to 'real' targets are successful and unknown targets fail""" p = pexpect.spawn( 'python -m mininet.examples.multiping' ) opts = [ "Host (h\d+) \(([\d.]+)\) will be pinging ips: ([\d\. ]+)", ...
Verify that each target is pinged at least once, and that pings to 'real' targets are successful and unknown targets fail
testMultiPing
python
mininet/mininet
examples/test/test_multiping.py
https://github.com/mininet/mininet/blob/master/examples/test/test_multiping.py
BSD-3-Clause
def testMultiPoll( self ): "Verify that we receive one ping per second per host" p = pexpect.spawn( 'python -m mininet.examples.multipoll' ) opts = [ "\*\*\* (h\d) :" , "(h\d+): \d+ bytes from", "Monitoring output for (\d+) seconds", pexpect.EOF...
Verify that we receive one ping per second per host
testMultiPoll
python
mininet/mininet
examples/test/test_multipoll.py
https://github.com/mininet/mininet/blob/master/examples/test/test_multipoll.py
BSD-3-Clause
def testMultiTest( self ): "Verify pingall (0% dropped) and hX-eth0 interface for each host (ifconfig)" p = pexpect.spawn( 'python -m mininet.examples.multitest' ) p.expect( '(\d+)% dropped' ) dropped = int( p.match.group( 1 ) ) self.assertEqual( dropped, 0 ) ifCount = 0 ...
Verify pingall (0% dropped) and hX-eth0 interface for each host (ifconfig)
testMultiTest
python
mininet/mininet
examples/test/test_multitest.py
https://github.com/mininet/mininet/blob/master/examples/test/test_multitest.py
BSD-3-Clause
def testNAT( self ): "Attempt to ping an IP on the Internet and verify 0% packet loss" p = pexpect.spawn( 'python -m mininet.examples.nat' ) p.expect( self.prompt ) p.sendline( 'h1 ping -c 1 %s' % destIP ) p.expect ( '(\d+)% packet loss' ) percent = int( p.match.group( 1 ...
Attempt to ping an IP on the Internet and verify 0% packet loss
testNAT
python
mininet/mininet
examples/test/test_nat.py
https://github.com/mininet/mininet/blob/master/examples/test/test_nat.py
BSD-3-Clause
def testPublicPing( self ): "Attempt to ping the public server (h0) from h1 and h2" self.net.sendline( 'h1 ping -c 1 h0' ) self.net.expect ( '(\d+)% packet loss' ) percent = int( self.net.match.group( 1 ) ) if self.net.match else -1 self.assertEqual( percent, 0 ) self.net...
Attempt to ping the public server (h0) from h1 and h2
testPublicPing
python
mininet/mininet
examples/test/test_natnet.py
https://github.com/mininet/mininet/blob/master/examples/test/test_natnet.py
BSD-3-Clause
def testPrivatePing( self ): "Attempt to ping h1 and h2 from public server" self.net.sendline( 'h0 ping -c 1 -t 1 h1' ) result = self.net.expect ( [ 'unreachable', 'loss' ] ) self.assertEqual( result, 0 ) self.net.expect( self.prompt ) self.net.sendline( 'h0 ping -c 1 -t...
Attempt to ping h1 and h2 from public server
testPrivatePing
python
mininet/mininet
examples/test/test_natnet.py
https://github.com/mininet/mininet/blob/master/examples/test/test_natnet.py
BSD-3-Clause
def testPrivateToPrivatePing( self ): "Attempt to ping from NAT'ed host h1 to NAT'ed host h2" self.net.sendline( 'h1 ping -c 1 -t 1 h2' ) result = self.net.expect ( [ '[Uu]nreachable', 'loss' ] ) self.assertEqual( result, 0 ) self.net.expect( self.prompt )
Attempt to ping from NAT'ed host h1 to NAT'ed host h2
testPrivateToPrivatePing
python
mininet/mininet
examples/test/test_natnet.py
https://github.com/mininet/mininet/blob/master/examples/test/test_natnet.py
BSD-3-Clause
def testConsistency( self ): """verify consistency between mininet and ovs ports""" p = pexpect.spawn( 'python -m mininet.examples.numberedports' ) opts = [ 'Validating that s1-eth\d is actually on port \d ... Validated.', 'Validating that s1-eth\d is actually on port \d ... WAR...
verify consistency between mininet and ovs ports
testConsistency
python
mininet/mininet
examples/test/test_numberedports.py
https://github.com/mininet/mininet/blob/master/examples/test/test_numberedports.py
BSD-3-Clause
def testNumbering( self ): """verify that all of the port numbers are printed correctly and consistent with their interface""" p = pexpect.spawn( 'python -m mininet.examples.numberedports' ) opts = [ 's1-eth(\d+) : (\d+)', pexpect.EOF ] count_intfs = 0 while Tru...
verify that all of the port numbers are printed correctly and consistent with their interface
testNumbering
python
mininet/mininet
examples/test/test_numberedports.py
https://github.com/mininet/mininet/blob/master/examples/test/test_numberedports.py
BSD-3-Clause
def pingTest( self, name ): "Verify that there are no dropped packets for each host" p = pexpect.spawn( 'python -m %s' % name ) opts = [ "<(h\d+)>: PING ", "<(h\d+)>: (\d+) packets transmitted, (\d+) received", pexpect.EOF ] pings = {} while True...
Verify that there are no dropped packets for each host
pingTest
python
mininet/mininet
examples/test/test_popen.py
https://github.com/mininet/mininet/blob/master/examples/test/test_popen.py
BSD-3-Clause
def pingTest( self, name ): "Verify that no ping packets were dropped" p = pexpect.spawn( 'python -m %s' % name ) index = p.expect( self.opts, timeout=120 ) self.assertEqual( index, 0 ) p.wait()
Verify that no ping packets were dropped
pingTest
python
mininet/mininet
examples/test/test_scratchnet.py
https://github.com/mininet/mininet/blob/master/examples/test/test_scratchnet.py
BSD-3-Clause
def testE2E( self ): "Run the example and verify iperf results" # 10 Mb/s, plus or minus 20% tolerance BW = 10 TOLERANCE = .2 p = pexpect.spawn( 'python -m mininet.examples.simpleperf testmode' ) # Log since this seems to be failing intermittently p.lo...
Run the example and verify iperf results
testE2E
python
mininet/mininet
examples/test/test_simpleperf.py
https://github.com/mininet/mininet/blob/master/examples/test/test_simpleperf.py
BSD-3-Clause
def testSSH( self ): "Verify that we can ssh into all hosts (h1 to h4)" for h in range( 1, 5 ): self.assertTrue( self.connected( '10.0.0.%d' % h ) )
Verify that we can ssh into all hosts (h1 to h4)
testSSH
python
mininet/mininet
examples/test/test_sshd.py
https://github.com/mininet/mininet/blob/master/examples/test/test_sshd.py
BSD-3-Clause
def testTree1024( self ): "Run the example and do a simple ping test from h1 to h1024" p = pexpect.spawn( 'python -m mininet.examples.tree1024' ) p.expect( self.prompt, timeout=6000 ) # it takes awhile to set up p.sendline( 'h1 ping -c 20 h1024' ) p.expect ( '(\d+)% packet loss' ...
Run the example and do a simple ping test from h1 to h1024
testTree1024
python
mininet/mininet
examples/test/test_tree1024.py
https://github.com/mininet/mininet/blob/master/examples/test/test_tree1024.py
BSD-3-Clause
def testTreePing64( self ): "Run the example and verify ping results" p = pexpect.spawn( 'python -m mininet.examples.treeping64' ) p.expect( 'Tree network ping results:', timeout=6000 ) count = 0 while True: index = p.expect( [ '(\d+)% packet loss', pexpect.EOF ] ) ...
Run the example and verify ping results
testTreePing64
python
mininet/mininet
examples/test/test_treeping64.py
https://github.com/mininet/mininet/blob/master/examples/test/test_treeping64.py
BSD-3-Clause
def testVLANTopo( self ): "Test connectivity (or lack thereof) between hosts in VLANTopo" p = pexpect.spawn( 'python -m mininet.examples.vlanhost' ) p.expect( self.prompt ) p.sendline( 'pingall 1' ) #ping timeout=1 p.expect( '(\d+)% dropped', timeout=30 ) # there should be 24 fa...
Test connectivity (or lack thereof) between hosts in VLANTopo
testVLANTopo
python
mininet/mininet
examples/test/test_vlanhost.py
https://github.com/mininet/mininet/blob/master/examples/test/test_vlanhost.py
BSD-3-Clause
def testSpecificVLAN( self ): "Test connectivity between hosts on a specific VLAN" vlan = 1001 p = pexpect.spawn( 'python -m mininet.examples.vlanhost %d' % vlan ) p.expect( self.prompt ) p.sendline( 'h1 ping -c 1 h2' ) p.expect ( '(\d+)% packet loss' ) percent =...
Test connectivity between hosts on a specific VLAN
testSpecificVLAN
python
mininet/mininet
examples/test/test_vlanhost.py
https://github.com/mininet/mininet/blob/master/examples/test/test_vlanhost.py
BSD-3-Clause
def sh( cmd ): "Print a command and send it to the shell" info( cmd + '\n' ) p = Popen( # pylint: disable=consider-using-with [ '/bin/sh', '-c', cmd ], stdout=PIPE ) result = p.communicate()[ 0 ] return decode( result )
Print a command and send it to the shell
sh
python
mininet/mininet
mininet/clean.py
https://github.com/mininet/mininet/blob/master/mininet/clean.py
BSD-3-Clause
def killprocs( pattern ): "Reliably terminate processes matching a pattern (including args)" sh( 'pkill -9 -f %s' % pattern ) # Make sure they are gone while True: try: pids = co( [ 'pgrep', '-f', pattern ] ) except CalledProcessError: pids = '' if pids: ...
Reliably terminate processes matching a pattern (including args)
killprocs
python
mininet/mininet
mininet/clean.py
https://github.com/mininet/mininet/blob/master/mininet/clean.py
BSD-3-Clause
def cleanup( cls): """Clean up junk which might be left over from old runs; do fast stuff before slow dp and link removal!""" info( "*** Removing excess controllers/ofprotocols/ofdatapaths/" "pings/noxes\n" ) zombies = ( 'controller ofprotocol ofdatapath ping nox_core '...
Clean up junk which might be left over from old runs; do fast stuff before slow dp and link removal!
cleanup
python
mininet/mininet
mininet/clean.py
https://github.com/mininet/mininet/blob/master/mininet/clean.py
BSD-3-Clause
def __init__( self, mininet, stdin=sys.stdin, script=None, **kwargs ): """Start and run interactive or batch mode CLI mininet: Mininet network object stdin: standard input for CLI script: script to run in batch mode""" self.mn = mininet # Local ...
Start and run interactive or batch mode CLI mininet: Mininet network object stdin: standard input for CLI script: script to run in batch mode
__init__
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def initReadline( cls ): "Set up history if readline is available" # Only set up readline once to prevent multiplying the history file if cls.readlineInited: return cls.readlineInited = True try: # pylint: disable=import-outside-toplevel from r...
Set up history if readline is available
initReadline
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def getLocals( self ): "Local variable bindings for py command" self.locals.update( self.mn ) return self.locals
Local variable bindings for py command
getLocals
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def do_ports( self, _line ): "display ports and interfaces for each switch" dumpPorts( self.mn.switches )
display ports and interfaces for each switch
do_ports
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def do_sh( self, line ): """Run an external shell command Usage: sh [cmd args]""" assert self # satisfy pylint and allow override call( line, shell=True )
Run an external shell command Usage: sh [cmd args]
do_sh
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def do_py( self, line ): """Evaluate a Python expression. Node names may be used, e.g.: py h1.cmd('ls')""" try: # pylint: disable=eval-used result = eval( line, globals(), self.getLocals() ) if result is None: return elif isinsta...
Evaluate a Python expression. Node names may be used, e.g.: py h1.cmd('ls')
do_py
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def do_px( self, line ): """Execute a Python statement. Node names may be used, e.g.: px print h1.cmd('ls')""" try: exec( line, globals(), self.getLocals() ) except Exception as e: output( str( e ) + '\n' )
Execute a Python statement. Node names may be used, e.g.: px print h1.cmd('ls')
do_px
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def do_iperf( self, line ): """Simple iperf TCP test between two (optionally specified) hosts. Usage: iperf node1 node2""" args = line.split() if not args: self.mn.iperf() elif len(args) == 2: hosts = [] err = False for arg in ar...
Simple iperf TCP test between two (optionally specified) hosts. Usage: iperf node1 node2
do_iperf
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def do_iperfudp( self, line ): """Simple iperf UDP test between two (optionally specified) hosts. Usage: iperfudp bw node1 node2""" args = line.split() if not args: self.mn.iperf( l4Type='UDP' ) elif len(args) == 3: udpBw = args[ 0 ] hosts =...
Simple iperf UDP test between two (optionally specified) hosts. Usage: iperfudp bw node1 node2
do_iperfudp
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause
def do_link( self, line ): """Bring link(s) between two nodes up or down. Usage: link node1 node2 [up/down]""" args = line.split() if len(args) != 3: error( 'invalid number of args: link end1 end2 [up down]\n' ) elif args[ 2 ] not in [ 'up', 'down' ]: e...
Bring link(s) between two nodes up or down. Usage: link node1 node2 [up/down]
do_link
python
mininet/mininet
mininet/cli.py
https://github.com/mininet/mininet/blob/master/mininet/cli.py
BSD-3-Clause