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


Python Mininet.pingAll方法代码示例

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


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

示例1: run_exercise

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def run_exercise():
    #Create and start a new network with our custom topology
    topo = TLSTopo()
    net = Mininet(topo=topo)
    net.start()
    net.pingAll()

    processes = []

    #Start Nginx HTTP-server
    processes.append(net["Server-1"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_1.conf'))
    processes.append(net["Server-2"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_2.conf'))
    processes.append(net["Server-3"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_3.conf'))
    processes.append(net["Server-4"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_4.conf'))
    processes.append(net["Server-5"].popen('nginx -p /home/vagrant/assignments/ssl_tls/nginx -c nginx_5.conf'))

    #Open wireshark
    processes.append(net["A"].popen('wireshark'))

    #Open terminals
    processes.append(makeTerms([net["A"]], title="Student terminal")[0])

    raw_input("Press Enter to exit....")
    for process in processes:
        process.kill()
    Cleanup.cleanup()
开发者ID:ut-dacs,项目名称:MOOC-Internet-Security-Protocols,代码行数:28,代码来源:excercise.py

示例2: FaucetTaggedAndUntaggedVlanTest

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

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

    def setUp(self):
        self.CONFIG = self.CONFIG % PORT_MAP
        super(FaucetTaggedAndUntaggedVlanTest, 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:KitL,项目名称:faucet,代码行数:36,代码来源:faucet_mininet_test.py

示例3: Topology

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def Topology():
	net = Mininet(controller= Cotroller, switch = OVSSwitch)
	
	print "******** Creating controller"
	c1= net.addController ('c1', ip='127.0.0.1', port = 6633)
	
	print "******** Creating switches"
	s1 = net.addSwitch( 's1' )
	s2 = net.addSwitch( 's2' )

	print "******** Creating host"
	h1 = net.addHost( 'h1' )
	h2 = net.addHost( 'h2' )
	
	print "******** Creating links"
	net.addLink (h1,s1)
	net.addLink (h2,s2)
	net.addLink (s1,s2)

	print "******* Starting network"
	net.build()
	c1.start
	s1.start([c1])
	s2.start([c2])
	
	net.start()

	print "******* Testing network"
	net.pingAll()

	print "****** Running CLI"
	CLI(net)
开发者ID:hungluong,项目名称:Mininetfile,代码行数:34,代码来源:mesh.py

示例4: mobilityTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def mobilityTest():
    "A simple test of mobility"
    print( '* Simple mobility test' )
    net = Mininet( topo=LinearTopo( 3 ), switch=MobilitySwitch )
    print( '* Starting network:' )
    net.start()
    printConnections( net.switches )
    print( '* Testing network' )
    net.pingAll()
    print( '* Identifying switch interface for h1' )
    h1, old = net.get( 'h1', 's1' )
    for s in 2, 3, 1:
        new = net[ 's%d' % s ]
        port = randint( 10, 20 )
        print( '* Moving', h1, 'from', old, 'to', new, 'port', port )
        hintf, sintf = moveHost( h1, old, new, newPort=port )
        print( '*', hintf, 'is now connected to', sintf )
        print( '* Clearing out old flows' )
        for sw in net.switches:
            sw.dpctl( 'del-flows' )
        print( '* New network:' )
        printConnections( net.switches )
        print( '* Testing connectivity:' )
        net.pingAll()
        old = new
    net.stop()
开发者ID:AlexanderFroemmgen,项目名称:mininet,代码行数:28,代码来源:mobility.py

示例5: perfTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def perfTest():
		"Create network and run simple performance test"
		topo =LinearTopo(k=Y)
		net =Mininet(topo=topo, host=CPULimitedHost, link=TCLink,controller=OVSController)
		count=1
		for i in range(1,X+1,2):
			stri="h"
			stri2="127.0.0."
			stri2=stri2+str(count)
			count=count+1
			stri=stri+str(i)
			hi=net.get(stri)
			hi.setIP(stri2,24)
		count=1
		for i in range(2,X+1,2):
			stri="h"
			stri2="192.168.0."
			stri=stri+str(i)
			stri2=stri2+str(count)
			count=count+1
			hi=net.get(stri)
			hi.setIP(stri2,29)

		net.start()
		print "Dumping host connections"
		dumpNodeConnections(net.hosts)
		print "Testing network connectivity"
		net.pingAll()
		net.stop()
开发者ID:shyamliv,项目名称:2013330073_cloud_assignments,代码行数:31,代码来源:mini1.py

示例6: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def main():
    "Create and run experiment"
    start = time()

    topo = MNTopo()

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, max_queue_size=200)

    net = Mininet(topo=topo, host=host, link=link)

    net.start()

    print "*** Dumping network connections:"
    dumpNetConnections(net)

    print "*** Testing connectivity"

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        print "*** Running experiment"
        run_topology_experiment(net)

    net.stop()
    end = time()
    os.system("killall -9 bwm-ng")
    print "Experiment took %.3f seconds" % (end - start)
开发者ID:09beeihaq,项目名称:CS6250,代码行数:33,代码来源:measure.py

示例7: RunTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def RunTest():
    """TOPO"""
    topo = FatTreeTopo()
    topo.topoCreate(4,4,2,2,2)

    CONTROLLER_NAME = topo.crtlname
    CONTROLLER_IP = topo.crtlip
    CONTROLLER_PORT = topo.crtlport
    net = Mininet(topo=topo,build= False,link=TCLink, controller=None)
    time.sleep(1)
    net.addController( CONTROLLER_NAME,controller=RemoteController,
                      ip=CONTROLLER_IP,
                      port=CONTROLLER_PORT)

    net.start()
    dumpNodeConnections(net.hosts)
    net.pingAll()
    h1 = net.get('h000')
    h16 = net.get('h311')
    h2 = net.get('h001')
    h1.popen('iperf -s -u -i 1')
    h16.popen('iperf -s -u -i 1')
    h2.cmdPrint('iperf -c '+ h1.IP() + ' -u -t 10 -i 1 -b 100m')
    h2.cmdPrint('iperf -c '+ h16.IP() + ' -u -t 10 -i 1 -b 100m')
    CLI(net)
    net.stop()
开发者ID:ZXYUSTC,项目名称:FatreeMinineTopo,代码行数:28,代码来源:topo.py

示例8: required

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def  required(x,y):
    topo = MyTopo(x, y)
    net = Mininet(topo,host=CPULimitedHost, link=TCLink)
    net.start()

    for i in xrange(y):
        for j in xrange(y):
            if (i+1)%2==0 and (j+1)%2==1:
                net.nameToNode["h"+str(i+1)].cmd("iptables -A OUTPUT -o h"+str(i+1)+"-eth0 -d 10.0.0."+ str(j+1)+" -j DROP")
                net.nameToNode["h"+str(j+1)].cmd("iptables -A OUTPUT -o h"+str(j+1)+"-eth0 -d 10.0.0."+ str(i+1)+" -j DROP")
            elif (i+1)%2==1 and (j+1)%2==0:
                net.nameToNode["h"+str(i+1)].cmd("iptables -A OUTPUT -o h"+str(i+1)+"-eth0 -d 10.0.0."+ str(j+1)+" -j DROP")
                net.nameToNode["h"+str(j+1)].cmd("iptables -A OUTPUT -o h"+str(j+1)+"-eth0 -d 10.0.0."+ str(i+1)+" -j DROP")
    
    net.pingAll()
    try:
        
        print "Testing bandwidth between h1 and h3"
        h1, h3 = net.get('h1', 'h3')
        net.iperf((h1, h3))
    except:
        c=1
    try:
        
        print "Testing bandwidth between h1 and h3"
        h4, h2 = net.get('h2', 'h4')
        net.iperf((h2, h4))
    except:
        c=1

    
    dumpNodeConnections(net.switches)
    CLI(net)
    net.stop()
开发者ID:ChilupuriAnilReddy,项目名称:201301238_cloud_assignments,代码行数:36,代码来源:custom_topology.py

示例9: bwtest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def bwtest( cpuLimits, period_us=100000, seconds=5 ):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo( depth=1, fanout=2 )

    results = {}

    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        for cpu in cpuLimits:
            host = custom( CPULimitedHost, sched=sched,
                           period_us=period_us,
                           cpu=cpu )
            net = Mininet( topo=topo, host=host )
            net.start()
            net.pingAll()
            hosts = [ net.getNodeByName( h ) for h in topo.hosts() ]
            client, server = hosts[ 0 ], hosts[ -1 ]
            server.cmd( 'iperf -s -p 5001 &' )
            waitListening( client, server, 5001 )
            result = client.cmd( 'iperf -yc -t %s -c %s' % (
                seconds, server.IP() ) ).split( ',' )
            bps = float( result[ -1 ] )
            server.cmdPrint( 'kill %iperf' )
            net.stop()
            updated = results.get( sched, [] )
            updated += [ ( cpu, bps ) ]
            results[ sched ] = updated

    return results
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:33,代码来源:cpu.py

示例10: rosTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def rosTest():
    "Create network and run simple performance test"
    topo = SingleSwitchTopo(n=3)
    net = Mininet(topo=topo, 
                  link=TCLink)
    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing network connectivity"
    net.pingAll()
    h1, h2, h3 = net.get('h1', 'h2', 'h3')
    print "Starting roscore"
    output = h3.cmd('source /opt/ros/indigo/setup.bash && '
                    'export ROS_IP='+h3.IP()+
                    ' && export ROS_MASTER_URI=http://'+h3.IP()+
                    ':11311 && roscore &')
    print output
    print "Starting receiver"
    output = h2.cmd('export LD_LIBRARY_PATH=/home/jeb/:$LD_LIBRARY_PATH && export ROS_IP='+h2.IP()+
                    ' && export ROS_MASTER_URI=http://'+h3.IP()+
                    ':11311 && /home/jeb/node_main -config /home/jeb/receiver.xml --tg_time 50 &')
    print output
    print "Starting sender"
    output = h1.cmd('export LD_LIBRARY_PATH=/home/jeb/:$LD_LIBRARY_PATH && export ROS_IP='+h1.IP()+
                    ' && export ROS_MASTER_URI=http://'+h3.IP()+
                    ':11311 && /home/jeb/node_main -config /home/jeb/sender.xml --tg_time 50 --max_data_length_bits 6000 &')
    print output
    sleep(70)
    net.stop()
开发者ID:rosmod,项目名称:rosmod,代码行数:31,代码来源:deployment.py

示例11: multiSwitchNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def multiSwitchNet(NS,NH):
    "Add 1 remote controller, NS switches & NH hosts per switch"
    port = 6633
    net = Mininet(controller=RemoteController, switch=Switch, host=CPULimitedHost, link=TCLink, build=False)

    k=NS+1;
   
    # Add a single controller for all switches
    remote = addController(net,1,port) 
 
    lastSwitch = None 
    for i in range(1,NS+1) :
       # name = 'c%d' % i
       # remote = addController(N=i,gateID=port)
        s = addSwitch(net,N=i)
        host = [addHost(net,n) for n in range(k,k+NH)]
        for h in host :
            net.addLink(h,s,bw=10,delay='5ms',loss=0,max_queue_size=1000,use_htb=True)
        if lastSwitch :
            net.addLink(s,lastSwitch,bw=10,delay='5ms',loss=0,max_queue_size=1000,use_htb=True)
        lastSwitch = s  
        port = port + 1
        k=k+NH
    
    print "Starting network"
    net.start()

    print "Testing network"
    net.pingAll()

    print "Running CLI"
    CLI( net )

    print "Stopping network"
    net.stop()
开发者ID:Beckersweet,项目名称:Open-Mobile-Hub,代码行数:37,代码来源:OpMub-minimalNetwork_remoteController.py

示例12: test_L3EthStar

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

    topo = L3EthStar(add_attacker=True)
    net = Mininet(
        topo=topo,
        link=TCLink,
        listenPort=OF_MISC['switch_debug_port'])

    net.start()

    net.pingAll()

    n = L3_NODES
    for h in range(n - 2):
        key = 'plc%s' % (h + 1)
        plc = net.get(key)  # get host obj reference by name
        ok_(plc.IP(), L1_PLCS_IP[key])
        ok_(plc.MAC(), PLCS_MAC[key])

    histn = net.get('histn')
    ok_(histn.IP(), L3_PLANT_NETWORK['histn'])
    ok_(histn.MAC(), OTHER_MACS['histn'])

    workstn = net.get('workstn')
    ok_(workstn.IP(), L3_PLANT_NETWORK['workstn'])
    ok_(workstn.MAC(), OTHER_MACS['workstn'])

    # alternative way to obtain IP and MAC
    # params = workstn.params

    net.stop()
开发者ID:LubuntuFu,项目名称:minicps,代码行数:33,代码来源:networks_tests.py

示例13: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def main():
    do_something()
    sstopo = SingleSwitchTopo(4)
    mn = Mininet(topo=sstopo)
    mn.start()
    mn.pingAll()
    mn.stop()
开发者ID:heryandi,项目名称:mininet-starter,代码行数:9,代码来源:__init__.py

示例14: testIt

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def testIt():
    topo = SingleSwitch()
    net = Mininet(topo)
    net.start()
    dumpNodeConnections(net.hosts)
    net.pingAll()
    net.stop()
开发者ID:moz,项目名称:mininet,代码行数:9,代码来源:simple-topo.py

示例15: bwtest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import pingAll [as 别名]
def bwtest(cpuLimits, period_us=100000, seconds=5):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo(depth=1, fanout=2)

    results = {}

    for sched in "rt", "cfs":
        print "*** Testing with", sched, "bandwidth limiting"
        for cpu in cpuLimits:
            host = custom(CPULimitedHost, sched=sched, period_us=period_us, cpu=cpu)
            try:
                net = Mininet(topo=topo, host=host)
            except:
                info("*** Skipping host %s\n" % sched)
                break
            net.start()
            net.pingAll()
            hosts = [net.getNodeByName(h) for h in topo.hosts()]
            client, server = hosts[0], hosts[-1]
            server.cmd("iperf -s -p 5001 &")
            waitListening(client, server, 5001)
            result = client.cmd("iperf -yc -t %s -c %s" % (seconds, server.IP())).split(",")
            bps = float(result[-1])
            server.cmdPrint("kill %iperf")
            net.stop()
            updated = results.get(sched, [])
            updated += [(cpu, bps)]
            results[sched] = updated

    return results
开发者ID:jplsegers,项目名称:SDN-TEST,代码行数:34,代码来源:cpu.py


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