我想从我的POX控制程序中选择一个主机,并检查是否有反应。我想这样做是为了测试主机是否真的存在。我将如何从控制程序中选择主机?
发布于 2016-06-06 17:09:07
快速的解决方案是使用python语言进行ping,并使用os capabilities.Assuming启动迷你仿真器。
sudo mn --controller=remote首先给交换机一个ip,这样ping才能找到到主机的路由。打开一个新的终端到ssh到您的小型vm。
ssh -X mininet@192.168.56.101如果您的小型vm有不同的ip,则更改192.168.56.101。在这种新的终端类型
ifconfig s1你应该得到这样的
Link encap:Ethernet HWaddr fa:64:44:9a:f9:4f UP BROADCAST RUNNING MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
这表示您的交换机没有ip。为了给交换机一个ip,我们必须
sudo ifconfig s1 10.0.1.1然后平一个连接到这个开关的主机(即。10.0.0.1)来自你的POX计划。
import os
host_ip = "10.0.0.1" #the host ip you want to ping from controller
response = os.system("ping -c 1 " + host_ip)
#check the response...
if response == 0:
print host_ip, 'is up!'
else:
print host_ip, 'is down!'https://stackoverflow.com/questions/37650571
复制相似问题