- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在调用构造函数的以下 python 程序中收到 TypeError。如果我删除延迟参数,我会得到与“bw”相同的错误。我无法弄清楚错误。请帮忙。
我正在尝试使用 python 创建网络拓扑。
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import irange,dumpNodeConnections
from mininet.log import setLogLevel
class CustomTopo(Topo):
def __init__(self, linkopts1, linkopts2, linkopts3, fanout=2, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
# Add your logic here ...
switch=self.addSwitch('c1')
self.linkopts1=linkopts1
self.linkopts2=linkopts2
self.linkopts3=linkopts3
self.fanout=fanout
n=0
for i in irange(1,fanout):
s=self.addSwitch('a%s' % i)
self.addLink(switch,s,**linkopts1)
if i==1:
n=0
else:
n=1
for j in irange(1,fanout):
if n==0:
sw=self.addSwitch('e%s' % j) #To generate labels e1, e2, e3 and e4:
else: #if n=0, edge switches e1 and e2 are added to a1
sw=self.addSwitch('e%s' % (j+2)) #if n=1, edge switched e3 and e4 are added to a2
self.addLink(s,sw,**linkopts2)
for k in irange(1,fanout):
if ((j==1)&(n==0)):
host=self.addHost('h%s' % k) #For edge switch e1, j=1,n=0. End-hosts are h1 and h2.
elif ((j==2)&(n==0)):
host=self.addHost('h%s' % (k+2)) #For edge switch e2, j=2,n=0. End-hosts are h3 and h4.
elif ((j==1)&(n==1)):
host=self.addHost('h%s' % (k+4)) #For edge switch e3, j=1,n=1. End-hosts are h5 and h6.
elif ((j==2)&(n==1)):
host=self.addHost('h%s' % (k+6)) #For edge switch e4, j=2,n=1. End-hosts are h7 and h8.
self.addLink(sw,host,**linkopts3)
def treeTest():
linkopts1=dict(bw=10, delay='5ms')
linkopts2=dict(bw=10, delay='5ms')
linkopts3=dict(bw=10, delay='5ms')
topo=CustomTopo(linkopts1,linkopts2,linkopts3,fanout=2)
net=Mininet(topo)
net.start()
print "Dumping node connections"
dumpNodeConnections(net.hosts)
print "Testing network connectivity"
net.pingAll()
net.stop()
if __name__=='__main__':
setLogLevel('info')
treeTest()
topos = { 'custom': ( lambda: CustomTopo() ) }
我得到的错误跟踪是:
Traceback (most recent call last):
File "CustomTopo.py", line 70, in <module>
treeTest()
File "CustomTopo.py", line 60, in treeTest
net=Mininet(topo)
File "/usr/local/lib/python2.7/dist-packages/mininet-2.1.0-py2.7.egg/mininet/net.py", line 164, in __init__
self.build()
File "/usr/local/lib/python2.7/dist-packages/mininet-2.1.0-py2.7.egg/mininet/net.py", line 357, in build
self.buildFromTopo( self.topo )
File "/usr/local/lib/python2.7/dist-packages/mininet-2.1.0-py2.7.egg/mininet/net.py", line 344, in buildFromTopo
self.addLink( src, dst, srcPort, dstPort, **params )
File "/usr/local/lib/python2.7/dist-packages/mininet-2.1.0-py2.7.egg/mininet/net.py", line 287, in addLink
return cls( node1, node2, **defaults )
TypeError: __init__() got an unexpected keyword argument 'delay'
最佳答案
记得将链接类型设置为tc。
在您的脚本中指定它,如下所示:
net = Mininet(topo=topo, link=TCLink)
请记住在您的 python 脚本中导入 TCLink:
from mininet.link import TCLink
相反,如果您想从命令提示符调用 mininet,则按如下方式设置 --link 参数:
sudo mn --custom custom.py --topo customtopo --link tc
关于python - 类型错误 :__init__() got an unexpected keyword argument 'delay' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24130398/
asyncio.sleep() 的阻塞表亲,time.sleep() , 不能保证它会在请求的时间内休眠。 The actual suspension time may be less than th
在 C# 中,我有以下两个简单示例: [Test] public void TestWait() { var t = Task.Factory.StartNew(() => {
这是一个 linqpad 示例,展示了在短暂延迟后异步执行方法的两种方法。这两个例子似乎做了完全相同的事情。我通常会实现第一个版本(使用 Task.Delay.ContinueWith),但我也看到使
这是一个 linqpad 示例,展示了在短暂延迟后异步执行方法的两种方法。这两个例子似乎做了完全相同的事情。我通常会实现第一个版本(使用 Task.Delay.ContinueWith),但我也看到使
使用 jQuery,我逐渐将“go”类添加到 div div { tranform:translate(20px,20px); opacity:0;
期待: 当 audioplayer.play(atTime: 1) 被调用时,定时器重置为 0,音频播放器在第 1 秒播放 现实: 我试过 delay = 0.000000001, 1, 100000
我一直在阅读 .Net 4.5 中引入的 async/await 语法并对其有所了解。 我找到了简单的示例,其中 Task.Yield 是要走的路,而不是 Application.DoEvents。我
我需要在一个延迟很大的系统中调整PI(D)的增益。这是一个常见的温度 Controller ,但温度探头距离加热器较远。一些进一步的信息: 加热器响应上的任何变化,探头的响应都会延迟约10秒 温度以1
代码很短,但是很经典,单位是秒,就是未测试过服务器资源消耗怎么样: <% Function Delay(s)
为什么这会立即清空文本(忽略延迟)? $('#error_box_text').html('error text').delay(5000).html('') # jQuery 1.4 最佳答案 de
我有一个 $image,我 .fadeIn 和 .fadeOut,然后 .remove .fadeOut 完成。这是我的代码: $image .fadeIn() .fadeOut(func
我希望用户将鼠标悬停在对撞机(只是一个透明矩形)上超过 2 或 3 秒时能够看到描述菜单。我目前正在使用 javaFX 扩展。 我将程序设置为每当我将鼠标悬停在对撞机上时,它都会播放声音效果,但我希望
在我创建的几个 .HTA 脚本中,我需要 VBScript WScript.Sleep 命令,它只是等待几毫秒而不使用 CPU。当我浏览网页时,似乎我不是唯一一个在寻找这个的人: https://ww
我在 javaFX 中创建了一些节点。我需要为每个节点设置动画,以便使用 TranslateTransition 在 Pane 中的某个点到某个点之间进行转换。但我需要使每个节点使用不同的起点独立移动
我需要在用户开始触摸屏幕、移动手指然后结束触摸时执行一些操作。触摸开始工作正常,也可以移动,但触摸结束运行有 0.5-1 秒的延迟。下面有一段代码: -(id) init { if (s
我正在寻找有关 jQuery 的 .delay 函数的帮助。我的网站上有一个弹出表单,我想在 2-3 分钟内随机弹出该表单。我了解如何使用 Math.random(),但我不了解如何使用它生成 120
我无法获取一些 javascript 和 Jquery 来延迟适当的时间。我想更改一些文本,请等待 5 秒钟,然后弹出警报。 代码如下: $('#result').html("Record has p
我有以下 JavaScript 片段: $("#dashboard").addClass("standby").delay(3000).removeClass("standby"); $(".acti
我有以下 JavaScript 片段: $("#dashboard").addClass("standby").delay(3000).removeClass("standby"); $(".acti
我已经编写了一个简单的 jQuery 淡入淡出插件,但我无法让延迟正常工作。它将在第一个项目上起作用,但之后它会被忽略 jQuery (function ($) { $.fn.setupQuo
我是一名优秀的程序员,十分优秀!