コード例 #1
0
ファイル: sshd1.py プロジェクト: Robin131/graduate
def connectToRootNS(network, switch, ip, routes):
    root = Node('root', inNamespace=False)
    intf = network.addLink(root, switch).intf1
    root.setIP(ip, intf=intf)
    root.setMAC("10:00:00:00:00:00")

    network.start()
    for route in routes:
        root.cmd('route add -net ' + route + ' dev ' + str(intf))
        print("route add completed=================")
    for route in routes:
        root.cmd('route add -net ' + route + ' dev ' + str(intf))
        print("route add completed=================")
コード例 #2
0
def myNet():
   "Defines a custom topology on mininet."

   print "*** Starting MyNet ***"
   cParams = ControllerParams( '10.0.3.0', 24 )
   net = Mininet( controller=RemoteController, switch=OVSKernelSwitch, cparams=cParams )

   print "** Adding controller"
   c = net.addController( 'c0' )

   print "** Adding switches"
   s1 = net.addSwitch( 's1' )
   s2 = net.addSwitch( 's2' )
   s3 = net.addSwitch( 's3' )
   s4 = net.addSwitch( 's4' )

   print "** Adding hosts"
   h5 = net.addHost( 'h5', ip='10.0.3.5' )
   h6 = net.addHost( 'h6', ip='10.0.3.6' )
   h7 = net.addHost( 'h7', ip='10.0.3.7' )
   h8 = net.addHost( 'h8', ip='10.0.3.8' )
   h9 = net.addHost( 'h9', ip='10.0.3.9' )

   print "** Linking switches together"
   s1.linkTo( s2 )
   s2.linkTo( s3 )
   s2.linkTo( s4 )

   print "** Linking hosts to switches"
   h5.linkTo( s1 )
   h6.linkTo( s3 )
   h7.linkTo( s3 )
   h8.linkTo( s4 )
   h9.linkTo( s4 )

   #print "** Setting up IP addresses"
   #h5.setIP( h5.defaultIntf(), '10.0.3.5', 24)

   #extraPort1 = s1.newPort()
   #extraPortName1 = s1.intfName( extraPort1 )
   #print "** Adding extra port to s1 - " + extraPortName1
   #s1.addIntf( extraPortName1, extraPort1 )

   #print "** Linking xeth0 to s1 port " + extraPortName1
   #makeIntfPair( "xeth0", extraPortName1 )

   #extraPort2 = s4.newPort()
   #extraPortName2 = s4.intfName( extraPort2 )
   #print "** Adding extra port to s4 - " + extraPortName2
   #s4.addIntf( extraPortName2, extraPort2 )

   #print "** Linking xeth1 to s4 port " + extraPortName2
   #makeIntfPair( "xeth1", extraPortName2 )

   print "** Creating extra node to enable access to others"
   # Create a node in root namespace and link to switch 0
   root = Node( 'root', inNamespace=False )
   root.linkTo( s1 )
   root.setMAC( root.defaultIntf(), "00:00:00:10:00:64" )
   root.setIP( root.defaultIntf(), "10.0.3.100", 24 )

   #Configure everything
   s1.setMAC ( 's1-eth1', '00:00:00:10:01:01' )
   s1.setMAC ( 's1-eth2', '00:00:00:10:01:02' )
   s1.setMAC ( 's1-eth3', '00:00:00:10:01:03' )
   s2.setMAC ( 's2-eth1', '00:00:00:10:02:01' )
   s2.setMAC ( 's2-eth2', '00:00:00:10:02:02' )
   s2.setMAC ( 's2-eth3', '00:00:00:10:02:03' )
   s3.setMAC ( 's3-eth1', '00:00:00:10:03:01' )
   s3.setMAC ( 's3-eth2', '00:00:00:10:03:02' )
   s3.setMAC ( 's3-eth3', '00:00:00:10:03:03' )
   s4.setMAC ( 's4-eth1', '00:00:00:10:04:01' )
   s4.setMAC ( 's4-eth2', '00:00:00:10:04:02' )
   s4.setMAC ( 's4-eth3', '00:00:00:10:04:03' )
   s1.setIP ( s1.defaultIntf(), '10.0.3.1', 24 )
   s2.setIP ( s2.defaultIntf(), '10.0.3.2', 24 )
   s3.setIP ( s3.defaultIntf(), '10.0.3.3', 24 )
   s4.setIP ( s4.defaultIntf(), '10.0.3.4', 24 )

   h5.setMAC( h5.defaultIntf(), "00:00:00:10:00:05" )
   h6.setMAC( h6.defaultIntf(), "00:00:00:10:00:06" )
   h7.setMAC( h7.defaultIntf(), "00:00:00:10:00:07" )
   h8.setMAC( h8.defaultIntf(), "00:00:00:10:00:08" )
   h9.setMAC( h9.defaultIntf(), "00:00:00:10:00:09" )

   print "** Firing up the network"
   net.build()
   # Try to add eth1 into s1
   #print s1.cmd( 'ovs-dpctl add-if dp0 eth1' )
   c.start()
   s1.start( [ c ] )
   s2.start( [ c ] )
   s3.start( [ c ] )
   s4.start( [ c ] )

   print "** Starting SSH Server in every host"
   sshpids = {}
   for h in net.hosts:
      h.cmd( '/usr/sbin/sshd -D &' )
      time.sleep(2) # Whait for the daemon to come up so we can see its pid (this is not very safe)
      output = h.cmd( 'cat /var/run/sshd.pid' )
      sshpids[h.name] = output.rstrip()

   print "** Starting Libvirt in every host"
   for h in net.hosts:
      ip = h.IP()
      h.cmd( 'ip addr flush ' + h.defaultIntf() )
      h.cmd( 'brctl addbr virbr1' )
      h.cmd( 'brctl addif virbr1 ' + h.defaultIntf() )
      h.cmd( 'ip link set dev virbr1 up' )
      h.setIP( 'virbr1', ip, 24 )
      h.cmd( '/home/juliano/' + h.name + '/sbin/libvirtd -d -l -p /home/juliano/' + h.name + '/var/run/libvirtd.pid -f /home/juliano/' + h.name + '/etc/libvirt/libvirtd.conf' )

   print "** Testing network"
   # net.pingAll()

   print "** Running CLI"
   CLI( net )

   print "** Killing daemons"
   for h in net.hosts:
      h.cmd( 'kill `cat /home/juliano/' + h.name + '/var/run/libvirtd.pid`' )
      if len( sshpids[h.name] ) < 7:
         h.cmd( 'kill ' + sshpids[h.name] )

   print "** Stopping network"
   net.stop()
コード例 #3
0
def myNet():
    "Defines a custom topology on mininet."

    print "*** Starting MyNet ***"
    cParams = ControllerParams( '10.0.3.0', 24 )
    net = Mininet( controller=RemoteController, switch=OVSKernelSwitch, cparams=cParams )

    print "** Adding controller"
    c = net.addController( 'c0' )

    print "** Adding switches"
    s1 = net.addSwitch( 's1' )
    s2 = net.addSwitch( 's2' )
    s3 = net.addSwitch( 's3' )
    s4 = net.addSwitch( 's4' )
    s5 = net.addSwitch( 's5' )
    s6 = net.addSwitch( 's6' )
    s7 = net.addSwitch( 's7' )
    s8 = net.addSwitch( 's8' )
    s9 = net.addSwitch( 's9' )
    s10 = net.addSwitch( 's10' )

    print "** Adding hosts"
    h1 = net.addHost( 'h1', ip='10.0.3.1' )
    h2 = net.addHost( 'h2', ip='10.0.3.2' )
    h3 = net.addHost( 'h3', ip='10.0.3.3' )
    h4 = net.addHost( 'h4', ip='10.0.3.4' )
    h5 = net.addHost( 'h5', ip='10.0.3.5' )
    h6 = net.addHost( 'h6', ip='10.0.3.6' )
    h7 = net.addHost( 'h7', ip='10.0.3.7' )
    h8 = net.addHost( 'h8', ip='10.0.3.8' )
    h9 = net.addHost( 'h9', ip='10.0.3.9' )
    h10 = net.addHost( 'h10', ip='10.0.3.10' )
    h11 = net.addHost( 'h11', ip='10.0.3.11' )
    h12 = net.addHost( 'h12', ip='10.0.3.12' )
    h13 = net.addHost( 'h13', ip='10.0.3.13' )
    h14 = net.addHost( 'h14', ip='10.0.3.14' )
    h15 = net.addHost( 'h15', ip='10.0.3.15' )
    h16 = net.addHost( 'h16', ip='10.0.3.16' )
    h17 = net.addHost( 'h17', ip='10.0.3.17' )
    h18 = net.addHost( 'h18', ip='10.0.3.18' )
    h19 = net.addHost( 'h19', ip='10.0.3.19' )
    h20 = net.addHost( 'h20', ip='10.0.3.20' )

    print "** Linking switches and hosts"
    # S1
    s1.linkTo( s2 )
    s1.linkTo( h1 )
    s1.linkTo( h2 )
    s1.linkTo( h3 )
    # S2
    s2.linkTo( s3 )
    s2.linkTo( s4 )
    s2.linkTo( s5 )
    # S3
    s3.linkTo( s6 )
    s3.linkTo( h4 )
    s3.linkTo( h5 )
    # S4
    s4.linkTo( s8 )
    s4.linkTo( h6 )
    s4.linkTo( h7 )
    s4.linkTo( h8 )
    # S5
    s5.linkTo( s9 )
    s5.linkTo( s10 )
    s5.linkTo( h9 )
    s5.linkTo( h10 )
    # S6
    s6.linkTo( s7 )
    s6.linkTo( h11 )
    s6.linkTo( h12 )
    s6.linkTo( h13 )
    # S7
    s7.linkTo( h14 )
    s7.linkTo( h15 )
    s7.linkTo( h16 )
    # S8
    s8.linkTo( h17 )
    s8.linkTo( h18 )
    # S9
    s9.linkTo( h19 )
    # S10
    s10.linkTo( h20 )

    print "** Creating extra node to enable access to others"
    # Create a node in root namespace and link to switch 0
    root = Node( 'root', inNamespace=False )
    root.linkTo( s1 )
    root.setMAC( root.defaultIntf(), "00:00:00:11:00:64" )
    root.setIP( root.defaultIntf(), "10.0.3.100", 24 )

    # Configure everything
    s1.setMAC ( 's1-eth1', '00:00:00:10:01:01' )
    s1.setMAC ( 's1-eth2', '00:00:00:10:01:02' )
    s1.setMAC ( 's1-eth3', '00:00:00:10:01:03' )
    s1.setMAC ( 's1-eth4', '00:00:00:10:01:04' )
    s1.setMAC ( 's1-eth5', '00:00:00:10:01:05' ) # Extra for the root

    s2.setMAC ( 's2-eth1', '00:00:00:10:02:01' )
    s2.setMAC ( 's2-eth2', '00:00:00:10:02:02' )
    s2.setMAC ( 's2-eth3', '00:00:00:10:02:03' )
    s2.setMAC ( 's2-eth4', '00:00:00:10:02:04' )

    s3.setMAC ( 's3-eth1', '00:00:00:10:03:01' )
    s3.setMAC ( 's3-eth2', '00:00:00:10:03:02' )
    s3.setMAC ( 's3-eth3', '00:00:00:10:03:03' )
    s3.setMAC ( 's3-eth4', '00:00:00:10:03:04' )

    s4.setMAC ( 's4-eth1', '00:00:00:10:04:01' )
    s4.setMAC ( 's4-eth2', '00:00:00:10:04:02' )
    s4.setMAC ( 's4-eth3', '00:00:00:10:04:03' )
    s4.setMAC ( 's4-eth4', '00:00:00:10:04:04' )
    s4.setMAC ( 's4-eth5', '00:00:00:10:04:05' )

    s5.setMAC ( 's5-eth1', '00:00:00:10:05:01' )
    s5.setMAC ( 's5-eth2', '00:00:00:10:05:02' )
    s5.setMAC ( 's5-eth3', '00:00:00:10:05:03' )
    s5.setMAC ( 's5-eth4', '00:00:00:10:05:04' )
    s5.setMAC ( 's5-eth5', '00:00:00:10:05:05' )

    s6.setMAC ( 's6-eth1', '00:00:00:10:06:01' )
    s6.setMAC ( 's6-eth2', '00:00:00:10:06:02' )
    s6.setMAC ( 's6-eth3', '00:00:00:10:06:03' )
    s6.setMAC ( 's6-eth4', '00:00:00:10:06:04' )
    s6.setMAC ( 's6-eth5', '00:00:00:10:06:05' )

    s7.setMAC ( 's7-eth1', '00:00:00:10:07:01' )
    s7.setMAC ( 's7-eth2', '00:00:00:10:07:02' )
    s7.setMAC ( 's7-eth3', '00:00:00:10:07:03' )
    s7.setMAC ( 's7-eth4', '00:00:00:10:07:04' )

    s8.setMAC ( 's8-eth1', '00:00:00:10:08:01' )
    s8.setMAC ( 's8-eth2', '00:00:00:10:08:02' )
    s8.setMAC ( 's8-eth3', '00:00:00:10:08:03' )

    s9.setMAC ( 's9-eth1', '00:00:00:10:09:01' )
    s9.setMAC ( 's9-eth2', '00:00:00:10:09:02' )

    s10.setMAC ( 's10-eth1', '00:00:00:10:10:01' )
    s10.setMAC ( 's10-eth2', '00:00:00:10:10:02' )

    s1.setIP ( s1.defaultIntf(), '10.0.3.101', 24 )
    s2.setIP ( s2.defaultIntf(), '10.0.3.102', 24 )
    s3.setIP ( s3.defaultIntf(), '10.0.3.103', 24 )
    s4.setIP ( s4.defaultIntf(), '10.0.3.104', 24 )
    s5.setIP ( s5.defaultIntf(), '10.0.3.105', 24 )
    s6.setIP ( s6.defaultIntf(), '10.0.3.106', 24 )
    s7.setIP ( s7.defaultIntf(), '10.0.3.107', 24 )
    s8.setIP ( s8.defaultIntf(), '10.0.3.108', 24 )
    s9.setIP ( s9.defaultIntf(), '10.0.3.109', 24 )
    s10.setIP ( s10.defaultIntf(), '10.0.3.110', 24 )

    h1.setMAC( h1.defaultIntf(), "00:00:00:11:00:01" )
    h2.setMAC( h2.defaultIntf(), "00:00:00:11:00:02" )
    h3.setMAC( h3.defaultIntf(), "00:00:00:11:00:03" )
    h4.setMAC( h4.defaultIntf(), "00:00:00:11:00:04" )
    h5.setMAC( h5.defaultIntf(), "00:00:00:11:00:05" )
    h6.setMAC( h6.defaultIntf(), "00:00:00:11:00:06" )
    h7.setMAC( h7.defaultIntf(), "00:00:00:11:00:07" )
    h8.setMAC( h8.defaultIntf(), "00:00:00:11:00:08" )
    h9.setMAC( h9.defaultIntf(), "00:00:00:11:00:09" )
    h10.setMAC( h10.defaultIntf(), "00:00:00:11:00:10" )
    h11.setMAC( h11.defaultIntf(), "00:00:00:11:00:11" )
    h12.setMAC( h12.defaultIntf(), "00:00:00:11:00:12" )
    h13.setMAC( h13.defaultIntf(), "00:00:00:11:00:13" )
    h14.setMAC( h14.defaultIntf(), "00:00:00:11:00:14" )
    h15.setMAC( h15.defaultIntf(), "00:00:00:11:00:15" )
    h16.setMAC( h16.defaultIntf(), "00:00:00:11:00:16" )
    h17.setMAC( h17.defaultIntf(), "00:00:00:11:00:17" )
    h18.setMAC( h18.defaultIntf(), "00:00:00:11:00:18" )
    h19.setMAC( h19.defaultIntf(), "00:00:00:11:00:19" )
    h20.setMAC( h20.defaultIntf(), "00:00:00:11:00:20" )

    print "** Firing up the network"
    net.build()
    c.start()
    for s in net.switches:
        s.start( [ c ] )
    
    print "** Starting SSH Server in every host"
    sshpids = {}
    for h in net.hosts:
        h.cmd( '/usr/sbin/sshd -D &' )
        time.sleep(0.5) # Whait for the daemon to come up so we can see its pid (this is not very safe)
        output = h.cmd( 'cat /var/run/sshd.pid' )
        sshpids[h.name] = output.rstrip()

    print "** Starting Libvirt in every host"
    for h in net.hosts:
        ip = h.IP()
        h.cmd( 'ip addr flush ' + h.defaultIntf() )
        if not os.path.exists( '/usr/local/etc/openvswitch/' + h.name + '-conf.db' ):
            h.cmd( 'ovsdb-tool create /usr/local/etc/openvswitch/' + h.name + '-conf.db /home/jwickboldt/openvswitch-1.10.0/vswitchd/vswitch.ovsschema' )
        h.cmd( 'ovsdb-server /usr/local/etc/openvswitch/' + h.name + '-conf.db --remote=punix:/usr/local/var/run/openvswitch/' + h.name + '-db.sock --pidfile=/usr/local/var/run/openvswitch/' + h.name + '-ovsdb-server.pid --detach' )
        h.cmd( 'ovs-vsctl --db=unix:/usr/local/var/run/openvswitch/' + h.name + '-db.sock --no-wait init' )
        h.cmd( 'ovs-vswitchd unix:/usr/local/var/run/openvswitch/' + h.name + '-db.sock --pidfile=/usr/local/var/run/openvswitch/' + h.name + '-ovs-vswitchd.pid --detach' )
        h.cmd( 'ovs-vsctl --db=unix:/usr/local/var/run/openvswitch/' + h.name + '-db.sock add-br virbr1' )
        h.cmd( 'ovs-vsctl --db=unix:/usr/local/var/run/openvswitch/' + h.name + '-db.sock add-port virbr1 ' + h.defaultIntf() )
        h.cmd( 'ovs-vsctl --db=unix:/usr/local/var/run/openvswitch/' + h.name + '-db.sock set-controller virbr1 tcp:10.0.3.100:6633' )
        h.cmd( 'ip link set dev virbr1 up' )
        h.setIP( 'virbr1', ip, 24 )

        # Default route through root-eth0
        h.cmd ( 'route add default gw 10.0.3.100' )
        h.cmd ( 'libvirtd-' + h.name + ' -d -l' )

    #print "** Testing network"
    #net.pingAll()

    print "** Running CLI"
    CLI( net )

    print "** Killing daemons"
    for h in net.hosts:
        h.cmd( 'kill `pidof libvirtd-' + h.name + '`' )
        h.cmd( 'ovs-vsctl --db=unix:/usr/local/var/run/openvswitch/' + h.name + '-db.sock del-br virbr1' )
        h.cmd( 'kill $(cat /usr/local/var/run/openvswitch/' + h.name + '-ovsdb-server.pid)' )
        h.cmd( 'kill $(cat /usr/local/var/run/openvswitch/' + h.name + '-ovs-vswitchd.pid)' )
        if len( sshpids[h.name] ) < 7:
            h.cmd( 'kill ' + sshpids[h.name] )

    print "** Stopping network"
    net.stop()
コード例 #4
0
ファイル: topology.py プロジェクト: assistof/sdn
def myNet(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)
    switch1 = Node('s1', inNamespace=False)
    h0 = Node('h0')
    h1 = Node('h1')

    info("*** Creating links\n")
    linkopts0 = dict(bw=100, delay='1ms', loss=0)
    linkopts1 = dict(bw=100, delay='10ms', loss=0)
    link0 = TCLink(h0, switch, **linkopts0)
    #initially, the delay from switch to switch1 is 10ms
    link1 = TCLink(switch, switch1, **linkopts1)
    link2 = TCLink(h1, switch1, **linkopts0)

    #print link0.intf1, link0.intf2
    link0.intf2.setMAC("0:0:0:0:0:1")
    link1.intf1.setMAC("0:0:0:0:0:2")
    link1.intf2.setMAC("0:1:0:0:0:1")
    link2.intf2.setMAC("0:1:0:0:0:2")

    info("*** Configuring hosts\n")
    h0.setIP('192.168.123.1/24')
    h1.setIP('192.168.123.2/24')
    h0.setMAC("a:a:a:a:a:a")
    h1.setMAC("8:8:8:8:8:8")

    info("*** Starting network using Open vSwitch\n")
    switch.cmd('ovs-vsctl del-br dp0')
    switch.cmd('ovs-vsctl add-br dp0')
    switch1.cmd('ovs-vsctl del-br dp1')
    switch1.cmd('ovs-vsctl add-br dp1')

    controller.cmd(cname + ' ' + cargs + '&')
    for intf in switch.intfs.values():
        print intf
        print switch.cmd('ovs-vsctl add-port dp0 %s' % intf)

    for intf in switch1.intfs.values():
        print intf
        print switch1.cmd('ovs-vsctl add-port dp1 %s' % intf)

    # Note: controller and switch are in root namespace, and we
    # can connect via loopback interface
    switch.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')
    switch1.cmd('ovs-vsctl set-controller dp1 tcp:127.0.0.1:6633')

    info('*** Waiting for switch to connect to controller')
    while 'is_connected' not in quietRun('ovs-vsctl show'):
        sleep(1)
        info('.')
    info('\n')

    def cDelay1():
        switch.cmdPrint('ethtool -K s0-eth1 gro off')
        switch.cmdPrint('tc qdisc del dev s0-eth1 root')
        switch.cmdPrint(
            'tc qdisc add dev s0-eth1 root handle 10: netem delay 50ms')
        switch1.cmdPrint('ethtool -K s1-eth0 gro off')
        switch1.cmdPrint('tc qdisc del dev s1-eth0 root')
        switch1.cmdPrint(
            'tc qdisc add dev s1-eth0 root handle 10: netem delay 50ms')

    def cDelay2():
        switch.cmdPrint('ethtool -K s0-eth1 gro off')
        switch.cmdPrint('tc qdisc del dev s0-eth1 root')
        switch.cmdPrint(
            'tc qdisc add dev s0-eth1 root handle 10: netem delay 200ms')
        switch1.cmdPrint('ethtool -K s1-eth0 gro off')
        switch1.cmdPrint('tc qdisc del dev s1-eth0 root')
        switch1.cmdPrint(
            'tc qdisc add dev s1-eth0 root handle 10: netem delay 200ms')

    # 15 seconds later, the delay from switch to switch 1 will change to 50ms
    t1 = Timer(15, cDelay1)
    t1.start()
    # 30 seconds later, the delay from switch to switch 1 will change to 200ms
    t2 = Timer(30, cDelay2)
    t2.start()

    #info( "*** Running test\n" )
    h0.cmdPrint('ping -i 1 -c 45 ' + h1.IP())
    sleep(1)
    info("*** Stopping network\n")
    controller.cmd('kill %' + cname)
    switch.cmd('ovs-vsctl del-br dp0')
    switch.deleteIntfs()
    switch1.cmd('ovs-vsctl del-br dp1')
    switch1.deleteIntfs()
    info('\n')
コード例 #5
0
def myNet(cname='controller', cargs='-v ptcp:'):
    "Create network from scratch using Open vSwitch."
    info("*** Creating nodes\n")
    controller = Node('c0', inNamespace=False)
    s1 = Node('s1', inNamespace=False)
    s2 = Node('s2', inNamespace=False)
    s3 = Node('s3', inNamespace=False)
    s4 = Node('s4', inNamespace=False)
    s6 = Node('s6', inNamespace=False)
    s7 = Node('s7', inNamespace=False)
    h1 = Node('h1')
    h2 = Node('h2')
    h3 = Node('h3')
    h4 = Node('h4')
    h5 = Node('h5')
    h6 = Node('h6')
    h7 = Node('h7')
    h8 = Node('h8')
    server = Node('server')

    info("*** Creating links\n")
    linkopts0 = dict(bw=10, delay='1ms', loss=0)
    TCLink(s1, s2, **linkopts0)
    TCLink(s2, s3, **linkopts0)
    TCLink(s2, s4, **linkopts0)
    TCLink(s2, s6, **linkopts0)
    TCLink(s2, s7, **linkopts0)
    TCLink(s1, h3, **linkopts0)
    TCLink(s1, h4, **linkopts0)
    TCLink(s3, h1, **linkopts0)
    TCLink(s4, h7, **linkopts0)
    TCLink(s4, h8, **linkopts0)
    TCLink(s6, h5, **linkopts0)
    TCLink(s6, h6, **linkopts0)
    TCLink(s7, server, **linkopts0)

    info("*** Configuring hosts\n")
    h1.setIP('30.30.1.20/22')
    h2.setIP('30.30.1.21/22')
    h3.setIP('30.30.1.22/22')
    h4.setIP('30.30.1.23/22')
    h5.setIP('30.30.1.24/22')
    h6.setIP('30.30.1.25/22')
    h7.setIP('30.30.1.26/22')
    h8.setIP('30.30.1.27/22')
    server.setIP('30.30.1.28/22')
    h1.setMAC('00:00:00:43:92:01')
    h2.setMAC('00:00:00:43:92:02')
    h3.setMAC('00:00:00:43:92:03')
    h4.setMAC('00:00:00:43:92:04')
    h5.setMAC('00:00:00:43:92:05')
    h6.setMAC('00:00:00:43:92:06')
    h7.setMAC('00:00:00:43:92:07')
    h8.setMAC('00:00:00:43:92:08')
    server.setMAC('00:00:00:43:92:09')
    s1.setMAC('00:00:02:43:92:01')
    s2.setMAC('00:00:02:43:92:02')
    s3.setMAC('00:00:02:43:92:03')
    s4.setMAC('00:00:02:43:92:04')
    s6.setMAC('00:00:02:43:92:05')
    s7.setMAC('00:00:02:43:92:06')

    info("*** Starting network using Open vSwitch\n")

    s1.cmd('ovs-vsctl del-br dp1')
    s1.cmd('ovs-vsctl add-br dp1')
    s2.cmd('ovs-vsctl del-br dp2')
    s2.cmd('ovs-vsctl add-br dp2')
    s3.cmd('ovs-vsctl del-br dp3')
    s3.cmd('ovs-vsctl add-br dp3')
    s4.cmd('ovs-vsctl del-br dp4')
    s4.cmd('ovs-vsctl add-br dp4')
    s6.cmd('ovs-vsctl del-br dp6')
    s6.cmd('ovs-vsctl add-br dp6')
    s7.cmd('ovs-vsctl del-br dp7')
    s7.cmd('ovs-vsctl add-br dp7')

    controller.cmd(cname + ' ' + cargs + '&')
    for intf in s1.intfs.values():
        print intf
        print s1.cmd('ovs-vsctl add-port dp1 %s' % intf)

    for intf in s2.intfs.values():
        print intf
        print s2.cmd('ovs-vsctl add-port dp2 %s' % intf)

    for intf in s3.intfs.values():
        print intf
        print s3.cmd('ovs-vsctl add-port dp3 %s' % intf)

    for intf in s4.intfs.values():
        print intf
        print s4.cmd('ovs-vsctl add-port dp4 %s' % intf)

    for intf in s6.intfs.values():
        print intf
        print s6.cmd('ovs-vsctl add-port dp6 %s' % intf)

    for intf in s7.intfs.values():
        print intf
        print s7.cmd('ovs-vsctl add-port dp7 %s' % intf)

    # Note: controller and switch are in root namespace, and we
    # can connect via loopback interface
    s1.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')
    s2.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')
    s3.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')
    s4.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')
    s6.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')
    s7.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')

    info('*** Waiting for switch to connect to controller')
    while 'is_connected' not in quietRun('ovs-vsctl show'):
        sleep(1)
        info('.')
    info('\n')

    #print s0.cmd('ovs-ofctl show dp0')
    #info( "*** Running test\n" )
    h3.cmdPrint('ping -c 3 ' + h2.IP())
    h4.cmdPrint('ping -c 3 ' + h2.IP())
    h2.cmd('iperf -s &')
    h3.cmdPrint('iperf -c 30.30.1.23 -t 10')
    h4.cmdPrint('iperf -c 30.30.1.23 -t 10')
    s1.cmdPrint('ethtool -K s0-eth2 gro off')
    s1.cmdPrint('tc qdisc del dev s0-eth2 root')
    s1.cmdPrint(
        'tc qdisc add dev s0-eth2 root handle 1: cbq avpkt 1000 bandwidth 10Mbit rate 512kbit bounded isolated'
    )
    h3.cmdPrint('iperf -c 30.30.1.23 -t 10')
    h4.cmdPrint('iperf -c 30.30.1.23 -t 10')

    info("*** Stopping network\n")
    controller.cmd('kill %' + cname)
    s1.cmd('ovs-vsctl del-br dp1')
    s1.deleteIntfs()
    s2.cmd('ovs-vsctl del-br dp2')
    s2.deleteIntfs()
    info('\n')