Cleanup of doc files.
Fixed xterm.py (and cleanup) to clean up screen sessions. Cleaned up sshd.py (though interface is still in flux.) Added 1024-node network example (treenet1024.py). Added example showing multiple tests on a single network (multitest.py). Renamed examples to make them easier to type!
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Test bandwidth on linear networks of varying size, using both
|
||||
the kernel and user datapaths.
|
||||
Test bandwidth (using iperf) on linear networks of varying size,
|
||||
using both kernel and user datapaths.
|
||||
|
||||
Each network looks like:
|
||||
|
||||
@@ -11,7 +11,6 @@ h0 <-> s0 <-> s1 .. sN <-> h1
|
||||
Note: by default, the reference controller only supports 16
|
||||
switches, so this test WILL NOT WORK unless you have recompiled
|
||||
your controller to support a 100 switches (or more.)
|
||||
|
||||
"""
|
||||
|
||||
from mininet import init, LinearNet, iperfTest
|
||||
@@ -36,7 +35,7 @@ def linearBandwidthTest():
|
||||
print "*** Linear network results for", datapath, "datapath:"
|
||||
print
|
||||
result = results[ datapath ]
|
||||
print "SwitchCount\tiPerf results"
|
||||
print "SwitchCount\tiperf Results"
|
||||
for switchCount, bandwidth in result:
|
||||
print switchCount, '\t\t',
|
||||
print bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client'
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"Run multiple tests on a network."
|
||||
|
||||
from mininet import init, TreeNet, pingTestVerbose, iperfTest, Cli
|
||||
|
||||
if __name__ == '__main__':
|
||||
init()
|
||||
network = TreeNet( depth=2, fanout=2, kernel=True )
|
||||
network.start()
|
||||
network.runTest( pingTestVerbose )
|
||||
network.runTest( iperfTest)
|
||||
network.runTest( Cli )
|
||||
network.stop()
|
||||
+34
-37
@@ -1,11 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""Create a network and start sshd(8) on the hosts.
|
||||
While something like rshd(8) would be lighter and faster,
|
||||
(and perfectly adequate on an in-machine network)
|
||||
the advantage of running sshd is that scripts can work
|
||||
unchanged on mininet and hardware."""
|
||||
"""
|
||||
Create a network and start sshd(8) on the hosts.
|
||||
|
||||
While something like rshd(8) would be lighter and faster,
|
||||
(and perfectly adequate on an in-machine network)
|
||||
the advantage of running sshd is that scripts can work
|
||||
unchanged on mininet and hardware.
|
||||
"""
|
||||
|
||||
import sys ; readline = sys.stdin.readline
|
||||
from mininet import init, Node, createLink, TreeNet, Cli
|
||||
|
||||
def nets( hosts ):
|
||||
@@ -17,42 +21,35 @@ def nets( hosts ):
|
||||
nets[ net ] = True
|
||||
return nets.keys()
|
||||
|
||||
def addRoutes( node, nets, intf ):
|
||||
"Add routes from node to nets through intf."
|
||||
for net in nets:
|
||||
node.cmdPrint( 'route add -net ' + net + ' dev ' + intf )
|
||||
|
||||
def removeRoutes( node, nets ):
|
||||
"Remove routes to nets from node."
|
||||
for net in nets:
|
||||
node.cmdPrint( 'route del -net ' + net )
|
||||
|
||||
def sshd( network ):
|
||||
"Start sshd up on each host, routing appropriately."
|
||||
controllers, switches, hosts = (
|
||||
network.controllers, network.switches, network.hosts )
|
||||
# Create a node in root ns and link to switch 0
|
||||
def connectToRootNS( network, switch ):
|
||||
"Connect hosts to root namespace via switch. Starts network."
|
||||
# Create a node in root namespace and link to switch 0
|
||||
root = Node( 'root', inNamespace=False )
|
||||
createLink( root, switches[ 0 ] )
|
||||
createLink( root, switch )
|
||||
ip = '10.0.123.1'
|
||||
root.setIP( root.intfs[ 0 ], ip, '/24' )
|
||||
# Start network that now includes link to root namespace
|
||||
network.start()
|
||||
# Add routes
|
||||
routes = nets( hosts )
|
||||
addRoutes( root, routes, root.intfs[ 0 ] )
|
||||
# Start up sshd on each host
|
||||
for host in hosts: host.cmdPrint( '/usr/sbin/sshd' )
|
||||
# Dump out IP addresses and run CLI
|
||||
print
|
||||
print "*** Hosts are running sshd at the following addresses:"
|
||||
for host in hosts: print host.name, host.IP()
|
||||
print
|
||||
print "*** Starting Mininet CLI - type 'exit' or ^D to exit"
|
||||
network.runTest( Cli )
|
||||
network.stop()
|
||||
removeRoutes( root, routes )
|
||||
|
||||
routes = nets( network.hosts )
|
||||
intf = root.intfs[ 0 ]
|
||||
for net in routes:
|
||||
root.cmdPrint( 'route add -net ' + net + ' dev ' + intf )
|
||||
|
||||
def startServers( network, server ):
|
||||
"Start network, and servers on each host."
|
||||
connectToRootNS( network, network.switches[ 0 ] )
|
||||
for host in network.hosts: host.cmdPrint( server )
|
||||
|
||||
if __name__ == '__main__':
|
||||
init()
|
||||
network = TreeNet( depth=1, fanout=2, kernel=True )
|
||||
sshd( network )
|
||||
network = TreeNet( depth=1, fanout=4, kernel=True )
|
||||
startServers( network, '/usr/sbin/sshd' )
|
||||
print
|
||||
print "*** Hosts are running sshd at the following addresses:"
|
||||
print
|
||||
for host in network.hosts: print host.name, host.IP()
|
||||
print
|
||||
print "*** Press return to shut down network: ",
|
||||
readline()
|
||||
network.stop()
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Create a 1024-host network, and run the CLI on it.
|
||||
If this fails because of kernel limits, you may have
|
||||
to adjust them, e.g. by adding entries to /etc/sysctl.conf
|
||||
and running sysctl -p.
|
||||
"""
|
||||
|
||||
from mininet import init, TreeNet
|
||||
|
||||
if __name__ == '__main__':
|
||||
init()
|
||||
network = TreeNet( depth=2, fanout=32, kernel=True )
|
||||
network.run( Cli )
|
||||
+13
-12
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Create a network and run an xterm (connected via screen(1) ) on each host.
|
||||
Requires xterm(1) and GNU screen(1).
|
||||
Create a network and run an xterm (connected via screen(1) ) on each
|
||||
host. Requires xterm(1) and GNU screen(1).
|
||||
"""
|
||||
|
||||
import os
|
||||
import os, re
|
||||
from subprocess import Popen
|
||||
from mininet import init, TreeNet, Cli, quietRun
|
||||
|
||||
@@ -13,18 +13,19 @@ def makeXterm( node, title ):
|
||||
"Run screen on a node, and hook up an xterm."
|
||||
node.cmdPrint( 'screen -dmS ' + node.name )
|
||||
title += ': ' + node.name
|
||||
if not node.inNamespace:
|
||||
title += ' (root namespace)'
|
||||
if not node.inNamespace: title += ' (root)'
|
||||
cmd = [ 'xterm', '-title', title ]
|
||||
cmd += [ '-e', 'screen', '-D', '-RR', '-S', node.name ]
|
||||
return Popen( cmd )
|
||||
|
||||
def cleanUpScreens():
|
||||
"Remove moldy old screen sessions."
|
||||
# XXX We need to implement this - otherwise those darned
|
||||
# screen sessions will just accumulate
|
||||
output = quietRun( 'screen -ls' )
|
||||
pass
|
||||
r = r'(\d+.[hsc]\d+)'
|
||||
output = quietRun( 'screen -ls' ).split( '\n' )
|
||||
for line in output:
|
||||
m = re.search( r, line )
|
||||
if m is not None:
|
||||
quietRun( 'screen -S ' + m.group( 1 ) + ' -X kill' )
|
||||
|
||||
def makeXterms( nodes, title ):
|
||||
terms = []
|
||||
@@ -34,18 +35,18 @@ def makeXterms( nodes, title ):
|
||||
return terms
|
||||
|
||||
def xterms( controllers, switches, hosts ):
|
||||
cleanUpScreens()
|
||||
terms = []
|
||||
terms += makeXterms( controllers, 'controller' )
|
||||
terms += makeXterms( switches, 'switch' )
|
||||
terms += makeXterms( hosts, 'host' )
|
||||
# Wait for xterms to exit
|
||||
for term in terms:
|
||||
for term in terms:
|
||||
os.waitpid( term.pid, 0 )
|
||||
cleanUpScreens()
|
||||
|
||||
if __name__ == '__main__':
|
||||
init()
|
||||
print "Running xterms on", os.environ[ 'DISPLAY' ]
|
||||
cleanUpScreens()
|
||||
network = TreeNet( depth=2, fanout=2, kernel=True )
|
||||
network.run( xterms )
|
||||
cleanUpScreens()
|
||||
Reference in New Issue
Block a user