in reply to Re: IP Header
in thread IP Header

Just to throw a wrench in the works ;-) The binary data is packed in Network bit order, won't pulling it out using C2 not respect that? So i tried this:
my ($data) = unpack "N", $foo; my ($ver, $hlen) = (vec($data,0,4), vec($data,1,4)); my $tos = vec($data, 1, 8); my $len = vec($data, 1, 16);
Which returned completely un-expected results. Is it not possible to use vec on data pulled using "N"? (yes, i know it can be more compact, split up for readability.)

Replies are listed 'Best First'.
Re^3: IP Header
by Aristotle (Chancellor) on Nov 03, 2002 at 00:29 UTC
    You misunderstand the purpose of that format. The network ordering is important for multibyte fields. The order of bytes inside such a field may differ from what the host platform expects. The order of fields however does not change, regardless of platform. Two byte-sized fields are always extracted using C2; a single 16-bit field is extracted using n.

    Makeshifts last the longest.