And yet another way. You can capture an incoming connection via tcpdump and write it to file. Then use can use Net::TcpDumpLog to read the tcpdumplog. It'll return some raw packet data in Ethernet/IP/TCP form usually. I took the two examples provided by Brenden Gregg and put them together. If you don't have a tcpdumplog, then use the one provided in the source.

You will need to put this script and the tcpdumplog in the same directory for it to work.

#!/usr/bin/perl # # example01.pl - Example of Net::TcpDumpLog. Prints out frame arrival +times. # # 11-Oct-2003 Brendan Gregg Created this use Net::TcpDumpLog; $log = Net::TcpDumpLog->new(32); $log->read("tcpdumplog"); $count = $log->maxindex + 1; @Indexes = $log->indexes; print "Log version : ",$log->version,"\n"; print "Linktype : ",$log->linktype,"\n"; print "Packet count: $count\n\n"; printf "%5s %25s %7s %5s %s\n","Frame","Arrival time","+ MSecs","Dr +ops", "Length"; foreach $index (@Indexes) { ($length_orig,$length_incl,$drops,$secs,$msecs) = $log->header($in +dex); $data = $log->data($index); $time = localtime($secs); $msecs = $msecs / 1000000; $length = length($data); printf "%5d %25s %7.5f %5d %d\n",$index,$time,$msecs,$drops,$le +ngth; } # example02.pl - Example of Net::TcpDumpLog. Prints out ethernet heade +rs. # 11-Oct-2003 Brendan Gregg Created this $log->read("tcpdumplog"); @Indexes = $log->indexes; printf "%5s %12s %12s %4s %s\n","Frame","Source","Dest","Type"," +Length"; foreach $index (@Indexes) { $data = $log->data($index); ### Process Ethernet header ($ether_dest,$ether_src,$ether_type,$ether_data) = unpack('H12H12H4a*',$data); $length = length($ether_data); printf "%5d %12s -> %12s %4s %s\n",$index,$ether_src,$ether_des +t, $ether_type,$length; }

In reply to Re: explore tcp/ip stack by Khen1950fx
in thread explore tcp/ip stack by sveni

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.