Ejemplo n.º 1
0
def testRemoteNet( remote='ubuntu2' ):
    "Test remote Node classes"
    print '*** Remote Node Test'
    net = Mininet( host=RemoteHost, switch=RemoteOVSSwitch,
                   link=RemoteLink )
    c0 = net.addController( 'c0' )
    # Make sure controller knows its non-loopback address
    Intf( 'eth0', node=c0 ).updateIP()
    print "*** Creating local h1"
    h1 = net.addHost( 'h1' )
    print "*** Creating remote h2"
    h2 = net.addHost( 'h2', server=remote )
    print "*** Creating local s1"
    s1 = net.addSwitch( 's1' )
    print "*** Creating remote s2"
    s2 = net.addSwitch( 's2', server=remote )
    print "*** Adding links"
    net.addLink( h1, s1 )
    net.addLink( s1, s2 )
    net.addLink( h2, s2 )
    net.start()
    print 'Mininet is running on', quietRun( 'hostname' ).strip()
    for node in c0, h1, h2, s1, s2:
        print 'Node', node, 'is running on', node.cmd( 'hostname' ).strip()
    net.pingAll()
    CLI( net )
    net.stop()
Ejemplo n.º 2
0
def emptyNet():

    "Create an empty network and add nodes to it."

    net = Mininet(controller=Controller)

    info('*** Adding controller\n')
    net.addController('c0')

    info('*** Adding hosts\n')
    h1 = net.addHost('h1', ip='10.0.0.1')
    h2 = net.addHost('h2', ip='10.0.0.2')

    info('*** Adding switch\n')
    s3 = net.addSwitch('s3')

    info('*** Creating links\n')
    net.addLink(h1, s3)
    net.addLink(h2, s3)

    info('*** Starting network\n')
    net.start()

    info('*** Running CLI\n')
    CLI(net)

    info('*** Stopping network')
    net.stop()
Ejemplo n.º 3
0
def intfOptions():
    "run various traffic control commands on a single interface"
    net = Mininet(autoStaticArp=True)
    net.addController('c0')
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')
    s1 = net.addSwitch('s1')
    link1 = net.addLink(h1, s1, cls=TCLink)
    net.addLink(h2, s1)
    net.start()

    # flush out latency from reactive forwarding delay
    net.pingAll()

    info('\n*** Configuring one intf with bandwidth of 5 Mb\n')
    link1.intf1.config(bw=5)
    info('\n*** Running iperf to test\n')
    net.iperf()

    info('\n*** Configuring one intf with loss of 50%\n')
    link1.intf1.config(loss=50)
    info('\n')
    net.iperf((h1, h2), l4Type='UDP')

    info('\n*** Configuring one intf with delay of 15ms\n')
    link1.intf1.config(delay='15ms')
    info('\n*** Run a ping to confirm delay\n')
    net.pingPairFull()

    info('\n*** Done testing\n')
    net.stop()
Ejemplo n.º 4
0
def testPortNumbering():
    """Test port numbering:
       Create a network with 5 hosts (using Mininet's
       mid-level API) and check that implicit and
       explicit port numbering works as expected."""

    net = Mininet(controller=Controller)

    info('*** Adding controller\n')
    net.addController('c0')

    info('*** Adding hosts\n')
    h1 = net.addHost('h1', ip='10.0.0.1')
    h2 = net.addHost('h2', ip='10.0.0.2')
    h3 = net.addHost('h3', ip='10.0.0.3')
    h4 = net.addHost('h4', ip='10.0.0.4')
    h5 = net.addHost('h5', ip='10.0.0.5')

    info('*** Adding switch\n')
    s1 = net.addSwitch('s1')

    info('*** Creating links\n')
    # host 1-4 connect to ports 1-4 on the switch
    net.addLink(h1, s1)
    net.addLink(h2, s1)
    net.addLink(h3, s1)
    net.addLink(h4, s1)
    # specify a different port to connect host 5 to on the switch.
    net.addLink(h5, s1, port1=1, port2=9)

    info('*** Starting network\n')
    net.start()

    # print the interfaces and their port numbers
    info('\n*** printing and validating the ports '
         'running on each interface\n')
    for intfs in s1.intfList():
        if not intfs.name == "lo":
            info(intfs, ': ', s1.ports[intfs], '\n')
            info('Validating that', intfs, 'is actually on port',
                 s1.ports[intfs], '... ')
            if validatePort(s1, intfs):
                info('Validated.\n')
    print '\n'

    # test the network with pingall
    net.pingAll()
    print '\n'

    info('*** Stopping network')
    net.stop()
Ejemplo n.º 5
0
def multiControllerNet():
    "Create a network from semi-scratch with multiple controllers."

    net = Mininet(controller=Controller, switch=OVSSwitch)

    print "*** Creating (reference) controllers"
    c1 = net.addController('c1', port=6633)
    c2 = net.addController('c2', port=6634)

    print "*** Creating switches"
    s1 = net.addSwitch('s1')
    s2 = net.addSwitch('s2')

    print "*** Creating hosts"
    hosts1 = [net.addHost('h%d' % n) for n in 3, 4]
    hosts2 = [net.addHost('h%d' % n) for n in 5, 6]

    print "*** Creating links"
    for h in hosts1:
        net.addLink(s1, h)
    for h in hosts2:
        net.addLink(s2, h)
    net.addLink(s1, s2)

    print "*** Starting network"
    net.build()
    c1.start()
    c2.start()
    s1.start([c1])
    s2.start([c2])

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

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()