(一)基本要求
1、使用Mininet可视化工具,生成下图所示的拓扑,并保存拓扑文件名为学号.py。
2、使用Mininet的命令行生成如下拓扑:
(a)3台交换机,每个交换机连接1台主机,3台交换机连接成一条线。
(b)3台主机,每个主机都连接到同1台交换机上。
在2 (b)的基础上,在Mininet交互界面上新增1台主机并且连接到交换机上,再测试新拓扑的连通性。
3. 修改过的“学号.py”代码、Mininet运行结果
(二)进阶要求
点击查看代码
#!/usr/bin/python
from curses.panel import top_panel
from mininet.topo import Topo
class MyTopo(Topo):
def build(self):
L1 = 2
L2 = L1 * 2
L3 = L2 * 2
c = []
a = []
e = []
# add core ovs
for i in range( L1 ):
sw = self.addSwitch( 'c{}'.format( i + 1 ) )
c.append( sw )
# add aggregation ovs
for i in range( L2 ):
sw = self.addSwitch( 'a{}'.format( L1 + i + 1 ) )
a.append( sw )
# add edge ovs
for i in range( L3 ):
sw = self.addSwitch( 'e{}'.format( L1 + L2 + i + 1 ) )
e.append( sw )
# add links between core and aggregation ovs
for i in range( L1 ):
sw1 = c[int(i)]
for sw2 in a[int(i/2)::int(L1/2)]:
# self.addLink(sw2, sw1, bw=10, delay='5ms', loss=10, max_queue_size=1000, use_htb=True)
self.addLink( sw2, sw1 )
# add links between aggregation and edge ovs
for i in range( 0, int(L2), 2 ):
for sw1 in a[int(i):int(i+2)]:
for sw2 in e[i:i+2]:
self.addLink( sw2, sw1 )
#add hosts and its links with edge ovs
count = 1
for sw1 in e:
for i in range(2):
host = self.addHost( 'h{}'.format( count ) )
self.addLink( sw1, host )
count += 1
topos = { 'mytopo': ( lambda: MyTopo() ) }