Mininet多数据中心网络拓扑流量带宽实验

简介: Mininet多数据中心网络拓扑流量带宽实验

任务目的

1、通过Mininet模拟搭建基于不同数据中心的网络拓扑; 2、掌握多数据中心网络拓扑的构建; 3、熟悉网络性能测试工具Iperf,根据实验测试SDN网络的性能; 4、通过程序生成真实网络流量。

任务环境

设备名称 软件环境 硬件环境
主机 Mininet_2.2.0_desktop_cv1.1 CPU:1核内存2G磁盘:20G

注:系统默认的账户为: 管理员权限用户名:root,密码:root@openlab; 普通用户用户名:openlab,密码:user@openlab。

实验步骤

*一、 实现iperfmulti功能生成多客户端随机产生UDP流量*

步骤1 登录Mininet所在虚机,在Mininet目录下mininet/net.py文件中定义iperf_single()函数

在两个主机间进行iperf udp测试,并且在server端记录,实现iperf_single函数:

def iperf_single( self,hosts=None, udpBw='10M', period=60, port=5001):
      """Run iperf between two hosts using UDP.
        hosts: list of hosts; if None, uses opposite hosts
        returns: results two-element array of server and client speeds"""
      if not hosts:
        return
      else:
        assert len( hosts ) == 2
      client, server = hosts
      filename = client.name[1:] + '.out'
      output( '*** Iperf: testing bandwidth between ' )
      output( "%s and %s\n" % ( client.name, server.name ) )
      iperfArgs = 'iperf -u '
      bwArgs = '-b ' + udpBw + ' '
      print "***start server***"
      server.cmd( iperfArgs + '-s -i 1' + ' > /home/sdnlab/log/' + filename + '&')
      print "***start client***"
      client.cmd(
        iperfArgs + '-t '+ str(period) + ' -c ' + server.IP() + ' ' + bwArgs
        +' > /home/sdnlab/log/' + 'client' + filename +'&')

步骤2 net.py中添加自定义命令iperfmulti() 函数

为mininet添加自定义命令iperfmulti,依次为每一台主机随机选择另一台主机作为iperf的服务器端,通过调用iperf_single,自身以客户端身份按照指定参数发送UDP流,服务器生成的报告以重定向的方式输出到文件中,使用iperfmulti命令,主机随机地向另一台主机发起一条恒定带宽的UDP数据流。

def iperfMulti(self, bw, period=60):
        base_port = 5001
        server_list = []
        client_list = [h for h in self.hosts]
        host_list = []
        host_list = [h for h in self.hosts]
        cli_outs = []
        ser_outs = []
        _len = len(host_list)
        for i in xrange(0, _len):
            client = host_list[i]
            server = client
            while( server == client ):
                server = random.choice(host_list)
            server_list.append(server)
            self.iperf_single(hosts = [client, server], udpBw=bw, period= period, port=base_port)
            sleep(.05)
            base_port += 1
        sleep(period)
        print "test has done"

步骤3 mininet/cli.py中注册iperfmulti命令

解析用户输入的命令,net.py定义的iperfmulti命令需要在CLI类中注册这条自定义命令。

def do_iperfmulti( self, line ):
        """Multi iperf UDP test between nodes"""
        args = line.split()
        if len(args) == 1:
            udpBw = args[ 0 ]
            self.mn.iperfMulti(udpBw)
        elif len(args) == 2:
            udpBw = args[ 0 ]
            period = args[ 1 ]
            err = False
            self.mn.iperfMulti(udpBw, float(period))
        else:
            error('invalid number of args: iperfmulti udpBw period\n' +
                   'udpBw examples: 1M 120\n')

步骤4 bin/mn中加入iperfmulti可执行命令

将iperfmulti加入到对应的列表中。

ALTSPELLING = { 'pingall': 'pingAll', 'pingpair': 'pingPair',
        'iperfudp': 'iperfUdp','iperfmulti':'iperfMulti' }

步骤5 重新编译mininet

进入mininet/util目录,重新编译安装mininet。

#~/mininet/util/install.sh -n

步骤6 验证iperfmulti是否成功

重新创建网络,如mn,输入iperf,可用table补全iperfmulti,从而可使用iperfmulti进行流量随机模型的测试:

*二、 多数据中心拓扑创建脚本编写*

步骤1 通过python脚本自定义拓扑,创建包含两个数据中心的网络拓扑

# cd custom
# vi fattree.py
#!/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.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
        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[i]
                for sw2 in a[i/2::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, L2, 2 ):
                for sw1 in a[i: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() ) }

*三、 数据中心拓扑脚本执行*

步骤1 启动Mininet,生成测试拓扑结构,进入到Mininet的custom目录下:

\# mn --custom fattree.py --topo mytopo --controller=remote,ip=30.0.1.12,port=6653

步骤2 验证主机间的连通性:

步骤3 查看ODL控制器Web页面拓扑:http://30.0.1.12:8181/index.html,用户名密码:admin/admin

*四、 数据中心拓扑网络测试—TCP带宽测试*

****

步骤1 同一交换机内部的主机间连通性及通信带宽测试

在h1和h2之间进行iperf操作进行测试:

mininet> iperf h1 h2

步骤2 相同汇聚交换机下不同机架的主机间测试

在h1和h3之间进行iperf操作进行测试:

mininet> iperf h1 h3

步骤3 相同核心交换机不同汇聚交换机下的主机间测试

在h1和h5之间进行iperf操作进行测试:

mininet> iperf h1 h5

*五、 数据中心拓扑网络测试—iperfmulti UDP测试*

步骤1 在mininet中执行iperfmulti命令,设置带宽参数为0.025M,我们将能看到8台主机随机地向另外一台主机发送数据包。

mininet> iperfmulti 0.025M

打开服务端数据记录:

打开服务端数据记录:

目录
相关文章
|
10月前
|
存储 人工智能 边缘计算
Gartner 魔力象限:数据中心网络交换机 2025
Gartner 魔力象限:数据中心网络交换机 2025
716 0
Gartner 魔力象限:数据中心网络交换机 2025
|
6月前
|
监控 区块链 数据中心
Arista EOS 4.35.0F 发布 - 适用于下一代数据中心和云网络的可扩展操作系统
Arista EOS 4.35.0F 发布 - 适用于下一代数据中心和云网络的可扩展操作系统
330 0
Arista EOS 4.35.0F 发布 - 适用于下一代数据中心和云网络的可扩展操作系统
|
监控 数据可视化 Linux
Cisco Nexus Dashboard 4.1(1g) 发布 - 云和数据中心网络管理软件
Cisco Nexus Dashboard 4.1(1g) - 云和数据中心网络管理软件
281 0
|
7月前
|
Devops API 语音技术
Cisco NX-OS 10.6(1)F 发布 - 数据中心网络操作系统
Cisco NX-OS 10.6(1)F 发布 - 数据中心网络操作系统
185 0
Cisco NX-OS 10.6(1)F 发布 - 数据中心网络操作系统
|
运维 监控 网络协议
面对全球化的泼天流量,出海企业观测多地域网络质量
网络监控与分析在保证网络可靠性、优化用户体验和提升运营效率方面发挥着不可或缺的作用,对于出海企业应对复杂的网络环境和满足用户需求具有重要意义,为出海企业顺利承接泼天流量保驾护航。
602 221
|
网络协议 网络架构
|
11月前
|
监控 安全 Linux
Arista CloudVision 2025.1 - 多云和数据中心网络自动化、监控和分析
Arista CloudVision 2025.1 - 多云和数据中心网络自动化、监控和分析
455 2
Arista CloudVision 2025.1 - 多云和数据中心网络自动化、监控和分析
|
11月前
|
网络协议 区块链 KVM
Arista vEOS 4.30.10M - 虚拟化的数据中心和云网络可扩展操作系统
Arista vEOS 4.30.10M - 虚拟化的数据中心和云网络可扩展操作系统
344 2
Arista vEOS 4.30.10M - 虚拟化的数据中心和云网络可扩展操作系统
|
10月前
|
机器学习/深度学习 人工智能 运维
“网太乱,AI来管”——聊聊AI在网络拓扑优化上的骚操作
“网太乱,AI来管”——聊聊AI在网络拓扑优化上的骚操作
863 15
下一篇
开通oss服务