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

Python util.ipAdd函数代码示例

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

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



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

示例1: 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


示例2: addHost

    def addHost( self, name, cls=None, **params ):
        """Add host.
           name: name of host to add
           cls: custom host class/constructor (optional)
           params: parameters for host
           returns: added host"""
        defaults = {}

        autoSetIp = params.get( 'autoSetIp', True )
        if autoSetIp:
            # Default IP and MAC addresses
            defaults[ 'ip' ] = ipAdd( self.nextIP, ipBaseNum=self.ipBaseNum,
                                    prefixLen=self.prefixLen) + '/%s' % (self.prefixLen,)
            if self.autoSetMacs:
                defaults[ 'mac' ] = macColonHex( self.nextIP )

            self.nextIP += 1
        if self.autoPinCpus:
            defaults[ 'cores' ] = self.nextCore
            self.nextCore = ( self.nextCore + 1 ) % self.numCores
        defaults.update( params )
        if not cls:
            cls = self.host
        h = cls( name, **defaults )
        self.hosts.append( h )
        self.nameToNode[ name ] = h
        return h
开发者ID:backb1,项目名称:mininet,代码行数:27,代码来源:net.py


示例3: build

 def build( self, count=1,ipstart=0x0a010000, br='br-int', brdp="0000abcdef000001" ):
     if isinstance(ipstart, str): ipstart=int(ipstart,16)
     customBr = self.addSwitch( str(br), dpid=str(brdp) )
     hosts = [ self.addHost( 'h%d' % i, ip= ipAdd(i,16,ipstart)+'/8') for i in range( 1, count + 1 ) ]
     # Add links
     for h in hosts:                                                                                                       
         self.addLink( h, customBr)
开发者ID:alexfeigin,项目名称:devel,代码行数:7,代码来源:topo-custom.py


示例4: addHost

 def addHost( self, name, cls=None, **params ):
     """Add host.
        name: name of host to add
        cls: custom host class/constructor (optional)
        params: parameters for host
        returns: added host"""
     # Default IP and MAC addresses
     defaults = { 'ip': ipAdd( self.nextIP,
                               ipBaseNum=self.ipBaseNum,
                               prefixLen=self.prefixLen ) +
                               '/%s' % self.prefixLen }
     print defaults
     IPS=[]
     for lin in defaults.values():
         IPS.append(lin[0:8])
         print IPS
         
     with open('my_dict.json','a')as f:
         json.dump(defaults.values(),f)
         f.write('\n')
     if self.autoSetMacs:
         defaults[ 'mac'] = macColonHex( self.nextIP )
     if self.autoPinCpus:
         defaults[ 'cores' ] = self.nextCore
         self.nextCore = ( self.nextCore + 1 ) % self.numCores
     self.nextIP += 1
     defaults.update( params )
     if not cls:
         cls = self.host
     h = cls( name, **defaults )
     self.hosts.append( h )
     self.nameToNode[ name ] = h
     return h
开发者ID:enavacp,项目名称:mininet,代码行数:33,代码来源:net.py


示例5: _auto_config_intf

 def _auto_config_intf(self, node_name, intf_name, **param):
     node = self.nodemap[node_name]
     if 'port' not in param:
         param['port'] = node.newPort()
     if intf_name == 'auto':
         intf_name = Link.intfName(node, param['port'])
     if intf_name in node.nameToIntf:
         error("Node %s already has interface %s." % (node, name))
         return False
     net = self.mn
     if 'ip' not in param:
         ip = net.nextIP
         net.nextIP += 1
         sufix = ipAdd(ip, ipBaseNum=net.ipBaseNum, prefixLen=net.prefixLen)
         prefix = '/%s' % net.prefixLen
         param['ip'] =  sufix + prefix 
         if 'mac' not in param:
             param['mac'] = macColonHex(ip)
     elif 'mac' not in param:
         ip, prefix = netParse(param['ip'])
         param['mac'] = macColonHex(ip)
     if 'cores' not in param and net.autoPinCpus:
         param['cores'] = self.nextCore
         net.nextCore = (net.nextCore + 1) % net.numCores
     return True
开发者ID:pantuza,项目名称:mininet,代码行数:25,代码来源:dynamicnet.py


示例6: addStation

 def addStation( self, name, cls=None, **params ):
     """Add host.
        name: name of host to add
        cls: custom host class/constructor (optional)
        params: parameters for host
        returns: added host"""
     #Default IP and MAC addresses
     defaults = { 'ip': ipAdd( self.nextIP,
                               ipBaseNum=self.ipBaseNum,
                               prefixLen=self.prefixLen ) +
                               '/%s' % self.prefixLen }
     if self.autoSetMacs:
         defaults[ 'mac' ] = macColonHex( self.nextIP )
     if self.autoPinCpus:
         defaults[ 'cores' ] = self.nextCore
         self.nextCore = ( self.nextCore + 1 ) % self.numCores
     #self.nextIP += 1
     defaults.update( params )
     if not cls:
         cls = self.host
     h = cls( name, **defaults )      
     self.hosts.append( h )
     self.nameToNode[ name ] = h
     self.wirelessifaceControl.append(self.nextIface)
     self.wirelessdeviceControl.append(name)
     self.stationName.append(name)
     
     os.system("iw phy phy%s set netns %s" % (self.nextIface, h.pid))
     self.host.cmd(h,"ip link set dev wlan%s name %s-wlan0" % (self.nextIface, h))
     self.host.cmd(h,"ifconfig %s-wlan0 up" % h)
     self.host.cmd(h,"ifconfig %s-wlan0 10.1.1.%s/%s" % (h, self.nextIP, self.prefixLen)) 
     
     #callfun="start"
     #intf=self.nextIface
     #src=name        
     #wlink(callfun, intf, src)
            
     #self.host.cmd(h,"iw %s-wlan0 connect %s" % (h, "my_ssid"))
     self.nextIP += 1        
     self.nextIface+=1
     #os.system("iw dev wlan2 interface add mesh2 type station")
     #os.system("sleep 2")
     #os.system("sleep 2")
     #os.system("iw dev mesh2 station join bazookaa")
     return h
开发者ID:ruacon35,项目名称:mininet-wifi,代码行数:45,代码来源:net.py


示例7: printInfo

    def printInfo( self ):
        "print nodes and links."
        for widget in self.widgetToItem:
            name = widget[ 'text' ]
            tags = self.canvas.gettags( self.widgetToItem[ widget ] )
            x1, y1 = self.canvas.coords( self.widgetToItem[ widget ] )
            nodeNum = int( name[ 1: ] )
            if 'Switch' in tags:
                print "Switch "+name+" at "+str(x1)+"/"+str(y1)+"."
            elif 'Host' in tags:
                ipBaseNum, prefixLen = netParse( self.minieditIpBase )
                print 'ipBaseNum='+str(ipBaseNum)
                print 'prefixLen='+str(prefixLen)
                ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
                print "Host "+name+" with IP "+ip+" at "+str(x1)+"/"+str(y1)+"."
            else:
                raise Exception( "Cannot create mystery node: " + name )

        for link in self.links.values():
            ( src, dst, linkopts ) = link
            srcName, dstName = src[ 'text' ], dst[ 'text' ]
            print "Link from "+srcName+" to "+dstName+"."
开发者ID:Phi-Ho,项目名称:pyretic,代码行数:22,代码来源:miniedit-2.0.0.3.1.py


示例8: addHost

 def addHost(self, name, cls=None, **params):
     """Add host.
        name: name of host to add
        cls: custom host class/constructor (optional)
        params: parameters for host
        returns: added host"""
     # Default IP and MAC addresses
     defaults = {
         "ip": ipAdd(self.nextIP, ipBaseNum=self.ipBaseNum, prefixLen=self.prefixLen) + "/%s" % self.prefixLen
     }
     if self.autoSetMacs:
         defaults["mac"] = macColonHex(self.nextIP)
     if self.autoPinCpus:
         defaults["cores"] = self.nextCore
         self.nextCore = (self.nextCore + 1) % self.numCores
     self.nextIP += 1
     defaults.update(params)
     if not cls:
         cls = self.host
     h = cls(name, **defaults)
     self.hosts.append(h)
     self.nameToNode[name] = h
     return h
开发者ID:ruifcardoso,项目名称:mininet,代码行数:23,代码来源:net.py


示例9: addTransitPortalRouter

    def addTransitPortalRouter( self, name, cls=None, **params ):
        """Add transit portal router.
           name: name of transit portal router to add
           cls: custom router class/constructor (optional)
           returns: added transit portal router ."""

        # Default IP and MAC addresses
        defaults = { 'ip': ipAdd( self.nextIP,
                                  ipBaseNum=self.ipBaseNum,
                                  prefixLen=self.prefixLen ) +
                                  '/%s' % self.prefixLen }
        if self.autoSetMacs:
            defaults[ 'mac'] = macColonHex( self.nextIP )
        if self.autoPinCpus:
            defaults[ 'cores' ] = self.nextCore
            self.nextCore = ( self.nextCore + 1 ) % self.numCores
        self.nextIP += 1
        defaults.update( params )
        if not cls:
            cls = self.transitPortalRouter
        tpr = cls( name, **defaults )
        self.transitPortalRouters.append( tpr )
        self.nameToNode[ name ] = tpr
        return tpr
开发者ID:aimonb,项目名称:miniNeXT,代码行数:24,代码来源:net.py


示例10: getNextIp

 def getNextIp( self ):
     ip = ipAdd( self.nextIP,
                 ipBaseNum=self.ipBaseNum,
                 prefixLen=self.prefixLen ) + '/%s' % self.prefixLen
     self.nextIP += 1
     return ip
开发者ID:stevenvanrossem,项目名称:containernet,代码行数:6,代码来源:net.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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