当前位置: 首页>>代码示例>>Python>>正文


Python Mininet.ping6方法代码示例

本文整理汇总了Python中mininet.net.Mininet.ping6方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.ping6方法的具体用法?Python Mininet.ping6怎么用?Python Mininet.ping6使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.net.Mininet的用法示例。


在下文中一共展示了Mininet.ping6方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping6 [as 别名]
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
开发者ID:25dedezembro,项目名称:p4factory,代码行数:82,代码来源:swl_l3_static.py

示例2: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping6 [as 别名]
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
开发者ID:25dedezembro,项目名称:p4factory,代码行数:88,代码来源:swl_bgp.py


注:本文中的mininet.net.Mininet.ping6方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。