ミニネットマルチデータセンターネットワークトポロジトラフィック帯域幅実験

機器名 ソフトウェア環境
host1 ミニネット
host1 リュウコントローラー
前提:
由于节省设备资源,vm我就开了一个利用host,系统ubuntu16.04,然后xshell远程
连接开两个窗口,一个窗口运行mininet,一个窗口运行ryu controller。

全文リファレンス:SDNLAB実験

プラットフォームを直接使用して実験を行うことができます。私は自分の仮想マシンで操作します。自分で行うと、予期しない間違いが頻繁に発生し、経験が増えるという利点があります。

1. iperfmulti関数を実現して、マルチクライアントを生成し、UDPトラフィックをランダムに生成します

ステップ1iperf_single()関数を定義し、Mininetディレクトリのmininet / net.pyファイルにカスタムコマンドiperfmulti()関数を追加します。

iperf_single函数目的:是为两个主机之间进行iperf udp测试,并且在server端记录
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/tian01/log/' + filename + '&')
        print "***start client***"
        client.cmd(
            iperfArgs + '-t '+ str(period) + ' -c ' + server.IP() + ' ' + bwArgs
            +' > /home/tian01/log/' + 'client' + filename +'&')

ヒント:
ここで注目する価値があります/ home / tian01 / log事前に入手したい場合は、既存のディレクトリを自分で選択できます

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"
为mininet添加自定义命令iperfmulti,依次为每一台主机随机选择另一台主机作为iperf
的服务器端,通过调用iperf_single,自身以客户端身份按照指定参数发送UDP流,服务器生
成的报告以重定向的方式输出到文件中(就是刚刚/home/tian01/log),使用iperfmulti命
令,主机随机地向另一台主机发起一条恒定带宽的UDP数据流

ステップ2Mininetディレクトリのmininet / cli.pyにiperfmultiコマンドを登録します

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')

ステップ3:iperfmulti実行可能コマンドを/ usr / local / bin / mnに追加します

まず、whereis mnコマンドを使用して、コマンドの場所を表示します

root@tian01-virtual-machine:/home/tian01/mininet/mininet# whereis mn
mn: /usr/local/bin/mn /usr/share/man/man1/mn.1

vimは次のように開いて変更できます

root@tian01-virtual-machine:/home/tian01/mininet/mininet# vim /usr/local/bin/mn
#Map to alternate spellings of Mininet() methods
ALTSPELLING = {
    
     'pingall': 'pingAll', 'pingpair': 'pingPair',
                'iperfudp': 'iperfUdp','iperfmulti':'iperfMulti'}

ステップ4mininet / utilディレクトリに入り、mininetを再コンパイルします

root@tian01-virtual-machine:/home/tian01/mininet#./mininet/util/install.sh -n

ステップ5の検証

ここに画像の説明を挿入

	输入iperf 按TAB补全就能看到

2.マルチデータセンタートポロジスクリプトコード

カスタムトポのコードファイルは、/ mininet / customディレクトリにあり、起動時にはこのディレクトリにもある必要があります。

#!/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() ) }

3つ目は、データセンタートポロジスクリプトの実行です。

ヒント:1つのウィンドウでリュウコントローラーを開き、1つのウィンドウでミニネット実験を実行してください!

root@tian01-virtual-machine:/home/tian01/mininet/custom# mn --custom fattree.py --topo mytopo --controller=remote,ip=127.0.0.1,port=6633
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4 h5 h6 h7 h8 
*** Adding switches:
a3 a4 a5 a6 c1 c2 e7 e8 e9 e10 
*** Adding links:
(a3, c1) (a3, c2) (a4, c1) (a4, c2) (a5, c1) (a5, c2) (a6, c1) (a6, c2) (e7, a3) (e7, a4) (e7, h1) (e7, h2) (e8, a3) (e8, a4) (e8, h3) (e8, h4) (e9, a5) (e9, a6) (e9, h5) (e9, h6) (e10, a5) (e10, a6) (e10, h7) (e10, h8) 
*** Configuring hosts
h1 h2 h3 h4 h5 h6 h7 h8 
*** Starting controller
c0 
*** Starting 10 switches
a3 a4 a5 a6 c1 c2 e7 e8 e9 e10 ...
*** Starting CLI:

4.データセンタートポロジネットワークテスト-TCP帯域幅テスト

	没有演示,自行实验

5.データセンタートポロジネットワークテスト-iperfmultiUDPテスト

	这里我也设置带宽参数为0.025M
mininet> pingall
*** Ping: testing ping reachability
h1 -> X X X X X X X 
h2 -> X X h4 h5 h6 h7 h8 
h3 -> h1 h2 h4 h5 h6 h7 h8 
h4 -> h1 h2 h3 h5 h6 h7 h8 
h5 -> h1 h2 h3 h4 h6 h7 h8 
h6 -> h1 h2 h3 h4 h5 h7 h8 
h7 -> h1 h2 h3 h4 h5 h6 h8 
h8 -> h1 h2 h3 h4 h5 h6 h7 
*** Results: 16% dropped (47/56 received)
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4 h5 h6 h7 h8 
h2 -> h1 h3 h4 h5 h6 h7 h8 
h3 -> h1 h2 h4 h5 h6 h7 h8 
h4 -> h1 h2 h3 h5 h6 h7 h8 
h5 -> h1 h2 h3 h4 h6 h7 h8 
h6 -> h1 h2 h3 h4 h5 h7 h8 
h7 -> h1 h2 h3 h4 h5 h6 h8 
h8 -> h1 h2 h3 h4 h5 h6 h7 
*** Results: 0% dropped (56/56 received)
mininet> iperfmulti 0.025M
*** Iperf: testing bandwidth between h1 and h6
***start server***
***start client***
*** Iperf: testing bandwidth between h2 and h1
***start server***
***start client***
*** Iperf: testing bandwidth between h3 and h5
***start server***
***start client***
*** Iperf: testing bandwidth between h4 and h5
***start server***
***start client***
*** Iperf: testing bandwidth between h5 and h4
***start server***
***start client***
*** Iperf: testing bandwidth between h6 and h2
***start server***
***start client***
*** Iperf: testing bandwidth between h7 and h2
***start server***
***start client***
*** Iperf: testing bandwidth between h8 and h3
***start server***
***start client***
test has done

6、レコードを表示

请自行查看,我放在/home/tian01/log下
root@tian01-virtual-machine:/home/tian01/mininet/custom# cd /home/tian01/log/
root@tian01-virtual-machine:/home/tian01/log# ls
1.out  3.out  5.out  7.out  client1.out  client3.out  client5.out  client7.out
2.out  4.out  6.out  8.out  client2.out  client4.out  client6.out  client8.out
root@tian01-virtual-machine:/home/tian01/log# 

おすすめ

転載: blog.csdn.net/weixin_46239293/article/details/113394544