Working on examples.

Added new example to create xterms.
Other minor changes.
This commit is contained in:
Bob Lantz
2009-12-10 23:39:06 -08:00
parent 4ccc7ee941
commit 748e35d50f
6 changed files with 117 additions and 43 deletions
+6 -7
View File
@@ -1,22 +1,21 @@
#!/usr/bin/python
"""Create a tree network of depth 4 and fanout 2, and
test connectivity using pingTest."""
from mininet import init, TreeNet, iperfTest
def bigTreePing64():
"""Create a tree network of depth 4 and fanout 2, and
test connectivity using pingTest."""
results = {}
print "*** Testing Mininet with kernel and user datapath"
for datapath in [ 'kernel', 'user' ]:
k = datapath == 'kernel'
results[ datapath ] = []
for switchCount in range( 1, 4 ):
print "*** Creating Linear Network of size", switchCount
network = TreeNet( depth=4, fanout=2, kernel=k )
testResult = network.run( iperfTest )
network = TreeNet( depth=4, fanout=4, kernel=k )
testResult = network.run( pingTest )
results[ datapath ] += testResult
print "*** Test results:", results
+24 -13
View File
@@ -1,36 +1,47 @@
#!/usr/bin/python
"""
Test bandwidth on a linear network of varying size, using both
the kernel and user datapaths.
The network looks like:
h0 <-> s0 <-> s1 .. sN <-> h1
"""
from mininet import init, LinearNet, iperfTest
def linearBandwidthTest():
"""Test bandwidth on a linear network of varying size, using both
the kernel and user datapaths."""
print "*** Testing Mininet with kernel and user datapath"
datapaths = [ 'kernel' ]
datapaths = [ 'kernel', 'user' ]
switchCounts = [ 1, 20, 40, 60, 80, 100 ]
results = {}
for datapath in datapaths:
k = datapath == 'kernel'
results[ datapath ] = []
for switchCount in range( 1, 17, 2 ):
print "*** Creating Linear Network of size", switchCount
for switchCount in switchCounts:
print "*** Creating linear network of size", switchCount
network = LinearNet( switchCount, k)
bandwidth = network.run( iperfTest )
results[ datapath ] += [ ( switchCount, bandwidth ) ]
for datapath in datapaths:
print
print "*** Linear network results for", datapath, "datapath"
print "*** Linear network results for", datapath, "datapath:"
print
result = results[ datapath ]
print "SwitchCount\tiPerf results"
for switchCount, bandwidth in result:
print "switchCount:", switchCount, "bandwidth:", bandwidth[ 0 ]
print switchCount, '\t\t',
print bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client'
print
print
if __name__ == '__main__':
init()
print "*** Running linearBandwidthTest"
linearBandwidthTest()
exit( 1 )
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/python
"""Create a tree network and run the CLI on it."""
from mininet import init, TreeNet, Cli
def treeInteract():
network = TreeNet( depth=2, fanout=4, kernel=True )
network.run( Cli )
if __name__ == '__main__':
init()
treeInteract()
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/python
"Create a network and run an xterm (connected via screen) on each host."
import os
from subprocess import Popen
from mininet import init, TreeNet, Cli, quietRun
def makeXterm( node, title ):
"Run screen on a node, and hook up an xterm."
node.cmdPrint( 'screen -dmS ' + node.name )
cmd = 'xterm -title ' + title + ':' + node.name
cmd += ' -e screen -D -RR -S ' + node.name
return Popen( cmd.split( ' ' ) )
def makeXterms( nodes, title ):
terms = []
for node in nodes:
if not node.execed:
terms += [ makeXterm( node, title ) ]
return terms
def xterms( controllers, switches, hosts ):
terms = []
terms += makeXterms( controllers, 'controller' )
terms += makeXterms( switches, 'switch' )
terms += makeXterms( hosts, 'host' )
# Wait for completion
for term in terms:
os.waitpid( term.pid, 0 )
def treeXterms():
print "Running xterms on", os.environ[ 'DISPLAY' ]
network = TreeNet( depth=2, fanout=4, kernel=True )
network.run( xterms )
if __name__ == '__main__':
init()
treeXterms()