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


Python Mininet.get方法代码示例

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


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

示例1: iperfTopo

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def iperfTopo():
	topo = CustomTopo()
	net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller=OVSController)
	net.start()
	
	H1 = net.get('H1')
	H2 = net.get('H2')
	H3 = net.get('H3')
	H4 = net.get('H4')
	
	# Generation of TCP flow from clients (H1,H2) to servers (H3,H4) respectively
	def iperfH3H1():
		h3 = H3.cmd('iperf -s &')
		print h3
		h1 = H1.cmd('iperf -c 10.0.0.3 -t 20 -i 0.5')
		print h1
	
	time.sleep(10)

	def iperfH4H2():
		h4 = H4.cmd('iperf -s &')
		print h4
		h2 = H2.cmd('iperf -c 10.0.0.4 -t 20 -i 0.5 ')
		print h2
	
	t1 = threading.Thread(target=iperfH3H1, args=())
	t2 = threading.Thread(target=iperfH4H2, args=())

	t1.start()
	t2.start()

	t1.join()
	t2.join()

	net.stop()
开发者ID:inair102,项目名称:Mininet-using-Python,代码行数:37,代码来源:Auto_iperf_Host_Mininet.py

示例2: myNet

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def myNet():
    #call(['sudo', 'mn', '-c'])
    britefile =  sys.argv[1] if len(sys.argv) >=2 else None
    print "britefile:",  britefile
    generateOps()


    topo = MyBriteTopo(britefile)
    remotecontroller = customConstructor(CONTROLLERS, "remote,ip=192.168.56.1")
    net = Mininet(topo = topo, controller=remotecontroller)
    net.start()    #启动您的拓扑网络
    for host in net.hosts:
        host.cmdPrint('route add default dev %s-eth0' %host.name)
    time.sleep(SLEEP_TIME)

    for i in range(len(operations)):
        if(operations[i] == 1):
            addhost = operationNodes[i]
            host = net.get(addhost)
            print "%s is ready to join" % addhost
            host.cmdPrint('iperf -s -u -B 224.0.55.55 &')
            time.sleep(ADD_SLEEP_T)
        else:
            removehost = operationNodes[i]
            host = net.get(removehost)
            print "%s is ready to leave and its last pid  is %s" % (removehost, host.lastPid)
            cmd = "kill %s" % host.lastPid
            host.cmd(cmd)
            time.sleep(REMOVE_SLEEP_T)

    net.stop()
开发者ID:daniel666,项目名称:testing,代码行数:33,代码来源:test.py

示例3: run_experiment

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def run_experiment(num_hosts, application_path):
    """
    Construct a mininet topology of num_hosts hosts running the Beehive
    application at application_path, run some benchmarking tests on it, and
    save the results to an output file.
    """

    topo = TestTopo(n=num_hosts)
    net = Mininet(topo=topo, host=CPULimitedHost)
    net.start()
    h0 = net.get("h0")

    # Start the initial end host that all peers will connect to
    command = get_run_command(h0, 0, application_path)
    print("Executing {} on host {}...".format(command, 0))
    h0.cmd(command)
    wait_for_hive(0)

    # Now start all the peers
    for i in range(1, num_hosts):
        host = net.get("h{}".format(i))
        command = get_run_command(host, i, application_path, [h0])
        print("Executing {} on host {}...".format(command, i))
        host.cmd(command)

    # Wait for all peers to start
    for i in range(1, num_hosts):
        wait_for_hive(i)

    print("All hives started")

    # Run the experiment and save the results to a file
    hcon = net.get("hcon")
    hcon.cmd("python ./metric.py >> experimentStdout 2>> experimentStderr")
    net.stop()
开发者ID:aaronchlam,项目名称:bee-reallocation-beehive-2016,代码行数:37,代码来源:beehive.py

示例4: perfTest

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def perfTest():
	"Create network and run perf test"
	linkopts1 = dict(bw=50, delay='5ms') #, loss=1, max_queue_size=1000, use_htb=True)
	linkopts2 = dict(bw=30, delay='10ms') #, loss=3, max_queue_size=2000, use_htb=True)
	linkopts3 = dict(bw=10, delay='15ms') #, loss=5, max_queue_size=3000, use_htb=True)

	topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=3)
	net = Mininet(topo=topo, link=TCLink)
	net.start()
	
	"""
	print "Dump host connections"
	dumpNodeConnections(net.hosts)
	
	print "Testing network connectivity"
	net.pingAll()
    """
	
	print "Testing bandwidth between h1 and h27"
	h1 = net.get('h1')
	h27 = net.get('h27')
	net.iperf((h1, h27))
	outputString = h1.cmd('ping', '-c6', h27.IP())
	print "output: " + outputString.strip()
	net.stop()
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:27,代码来源:CustomTopo.py

示例5: output

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def output(partIdx):
    """Uses the student code to compute the output for test cases."""
    outputString = ""

    if partIdx == 0:  # This is agPA2
        "Set up link parameters"
        print "a. Setting link parameters"
        "--- core to aggregation switches"
        linkopts1 = {"bw": 50, "delay": "5ms"}
        "--- aggregation to edge switches"
        linkopts2 = {"bw": 30, "delay": "10ms"}
        "--- edge switches to hosts"
        linkopts3 = {"bw": 10, "delay": "15ms"}

        "Creating network and run simple performance test"
        print "b. Creating Custom Topology"
        topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=3)

        print "c. Firing up Mininet"
        net = Mininet(topo=topo, link=TCLink)
        net.start()
        h1 = net.get("h1")
        h27 = net.get("h27")

        print "d. Starting Test"
        # Start pings
        outputString = h1.cmd("ping", "-c6", h27.IP())

        print "e. Stopping Mininet"
        net.stop()

    return outputString.strip()
开发者ID:jabbson,项目名称:SDN,代码行数:34,代码来源:CustomTopo.py

示例6: test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def test():
    topo = DssTopo()
    net = Mininet(topo, link=TCLink)
    net.start()

    pidList(net)

    global NPAUSE
    global NRESUME

    NPAUSE = 'sudo /home/vagrant/vTime/VirtualTimeKernel/test_virtual_time/freeze_all_procs -f -p %s'%pIDS
    NRESUME ='sudo /home/vagrant/vTime/VirtualTimeKernel/test_virtual_time/freeze_all_procs -u -p %s'%pIDS

    net.get('h1').cmd('iperf3 -s &')
    time.sleep(0.5)
    net.get('h2').cmd('iperf3 -c 10.0.0.1 -t 60 > %sbl.iperf 2>&1' % FileOut)
    '''

#    net.get('h1').cmd('iperf3 -s &')
    net.get('h2').cmd('iperf3 -c 10.0.0.1 -t 60 > %svt.iperf 2>&1 &' % FileOut)



    for x in range(0,int(sys.argv[3])):
        print 'pausing'
        pause()
        time.sleep(stime)
        print 'resumed'
    ''' 
    CLI(net)
    net.stop()
开发者ID:annonch,项目名称:DSSnet,代码行数:33,代码来源:iperf.py

示例7: perfTest

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

示例8: test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def test():
    topo = DssTopo()
    net = Mininet(topo, link=TCLink)
    net.start()

    pIDs = pidList(net)

    # start iperf server
    net.get('h1').cmd('iperf3 -s > %sSrv.log &' % file_out)
    # make sure server has started
    time.sleep(1)

    start = time.time()
    net.get('h2').cmd('iperf3 -c 10.0.0.1 -t %s > %sBsl.log 2>&1' \
            % (perf_time, file_out))
    baseline_runtime = time.time() - start

    frozen_iperf = iperfThread(net, perf_time, file_out)
    frozen_iperf.start()
    time.sleep(1)
    start = time.time()

    for x in range(0, num_pause):
        pause(pIDs)
        time.sleep(interval)

    frozen_iperf.join()
    frozen_runtime = time.time() - start

    print "Runtime of baseline iperf = %f" % baseline_runtime
    print "Runtime of frozen iperf = %f" % frozen_runtime
    net.stop()
开发者ID:XianliangJ,项目名称:VirtualTimeKernel,代码行数:34,代码来源:mn_iperf.py

示例9: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def main():
    """@todo: Docstring for main.
    :returns: @todo

    """
    linkopts1 = dict(bw=1000, delay='1ms')
    linkopts2 = dict(bw=100, delay='5ms')
    linkopts3 = dict(bw=10, delay='50ms')
    fanout = 4

    topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout)
    net = Mininet(topo = topo, link=TCLink)

    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing network connectivity"

    h1 = net.get('h1')
    h27 = net.get('h27')

    print "Starting Test: ping h1 to h27"
    # Start pings
    outputString = h1.cmd('ping', '-c6', h27.IP())
    print outputString
    print

    #  print "Starting Test2: pingAll"
    #  net.pingAll()

    net.stop()
开发者ID:ShemamAmir,项目名称:Software-Defined-Networking-002,代码行数:33,代码来源:CustomTopo.py

示例10: RunTest

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

示例11: required

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

示例12: myNetwork

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

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    info( '*** Add switches\n')
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone')

    info( '*** Add hosts\n')
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)

    info( '*** Add links\n')
    net.addLink(s1, h1)
    net.addLink(s1, h2)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s1').start([])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop()
开发者ID:Sirozha1337,项目名称:mininet-python,代码行数:33,代码来源:savedtopo.py

示例13: main

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def main():
    num_hosts = args.num_hosts

    topo = SingleSwitchTopo(args.behavioral_exe,
                            args.thrift_port,
                            num_hosts
    )
    net = Mininet(topo = topo,
                  host = P4Host,
                  switch = P4Switch,
                  controller = None )
    net.start()


    sw_mac = ["00:aa:bb:00:00:%02x" % n for n in xrange(num_hosts)]

    for n in xrange(num_hosts):
        h = net.get('h%d' % (n + 1))

    for n in xrange(num_hosts):
        h = net.get('h%d' % (n + 1))
        h.describe()

    sleep(1)

    print "Ready !"

    CLI( net )
    net.stop()
开发者ID:caichenwei1991,项目名称:cse222-project,代码行数:31,代码来源:l2_demo.py

示例14: test

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def test():
    topo = DssTopo()
    net = Mininet(topo, link=TCLink)
    net.start()

    pIDS = pidList(net)

    global NPAUSE
    global NRESUME
    NPAUSE = 'sudo /home/kd/VirtualTimeKernel/test_virtual_time/freeze_all_procs -f -p %s' % pIDS
    NRESUME = 'sudo /home/kd/VirtualTimeKernel/test_virtual_time/freeze_all_procs -u -p %s' % pIDS
    # skip ARP
    print(net.get('h1').cmd('ping -c 1 10.0.0.2'))

    info('\n*** Start baseline test ***\n')
    net.get('h1').cmd('ping -c %s 10.0.0.2 > %sBsl.log' % (ping_count, file_out))
    
    info('\n*** Start freeze test ***\n')
    frozen_ping = pingThread(net, ping_count, file_out)
    frozen_ping.start()
    
    print "Schedule %d freeze" % num_pause
    for x in range(0, num_pause):
        pause()
        time.sleep(interval)

    frozen_ping.join()

    net.stop()    
开发者ID:XianliangJ,项目名称:VirtualTimeKernel,代码行数:31,代码来源:mn_ping.py

示例15: project

# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import get [as 别名]
def project(choice, buffsize, destfile, segments):
    topo = router(choice)
    net = Mininet(topo=topo, link=TCLink)
    print('Starting network...')
    net.start()
    print('Network started!')

    h1 = net.get('h1')
    h2 = net.get('h2')
    h3 = net.get('h3')

    #the configuration of hosts
    h1.cmd('ifconfig h1-eth0 10.0.0.1 netmask 255.255.255.0')
    h2.cmd('ifconfig h2-eth0 10.0.0.2 netmask 255.255.255.0')
    h2.cmd('ifconfig h2-eth1 10.0.1.2 netmask 255.255.255.0')
    h3.cmd('ifconfig h3-eth0 10.0.1.3 netmask 255.255.255.0')

    h1.cmd('route add default gw 10.0.0.2')
    h3.cmd ('route add default gw 10.0.1.2')
    #Activating the forward mode at host B
    h2.cmd('sysctl net.ipv4.ip_forward=1')

    #ping between hosts
    print('ping h1 - > h3')
    print h1.cmd('ping -c5 10.0.1.3')
    #nc6 and tcpdump
    nc6TCPd(h1, h2, h3, transferSize(buffsize), destfile, segments)

    net.stop()
    print ('Network stopped!')
开发者ID:IstanbulBoy,项目名称:mininet-project-t020,代码行数:32,代码来源:mininet_tlp_measurement.py


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