I want to ping a host from my POX control program and check for response. I want to do this to test if the host really exists. How will I ping a host from the control program?
The quick solution is to make a ping using the python language and the os capabilities.Assuming you started the mininet emulator with
sudo mn --controller=remote
First give the switch an ip in order for the ping to find a route to go to the host. Open a new terminal to ssh to your mininet vm
ssh -X mininet@192.168.56.101
change 192.168.56.101 if your mininet vm has a different ip. In this new terminal type
ifconfig s1
you should get something like
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)
which indicates that your switch does not have an ip. To give an ip to the switch we have to
sudo ifconfig s1 10.0.1.1
and then ping a host connected to this switch (ie. 10.0.0.1) from your POX program.
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!'