使用 POX 控制器反向路径转发



我想从我的 POX 控制程序 ping 主机并检查响应。我想这样做来测试主机是否真的存在。如何从控制程序 ping 主机?

快速的解决方案是使用 python 语言和操作系统功能进行 ping。假设您启动了迷你网模拟器

sudo mn --controller=remote

首先给交换机一个 ip,以便 ping 找到转到主机的路由。打开一个新终端以 ssh 连接到您的迷你网虚拟机

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

然后从 POX 程序 ping 连接到此交换机(即 10.0.0.1)的主机。

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!'

最新更新