# 2019 SDN上机第一次作业

## 1.安装轻量级网络仿真工具Mininet

• 从GitHub上获取mininet源码

/* sudo git clone git://github.com/mininet/mininet

• 安装时可选择的mininet版本

• 进入mininet/util/目录下进行安装

mininet/util/install.sh [options]
-a:  全部安装
-nfv:仅安装MINIENT OPENFLOW引用多SWITCH 和OPEN VSWITCH
-s mydir: 指定目录

• 安装成功后进行最小拓扑测试

## 2.用字符命令搭建如下拓扑，要求写出命令

/*   sudo mn --topo linear,3


/*    sudo mn --topo tree,fanout=3,depth=2


## 4.利用Python脚本完成如下图所示的一个Fat-tree型的拓扑

#!/usr/bin/python
#创建网络拓扑
"""Custom topology example
Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import RemoteController,CPULimitedHost
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
c = []
a = []
e = []

for i in range( L1 ):
sw = self.addSwitch( 's{}'.format( i + 1 ) )
c.append( sw )

for i in range( L2 ):
sw = self.addSwitch( 's{}'.format( L1 + i + 1 ) )
a.append( sw )

for i in range( L1 ):
sw1 = c[i]
for sw2 in a[i/2::L1/2]: