I have a Pox-based SDN application that listens for PacketIns to the controller. I would like to check if a packet to the controller is ICMP. The Pox docs provide an example to check if a PacketIn is ARP as shown by the following code.
def _handle_PacketIn (self, event):
packet = event.parsed
if packet.type == packet.ARP_TYPE: # packet.ARP_TYPE is const equal to 2054
# do something neat with the packet
pass
But I cannot use the same logic to check for ICMP messages:
def _handle_PacketIn (self, event):
packet = event.parsed
if packet.type == packet.ICMP_TYPE:
# do something neat with the packet
pass
The latter code returns an error:
*** AttributeError: 'ethernet' object has no attribute 'ICMP_TYPE'
There is no packet.ICMP_TYPE, which can be seen by checking dir(packet).
The packet.type is equal to a number which represents a protocol, and somewhere in the pox code these numbers are probably neatly laid out besides the protocols they represent - I have no idea where this may be. For example, I can see that the packet.type of my PacketIn is 2048, but I don't know which protocol that represents or how to find out.
tp = packet.icmp() if packet.type == tp.type: # do something
– Poojan