in reply to How read ICMP UDP port unreachable?

I've played around some with NetPacket::ICMP and such. What I think you'd need to do, to test that particular UDP port, would be to listen locally on the ICMP port (which is a protocol like UDP and TCP), and read any incoming packets that occur when you connect via UDP.

Anyway, this is as far as I got, it doesn't seem to get a ICMP packet type that makes any sense, though, anyone have an idea why?

#!/usr/bin/perl -w use Data::Dumper; use NetPacket::ICMP; use IO::Socket; my $icmps = IO::Socket::INET->new("LocalHost" => "192.168.1.2", "Proto" => "icmp") or die "Cant icmp listen ($!)"; print "boo\n"; my $udptest = IO::Socket::INET->new("PeerAddr" => "192.168.1.20", "PeerPort" => "2222", "Proto" => "udp", "Timeout" => 20); $udptest->print("test"); my $y = $icmps->recv($buffer, 1024, 0); if($y) { ($xport, $iaddr) = unpack_sockaddr_in($y); $remotehost = inet_ntoa($iaddr); print("peerhost $remotehost:$xport\n"); } my $dec = NetPacket::ICMP->decode($buffer); print Dumper($dec);
Which outputs:
boo peerhost 192.168.1.20:0 $VAR1 = bless( { '_parent' => undef, 'data' => 'c @À¨À¨E Àl@@öùÀ¨À¨® qtest', 'cksum' => 60, 'type' => 69, '_frame' => 'EÀ<c @À¨À¨E Àl@@öùÀ¨À¨® qtest', 'code' => 192 }, 'NetPacket::ICMP' );
Where 69 is not any of the possible packet types listed in NetPacket::ICMP.. So, no clue whats going haywire..

C.