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

Python util.custom函数代码示例

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

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



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

示例1: main

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


示例2: main

def main():
    "Create and run experiment"
    start = time()

    topo = ParkingLotTopo(n=args.n)

    host = custom(CPULimitedHost, cpu=.15)  # 15% of system bandwidth
    link = custom(TCLink, bw=args.bw, delay='1ms',
                  max_queue_size=200)

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

    net.start()

    cprint("*** Dumping network connections:", "green")
    dumpNetConnections(net)

    cprint("*** Testing connectivity", "blue")

    net.pingAll()

    if args.cli:
        # Run CLI instead of experiment
        CLI(net)
    else:
        cprint("*** Running experiment", "magenta")
        run_parkinglot_expt(net, n=args.n)

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


示例3: pairNet

def pairNet( pairs=1, useSwitches=False, bw=None, cpu=-1, **kwargs ):
    "Convenience function for creating pair networks"
    clients, servers = [], []
    # This is a bit ugly - a lot of work to avoid flushing
    # routes; I think we should rethink how that works.
    class MyHost( CPULimitedHost ):
        "Put clients in root namespace and DON'T flush routes"
        def __init__( self, name, **kwargs ):
            # First N (=pairs) hosts are clients, in root NS
            kwargs.pop('inNamespace', True)
            isServer = int( name[ 1: ] ) > pairs
            CPULimitedHost.__init__( self, name, inNamespace=isServer, **kwargs )
        def setDefaultRoute( self, intf ):
            "Hack of sorts: don't set or flush route"
            pass

    cpu = custom( MyHost, cpu=cpu )
    link = custom( TCLink, bw=bw )
    topo = PairTopo( pairs, useSwitches )
    net = Mininet( topo, host=MyHost, **kwargs )
    net.hosts = sorted( net.hosts, key=lambda h: natural( h.name ) )
    clients, servers = net.hosts[ :pairs ], net.hosts[ pairs: ]
    info( "*** Configuring host routes\n" )
    for client, server in zip( clients, servers ):
        client.setHostRoute( server.IP(), client.defaultIntf() )
        server.setHostRoute( client.IP(), server.defaultIntf() )
    return net, clients, servers
开发者ID:EliseuTorres,项目名称:mininet-tests,代码行数:27,代码来源:pair_intervals.py


示例4: set_topo

    def set_topo(self, optNet, init_ip = False, init_mac = False):

        # add hosts
        hosts = {}
        for node in optNet.get_logical_nodes():
	    if init_ip and init_mac:
                host = self.addHost('h%d'% node, ip='0.0.0.0', mac=self.hostid_to_mac(node)) #DONT DO IT UNLESS U SET DHCLIENTS
	    elif init_ip:
                host = self.addHost('h%d'% node, ip='0.0.0.0') #DONT DO IT UNLESS U SET DHCLIENTS
	    if init_mac:
                host = self.addHost('h%d'% node, mac=self.hostid_to_mac(node))
	    else:
	        host = self.addHost('h%d'% node)
            hosts[node] = host

        # add switches
        switches = {}
        for node in optNet.nodes():
            switches[node] = self.addSwitch('s%d' % node, mac = "")

        CAPACITY_TO_MBITS = 5
        MAX_MBITS = 50

        # link hosts to switches
        for node in optNet.get_logical_nodes():
            _bw = MAX_MBITS
            intf = custom( TCIntf, bw=_bw )
            self.addLink(switches[node], hosts[node], intf=intf )

        # link switches
        for edge in optNet.physical_links():
            if edge[0] in switches.keys() and edge[1] in switches.keys():
                _bw = CAPACITY_TO_MBITS * optNet.get_plink_capacity(edge)
                intf = custom( TCIntf, bw=_bw )
                self.addLink(switches[edge[0]], switches[edge[1]], intf=intf)
开发者ID:gitprof,项目名称:optical_network,代码行数:35,代码来源:mn_interface.py


示例5: launch_network

def launch_network(k=4, bw=10, ip_alias=True, fair_queues=False, cli=False):
    signal.signal(signal.SIGTERM, signal_term_handler)

    # Cleanup the network
    cleanup()
    sh("killall ospfd zebra getLoads.py nc")

    # Remove tmp files and old namespaces
    subprocess.call(['rm', '/tmp/*.log', '/tmp/*.pid', '/tmp/mice*'])
    subprocess.call(['rm', '/var/run/netns/*'])

    # Flush root namespace mangle table
    subprocess.call(["iptables", "-t", "mangle" ,"-F"])
    subprocess.call(["iptables", "-t", "mangle" ,"-X"])

    # Topology
    topo = FatTree(k=k, sflow=False, ovs_switches=False)

    # Interfaces
    if fair_queues:
        print("*** Using FairQueues at the network interfaces")
        intf = custom(DCTCIntf, bw=bw)
    else:
        print("*** Using normal pFIFO queues at the network interfaces")
        intf = custom(PrioFifoIntf, bw=bw)

    # Network
    net = IPNet(topo=topo, debug=_lib.DEBUG_FLAG, intf=intf)

    # Save the TopoDB object
    TopologyDB(net=net).save(cfg.DB_path)

    # Start the network
    net.start()

    # Setup hash seeds
    setupHashSeeds(topo)

    # Start intreface collectors
    startCounterCollectors(topo, interval=1)

    if ip_alias:
        setupSecondaryIps(net)

    if cli:
        # Start the Fibbing CLI
        FibbingCLI(net)
    else:
        print("*** Looping forever. Press CTRL+C to quit")
        while True:
            try:
                time.sleep(2)
            except KeyboardInterrupt:
                print("*** KeyboardInterrupt catched! Shutting down")
                break

    net.stop()

    stopCounterCollectors(topo)
开发者ID:lferran,项目名称:fibte,代码行数:59,代码来源:network_example.py


示例6: main

def main():
    topo = KLTopo()
    host = custom(CPULimitedHost, cpu=.15)
    link = custom(TCLink, bw=10, delay='1ms', max_queue_size=200)
    net = Mininet(topo=topo, host=host, link=link, controller=RemoteController)
    net.start()
    dumpNetConnections(net)
    CLI(net)
开发者ID:cli402,项目名称:CS6250Project,代码行数:8,代码来源:main.py


示例7: RegularTreeNet

def RegularTreeNet(depth=4, fanout=2, bw=BW, cpu=-1, queue=100):
    "Create an empty network and add nodes to it."
    topo = TreeTopo(depth, fanout)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    #net = Mininet(host=host, link=link, switch=OVSKernelSwitch, controller=RemoteController, autoSetMacs=True, autoStaticArp=False)
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=OVSController, autoSetMacs=True, autoStaticArp=False)

    return net
开发者ID:mvneves,项目名称:mremu,代码行数:9,代码来源:network.py


示例8: run_experiment

def run_experiment( output = "sender.dump"):
    topo = MyTopo()
    host = custom(CPULimitedHost, cpu = .15)
    link = custom(TCLink, bw=1000, delay='100ms')

    net = Mininet(topo=topo, host=host, link=link)
    net.start()
    dumpNetConnections(net)
    net.pingAll()

    sender = net.getNodeByName('sender')
    receiver = net.getNodeByName('receiver')

    if CAPTURE_ACKS:
        sender.cmd("tcpdump -tt -nn 'tcp port 5001' &> %s &" % output)
    else:
        sender.cmd("tcpdump -tt -nn 'tcp dst port 5001' &> %s &" % output)
    sleep(1)


    # randomize address, because after a few repeats, the slow start is not observed anymore
    rand = str(random.randint(0,99)).zfill(2)
    receiver_IP = '1%s.11.0.2' % rand
    gateway_IP = '1%s.11.0.1' % rand


    receiver.cmd('../lwip/tcpsink -p 5001 -i %s -g %s &> receiver.out &' % (receiver_IP, gateway_IP))

    #make receiver forward packets from sender to internal tap interface
    receiver.cmd('sysctl net.ipv4.ip_forward=1')


    sender.cmd('sysctl net.core.netdev_max_backlog=500000')
    sender.cmd('sysctl net.ipv4.tcp_congestion_control=cubic')

    #add default route so that sender can sender to receiver's tap interface through the mininet link
    sender.cmd('route add default gw %s' % receiver.IP())

    #reduce MTU because otherwise the receive window is the limiting factor
    sender.cmd('ifconfig sender-eth0 mtu 200')

    print "starting transmission of data to %s" % receiver_IP
    sender.sendCmd('python sender.py --receiver=%s &> sender.out' % receiver_IP)


    print "waiting for transmission to complete"
    sender.waitOutput()

    print "killing tcpdump"
    sender.cmd('killall tcpdump')

    sleep(1)
    print "killing tcpsink"
    receiver.cmd("killall tcpsink")

    net.stop()
开发者ID:jamesbw,项目名称:tcp-daytona,代码行数:56,代码来源:run_exps.py


示例9: NonBlockingNet

def NonBlockingNet(k=4, bw=10, cpu=-1, queue=100):
    """ Create a NonBlocking Net """

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=Controller)

    return net
开发者ID:jasonlyc,项目名称:ashman-POX,代码行数:10,代码来源:hedera.py


示例10: NonBlockingNet

def NonBlockingNet(k=4, bw=10, cpu=-1, queue=100):
    ''' Create a NonBlocking Net '''

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    #net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=RemoteController)
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch, controller=OVSController, autoSetMacs=True, autoStaticArp=False)

    return net
开发者ID:mvneves,项目名称:mremu,代码行数:11,代码来源:network.py


示例11: NonBlockingNet

def NonBlockingNet(k=4, bw=100, cpu=-1, queue=100):
    "Convenience function for creating a non-blocking network"

    topo = NonBlockingTopo(k)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
	                      
    net = Mininet(topo, host=host, link=link, 
	    switch=OVSKernelSwitch, controller=Controller, 
	    autoPinCpus=opts.static, autoStaticArp=True)
    return net
开发者ID:EliseuTorres,项目名称:mininet-tests,代码行数:11,代码来源:ecmp_routing.py


示例12: main

def main():
  "Create and run experiment"
  start = time()
 
  if 'seed' in vars(args):
    random.seed(args.seed)

  k = args.k
  host = custom(CPULimitedHost, cpu=4.0/(k**3))
  link = custom(TCLink, bw=args.bw, delay='0ms')

  if args.control:
    topo = NonblockingFatTreeTopo(k=k)
    net = Mininet(topo=topo, host=host, link=link, build=True, cleanup=True, autoPinCpus=True, autoSetMacs=True)
  else:
    topo = FatTreeTopo(k=k)
    net = Mininet(topo=topo, host=host, link=link, build=True, cleanup=True, autoPinCpus=True, autoSetMacs=True, controller=RemoteController)
  net.start()

  flowsToCreate = []
  for fcount in range(args.fph):
    if args.traffic.startswith('stride'):
      stride_amt = int(args.traffic.split(',')[1])
      matrix = compute_stride(k, stride_amt)
    elif args.traffic.startswith('stag'):
      edge_prob, pod_prob = map(float, args.traffic.split(',')[1:])
      matrix = compute_stagger_prob(k, edge_prob, pod_prob)
    elif args.traffic.startswith('random'):
      matrix = compute_random(k)
    elif args.traffic.startswith('randbij'):
      matrix = compute_randbij(k)
    else:
      raise Exception('Unrecognized traffic type')
    print "Running with matrix", matrix
    addMatrixToFlow(flowsToCreate, matrix)

  if args.controller:
    controller = Popen(args.controller, shell=True, preexec_fn=os.setsid)

  # NOTE: special signal for random number of flows
  if args.fph >= 6:
   random.shuffle(flowsToCreate)
   flowsToCreate = flowsToCreate[0:len(flowsToCreate)/2]

  start = time()
  run_expt(net, k, flowsToCreate)
  end = time()

  if args.controller:
    os.killpg(controller.pid, signal.SIGKILL)

  net.stop()
开发者ID:StonyBrookUniversity,项目名称:hedera,代码行数:52,代码来源:hedera.py


示例13: FatTreeNet

def FatTreeNet(k=4, bw=10, cpu=-1, queue=100):
    ''' Create a Fat-Tree network '''

    info('*** Creating the topology')
    topo = FatTreeTopo(k)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)

    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=RemoteController, autoStaticArp=True)

    return net
开发者ID:mvneves,项目名称:mremu,代码行数:13,代码来源:network.py


示例14: LinearNet

def LinearNet(n=2, m=4, bw=100, cpu=-1, queue=100):
    ''' Create a Linear network '''

    info('*** Creating the topology')
    topo = LinearMultipathTopo(n,m)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=RemoteController)

    return net
开发者ID:mvneves,项目名称:mremu,代码行数:13,代码来源:network.py


示例15: __init__

    def __init__(self, k = 4):
        ''' Create FatTree topology 
            
            k : Number of pods (can support upto k^3/4 hosts)
        '''
        super(FatTreeTopo, self).__init__()

        self.k = k
        self.node_gen = FatTreeNode
        self.numPods = k
        self.aggPerPod = k / 2

        pods = range(0, k)
        edge_sw = range(0, k/2)
        agg_sw = range(k/2, k)
        core_sw = range(1, k/2+1)
        hosts = range(2, k/2+2)

        for p in pods:
            for e in edge_sw:
                edge = self.node_gen(p, e, 1)
                edge_opts = self.def_opts(edge.name_str())
                self.addSwitch(edge.name_str(), **edge_opts)

                for h in hosts:
                    host = self.node_gen(p, e, h)
                    host_opts = self.def_opts(host.name_str())
                    self.addHost(host.name_str(), **host_opts)
                    self.addLink(edge.name_str(),host.name_str())

                for a in agg_sw:
                    agg = self.node_gen(p, a, 1)
                    agg_opts = self.def_opts(agg.name_str())
                    self.addSwitch(agg.name_str(), **agg_opts)
                    link = custom(TCLink, bw=100, max_queue_size=100)
                    self.addLink(agg.name_str(),edge.name_str(), cls=link)
            
            for a in agg_sw:
                agg = FatTreeNode(p, a, 1)
                i = 1        
                for c in core_sw:
                    core = self.node_gen(k, a-k/2+1, c)
                    core_opts = self.def_opts(core.name_str())
                    self.addSwitch(core.name_str(), **core_opts)
                    if i == 1:
                        band=100
                    else:
                        band=100
                    i = i + 1
                    link = custom(TCLink, bw=band, max_queue_size=100)
                    self.addLink(agg.name_str(),core.name_str(), cls=link)
开发者ID:mvneves,项目名称:mremu,代码行数:51,代码来源:topology.py


示例16: limit

def limit( bw=10, cpu=.1 ):
    """Example/test of link and CPU bandwidth limits
       bw: interface bandwidth limit in Mbps
       cpu: cpu limit as fraction of overall CPU time"""
    intf = custom( TCIntf, bw=bw )
    myTopo = TreeTopo( depth=1, fanout=2 )
    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        host = custom( CPULimitedHost, sched=sched, cpu=cpu )
        net = Mininet( topo=myTopo, intf=intf, host=host )
        net.start()
        testLinkLimit( net, bw=bw )
        net.runCpuLimitTest( cpu=cpu )
        net.stop()
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:14,代码来源:limit.py


示例17: FatTreeNet

def FatTreeNet(k=4, bw=100, cpu=-1,  queue=100):
    "Convenience function for creating pair networks"
    global opts

    pox_c = Popen("~/pox/pox.py --no-cli riplpox.riplpox --topo=ft,%s --routing=st --mode=proactive 1> %s/pox.out 2> %s/pox.out" % (k, opts.outputdir, opts.outputdir), shell=True)

    topo = FatTreeTopo(k, speed=bw/1000.)
    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
	                      
    net = Mininet(topo, host=host, link=link, 
	    switch=OVSKernelSwitch, controller=RemoteController, 
	    autoPinCpus=opts.static, autoStaticArp=True)
    return net, pox_c
开发者ID:EliseuTorres,项目名称:mininet-tests,代码行数:14,代码来源:ecmp_routing.py


示例18: __init__

 def __init__( self, **params ):
   """Mininet set up to test barrier transactions with one client
      and a specified number of servers.
      numberOfServers: number of servers 
      linkBandwidth: link bandwidth in Mb/s
      roundTripTime: unloaded round trip time from client to server, in microseconds"""
   
   host = custom( CPULimitedHost, cpu=cpuShare() )  
   link = custom( TCLink, bw=args.bandwidth, delay=delay() )
   
   Mininet.__init__(
     self,
     topo=BarrierTransactionTopo( **params ),
     host=host,
     link=link )
开发者ID:PeiwenYu2,项目名称:incast-cumings-ramesh,代码行数:15,代码来源:simulation.py


示例19: FatTreeNet

def FatTreeNet(k=4, bw=10, cpu=-1, queue=100,controller='HController'):
    ''' Create a Fat-Tree network '''

    pox_c = Popen("~/pox/pox.py %s --topo=ft,4 --routing=ECMP"%controller, shell=True)

    info('*** Creating the topology')
    topo = FatTreeTopo(k)

    host = custom(CPULimitedHost, cpu=cpu)
    link = custom(TCLink, bw=bw, max_queue_size=queue)
    
    net = Mininet(topo, host=host, link=link, switch=OVSKernelSwitch,
            controller=RemoteController)

    return net
开发者ID:jasonlyc,项目名称:nsdi-exp,代码行数:15,代码来源:hedera.py


示例20: graph_network

def graph_network(topo):
    link = custom(TCLink)
    net = Mininet(topo=topo, link=link)
    mininet.util.dumpNetConnections(net)
    nodes = net.controllers + net.switches + net.hosts

    dot = pygraphviz.AGraph()

    edges = []

    for node in nodes:
        if 'c0' == node.name: continue
        dot.add_node(node.name)
        
        for intf in node.intfList():
            if not intf.link: continue
            (a, ai,) = intf.link.intf1.name.split('-')
            (b, bi,) = intf.link.intf2.name.split('-')
            ai = ai.replace('eth', 'p')
            bi = bi.replace('eth', 'p')
            s = [a, b]
            s.sort()
            if s not in edges:
                edges.append(s)
                dot.add_edge(a, b,
                             taillabel=ai+(' '*5),
                             headlabel=bi+(' '*5))

    dot.layout()
    dot.draw('topology.png', prog='dot')
开发者ID:roterdam,项目名称:cs6250-1,代码行数:30,代码来源:parkinglot.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.dumpNodeConnections函数代码示例发布时间:2022-05-27
下一篇:
Python topo.Topo类代码示例发布时间: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