SDN mininet fat tree k=4

1 实验任务

Create a Fat Tree (k=4) datacenter topology and test it, including:
(1) display all the nodes and links;
(2) let h1 ping h16 for 10 times;
(3) let each pair of host ping each other with pingall;
(4) test bandwidth with iperf.

2 Fat tree介绍

FatTree拓扑结构是由MIT的Fares等人在改进传统树形结构性能的基础上提出的,属于switch-only型拓扑。1
整个拓扑网络分为三个层次:自上而下分别为边缘层(edge)、汇聚层(aggregate)和核心层(core),其中汇聚层交换机与边缘层交换机构成一个pod,交换设备均采用商用交换设备。

2.1 拓扑结构

下图是fat tree k=4的拓扑结构
在这里插入图片描述

2.2 结构特点

  1. There are k pods
  2. Each pod consists of 2 layers of k 2 \frac{k}{2} 2k switches
  3. Each edge switch is connected to k 2 \frac{k}{2} 2k hosts
  4. Each edge switch is connected to k 2 \frac{k}{2} 2kaggregation switches
  5. There are k 2 4 \frac{k^2}{4} 4k2 core switches
  6. Each core switch is connected to an aggregation switch for each pod

3 实验过程

3.1 启动ryu控制器

防止广播风暴,使用生成树协议STP

cd ryu/ryu/app
ryu-manager simple_switch_stp.py

我使用的是simple_switch_stp.py。有同学和我说他使用的是simple_switch_stp_13.py,不然会报错。
截图

3.2 mininet启动拓扑

sudo mn --custom ./fattree.py --topo=mytopo --controller=remote,ip=127.0.0.1,port=6633

3.3 问题回答

建议先h1 ping h2几次,打通流表

  1. display all the nodes and links;
    在这里插入图片描述
    在这里插入图片描述

  2. let h1 ping h16 for 10 times;
    在这里插入图片描述

  3. let each pair of host ping each other with pingall;
    在这里插入图片描述

  4. test bandwidth with iperf.
    在这里插入图片描述

代码

翻了很多网上的代码,全是针对 k = 2 k=2 k=2的fat tree的代码,直接改成 k = 4 k=4 k=4拓扑结构是错误的。自己重写了以下针对任意 k k k的代码。直接修改代码中 k k k的大小就可以获得相应的fat tree拓扑结构。
以下代码需要使用python3;若要使用python2运行,则需要将所有的“//”替换为“/”。

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
 
class MyTopo(Topo):
 
    def __init__(self):
        super(MyTopo,self).__init__()
 
        #Marking the number of switch for per level
        k=4
        pod=k
        L1 = (pod//2)**2
        L2 = pod*pod//2
        L3 = L2
 
        #Starting create the switch
        c = []    #core switch
        a = []    #aggregate switch
        e = []    #edge switch
 
        #notice: switch label is a special data structure
        for i in range(L1):
            c_sw = self.addSwitch('c{}'.format(i+1))    #label from 1 to n,not start with 0
            c.append(c_sw)
 
        for i in range(L2):
            a_sw = self.addSwitch('a{}'.format(L1+i+1))
            a.append(a_sw)
 
        for i in range(L3):
            e_sw = self.addSwitch('e{}'.format(L1+L2+i+1))
            e.append(e_sw)
 
        #Starting create the link between switchs
        #first the first level and second level link
        for i in range(L1):
            c_sw=c[i]
            start=i%(pod//2)
            for j in range(pod):
                self.addLink(c_sw,a[start+j*(pod//2)])
 
        #second the second level and third level link
        for i in range(L2):
            group=i//(pod//2)
            for j in range(pod//2):
                self.addLink(a[i],e[group*(pod//2)+j])
 
        #Starting create the host and create link between switchs and hosts
        for i in range(L3):
            for j in range(2):
                hs = self.addHost('h{}'.format(i*2+j+1))
                self.addLink(e[i],hs)
 
 
topos = {"mytopo":(lambda:MyTopo())}


  1. 一个fat tree的介绍https://www.jianshu.com/p/99642d24fe84 ↩︎

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值