1. 3台交换机,每个交换机连接1台主机,3台交换机连接成一条线。
2. 3台主机,每个主机都连接到同1台交换机上。
1.102299105.py(修改后)
2. 执行结果截图
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 L3 = L2 * 2 first = [] second = [] third = [] # addd core ovs for i in range( L1 ): sw = self.addSwitch( 's{}'.format( i + 1 ) ) first.append( sw ) # add aggregation ovs for i in range( L2 ): sw = self.addSwitch( 's{}'.format( L1 + i + 1 ) ) second.append( sw ) # add edge ovs for i in range( L3 ): sw = self.addSwitch( 's{}'.format( L1 + L2 + i + 1 ) ) third.append( sw ) # add links between core and aggregation ovs for i in range( L1 ): sw1 = first[i] for sw2 in second: # self.addLink(sw2, sw1, bw=10, delay='5ms', loss=10, max_queue_size=1000, use_htb=True) self.addLink( sw1, sw2 ) # add links between aggregation and edge ovs for i in range( L2 ): t=i sw1=second[i] if (i&2)!=0: t=t-1 t=t*2 for sw2 in third[t:t+4]: self.addLink( sw1, sw2 ) # add hosts and its links with edge ovs count = 1 for sw1 in third: for i in range(2): host = self.addHost( 'h{}'.format( count ) ) self.addLink( sw1,host ) count += 1 topos = { 'mytopo': ( lambda: MyTopo() ) }
第二次作业以mininet为主展开,在老师给的文件指导下还算顺利,虽然未曾谋面的Python给了迎头痛击。但在先前第一次作业安装网络给的当头一棒后,算是尝到进度条一路加载的快乐。 在这个过程中,我发现面对未知的东西,要敢于探索,敢于发现。曾经以为此生都无法越过去的安装环境,事后再尝试复盘了一次,发现畏难才是学习路上最大的敌人。并且在这期间,寻求帮助变成了常态,也明白了自己多多探索也是一条求知的坦途。 很是期待这门课接下来的作业,在学习Sdn的路上,会为我开启怎样的副本。