Exemple #1
0
def main(cli=0, ipv6=0):
    net = Mininet( controller = None )

    # add hosts
    h1 = net.addHost( 'h1', ip = '172.16.101.5/24', mac = '00:04:00:00:00:02' )
    h2 = net.addHost( 'h2', ip = '172.16.102.5/24', mac = '00:05:00:00:00:02' )

    # add switch 1
    sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw1/l3_bgp',
            pcap_dump = True )

    # add switch 2
    sw2 = net.addSwitch( 'sw2', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw2/l3_bgp',
            pcap_dump = True )

    # add links
    if StrictVersion(VERSION) <= StrictVersion('2.2.0') :
        net.addLink( sw1, h1, port1 = 1 )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2 )
        net.addLink( sw2, h2, port1 = 1 )
    else:
        net.addLink( sw1, h1, port1 = 1, fast=False )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2, fast=False )
        net.addLink( sw2, h2, port1 = 1, fast=False )

    net.start()

    # hosts configuration - ipv4
    h1.setDefaultRoute( 'via 172.16.101.1' )
    h2.setDefaultRoute( 'via 172.16.102.1' )

    if ipv6:
        # hosts configuration - ipv6
        h1.setIP6('2ffe:0101::5', 64, 'h1-eth0')
        h2.setIP6('2ffe:0102::5', 64, 'h2-eth0')
        h1.setDefaultRoute( 'via 2ffe:0101::1', True )
        h2.setDefaultRoute( 'via 2ffe:0102::1', True )

    sw1.cmd( 'service quagga start')
    sw2.cmd( 'service quagga start')

    result = 0
    if cli:
        CLI( net )
    else:
        sleep(30)

        node_values = net.values()
        print node_values

        hosts = net.hosts
        print hosts

        # ping hosts
        print "PING BETWEEN THE HOSTS"
        result = net.ping(hosts,30)

        if result != 0:
            print "PING FAILED BETWEEN HOSTS %s"  % (hosts)
        else:
            print "PING SUCCESSFUL!!!"

        if ipv6:
            # ping6 hosts
            print "PING6 BETWEEN THE HOSTS"
            result = net.ping6(hosts, 30)
            if result != 0:
                print "PING6 FAILED BETWEEN HOSTS %s" % (hosts)
            else:
                print "PING6 SUCCESSFUL!!!"

        # print host arp table & routes
        for host in hosts:
            print "ARP ENTRIES ON HOST"
            print host.cmd('arp -n')
            print "HOST ROUTES"
            print host.cmd('route')
            print "HOST INTERFACE LIST"
            intfList = host.intfNames()
            print intfList


    net.stop()
    return result
Exemple #2
0
def main(cli=0, ipv6=0):
    net = Mininet( controller = None )

    # add hosts
    h1 = net.addHost( 'h1', ip = '172.16.101.5/24', mac = '00:04:00:00:00:02' )
    h2 = net.addHost( 'h2', ip = '172.16.102.5/24', mac = '00:05:00:00:00:02' )

    # add switch 1
    sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw1/l3_static',
            pcap_dump = True )

    # add switch 2
    sw2 = net.addSwitch( 'sw2', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw2/l3_static',
            pcap_dump = True )

    # add links
    if StrictVersion(VERSION) <= StrictVersion('2.2.0') :
        net.addLink( sw1, h1, port1 = 1 )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2 )
        net.addLink( sw2, h2, port1 = 1 )
    else:
        net.addLink( sw1, h1, port1 = 1, fast=False )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2, fast=False )
        net.addLink( sw2, h2, port1 = 1, fast=False )

    net.start()

    # hosts configuration - ipv4
    h1.setARP( ip = '172.16.101.1', mac = '00:01:00:00:00:01' )
    h2.setARP( ip = '172.16.102.1', mac = '00:02:00:00:00:01' )

    h1.setDefaultRoute( 'via 172.16.101.1' )
    h2.setDefaultRoute( 'via 172.16.102.1' )

    if ipv6:
        # hosts configuration - ipv6
        h1.setIP6('2ffe:0101::5', 64, 'h1-eth0')
        h2.setIP6('2ffe:0102::5', 64, 'h2-eth0')

        h1.setDefaultRoute('via 2ffe:0101::1', True)
        h2.setDefaultRoute('via 2ffe:0102::1', True)

    result = 0

    if cli:
        CLI( net )
    else:
        sleep(10)
        hosts = net.hosts
        print hosts

        # ping hosts
        print "ping between the hosts"
        result = net.ping(hosts, 30)
        if result != 0:
            print "PING FAILED BETWEEN HOSTS %s" % (hosts)
        else:
            print "PING SUCCESSFUL"

        if ipv6:
            result = net.ping6(hosts, 30)
            if result != 0:
                print "PING6 FAILED BETWEEN HOSTS %s" % (hosts)
            else:
                print "PING6 SUCCESSFUL"

        # print host arp table & routes
        for host in hosts:
            print "arp entries on host"
            print host.cmd('arp -n')
            print "host routes"
            print host.cmd('route')
            print "host interface list"
            intfList = host.intfNames()
            print intfList

    net.stop()
    return result
Exemple #3
0
def main(cli=0, ipv6=0):
    net = Mininet( controller = None )

    # add hosts
    h1 = net.addHost( 'h1', ip = '172.16.101.5/24', mac = '00:04:00:00:00:02' )
    h2 = net.addHost( 'h2', ip = '172.16.102.5/24', mac = '00:05:00:00:00:02' )

    # add switch 1
    sw1 = net.addSwitch( 'sw1', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw1/l3_ospf',
            pcap_dump = True )

    # add switch 2
    sw2 = net.addSwitch( 'sw2', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw2/l3_ospf',
            pcap_dump = True )

    # add links
    if StrictVersion(VERSION) <= StrictVersion('2.2.0') :
        net.addLink( sw1, h1, port1 = 1 )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2 )
        net.addLink( sw2, h2, port1 = 1 )
    else:
        net.addLink( sw1, h1, port1 = 1, fast=False )
        net.addLink( sw1, sw2, port1 = 2, port2 = 2, fast=False )
        net.addLink( sw2, h2, port1 = 1, fast=False )

    net.start()

    # hosts configuration - ipv4
    h1.setDefaultRoute( 'via 172.16.101.1' )
    h2.setDefaultRoute( 'via 172.16.102.1' )

    if ipv6:
        # hosts configuration - ipv6
        h1.setIP6( '2ffe:0101::5', 64, 'h1-eth0' )
        h2.setIP6( '2ffe:0102::5', 64, 'h2-eth0' )

        h1.setDefaultRoute( 'via 2ffe:0101::1', True )
        h2.setDefaultRoute( 'via 2ffe:0102::1', True )

    sw1.cmd( 'service quagga start')
    sw2.cmd( 'service quagga start')

    result = 0

    if cli:
        CLI( net )
    else:
        sleep(60)

        node_values = net.values()
        print node_values

        hosts = net.hosts
        print hosts

        # ping hosts
        print "PING BETWEEN THE HOSTS"
        result = net.ping(hosts,30)

        if result != 0:
            print "PING FAILED BETWEEN HOSTS %s"  % (hosts)
        else:
            print "PING SUCCESSFUL!!!"

        if ipv6:
            print "PING6 BETWEEN THE HOSTS"
            result = net.ping6(hosts, 30)

            if result != 0:
                print "PING6 FAILED BETWEEN HOSTS %s" % (hosts)
            else:
                print "PING6 SUCCESSFUL!!!"

        # print host arp table & routes
        for host in hosts:
            print "ARP ENTRIES ON HOST"
            print host.cmd('arp -n')
            print "HOST ROUTES"
            print host.cmd('route')
            print "HOST INTERFACE LIST"
            intfList = host.intfNames()
            print intfList

    net.stop()
    return result