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


Python Mininet.ping方法代码示例

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


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

示例1: standalone

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def standalone():
	if "info" in argv:
		setLogLevel( 'info' )
	scls=None
	if "of" in argv:
		scls = StaticSwitch 
	elif "lr" in argv:
		scls = DRtr
	else:
		print("Supply either of (for OpenFlow) or lr (for a Linux Router)")
		exit(-1)
	topo = DTopo(scls=scls)
	net = Mininet(topo=topo,autoSetMacs=True)
	net.start()
	sw, h1, h2 = net.get('s1', 'h1', 'n1')
	if "noarp" not in argv:
		makearpentries(sw, [h1, h2])
	#print(sw.cmd("netstat -tulpen"))
	if "dump" in argv:
		if "lr" in argv:
			dump('iptables-save', sw.cmd('iptables-save'))
			dump('ip-route', sw.cmd('ip route'))
			dump('collectedmacs', sw.cmd('collectmacs.sh'))
		elif "of" in argv:
			print("of/dump TODO")
	if "test" in argv:
		sese = [h1,h2]
		net.ping(sese)
		tcpreachtests(net,sese,ports=[80,22])
	if "cli" in argv:
		CLI(net)
	net.stop()
开发者ID:ammbauer,项目名称:Iptables_Semantics,代码行数:34,代码来源:3chn.py

示例2: simple

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def simple():
	t=MyTopo();
	#c=Controller(name="c0",command="python ./pox/pox.py")
	#net=Mininet(t,controller=bridge);
	net=Mininet(topo=t,controller=lambda name:RemoteController(name,ip='127.0.0.1'))
	#net.addController(name="c0",port=6633);
	#mininet.node.RemoteController(port=6633)
	net.start();
	
	#print net.host;
	f=open("MacHost.txt","w");
	for i in net.hosts:
		print "i= ";
		print i;
		print Node.MAC(i);
		f.write(str(i)+" "+str(Node.MAC(i))+"\n");
	f.close();
	z=0
	f=open("/home/saumya/pox/output.txt","w")
	f.close()
	for i in net.hosts:
		for j in net.hosts:
			if(i!=j):
				time.sleep(10);
				net.ping([i,j])
				z=z+1;
				parse("/home/saumya/pox/output.txt");
				draw_graph();
开发者ID:kalyani12,项目名称:sdn-openflow,代码行数:30,代码来源:dup2.py

示例3: linearBandwidthTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def linearBandwidthTest( lengths ):

    "Check bandwidth at various lengths along a switch chain."

    results = {}
    switchCount = max( lengths )
    hostCount = switchCount + 1

    switches = { 'reference user': UserSwitch,
                 'Open vSwitch kernel': OVSKernelSwitch }

    # UserSwitch is horribly slow with recent kernels.
    # We can reinstate it once its performance is fixed
    del switches[ 'reference user' ]

    topo = LinearTestTopo( hostCount )

    # Select TCP Reno
    output = quietRun( 'sysctl -w net.ipv4.tcp_congestion_control=reno' )
    assert 'reno' in output

    for datapath in switches.keys():
        print( "*** testing", datapath, "datapath" )
        Switch = switches[ datapath ]
        results[ datapath ] = []
        link = partial( TCLink, delay='1ms' )
        net = Mininet( topo=topo, switch=Switch,
                       controller=Controller, waitConnected=True,
                       link=link )
        net.start()
        print( "*** testing basic connectivity" )
        for n in lengths:
            net.ping( [ net.hosts[ 0 ], net.hosts[ n ] ] )
        print( "*** testing bandwidth" )
        for n in lengths:
            src, dst = net.hosts[ 0 ], net.hosts[ n ]
            # Try to prime the pump to reduce PACKET_INs during test
            # since the reference controller is reactive
            src.cmd( 'telnet', dst.IP(), '5001' )
            print( "testing", src.name, "<->", dst.name )
            bandwidth = net.iperf( [ src, dst ], seconds=10 )
            print( bandwidth )
            flush()
            results[ datapath ] += [ ( n, bandwidth ) ]
        net.stop()

    for datapath in switches.keys():
        print()
        print( "*** Linear network results for", datapath, "datapath:" )
        print()
        result = results[ datapath ]
        print( "SwitchCount\tiperf Results" )
        for switchCount, bandwidth in result:
            print( switchCount, '\t\t' )
            print( bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client' )
        print()
    print()
开发者ID:jhall11,项目名称:mininet,代码行数:59,代码来源:linearbandwidth.py

示例4: linearBandwidthTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def linearBandwidthTest( lengths ):

    "Check bandwidth at various lengths along a switch chain."

    results = {}
    switchCount = max( lengths )
    hostCount = switchCount + 1

    switches = { 'reference user': UserSwitch,
                 'Open vSwitch kernel': OVSKernelSwitch }

    # UserSwitch is horribly slow with recent kernels.
    # We can reinstate it once its performance is fixed
    del switches[ 'reference user' ]

    topo = LinearTestTopo( hostCount )

    for datapath in switches.keys():
        print "*** testing", datapath, "datapath"
        Switch = switches[ datapath ]
        results[ datapath ] = []
        link = partial( TCLink, delay='1ms' )
        net = Mininet( topo=topo, switch=Switch,
                       controller=Controller, waitConnected=True,
                       link=link )
        net.start()
        print "*** testing basic connectivity"
        for n in lengths:
            net.ping( [ net.hosts[ 0 ], net.hosts[ n ] ] )
        print "*** testing bandwidth"
        for n in lengths:
            src, dst = net.hosts[ 0 ], net.hosts[ n ]
            print "testing", src.name, "<->", dst.name,
            bandwidth = net.iperf( [ src, dst ] )
            print bandwidth
            flush()
            results[ datapath ] += [ ( n, bandwidth ) ]
        net.stop()

    for datapath in switches.keys():
        print
        print "*** Linear network results for", datapath, "datapath:"
        print
        result = results[ datapath ]
        print "SwitchCount\tiperf Results"
        for switchCount, bandwidth in result:
            print switchCount, '\t\t',
            print bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client'
        print
    print
开发者ID:Azmonkh,项目名称:mininet,代码行数:52,代码来源:linearbandwidth.py

示例5: startNetwork

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def startNetwork():
    info( '** Creating Quagga network\n' )
    topo = QuaggaTopo()
    global net
    net = Mininet(topo, controller=None )
    net.start()

    info( '** Dumping host connections\n' )
    dumpNodeConnections(net.legacyRouters)

    info( '** Testing network connectivity\n' )
    net.ping(net.legacyRouters)

    info( '** Running CLI\n' )
    CLI( net )
开发者ID:aimonb,项目名称:miniNeXT,代码行数:17,代码来源:quagga.py

示例6: testLinkLoss

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
    def testLinkLoss( self ):
        "Verify that we see packet drops with a high configured loss rate."
        LOSS_PERCENT = 99
        REPS = 1
        lopts = { 'loss': LOSS_PERCENT, 'use_htb': True }
        mn = Mininet( topo=SingleSwitchOptionsTopo( n=N, lopts=lopts ),
                      host=CPULimitedHost, link=TCLink,
                      switch=self.switchClass,
                      waitConnected=True )
        # Drops are probabilistic, but the chance of no dropped packets is
        # 1 in 100 million with 4 hops for a link w/99% loss.
        dropped_total = 0
        mn.start()
        for _ in range(REPS):
            dropped_total += mn.ping(timeout='1')
        mn.stop()

        loptsStr = ', '.join( '%s: %s' % ( opt, value )
                              for opt, value in lopts.items() )
        msg = ( '\nTesting packet loss with %d%% loss rate\n'
                'number of dropped pings during mininet.ping(): %s\n'
                'expected number of dropped packets: 1\n'
                'Topo = SingleSwitchTopo, %s hosts\n'
                'Link = TCLink\n'
                'lopts = %s\n'
                'host = default\n'
                'switch = %s\n'
                % ( LOSS_PERCENT, dropped_total, N, loptsStr,
                    self.switchClass ) )

        self.assertGreater( dropped_total, 0, msg )
开发者ID:1514louluo,项目名称:mininet,代码行数:33,代码来源:test_hifi.py

示例7: FaucetTaggedAndUntaggedTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [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

示例8: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [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

示例9: testDecisionTopology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def testDecisionTopology():
    "Create network and run simple performance test"
    topo = SpecialTopo(100, 10)
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller=RemoteController)
    net.start()
    time.sleep(10)
    h1, h2, h3, h4, h5, h6 = net.hosts
    pairs = [(h1, h2), (h2, h3), (h4, h5), (h5, h6), (h1, h4), (h2, h5), (h3, h6), (h2, h4), (h3, h5)]
    for a,b in pairs:
        net.ping([a,b])
        net.iperf([a,b])
    for i in xrange(4):
        j = requests.get("http://localhost:8080/set?f={}".format(i)).json()
        print j["message"]
        print test_pings(h1, h6, 40)
        print net.iperf([h1,h6], l4Type='UDP', udpBw='10M')
        time.sleep(20)
    CLI(net)
    net.stop()
开发者ID:ThiagoRRamos,项目名称:SDN-StateMonitor,代码行数:21,代码来源:run_topos.py

示例10: linearBandwidthTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def linearBandwidthTest( lengths ):

    "Check bandwidth at various lengths along a switch chain."

    results = {}
    switchCount = max( lengths )
    hostCount = switchCount + 1

    switches = { 'reference user': UserSwitch,
                 'Open vSwitch kernel': OVSKernelSwitch }

    topo = LinearTestTopo( hostCount )

    for datapath in switches.keys():
        print "*** testing", datapath, "datapath"
        Switch = switches[ datapath ]
        results[ datapath ] = []
        net = Mininet( topo=topo, switch=Switch )
        net.start()
        print "*** testing basic connectivity"
        for n in lengths:
            net.ping( [ net.hosts[ 0 ], net.hosts[ n ] ] )
        print "*** testing bandwidth"
        for n in lengths:
            src, dst = net.hosts[ 0 ], net.hosts[ n ]
            print "testing", src.name, "<->", dst.name,
            bandwidth = net.iperf( [ src, dst ] )
            print bandwidth
            flush()
            results[ datapath ] += [ ( n, bandwidth ) ]
        net.stop()

    for datapath in switches.keys():
        print
        print "*** Linear network results for", datapath, "datapath:"
        print
        result = results[ datapath ]
        print "SwitchCount\tiperf Results"
        for switchCount, bandwidth in result:
            print switchCount, '\t\t',
            print bandwidth[ 0 ], 'server, ', bandwidth[ 1 ], 'client'
        print
    print
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:45,代码来源:linearbandwidth.py

示例11: FaucetTaggedAndUntaggedTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [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

示例12: startNetwork

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def startNetwork():
    info( '** Creating Quagga network\n' )
    topo = QuaggaTopo()
    global net
    net = Mininet(topo, controller=None )
    net.start()

    info( '** Dumping host connections\n' )
    dumpNodeConnections(net.legacyRouters)

    info( '** Testing network connectivity\n' )
    net.ping(net.legacyRouters)

    info( '** Collecting BGP neighbors\n' )
    for router in net.legacyRouters:
        quagga_cmd = "show ip bgp summary"
        result = router.cmd('vtysh -c \"%s\"' % quagga_cmd)
        info("*** %s:\n%s" % (router, result))

    info( '** Running CLI\n' )
    CLI( net )
开发者ID:sk2,项目名称:mininet-extreme,代码行数:23,代码来源:quagga.py

示例13: perfTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
def perfTest():
    topo = MyTopo()
    net = Mininet(topo, controller=partial(RemoteController, ip='192.168.1.1', port=6633), link=TCLink, host=CPULimitedHost)
    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)

    print "Testing network connectivity"
    h1,h2 = net.getNodeByName('h1', 'h2')
    h3,h20 = net.getNodeByName('h3', 'h20')
 
    net.ping((h1, h2))
    net.ping((h3, h20))   

    sleep(2)

    print "Executing the program to for Installing Flows"
    os.system('python Flow_Install.py')

    print "Testing bandwidth between h1 and h2"
    h1,h2 = net.getNodeByName('h1', 'h2')
    net.iperf((h1, h2))

    print "Testing bandwidth between h3 and h20"
    h3,h20 = net.getNodeByName('h3', 'h20')
    net.iperf((h3, h20))
    sleep(10)

    print "Testing bandwidth between h1 and h2"
    h1,h2 = net.getNodeByName('h1', 'h2')

    net.iperf((h1, h2))
    net.stop()

    print "Testing bandwidth between h3 and h20"
    h3,h20 = net.getNodeByName('h3', 'h20')

    net.iperf((h3, h20))
    net.stop()
开发者ID:rakheetiwari,项目名称:SDNTestBed,代码行数:41,代码来源:iperf.py

示例14: testLinkLoss

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [as 别名]
 def testLinkLoss(self):
     "Verify that we see packet drops with a high configured loss rate."
     LOSS_PERCENT = 99
     REPS = 1
     lopts = {"loss": LOSS_PERCENT, "use_htb": True}
     mn = Mininet(topo=SingleSwitchOptionsTopo(n=N, lopts=lopts), host=CPULimitedHost, link=TCLink)
     # Drops are probabilistic, but the chance of no dropped packets is
     # 1 in 100 million with 4 hops for a link w/99% loss.
     dropped_total = 0
     mn.start()
     for _ in range(REPS):
         dropped_total += mn.ping(timeout="1")
     mn.stop()
     self.assertTrue(dropped_total > 0)
开发者ID:RimHaw,项目名称:mn-ccnx,代码行数:16,代码来源:test_hifi.py

示例15: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import ping [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


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