linearbandwidth.py now works for kernel switch.

This commit is contained in:
Bob Lantz
2010-03-04 16:55:38 -08:00
parent 47e26cce19
commit 95f6e7b728
+48 -41
View File
@@ -4,46 +4,52 @@
Test bandwidth (using iperf) on linear networks of varying size, Test bandwidth (using iperf) on linear networks of varying size,
using both kernel and user datapaths. using both kernel and user datapaths.
Each network has N switches and N+1 hosts, connected as follows: We construct a network of N switches and N+1 hosts, connected as follows:
h0 <-> s0 <-> s1 .. sN-1 hN <-> s0 <-> s1 .. sN-1
| | | | | |
h1 h2 hN hN+1 hN+2 hN+N
Note: by default, the reference controller only supports 16 Note: by default, the reference controller only supports 16
switches, so this test WILL NOT WORK unless you have recompiled switches, so this test WILL NOT WORK unless you have recompiled
your controller to support 100 switches (or more.) your controller to support 100 switches (or more.)
""" """
from mininet.mininet import init, Network, defaultNames, Host, Switch import sys
from mininet.mininet import createLink, flush, iperf, pingTestVerbose, Cli flush = sys.stdout.flush
class LinearNet( Network ): from mininet.net import init, Mininet
def __init__( self, switchCount, **kwargs ): from mininet.node import Host, KernelSwitch, UserSwitch
self.switchCount = switchCount from mininet.topo import Topo, Node
Network.__init__( self, **kwargs ) from mininet.log import lg
def makeNet( self, controller ):
snames, hnames, dpnames = defaultNames() class LinearTopo( Topo ):
previous = None "Topology for a string of N switches and 1+N hosts."
hosts = []
switches = [] def __init__( self, N ):
def newHost( switch ):
host = Host( hnames.next() ) # Add default members to class.
createLink( host, switch ) super( LinearTopo, self ).__init__()
print host.name, ; flush()
return [ host ] # Create switch and host nodes
print "*** Creating linear network of size", self.switchCount switches = range( 0, N )
for s in range( 0, self.switchCount ): hosts = range( N, 2*N + 1 )
dp = dpnames.next() if self.kernel else None for id in switches:
switch = Switch( snames.next(), dp ) self._add_node( id, Node( is_switch=True ) )
switches += [ switch ] for id in hosts:
print switch.name, ; flush() self._add_node( id, Node( is_switch=False ) )
if not self.kernel: createLink( controller, switch )
if s == 0: hosts += newHost( switch ) # Connect switches
hosts += newHost( switch) for s in switches[ :-1 ]:
if previous is not None: createLink( previous, switch) self._add_edge( s, s + 1 )
previous = switch
return switches, hosts # Connect hosts
self._add_edge( hosts[ 0 ], switches[ 0 ] )
for s in switches:
self._add_edge( s, s + N + 1)
# Consider all switches and hosts 'on'
self.enable_all()
def linearBandwidthTest( lengths ): def linearBandwidthTest( lengths ):
@@ -54,19 +60,19 @@ def linearBandwidthTest( lengths ):
switchCount = max( lengths ) switchCount = max( lengths )
for datapath in datapaths: for datapath in datapaths:
k = datapath == 'kernel' Switch = KernelSwitch if datapath == 'kernel' else UserSwitch
results[ datapath ] = [] results[ datapath ] = []
network = LinearNet( switchCount, kernel=k) net = Mininet( topo=LinearTopo( switchCount ), switch=Switch )
network.start() net.start()
print "*** testing basic connectivity"
net.ping( [ net.hosts[ 0 ], net.hosts[ -1 ] ] )
print "*** testing bandwidth"
for n in lengths: for n in lengths:
def test( controllers, switches, hosts ):
print "testing h0 <-> h" + `n`, ; flush() print "testing h0 <-> h" + `n`, ; flush()
result = iperf( [ hosts[ 0 ], hosts[ n ] ] ) bandwidth = net.iperf( [ net.hosts[ 0 ], net.hosts[ n ] ] )
print result ; flush() print bandwidth ; flush()
return result
bandwidth = network.runTest( test )
results[ datapath ] += [ ( n, bandwidth ) ] results[ datapath ] += [ ( n, bandwidth ) ]
network.stop() net.stop()
for datapath in datapaths: for datapath in datapaths:
print print
@@ -81,8 +87,9 @@ def linearBandwidthTest( lengths ):
print print
if __name__ == '__main__': if __name__ == '__main__':
lg.setLogLevel( 'info' )
init() init()
print "*** Running linearBandwidthTest" print "*** Running linearBandwidthTest"
linearBandwidthTest( [ 1, 10, 20, 40, 60, 80, 100 ] ) linearBandwidthTest( [ 1, 10 ] )