由 tc 配置时的 Mininet 网络错误

Mininet network errors when configured by tc

我正在尝试通过 tc 命令在我使用 mininet 创建的网络交换机部分的接口(端口)1 上指定数据包丢失: sudo tc qdisc change dev s1-eth1 root netem loss 0.1% 但是出现错误: RTNETLINK answers: Invalid argument

如有任何帮助,我们将不胜感激。

网络详细信息:

它是 Ubuntu 14.04 上基于树形拓扑的 mininet 网络,深度 = 2,扇出 = 5。在第一层,一个交换机连接到 5 个交换机,每个交换机连接到 5 个主机。所有交换机都是 OpenvSwitch。

Mininet网络:

#!/usr/bin/python

from functools import partial
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.node import OVSKernelSwitch
from mininet.node import RemoteController
from mininet.topo import Topo
from mininet.util import dumpNodeConnections


class MyNet( Topo ):
    "Simple topology example."

    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self )

        # Add hosts
        h1 = self.addHost( 'h1' )
        h2 = self.addHost( 'h2' )
        h3 = self.addHost( 'h3' )
        h4 = self.addHost( 'h4' )
        h5 = self.addHost( 'h5' )
        h6 = self.addHost( 'h6' )
        h7 = self.addHost( 'h7' )
        h8 = self.addHost( 'h8' )
        h9 = self.addHost( 'h9' )
        h10 = self.addHost( 'h10' )
        h11 = self.addHost( 'h11' )
        h12 = self.addHost( 'h12' )
        h13 = self.addHost( 'h13' )
        h14 = self.addHost( 'h14' )
        h15 = self.addHost( 'h15' )
        h16 = self.addHost( 'h16' )
        h17 = self.addHost( 'h17' )
        h18 = self.addHost( 'h18' )
        h19 = self.addHost( 'h19' )
        h20 = self.addHost( 'h20' )
        h21 = self.addHost( 'h21' )
        h22 = self.addHost( 'h22' )
        h23 = self.addHost( 'h23' )
        h24 = self.addHost( 'h24' )
        h25 = self.addHost( 'h25' )

    # Add switches
        s1 = self.addSwitch( 's1' )
        s2 = self.addSwitch( 's2' )
        s3 = self.addSwitch( 's3' )
        s4 = self.addSwitch( 's4' )
        s5 = self.addSwitch( 's5' )
        s6 = self.addSwitch( 's6' )

        # Add links
        self.addLink( s2, s1 ,bw=0.1)
        self.addLink( s3, s1 ,bw=10)
        self.addLink( s4, s1 ,bw=10)
        self.addLink( s5, s1 ,bw=10)
        self.addLink( s6, s1 ,bw=100)

        self.addLink( h1, s2 ,bw=0.1)
        self.addLink( h2, s2 ,bw=10)
        self.addLink( h3, s2 ,bw=10)
        self.addLink( h4, s2 ,bw=10)
        self.addLink( h5, s2 ,bw=10)

        self.addLink( h6, s3 ,bw=10)
        self.addLink( h7, s3 ,bw=10)
        self.addLink( h8, s3 ,bw=10)
        self.addLink( h9, s3 ,bw=10)
        self.addLink( h10, s3 ,bw=10)

        self.addLink( h11, s4 ,bw=10)
        self.addLink( h12, s4 ,bw=10)
        self.addLink( h13, s4 ,bw=10)
        self.addLink( h14, s4 ,bw=10)
        self.addLink( h15, s4 ,bw=10)

        self.addLink( h16, s4 ,bw=10)
        self.addLink( h17, s4 ,bw=10)
        self.addLink( h18, s4 ,bw=10)
        self.addLink( h19, s4 ,bw=10)
        self.addLink( h20, s4 ,bw=10)

        self.addLink( h21, s6 ,bw=10)
        self.addLink( h22, s6 ,bw=10)
        self.addLink( h23, s6 ,bw=10)
        self.addLink( h24, s6 ,bw=10)
        self.addLink( h25, s6 ,bw=100)

topos = { 'MyNet': ( lambda: MyNet() ) }
#sudo mn --custom MyNet.py --topo MyNet --controller=remote,ip=10.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13 --link tc

我不知道如何解决你遇到的问题。但我知道你可以在 mininet API 中指定延迟和丢失率。

看看下面的第 29 行: https://github.com/mininet/mininet/blob/master/examples/simpleperf.py

根据这个 link,似乎 mininet 使用 tc 命令在内部设置 packet lossdelay 等。

它试图覆盖 qdisc 文件,因此,它会出错 RTNETLINK answers: Invalid argument

要设置数据包丢失,请在创建 link 时使用 loss 参数在 mininet 脚本中进行设置。有关示例,请参见 this