• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python net.Mininet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: start_networking

    def start_networking(self):
        setLogLevel("info")
        net = Mininet(topo=self, \
                      controller=lambda name: RemoteController(name))
        net.start()

        # setup each switch
        for sw in net.switches:
            # set ofp version
            self.set_ofp_version(sw, ['OpenFlow10', 'OpenFlow13'])
            # if sw is bridge, set it up for normal SW
            swEntry = self.switchList[sw.name][1]
            isBridge = swEntry["bridge"]
            if isBridge:
                self.set_normalsw(sw)
            self.switchList[sw.name].append(sw)

        # setup each host
        for host in net.hosts:
            self.add_ipv6address(host)
            self.hostList[host.name].append(host)

        # execute pre_command
        if "pre_cmd_file" in self.jsonData:
            cmd_file = self.jsonData["pre_cmd_file"]
            self.exec_usercmd(cmd_file)

        CLI(net)

        # execute post_command
        if "post_cmd_file" in self.jsonData:
            cmd_file = self.jsonData["post_cmd_file"]
            self.exec_usercmd(cmd_file)

        net.stop()
开发者ID:saitoh-ats,项目名称:Sandbox,代码行数:35,代码来源:custom-topo.py


示例2: run

def run( n ):
    topo = OpticalTopo( n )
    net = Mininet( topo=topo, controller=RemoteController, autoSetMacs=True )
    net.start()
    #installStaticFlows( net )
    CLI( net )
    net.stop()
开发者ID:CrazyCooper,项目名称:onos,代码行数:7,代码来源:optical.py


示例3: topology

def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8', position='10,20,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8', position='10,30,0' )
    ap1 = net.addBaseStation( 'ap1', ssid= 'new-ssid', mode= 'g', channel= '1', position='15,30,0' )
    c1 = net.addController( 'c1', controller=Controller )

    """uncomment to plot graph"""
    #net.plotGraph(max_x=60, max_y=60)

    print "*** Creating links"
    net.addLink(ap1, sta1)
    net.addLink(ap1, sta2)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start( [c1] )

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
开发者ID:HerrOber,项目名称:mininet-wifi,代码行数:28,代码来源:wifiPosition.py


示例4: test

def test():
    topo = DssTopo()
    net = Mininet(topo, link=TCLink)
    net.start()

    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
    
    #block
    print(net.get('h1').cmd('ping -c 1 10.0.0.2'))

    net.get('h1').cmd('ping -c 40 10.0.0.2 > %sbl.test'% FileOut)
    
    #dont block
    net.get('h1').cmd('/home/kd/VirtualTimeKernel/iputils/ping -c 40 -D 10.0.0.2 > %svt.test &'% FileOut)
    time.sleep(5)

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


示例5: build

    def build( self ):
        print "Build network based on our topology."

        net = Mininet( topo=None, build=False, link=TCLink, ipBase=self.minieditIpBase )
 
        net.controllers = self.addControllers()
        
        # Make nodes
        print "Getting Hosts and Switches."
        for widget in self.widgetToItem:
            name = widget[ 'text' ]
            tags = self.canvas.gettags( self.widgetToItem[ widget ] )
            nodeNum = int( name[ 1: ] )
            if 'Switch' in tags:
                net.addSwitch( name )
            elif 'Host' in tags:
                ipBaseNum, prefixLen = netParse( self.minieditIpBase )
                ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
                net.addHost( name, ip=ip )
            else:
                raise Exception( "Cannot create mystery node: " + name )

        # Make links
        print "Getting Links."
        for link in self.links.values():
            ( src, dst, linkopts ) = link
            srcName, dstName = src[ 'text' ], dst[ 'text' ]
            src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
            net.addLink(src, dst, **linkopts)

        self.printInfo()
        # Build network (we have to do this separately at the moment )
        net.build()

        return net
开发者ID:Phi-Ho,项目名称:pyretic,代码行数:35,代码来源:miniedit-2.0.0.3.1.py


示例6: LowMnNet

def LowMnNet(n, nn, nnn):
	print "############ Instanitiate a mininet of topology LowMnTopo ###############\n"
	topo = LowMnTopo(n, nn, nnn)
	ctrl_port=6633
	net = Mininet(topo=topo, ipBase='10.0.0.0/8', autoSetMacs=True, host=CPULimitedHost, link=TCLink)
 	net.start()
	return net
开发者ID:UrbanLynx,项目名称:datacenter_simulation,代码行数:7,代码来源:final.py


示例7: main

def main():

	# All b/w are in megabits
	max_bw = 1000

	# B/w of queue 1 and queue 2
	values = [3,1,4]

	topo = MyTopo(max_bw)

	net = Mininet(topo, link = TCLink, controller = partial(RemoteController, ip = '127.0.0.1', port = 6633))
	
	net.start()

	# Queue set in between h1 and s1
	cmd = 'ovs-vsctl -- set Port s2-eth4 [email protected] -- \
		[email protected] create QoS type=linux-htb other-config:max-rate=1000000000 [email protected],[email protected],[email protected],[email protected] -- \
		[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d -- \
		[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d -- \
		[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d -- \
		[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d' % \
		(max_bw * 10**6, max_bw * 10**6, \
		values[0] * 10**6, values[0] * 10**6, \
		values[1] * 10**6, values[1] * 10**6, \
		values[2] * 10**6, values[2] * 10**6)

	sp.call(cmd, shell = True)
	
	CLI(net)
	net.stop()
开发者ID:harshitgupta1337,项目名称:fog_sdn,代码行数:30,代码来源:topology_new.py


示例8: main

def main():
    net = Mininet()
    # create hosts
    h1 = net.addHost('h1')
    h2 = net.addHost('h2')

    # create switch
    s1 = net.addSwitch('S1')

    # create controller
    c1 = net.addController('c1')

    # create links
    net.addLink(h1, s1)
    net.addLink(h2, s1)

    net.start()

    # start web server on h2
    print('starting web server...')
    h2.cmd('python -m SimpleHTTPServer 80 &')
    sleep(2)

    # use h1 as a web client
    print('accessing web server..')
    h1.cmd('curl', h2.IP())

    # CLI(net)
    print('kill web server..')
    h2.cmd('kill %python')

    print('finish.')
    net.stop()
开发者ID:wicaksana,项目名称:sdn-playing-with,代码行数:33,代码来源:simple02.py


示例9: multiping

def multiping(netsize, chunksize, seconds):
    "Ping subsets of size chunksize in net of size netsize"

    # Create network and identify subnets
    topo = SingleSwitchTopo(netsize)
    net = Mininet(topo=topo)
    net.start()
    hosts = net.hosts
    subnets = chunks(hosts, chunksize)

    # Create polling object
    fds = [host.stdout.fileno() for host in hosts]
    poller = poll()
    for fd in fds:
        poller.register(fd, POLLIN)

    # Start pings
    for subnet in subnets:
        ips = [host.IP() for host in subnet]
        for host in subnet:
            startpings(host, ips)

    # Monitor output
    endTime = time() + seconds
    while time() < endTime:
        readable = poller.poll(1000)
        for fd, _mask in readable:
            node = Node.outToNode[fd]
            print "%s:" % node.name, node.monitor().strip()

    # Stop pings
    for host in hosts:
        host.cmd("kill %while")

    net.stop()
开发者ID:RimHaw,项目名称:mn-ccnx,代码行数:35,代码来源:multiping.py


示例10: monitorTest

def monitorTest( N=3, seconds=3 ):
    "Run pings and monitor multiple hosts"
    topo = SingleSwitchTopo( N )
    net = Mininet( topo )
    net.start()
    hosts = net.hosts
    info( "Starting test...\n" )
    server = hosts[ 0 ]
    outfiles, errfiles = {}, {}
    for h in hosts:
        # Create and/or erase output files
        outfiles[ h ] = '/tmp/%s.out' % h.name
        errfiles[ h ] = '/tmp/%s.err' % h.name
        h.cmd( 'echo >', outfiles[ h ] )
        h.cmd( 'echo >', errfiles[ h ] )
        # Start pings
        h.cmdPrint('ping', server.IP(),
                   '>', outfiles[ h ],
                   '2>', errfiles[ h ],
                   '&' )
    info( "Monitoring output for", seconds, "seconds\n" )
    for h, line in monitorFiles( outfiles, seconds, timeoutms=500 ):
        if h:
            info( '%s: %s\n' % ( h.name, line ) )
    for h in hosts:
        h.cmd('kill %ping')
    net.stop()
开发者ID:NvanAdrichem,项目名称:mininet,代码行数:27,代码来源:multipoll.py


示例11: topoTest

def topoTest():
    "Create network and run simple performance test"
    topo = ITATopo()
    # topo = ITATopo(12, 10)
    net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink)

    net.interact()
开发者ID:vsmontalvao,项目名称:itasdn,代码行数:7,代码来源:ex2.py


示例12: main

def main():
    # Defines the log level
    setLogLevel('info')

    # parses command line arguments
    parser = OptionParser()
    parser.add_option('-H', dest='hosts', default=5,
                      help='Number of hosts per switch')
    parser.add_option('-S', dest='switches', default=2,
                      help='Number of switches')
    (options, args) = parser.parse_args()

    # Build network topology (see mininet/topo.py)
    topo = LinearTopo(int(options.switches), int(options.hosts))

    # Creates the Network using a remote controller
    net = Mininet(topo,
                  controller=lambda a: RemoteController(a, ip='127.0.0.1'))

    # Starts the network
    net.start()
    # Run the mininet client
    CLI(net)
    # Stop the network
    net.stop()
开发者ID:dshulyak,项目名称:mininet,代码行数:25,代码来源:dynamicnet.py


示例13: run

def run():
    "Create network and run the CLI"
    topo = InternetTopo()
    net = Mininet(topo=topo)
    net.start()
    CLI(net)
    net.stop()
开发者ID:alizamus,项目名称:mininet,代码行数:7,代码来源:natnet.py


示例14: emptyNet

def emptyNet():

    net = Mininet(topo=None, build=False)
    c0 = Controller('c0', inNamespace=False)

    h1 = Host('h1')
    h2 = Host('h2')
    #intf1 = Intf("h1-eth1")
    #intf2 = Intf("h2-eth1")
    s1 = OVSSwitch('br0', inNamespace=False)    

    Link(h1, s1)
    Link(h2, s1)


    c0.start()
    s1.start([c0])

    net.start()    
    #s1.cmd('ovs-vsctl set bridge br0 protocols=OpenFlow13')
    CLI(net)

    net.stop()
    h1.stop()
    h2.stop()
    s1.stop()
    c0.stop()
开发者ID:exuuwen,项目名称:study,代码行数:27,代码来源:mininet_basic.py


示例15: testLinkBandwidth

    def testLinkBandwidth( self ):
        "Verify that link bandwidths are accurate within a bound."
        if self.switchClass is UserSwitch:
            self.skipTest( 'UserSwitch has very poor performance -'
                           ' skipping for now' )
        BW = 5  # Mbps
        BW_TOLERANCE = 0.8  # BW fraction below which test should fail
        # Verify ability to create limited-link topo first;
        lopts = { 'bw': BW, 'use_htb': True }
        # Also verify correctness of limit limitng within a bound.
        mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
                      link=TCLink, switch=self.switchClass,
                      waitConnected=True )
        bw_strs = mn.run( mn.iperf, fmt='m' )
        loptsStr = ', '.join( '%s: %s' % ( opt, value )
                              for opt, value in lopts.items() )
        msg = ( '\nTesting link bandwidth limited to %d Mbps per link\n'
                'iperf results[ client, server ]: %s\n'
                'Topo = SingleSwitchTopo, %s hosts\n'
                'Link = TCLink\n'
                'lopts = %s\n'
                'host = default\n'
                'switch = %s\n'
                % ( BW, bw_strs, N, loptsStr, self.switchClass ) )

        # On the client side, iperf doesn't wait for ACKs - it simply
        # reports how long it took to fill up the TCP send buffer.
        # As long as the kernel doesn't wait a long time before
        # delivering bytes to the iperf server, its reported data rate
        # should be close to the actual receive rate.
        serverRate, _clientRate = bw_strs
        bw = float( serverRate.split(' ')[0] )
        self.assertWithinTolerance( bw, BW, BW_TOLERANCE, msg )
开发者ID:1514louluo,项目名称:mininet,代码行数:33,代码来源:test_hifi.py


示例16: prev_get_default_net_hosts_switches

def prev_get_default_net_hosts_switches(topo, listen_port, num_hosts, num_switches):
    net = Mininet(topo=topo, host=CPULimitedHost, controller=RemoteController,
                  listenPort=listen_port)
    net.start()
    hosts = get_hosts(net, num_hosts)
    switches = get_switches(net, num_switches)
    return (net, hosts, switches)
开发者ID:15ramky,项目名称:pyretic,代码行数:7,代码来源:old_mininet_setup.py


示例17: myNet

def myNet():
    #OpenDayLight controller
    CONTROLLER1_IP='127.0.0.1'

    #Floodlight controller

    net = Mininet( topo=None, build=False)

    # Create nodes
    h1 = net.addHost( 'h1', mac='01:00:00:00:01:00', ip='192.168.0.1/24' )

    # Create switches
    s1 = net.addSwitch( 's1', listenPort=6634, mac='00:00:00:00:00:01' )
    
    print "*** Creating links"
    net.addLink(h1, s1 )
  

    # Add Controllers
    c0 = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER1_IP, port=6633)

    net.build()

    # Connect each switch to a different controller
    s1.start([c0])

    s1.cmdPrint('ovs-vsctl show')
    
    CLI( net )
    net.stop()
开发者ID:linuxxunil,项目名称:ys-ryu,代码行数:30,代码来源:test.py


示例18: get_default_net_hosts_switches

def get_default_net_hosts_switches(topo, listen_port):
    net = Mininet(topo=topo, host=CPULimitedHost, controller=RemoteController,
                  listenPort=listen_port)
    net.start()
    hosts = get_nodes(net, topo.hosts())
    switches = get_nodes(net, topo.switches())
    return (net, hosts, switches)
开发者ID:15ramky,项目名称:pyretic,代码行数:7,代码来源:old_mininet_setup.py


示例19: perfTest

def perfTest():
    topo = crazy_switches()
    net = Mininet(topo=topo, controller=lambda name: RemoteController( 'c0', '127.0.0.1' ),
                  host=CPULimitedHost, link=TCLink)
    net.start()
    CLI(net)
    net.stop()
开发者ID:tuxerman,项目名称:softnannies,代码行数:7,代码来源:sf_topo_1.py


示例20: simple

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,代码行数:28,代码来源:dup2.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python node.Controller类代码示例发布时间:2022-05-27
下一篇:
Python net.Containernet类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap