On Jul 9, 2012, at 1:42 PM, Weiyun Mao wrote:

> Logically, when a packet comes into the controller, first, the ethernet 
> header needs to be parsed,
> if it can’t be deliverd in L2, then parse the IP header, and then, 
> TCP/UDP/ICMP header. Right?

Actually, it will get parsed as deeply as it can figure out how to and create a 
linked list of parsed packet objects.

In a typical example, you'll have ethernet holding IP holding TCP:

ether_packet = packet
ip_packet = packet.next
tcp_packet = packet.next.next

You might be better searching for the packet type you want, since there may be 
unexpected encapsulations.

ip_packet = packet.find("ipv4")


Hope that helps clear things up.

As a sidenote, it looks like you're using NOX-Classic, which we're not really 
maintaining now.  If you're writing controllers in Python, you might look at 
POX (which, among other things, has an improved version of the packet library).

-- Murphy

Reply via email to