Skip to main content
 首页 » 编程设计

python之在 mininet 中动态移动主机

2024年10月24日7tuyile006

如何在mininet中动态移动主机? 任何 CLI 命令或脚本? 我在 https://github.com/mininet/mininet/blob/master/examples/mobility.py 尝试了代码 但我得到这个错误:

anusha@anusha-Lenovo-IdeaPad-Z500:~$ sudo python ~/mininet/custom/mobility.py  
* Simple mobility test 
* Starting network: 
s1: h1(1) s2(2)  
s2: h2(1) s1(2) s3(3)  
s3: h3(1) s2(2)  
* Testing network 
*** Ping: testing ping reachability 
h1 -> h2 h3  
h2 -> h1 h3  
h3 -> h1 h2  
*** Results: 0% dropped (6/6 received) 
* Identifying switch interface for h1 
* Moving h1 from s1 to s2 port 13 
Traceback (most recent call last): 
  File "/home/anusha/mininet/custom/mobility.py", line 128, in <module> 
    mobilityTest() 
  File "/home/anusha/mininet/custom/mobility.py", line 115, in mobilityTest 
    hintf, sintf = moveHost( h1, old, new, newPort=port ) 
  File "/home/anusha/mininet/custom/mobility.py", line 96, in moveHost 
    oldSwitch.moveIntf( sintf, newSwitch, port=newPort ) 
  File "/home/anusha/mininet/custom/mobility.py", line 77, in moveIntf 
    switch.attach( intf ) 
  File "/home/anusha/mininet/custom/mobility.py", line 45, in attach 
    if self.isOldOVS(): 
AttributeError: 'MobilitySwitch' object has no attribute 'isOldOVS' 

谢谢!

请您参考如下方法:

经过大量研究,我发现在 mininet 中没有直接的命令或函数或脚本可以促进主机在网络中的移动。

相反,您可以做的是模拟宿主的运动! mininet> link h1 s1 down ----> does only logical link down mininet> py net.addLink(s2,net.get(h1))

一切顺利:)