Experimento de ancho de banda de tráfico de topología de red de múltiples centros de datos de Mininet

Nombre del equipo Entorno de software
host1 mininet
host1 controlador ryu
前提:
由于节省设备资源,vm我就开了一个利用host,系统ubuntu16.04,然后xshell远程
连接开两个窗口,一个窗口运行mininet,一个窗口运行ryu controller。

Referencia de texto completo: experimento SDNLAB

Puedes usar la plataforma directamente para hacer experimentos. Yo opero en mi propia máquina virtual. La ventaja es que cuando lo haces tú mismo, a menudo hay errores inesperados y tienes más experiencia.

1. Realice la función iperfmulti para generar múltiples clientes y generar tráfico UDP de forma aleatoria

Paso 1 Defina la función iperf_single () y agregue la función de comando personalizado iperfmulti () en el archivo mininet / net.py en el directorio Mininet

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

consejos:
Vale la pena señalar aquí/ inicio / tian01 / logSi desea tenerlo con anticipación, puede elegir un directorio existente usted mismo

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数据流

Paso 2 Registre el comando iperfmulti en mininet / cli.py en el directorio de Mininet

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

Paso 3: agregue el comando ejecutable iperfmulti a / usr / local / bin / mn

Primero use el comando whereis mn para ver la ubicación del comando

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

vim se puede abrir y modificar de la siguiente manera

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

Paso 4 Ingrese al directorio mininet / util para recompilar mininet

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

Verificación del paso 5

Inserte la descripción de la imagen aquí

	输入iperf 按TAB补全就能看到

2. Código de secuencia de comandos de topología de varios centros de datos

El archivo de código del topo personalizado debe estar en el directorio / mininet / custom, y también en este directorio al iniciar

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

Tres, ejecución de script de topología del centro de datos

Consejos: ¡Abra el controlador ryu en una ventana y realice el experimento de mininet en una ventana!

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. Prueba de ancho de banda de TCP de prueba de red de topología del centro de datos

	没有演示,自行实验

5. Prueba de red de topología del centro de datos: prueba iperfmulti UDP

	这里我也设置带宽参数为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

Seis, ver registros

请自行查看,我放在/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# 

Supongo que te gusta

Origin blog.csdn.net/weixin_46239293/article/details/113394544
Recomendado
Clasificación