in reply to Re: Need help with (un)pack templates
in thread Need help with (un)pack templates

Hey gmargo, that's exactly what I was looking for. Is there a site you got that from? I'd also like to be able to figure out how to decode other protocols as well.

  • Comment on Re^2: Need help with (un)pack templates

Replies are listed 'Best First'.
Re^3: Need help with (un)pack templates
by gmargo (Hermit) on Dec 20, 2009 at 14:08 UTC

    I typed it in from the front inside cover of my Stevens book (TCP/IP Illustrated Volume 1).

    Wikipedia has it too: http://en.wikipedia.org/wiki/IPv4, but the real gospel is RFC791: http://www.ietf.org/rfc/rfc791.txt.

    Update: Other protocol standards you might like:
    RFC 768 User Datagram Protocol
    RFC 792 Internet Control Message Protocol
    RFC 793 Transmission Control Protocol

      I have that same book and just see the IP header format. How do you know what letters to use in the (un)pack template just by looking at the header format?

        It's pretty well spelled out in the pack documentation. C for unsigned char (byte), n for unsigned 16-bit short in network order, N for 32-bit long in network order, a for "arbitrary binary data".

        Don't be confused by the 32-bit CCCC's, since an IP address is 4 8-bit numbers, not a 32-bit number.