in reply to explore tcp/ip stack

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; }