Dear Monks,
I've recently started programming perl, I have an interest in pkt encoding and have stumbled upon errors with the following script.

use strict; use Net::TcpDumpLog; use NetPacket::IP qw(:strip); use NetPacket::TCP qw(:strip); my $log = Net::TcpDumpLog->new(); $log->read("tcp01.dump"); my @Indexes = $log->indexes; my $index; my ($length_orig,$length_incl,$drops,$secs,$msecs); my $data; foreach $index (@Indexes) { ($length_orig,$length_incl,$drops,$secs,$msecs) = $log->header($in +dex); $data = $log->data($index); my ($ether_dest,$ether_src,$ether_type,$ether_data) = unpack('H12H +12H4a*',$data); my $ip_obj = NetPacket::IP->decode($ether_data); my $tcp_obj = NetPacket::TCP->decode( $ip_obj->{data} ); print("$ip_obj->{src_ip}:$ip_obj->{dest_ip}\n"); }

output:

250.84.80.45:76.34.213.120 250.19.80.45:76.34.213.120 249.4.213.120:252.2.80.45 249.3.213.120:252.2.80.45 249.2.213.120:252.2.80.45 223.68.213.120:252.2.80.45

tcpdump snippet:

IP 80.45.76.34.22 > 213.120.252.2.49191: IP 80.45.76.34.22 > 213.120.252.2.49191: IP 213.120.252.2.49191 > 80.45.76.34.22: IP 213.120.252.2.49191 > 80.45.76.34.22: IP 213.120.252.2.49191 > 80.45.76.34.22:

As you can see the addresses are messed up.

kernel 2.6.22-14-386
tcpdump 3.9.7-1
distro ubuntu 7.10

Is this compatibility issues? or can errors be overcome with correct code syntax?

Regards,

k_grdn


In reply to NetPacket IP Problems by k_grdn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.