zoukankan      html  css  js  c++  java
  • 利用Python脚本完成一个Fat-tree型的拓扑

    利用Python脚本完成如下图所示的一个Fat-tree型的拓扑(交换机和主机名需与图中一致,即s1~s6,h1~h8)

    from mininet.topo import Topo
    from mininet.net import Mininet
    from mininet.node import RemoteController,CPULimitedHost
    from mininet.link import TCLink
    from mininet.util import dumpNodeConnections
     
    class MyTopo( Topo ):
        "Simple topology example."
     
        def __init__( self ):
            "Create custom topo."
     
            # Initialize topology
            Topo.__init__( self )
            L1 = 2
            L2 = L1 * 2 
            s = []
          
              
            # add core ovs  
            for i in range( L1 ):
                    sw = self.addSwitch( 's{}'.format( i + 1 ) )
                    s.append( sw )
        
            # add aggregation ovs
            for i in range( L2 ):
                    sw = self.addSwitch( 's{}'.format( i + L1 + 1 ) )
                    s.append( sw )
     
            # add links between core and aggregation/edge ovs
            for i in range( L1 ):
    		sw1 = s[i]
                    for j in range( L2 ):
    			sw2 = s[L1 + j]
    			self.addLink( sw2, sw1 )
     
            #add hosts and its links with aggregation/edge ovs
            count = 1
            for sw1 in s[L1::1]:
                    for i in range(2):
                    	host = self.addHost( 'h{}'.format( count ) )
                    	self.addLink( sw1, host )
                    	count += 1
    topos = { 'mytopo': ( lambda: MyTopo() ) }
    
  • 相关阅读:
    Moya 浅析
    Swift: Alamofire -> http请求 & ObjectMapper -> 解析JSON
    ReactiveCocoa 用法实例
    RACSignal的Subscription深入
    idea 不能编译生成class文件
    idea 右下角不显示git分支
    SSO单点登录的研究
    JVM内存模型简介
    Spring事务处理
    RabbitMQ
  • 原文地址:https://www.cnblogs.com/fjlinww/p/11763313.html
Copyright © 2011-2022 走看看