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


Python Mininet.values方法代码示例

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


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

示例1: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import values [as 别名]
def main():
    behavioral_model = os.path.join(sys.path[0], '../targets/switch/behavioral-model')
    topo = SingleSwitchTopo(behavioral_model)
    net = Mininet(topo=topo, host=P4Host, switch=OpenflowEnabledP4Switch,
                  controller=None )
    net.start()

    h1 = net.get('h1')
    h1.setARP("10.0.0.1", "00:aa:bb:00:00:00")
    h1.setDefaultRoute("dev eth0 via 10.0.0.1")
    h1.describe()

    h2 = net.get('h2')
    h2.setARP("10.0.1.1", "00:aa:bb:00:00:01")
    h2.setDefaultRoute("dev eth0 via 10.0.1.1")
    h2.describe()

    configure_switch()

    time.sleep(1)

    print "Ready !"

    result = 0
    if parser_args.cli:
        CLI( net )
    else:
        time.sleep(3)

        node_values = net.values()
        print node_values

        hosts = net.hosts
        print hosts

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

        # 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

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

    net.stop()
    return result
开发者ID:wsfroes,项目名称:p4factory,代码行数:58,代码来源:openflow_l2.py

示例2: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import values [as 别名]
def main():
    lg.setLogLevel('info')

    context = Context()
    if not get_cmd_line_args(context):
        return

    print 'Starting with [%s] switches' % context.switch_number

    # Create the topology with the context args taken from the cmd-line
    myTopo = create_topology(context)

    # The network
    myNet = Mininet(myTopo)

    # The SDN-remote_controller connection
    mySDNController = myNet.addController(
        context.remote_controller_name,
        customConstructor({'remote': RemoteController},
                          context.remote_controller_args))
    myLocalController = myNet.addController('c1', controller=OVSController)
    myLocalController.start()

    dump_hosts(myNet)

    # This will output the nodes port connections to MININET_NET_FILE
    dumpNodeConnections(myNet.values())
    # This will output the nodes port connections to MININET_DUMP_FILE
    dumpNodes(myNet.values())

    # start_gateways(myNet)
    start_switches(context, myNet, mySDNController, myLocalController)

    # Insert ovs-ofctl rules
    print 'Inserting flows into the switches...'
    init_flows(context)

    # Start the command line
    CLI(myNet)

    cleanup()
开发者ID:CiscoDevNet,项目名称:iOAM,代码行数:43,代码来源:sfc-openflow-renderer_mininet.py

示例3: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import values [as 别名]
def main():
    net = Mininet( controller=None )
    sw1 = net.addSwitch( 'sw1', cls=P4DockerSwitch,
                        target_name="p4openflowswitch",
                        start_program="/bin/bash")

    h1 = net.addHost( 'h1', ip = '10.0.0.1', mac = '00:04:00:00:00:02' )
    h2 = net.addHost( 'h2', ip = '10.0.0.2', mac = '00:05:00:00:00:02' )

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

    sw1.execProgram("/switch/docker/startup.sh", args="--of-ip %s" % parser_args.controller_ip)

    time.sleep(1)

    net.start()

    print "Ready !"

    result = 0
    time.sleep(3)

    if parser_args.cli:
        CLI(net)
    else:
        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!!!"

    net.stop()
    return result
开发者ID:p4lang,项目名称:switch,代码行数:50,代码来源:openflow_l2.py

示例4: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import values [as 别名]
def main(cli=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()

    # configure hosts
    h1.setDefaultRoute( 'via 172.16.101.1' )
    h2.setDefaultRoute( 'via 172.16.102.1' )

    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)

        # 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

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

    net.stop()
    return result
开发者ID:hanw,项目名称:p4factory,代码行数:71,代码来源:swl_bgp.py

示例5: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import values [as 别名]
def main(cli=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.18.101.5/24', mac = '00:04:00:00:00:03' )
    h3 = net.addHost( 'h3', ip = '172.16.102.5/24', mac = '00:05:00:00:00:02' )
    h4 = net.addHost( 'h4', ip = '172.18.102.5/24', mac = '00:05:00:00:00:03' )

    # add switch 1 - spine 1
    sw1 = net.addSwitch( 'sw1', target_name = "p4sonicswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw1/l3_bgp',
            pcap_dump = True, start_program='/bin/bash')

    # add switch 2 - spine 2
    sw2 = net.addSwitch( 'sw2', target_name = "p4sonicswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw2/l3_bgp',
            pcap_dump = True, start_program='/bin/bash')

    # add switch 3 - leaf 1
    sw3 = net.addSwitch( 'sw3', target_name = "p4sonicswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw3/l3_bgp',
            pcap_dump = True, start_program='/bin/bash')

    # add switch 4 - leaf 2
    sw4 = net.addSwitch( 'sw4', target_name = "p4sonicswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw4/l3_bgp',
            pcap_dump = True, start_program='/bin/bash')

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

    sw1.cpFile('run_bm_sw1.sh', '/sonic-swss/bmv2/run_bm.sh')
    sw1.execProgram('/scripts/startup.sh', args='-m  00:00:01:00:00:01')
    sw1.execProgram("/configs/startup_config.sh")

    sw2.cpFile('run_bm_sw2.sh', '/sonic-swss/bmv2/run_bm.sh')
    sw2.execProgram('/scripts/startup.sh', args='-m 00:00:01:00:00:02')
    sw2.execProgram("/configs/startup_config.sh")

    sw3.cpFile('run_bm_sw3.sh', '/sonic-swss/bmv2/run_bm.sh')
    sw3.execProgram('/scripts/startup.sh', args='-m 00:00:01:00:00:03')
    sw3.execProgram("/configs/startup_config.sh")

    sw4.cpFile('run_bm_sw4.sh', '/sonic-swss/bmv2/run_bm.sh')
    sw4.execProgram('/scripts/startup.sh', args='-m 00:00:01:00:00:04')
    sw4.execProgram("/configs/startup_config.sh")

    net.start()

    # hosts configuration - ipv4
    h1.setDefaultRoute( 'via 172.16.101.1' )
    h2.setDefaultRoute( 'via 172.18.101.1' )
    h3.setDefaultRoute( 'via 172.16.102.1' )
    h4.setDefaultRoute( 'via 172.18.102.1' )

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

    result = 0

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

        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!!!"

#.........这里部分代码省略.........
开发者ID:krambn,项目名称:sonic-swss,代码行数:103,代码来源:spine_leaf_topo.py

示例6: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import values [as 别名]
def main(cli=0):
    net = Mininet( controller = None )

    # add hosts
    h1 = net.addHost( 'h1', ip = '172.16.10.1/24' )
    h2 = net.addHost( 'h2', ip = '172.16.10.2/24' )

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

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

    # add switch 3
    sw3 = net.addSwitch( 'sw3', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw3/stp',
            pcap_dump = True )

    # add switch 4
    sw4 = net.addSwitch( 'sw4', target_name = "p4dockerswitch",
            cls = P4DockerSwitch, config_fs = 'configs/sw4/stp',
            pcap_dump = True )

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

    net.start()
    result = 0

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

        node_values = net.values()
        print node_values
        hosts = net.hosts
        print hosts

        print "PING BETWEEN THE HOSTS"
        result = net.ping(hosts, 30)
        # 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

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

    net.stop()
    return result
开发者ID:25dedezembro,项目名称:p4factory,代码行数:79,代码来源:swl_stp.py


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