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


Python Mininet.waitConnected方法代码示例

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


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

示例1: FaucetTaggedTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
class FaucetTaggedTest(FaucetTest):

    CONFIG = CONFIG_HEADER + """
interfaces:
    %(port_1)d:
        tagged_vlans: [100]
        description: "b1"
    %(port_2)d:
        tagged_vlans: [100]
        description: "b2"
    %(port_3)d:
        tagged_vlans: [100]
        description: "b3"
    %(port_4)d:
        tagged_vlans: [100]
        description: "b4"
vlans:
    100:
        description: "tagged"
"""

    def setUp(self):
        self.CONFIG = self.CONFIG % PORT_MAP
        super(FaucetTaggedTest, self).setUp()
        self.topo = FaucetSwitchTopo(n_tagged=4)
        self.net = Mininet(self.topo, controller=FAUCET)
        self.net.start()
        dumpNodeConnections(self.net.hosts)
        self.net.waitConnected()
        self.wait_until_matching_flow('actions=CONTROLLER')

    def test_tagged(self):
        self.assertEquals(0, self.net.pingAll())
开发者ID:KitL,项目名称:faucet,代码行数:35,代码来源:faucet_mininet_test.py

示例2: FaucetTaggedTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
class FaucetTaggedTest(FaucetTest):

    CONFIG = CONFIG_HEADER + """
interfaces:
    1:
        tagged_vlans: [100]
        description: "b1"
    2:
        tagged_vlans: [100]
        description: "b2"
    3:
        tagged_vlans: [100]
        description: "b3"
    4:
        tagged_vlans: [100]
        description: "b4"
vlans:
    100:
        description: "tagged"
"""

    def setUp(self):
        super(FaucetTaggedTest, self).setUp()
        self.topo = FaucetSwitchTopo(n_tagged=4)
        self.net = Mininet(self.topo, controller=FAUCET)
        self.net.start()
        dumpNodeConnections(self.net.hosts)
        self.net.waitConnected()

    def test_tagged(self):
        self.assertEquals(0, self.net.pingAll())
开发者ID:dr-clark,项目名称:faucet,代码行数:33,代码来源:faucet_mininet_test.py

示例3: FaucetTaggedAndUntaggedVlanTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
class FaucetTaggedAndUntaggedVlanTest(FaucetUntaggedTest):

    CONFIG = CONFIG_HEADER + """
interfaces:
    1:
        tagged_vlans: [100]
        description: "b1"
    2:
        native_vlan: 100
        description: "b2"
    3:
        native_vlan: 100
        description: "b3"
    4:
        native_vlan: 100
        description: "b4"
vlans:
    100:
        description: "mixed"
        unicast_flood: False
"""

    def setUp(self):
        super(FaucetUntaggedTest, self).setUp()
        self.topo = FaucetSwitchTopo(n_tagged=1, n_untagged=3)
        self.net = Mininet(self.topo, controller=FAUCET)
        self.net.start()
        dumpNodeConnections(self.net.hosts)
        self.net.waitConnected()
        self.wait_until_matching_flow('actions=CONTROLLER')

    def test_untagged(self):
        self.net.pingAll()
开发者ID:dr-clark,项目名称:faucet,代码行数:35,代码来源:faucet_mininet_test.py

示例4: FaucetUntaggedTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
class FaucetUntaggedTest(FaucetTest):

    CONFIG = CONFIG_HEADER + """
interfaces:
    1:
        native_vlan: 100
        description: "b1"
    2:
        native_vlan: 100
        description: "b2"
    3:
        native_vlan: 100
        description: "b3"
    4:
        native_vlan: 100
        description: "b4"
vlans:
    100:
        description: "untagged"
"""

    def setUp(self):
        super(FaucetUntaggedTest, self).setUp()
        self.topo = FaucetSwitchTopo(n_untagged=4)
        self.net = Mininet(self.topo, controller=FAUCET)
        self.net.start()
        dumpNodeConnections(self.net.hosts)
        self.net.waitConnected()
        self.wait_until_matching_flow('actions=CONTROLLER')

    def test_untagged(self):
        self.assertEquals(0, self.net.pingAll())
开发者ID:dr-clark,项目名称:faucet,代码行数:34,代码来源:faucet_mininet_test.py

示例5: test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
def test( serverCount ):
    "Test this setup"
    setLogLevel( 'info' )
    net = Mininet( topo=SingleSwitchTopo( 3 ),
                   controller=[ ONOSCluster( 'c0', serverCount ) ],
                   switch=ONOSOVSSwitch )
    net.start()
    net.waitConnected()
    CLI( net )
    net.stop()
开发者ID:Shashikanth-Huawei,项目名称:bmp,代码行数:12,代码来源:onos.py

示例6: FaucetTaggedAndUntaggedTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
class FaucetTaggedAndUntaggedTest(FaucetTest):

    CONFIG = CONFIG_HEADER + """
interfaces:
    1:
        tagged_vlans: [100]
        description: "b1"
    2:
        tagged_vlans: [100]
        description: "b2"
    3:
        native_vlan: 101
        description: "b3"
    4:
        native_vlan: 101
        description: "b4"
vlans:
    100:
        description: "tagged"
    101:
        description: "untagged"
"""

    def setUp(self):
        super(FaucetTaggedAndUntaggedTest, self).setUp()
        self.topo = FaucetSwitchTopo(n_tagged=2, n_untagged=2)
        self.net = Mininet(self.topo, controller=FAUCET)
        self.net.start()
        dumpNodeConnections(self.net.hosts)
        self.net.waitConnected()

    def test_seperate_untagged_tagged(self):
        tagged_host_pair = self.net.hosts[0:1]
        untagged_host_pair = self.net.hosts[2:3]
        # hosts within VLANs can ping each other
        self.assertEquals(0, self.net.ping(tagged_host_pair))
        self.assertEquals(0, self.net.ping(untagged_host_pair))
        # hosts cannot ping hosts in other VLANs
        self.assertEquals(100,
            self.net.ping([tagged_host_pair[0], untagged_host_pair[0]]))

    def tearDown(self):
        self.net.stop()
        super(FaucetTaggedAndUntaggedTest, self).tearDown()
        time.sleep(1)
开发者ID:Gigglebit,项目名称:faucet_343,代码行数:47,代码来源:faucet_mininet_test.py

示例7: FaucetTaggedAndUntaggedTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
class FaucetTaggedAndUntaggedTest(FaucetTest):

    CONFIG = CONFIG_HEADER + """
interfaces:
    %(port_1)d:
        tagged_vlans: [100]
        description: "b1"
    %(port_2)d:
        tagged_vlans: [100]
        description: "b2"
    %(port_3)d:
        native_vlan: 101
        description: "b3"
    %(port_4)d:
        native_vlan: 101
        description: "b4"
vlans:
    100:
        description: "tagged"
    101:
        description: "untagged"
"""

    def setUp(self):
        self.CONFIG = self.CONFIG % PORT_MAP
        super(FaucetTaggedAndUntaggedTest, self).setUp()
        self.topo = FaucetSwitchTopo(n_tagged=2, n_untagged=2)
        self.net = Mininet(self.topo, controller=FAUCET)
        self.net.start()
        dumpNodeConnections(self.net.hosts)
        self.net.waitConnected()
        self.wait_until_matching_flow('actions=CONTROLLER')

    def test_seperate_untagged_tagged(self):
        tagged_host_pair = self.net.hosts[0:1]
        untagged_host_pair = self.net.hosts[2:3]
        # hosts within VLANs can ping each other
        self.assertEquals(0, self.net.ping(tagged_host_pair))
        self.assertEquals(0, self.net.ping(untagged_host_pair))
        # hosts cannot ping hosts in other VLANs
        self.assertEquals(100,
            self.net.ping([tagged_host_pair[0], untagged_host_pair[0]]))
开发者ID:KitL,项目名称:faucet,代码行数:44,代码来源:faucet_mininet_test.py

示例8: perfTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
def perfTest():
    "Create network and run simple performance test"
    """available tests include FatTreeTopoNoLoop, DcellNoLoop, FacebookNoLoop"""
    topo = FatTreeTopoNoLoop(n=4)
    test = 'FatTreeTopoNoLoop'
    run_test = 2 #Set to 1 for IPERF test or 2 for Ping Test
    packetsize = 1472
    #max packet size 1472 since MTU is 1500
    net = Mininet(topo=topo, controller=RemoteController, link=TCLink, ipBase='192.168.0.0/16')

    net.start()
    seconds = 10
    #dumpNodeConnections(net.hosts) #Dumps the connections from each host
    net.waitConnected()


    print "Waiting for network to converge"
    net.pingAll()
    host = {}

    print "Starting tests"
    if (test == 'FatTreeTopoNoLoop'):
        max_host = 512
        for y in range(0, max_host):
            host_name = 'h' +str(y)
            host[y] = net.get(host_name)

    elif (test == 'FacebookNoLoop'):
        print "*** Running Facebook tests ***"
        max_host = 48
        for x in range(0, max_host):
            host_name = 'h' +str(x)
            host[x] = net.get(host_name)

    elif (test =='DcellNoLoop'):
        print "***Running DCellNoLoop tests"
        max_host = 50
        for x in range(0, max_host):
            host_name = 'h' +str(x)
            print "Adding %s" % host_name
            host[x] = net.get(host_name)

    if (run_test == 1):
        print "IPERF Testing"
        sleep(5)


    elif (run_test ==2 and test =='DcellNoLoop'):

        print "Ping Testing"
        outfiles, errfiles = {}, {}
        bottom = 0
        for h in range(0, max_host):
            # Create and/or erase output files
            outfiles[ host[h] ] = '/tmp/%s.out' % host[h].name
            errfiles[ host[h] ] = '/tmp/%s.err' % host[h].name
            host[h].cmd( 'echo >', outfiles[ host[h] ] )
            host[h].cmd( 'echo >', errfiles[ host[h] ] )
            # Start pings

            if (h<max_host-1):
                host[h].cmdPrint('ping', host[h+1].IP(), '-s', packetsize,
                        '>', outfiles[ host[h] ],
                        '2>', errfiles[ host[h] ],
                        '&' )
            else:
                host[h].cmdPrint('ping', host[0].IP(), '-s', packetsize,
                        '>', outfiles[ host[h] ],
                        '2>', errfiles[ host[h] ],
                        '&' )


        print "Monitoring output for", seconds, "seconds"
        f = open('output%s.txt' % str(packetsize), 'w')
        for host[h], line in monitorFiles( outfiles, seconds, timeoutms=500 ):
            if host[h]:
                f.write(line)



        #Still working on killing ping. Run as last test.
        #for h in range(0, max_host):
            #host[h].cmd( 'kill %ping')


        sleep(11)
    elif (run_test ==2 and test !='DcellNoLoop'):
        print "Ping Testing"
        outfiles, errfiles = {}, {}
        for h in range(0, max_host):
            # Create and/or erase output files
            outfiles[ host[h] ] = '/tmp/%s.out' % host[h].name
            errfiles[ host[h] ] = '/tmp/%s.err' % host[h].name
            host[h].cmd( 'echo >', outfiles[ host[h] ] )
            host[h].cmd( 'echo >', errfiles[ host[h] ] )
            # Start pings

            if (h<max_host-1):
                host[h].cmdPrint('ping', host[h+1].IP(), '-s', packetsize,
                        '>', outfiles[ host[h] ],
#.........这里部分代码省略.........
开发者ID:lebiednik,项目名称:ICNmininet,代码行数:103,代码来源:scaling_hosts.py

示例9: perfTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
def perfTest():
    "Create network and run simple performance test"
    """available tests include FatTreeTopoNoLoop, FatTreeTopo, Dcell, Facebook"""
    topo = FatTreeTopoNoLoop(n=4)
    test = 'FatTreeTopoNoLoop'
    run_test = 2 #Set to 1 for IPERF test or 2 for Ping Test
    net = Mininet(topo=topo, controller=RemoteController, link=TCLink, ipBase='192.168.0.0/24')

    net.start()
    seconds = 10
    #dumpNodeConnections(net.hosts) #Dumps the connections from each host
    net.waitConnected()


    print "Waiting for network to converge"
    net.pingAll()
    host = {}
    
    print "Starting tests"
    if (test == 'FatTreeTopoNoLoop' or test == 'FatTreeTopo' or test == 'FatTreeTopotest'):
        max_host = 8
        for y in range(0, max_host):
            host_name = 'h' +str(y)
            host[y] = net.get(host_name)

    elif (test == 'Facebook' or test =='FacebookNoLoop'):
        print "*** Running Facebook tests ***"
        max_host = 48
        for y in range(0, max_host):
            host_name = 'h' +str(y)
            host[y] = net.get(host_name)

    elif (test =='DcellNoLoop' or test == 'Dcell'):
        print "***Running DCellNoLoop tests"
        max_host = 25
        for x in range(0, max_host):
            host_name = 'h' +str(x)
            print "Adding %s" % host_name
            host[x] = net.get(host_name)

    if (run_test == 1):
        print "IPERF Testing"
        if ((max_host%2) == 0):
            for x in range(0, (max_host/2)):
                src = host[x]
                dst = host[(max_host-1)-x]
                thread.start_new_thread(iperf_thread, (net, src, dst))
            sleep(10)
            for x in range(0, (max_host/2)):
                dst = host[x]
                src = host[(max_host-1)-x]
                thread.start_new_thread(iperf_thread, (net, src, dst))
            sleep(10)
        else:
            dst = host[0]
            src = host[5]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[1]
            src = host[10]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[2]
            src = host[15]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[3]
            src = host[20]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[6]
            src = host[11]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[7]
            src = host[16]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[8]
            src = host[21]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[12]
            src = host[17]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[13]
            src = host[22]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            dst = host[18]
            src = host[23]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            sleep(10)

            src = host[0]
            dst = host[5]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            src = host[1]
            dst = host[10]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            src = host[2]
            dst = host[15]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            src = host[3]
            dst = host[20]
            thread.start_new_thread(iperf_thread, (net, src, dst))
            src = host[6]
            dst = host[11]
#.........这里部分代码省略.........
开发者ID:lebiednik,项目名称:ICNmininet,代码行数:103,代码来源:performancetest.py

示例10: FaucetTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import waitConnected [as 别名]
class FaucetTest(unittest.TestCase):

    ONE_GOOD_PING = '1 packets transmitted, 1 received, 0% packet loss'
    CONFIG = ''
    CONTROLLER_IPV4 = '10.0.0.254'
    CONTROLLER_IPV6 = 'fc00::1:254'
    OFCTL = 'ovs-ofctl -OOpenFlow13'

    def setUp(self):
        self.tmpdir = tempfile.mkdtemp()
        os.environ['FAUCET_CONFIG'] = os.path.join(self.tmpdir,
             'faucet.yaml')
        os.environ['FAUCET_LOG'] = os.path.join(self.tmpdir,
             'faucet.log')
        os.environ['FAUCET_EXCEPTION_LOG'] = os.path.join(self.tmpdir,
             'faucet-exception.log')
        self.debug_log_path = os.path.join(self.tmpdir, 'ofchannel.log')
        self.CONFIG = '\n'.join((
            self.get_config_header(DPID, HARDWARE),
            self.CONFIG % PORT_MAP,
            'ofchannel_log: "%s"' % self.debug_log_path))
        open(os.environ['FAUCET_CONFIG'], 'w').write(self.CONFIG)
        self.net = None
        self.topo = None

    def get_config_header(self, dpid, hardware):
        return '''
---
dp_id: 0x%s
name: "faucet-1"
hardware: "%s"
''' % (dpid, hardware)

    def attach_physical_switch(self):
        switch = self.net.switches[0]
        hosts_count = len(self.net.hosts)
        for i, test_host_port in enumerate(sorted(SWITCH_MAP)):
            port_i = i + 1
            mapped_port_i = port_i + hosts_count
            phys_port = Intf(SWITCH_MAP[test_host_port], node=switch)
            switch.cmd('ifconfig %s up' % phys_port)
            switch.cmd('ovs-vsctl add-port %s %s' % (switch.name, phys_port.name))
            for port_pair in ((port_i, mapped_port_i), (mapped_port_i, port_i)):
                port_x, port_y = port_pair
                switch.cmd('%s add-flow %s in_port=%u,actions=output:%u' % (
                    self.OFCTL, switch.name, port_x, port_y))
        for _ in range(20):
            if (os.path.exists(self.debug_log_path) and
                os.path.getsize(self.debug_log_path) > 0):
                return
            time.sleep(1)
        print 'physical switch could not connect to controller'
        sys.exit(-1)

    def start_net(self):
        self.net = Mininet(self.topo, controller=FAUCET)
        self.net.start()
        if SWITCH_MAP:
            self.attach_physical_switch()
        else:
            self.net.waitConnected()
            self.wait_until_matching_flow('actions=CONTROLLER')
        dumpNodeConnections(self.net.hosts)

    def tearDown(self):
        if self.net is not None:
            self.net.stop()
            # Mininet takes a long time to actually shutdown.
            # TODO: detect and block when Mininet isn't done.
            time.sleep(5)
        shutil.rmtree(self.tmpdir)

    def add_host_ipv6_address(self, host, ip_v6):
        host.cmd('ip -6 addr add %s dev %s' % (ip_v6, host.intf()))

    def one_ipv4_ping(self, host, dst):
        ping_result = host.cmd('ping -c1 %s' % dst)
        self.assertTrue(re.search(self.ONE_GOOD_PING, ping_result))

    def one_ipv4_controller_ping(self, host):
        self.one_ipv4_ping(host, self.CONTROLLER_IPV4)

    def one_ipv6_ping(self, host, dst):
        # TODO: retry our one ping. We should not have to retry.
        for _ in range(2):
            ping_result = host.cmd('ping6 -c1 %s' % dst)
            if re.search(self.ONE_GOOD_PING, ping_result):
                return
        self.assertTrue(re.search(self.ONE_GOOD_PING, ping_result))

    def one_ipv6_controller_ping(self, host):
        self.one_ipv6_ping(host, self.CONTROLLER_IPV6)

    def wait_until_matching_flow(self, flow, timeout=5):
        # TODO: actually verify flows were communicated to the physical switch.
        # Could use size of ofchannel log, though this is not authoritative.
        if SWITCH_MAP:
            time.sleep(1)
            return
        switch = self.net.switches[0]
#.........这里部分代码省略.........
开发者ID:cangus,项目名称:faucet,代码行数:103,代码来源:faucet_mininet_test.py


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