由tc

时间:2015-07-16 08:57:11

标签: python mininet packet-loss

我试图通过tc命令在我使用mininet创建的网络交换机部分的接口(端口)1上指定数据包丢失: sudo tc qdisc change dev s1-eth1 root netem loss 0.1% 但是gettring错误: 的 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

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

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

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

要设置数据包丢失,请在创建链接时使用mininet参数在loss脚本本身中设置它。有关示例,请参阅this