1

I’m trying to write code that checks if a node is up by pinging the node in ryu controller. If the node responds, then the node is marked as being up. I already have the code for the controller so I want to incorporate this ping code into the controller code.

So essentially I’m trying to find out how to ping a node using python program in ryu controller.

I’ve gone through various documentation but I can’t seem to find a direct way to do this. Any help would be appreciated.

Elo
  • 11
  • 2

1 Answers1

0

Create a packet and forward it through the port connected to the node. By node I assume you mean a host and I assume you know:

  • which port ((switches.Port object), or (dpid, port_no)) the host is connected to.
  • the mac address of host.
  • the ip address of host.
port : switches.Port = port # (known)
dpid = port.dpid
port_no = port.port_no
from ryu.lib.packet import packet, ether_types, ethernet, icmp
pkt = packet.Packet()
pkt.add_protocol(ethernet.ethernet(ethertype=ether_types.ETH_TYPE_IP, src=<src_mac>, dst=<dst_mac>))
pkt.add_protocol(icmp.icmp(...))
pkt.serialize()
send_packet_out(datapath, port_no, pkt.data)
Himanshu Tanwar
  • 198
  • 1
  • 11