[英]How to set bandwidth on Mininet custom topology?
I want to set bandwidth on Mininet custom topology.我想在 Mininet 自定义拓扑上设置带宽。
The python code is:蟒蛇代码是:
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
class MyTopo( Topo ):
"Simple topology example."
def __init__( self, **opts):
"Create custom topo."
# Initialize topology
Topo.__init__( self, **opts )
# Add hosts and switches
h1 = self.addHost('h1')
h2 = self.addHost( 'h2' )
s3 = self.addSwitch( 's3' )
s1 = self.addSwitch( 's1' )
s2 = self.addSwitch( 's2' )
# Add links
self.addLink(h1,s1,bw=10)
self.addLink(h2,s3,bw=20)
self.addLink(s3,s2,bw=10)
self.addLink(s1,s3,bw=10)
topos = { 'mytopo': ( lambda: MyTopo() ) }
But it has error但它有错误
------------------------------------------------------------------
Caught exception. Cleaning up...
TypeError: __init__() got an unexpected keyword argument 'bw'
------------------------------------------------------------------
What can I do?我能做什么? How to set bandwidth on Mininet custom topology?
如何在 Mininet 自定义拓扑上设置带宽?
You should add cls=TCLink
on the self.addLink(h1,s1,bw=10)
您应该在
self.addLink(h1,s1,bw=10)
上添加cls=TCLink
so the code will be self.addLink(h1,s1,cls=TCLink,bw=10)
所以代码将是
self.addLink(h1,s1,cls=TCLink,bw=10)
Add to the other addLink
to make it work添加到另一个
addLink
以使其工作
启动 Mininet 时,添加一个额外的参数--link=tc
You should use --link
argument.您应该使用
--link
参数。 For example: sudo mn --topo tree,depth=2,fanout=5 --controller=remote,ip=10.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13, --link tc,bw=1,delay=10ms
例如:
sudo mn --topo tree,depth=2,fanout=5 --controller=remote,ip=10.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13, --link tc,bw=1,delay=10ms
I'll update with an example soon.我很快会更新一个例子。
State the bandwidth and the delays in the python file, but while running the file, add在 python 文件中说明带宽和延迟,但在运行文件时,添加
--link=tc --link=tc
in the command line and it will work fine.在命令行中,它会正常工作。
If you are using CLI command mn
to run Mininet, add --link=tc
.如果您使用 CLI 命令
mn
运行 Mininet,请添加--link=tc
。
If you are using a run()
function in the python script to start Mininet, use如果您在 python 脚本中使用
run()
函数来启动 Mininet,请使用
net = Mininet(topo = MyTopo(), link = TCLink)
net.start()
to start with Mininet with TC links for bandwidth specification to work.从带有 TC 链接的 Mininet 开始,用于带宽规范工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.