(Sidenote: Since this message is explicitly and entirely about POX, you might 
have considered posting it on the pox-dev mailing list or the noxrepo POX 
forum.)

On Jun 27, 2013, at 2:42 PM, Kavit Shah wrote:

> ...
> import pox.lib.packet as packet
> ....

Just a note that that's not the POX convention.

> if packet.dst.is_multicast:

This doesn't seem to make sense with the above import.

>   ip_packet = packet.payload
>   src_ip = ip_packet.srcip
> 
>   if src.ip == "XXXXXX":
>     .....
>     .....
> 
> packet.dst ---> works fine no errors, I think it gives me the MAC address
> ip_packet.srcip --> error: arp packet has no attributes called srcip.
>                             I am expecting it to give me the src ip.

Well, it's not an IP packet, so you're running into trouble.  Apparently it's 
an ARP packet.  If it were an IP packet, this would work fine.

> I just want to extract the IP address from this packet.  I am trying to get 
> it by extracting individual header from each layer as mentioned in POX 
> tutorial.

Check that the packet is IP before attempting to access attributes that only 
make sense if it is.  There are lots of ways to do this.  The easiest is 
probably:

ip_packet = packet.find(pkt.ipv4)
if ip_packet is not None:
  src_ip = ip_packet.srcip
  ...

(The wiki has an example almost exactly like this.)

forwarding.l3_learning show a different technique -- using isinstance() to 
check the type of packet.payload.  This method, however, requires a bit of 
extra work if you want it to work with VLAN tags, since in the case of a tag, 
packet.payload is the VLAN tag and packet.payload.payload might be IP.

-- Murphy
_______________________________________________
openflow-discuss mailing list
openflow-discuss@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/openflow-discuss

Reply via email to