Fix to work with new Topo class.

This commit is contained in:
Bob Lantz
2012-03-20 15:44:50 -07:00
parent ff56881946
commit e52d0ee1de
+29 -30
View File
@@ -6,9 +6,9 @@ using both kernel and user datapaths.
We construct a network of N hosts and N-1 switches, connected as follows: We construct a network of N hosts and N-1 switches, connected as follows:
h1 <-> sN+1 <-> sN+2 .. sN+N-1 h1 <-> s1 <-> s2 .. sN-1
| | | | | |
h2 h3 hN h2 h3 hN
WARNING: by default, the reference controller only supports 16 WARNING: 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
@@ -23,42 +23,40 @@ of switches, this example demonstrates:
""" """
from mininet.net import Mininet
from mininet.node import UserSwitch, OVSKernelSwitch
from mininet.topo import Topo
from mininet.log import lg
from mininet.util import irange
import sys import sys
flush = sys.stdout.flush flush = sys.stdout.flush
from mininet.net import Mininet
# from mininet.node import KernelSwitch
from mininet.node import UserSwitch, OVSKernelSwitch
from mininet.topo import Topo, Node
from mininet.log import lg
class LinearTestTopo( Topo ): class LinearTestTopo( Topo ):
"Topology for a string of N hosts and N-1 switches." "Topology for a string of N hosts and N-1 switches."
def __init__( self, N ): def __init__( self, N, **params ):
# Add default members to class. # Initialize topology
super( LinearTestTopo, self ).__init__() Topo.__init__( self, **params )
# Create switch and host nodes # Create switches and hosts
hosts = range( 1, N + 1 ) hosts = [ self.add_host( 'h%s' % h )
switches = range( N + 1 , N + N ) for h in irange( 1, N ) ]
for h in hosts: switches = [ self.add_switch( 's%s' % s )
self.add_node( h, Node( is_switch=False ) ) for s in irange( 1, N - 1 ) ]
for s in switches:
self.add_node( s, Node( is_switch=True ) )
# Wire up switches # Wire up switches
for s in switches[ :-1 ]: last = None
self.add_edge( s, s + 1 ) for switch in switches:
if last:
self.add_link( last, switch )
last = switch
# Wire up hosts # Wire up hosts
self.add_edge( hosts[ 0 ], switches[ 0 ] ) self.add_link( hosts[ 0 ], switches[ 0 ] )
for h in hosts[ 1: ]: for host, switch in zip( hosts[ 1: ], switches ):
self.add_edge( h, h + N - 1 ) self.add_link( host, switch )
# Consider all switches and hosts 'on'
self.enable_all()
def linearBandwidthTest( lengths ): def linearBandwidthTest( lengths ):
@@ -69,15 +67,16 @@ def linearBandwidthTest( lengths ):
switchCount = max( lengths ) switchCount = max( lengths )
hostCount = switchCount + 1 hostCount = switchCount + 1
switches = { # 'reference kernel': KernelSwitch, switches = { 'reference user': UserSwitch,
'reference user': UserSwitch,
'Open vSwitch kernel': OVSKernelSwitch } 'Open vSwitch kernel': OVSKernelSwitch }
topo = LinearTestTopo( hostCount )
for datapath in switches.keys(): for datapath in switches.keys():
print "*** testing", datapath, "datapath" print "*** testing", datapath, "datapath"
Switch = switches[ datapath ] Switch = switches[ datapath ]
results[ datapath ] = [] results[ datapath ] = []
net = Mininet( topo=LinearTestTopo( hostCount ), switch=Switch ) net = Mininet( topo=topo, switch=Switch )
net.start() net.start()
print "*** testing basic connectivity" print "*** testing basic connectivity"
for n in lengths: for n in lengths: