ping 172.16.1.116 Pinging host 172.16.1.116 : 172.16.1.116 ping: No reply. Time Out !! ping: No reply. Time Out !! ping: No reply. Time Out !! ping: No reply. Time Out !! Host 172.16.1.116 replied to 0 of the 4 pings ready 12:26:32 |
telnet 172.16.1.116 1830 Trying... Connected to 172.16.1.116. Escape character is '^]'. |
telnet 172.16.1.116 1830 Trying... Connected to 172.16.1.116. Escape character is '^]'. telnet> quit |
On target system (Linux) [ndav@phx-lab-lnx64 ~]$ perl tcplisten.pl -p 1830 -m 'Connection has been accepted' perl tcplisten.pl -port 1830 -message 'Connection has been accepted' On OpenVOS client stp -ttp ascii ready 12:16:34 telnet 164.152.77.155 1830 Trying... Connected to 164.152.77.155. Escape character is '^]'. Connection has been accepted Escape character is '^]'.Connection closed by forei. Ready 12:16:40 |
On OpenVOS target system perl tcplisten.pl -p 1830 -m 'made it to m16' perl tcplisten.pl -port 1830 -message 'made it to m16' On Linux client [ndav@phx-lab-lnx64 ~]$ telnet 164.152.77.128 1830 Trying 164.152.77.128... Connected to rigel.az.stratus.com (164.152.77.128). Escape character is '^]'. made it to m16 Connection closed by foreign host. [ndav@phx-lab-lnx64 ~]$ |
telnet 172.16.1.116 1830 Trying... telnet: Unable to connect to remote host: The connection was refused. ready 12:31:28 |
telnet 172.16.1.116 1830 Trying... telnet: Unable to connect to remote host: Network trying to be reached is unreac +hable. ready 12:54:34 |
telnet 172.16.1.116 1830 Trying... telnet: Unable to connect to remote host: No route to host. ready 12:55:44 |
telnet 172.16.1.116 1830 Trying... telnet: Unable to connect to remote host: The operation timed out. |
Message
|
Meaning
|
---|---|
Connected (with banner)
|
Can reach host and application
|
Connected (no banner)
|
Can reach host and application – probably
|
Refused
|
Can reach host but not application – probably
|
Unreachable
|
Cannot reach host
|
Timeout
|
Cannot reach host – probably
|
perl tuc.pl -i 172.16.1.116 -p 1830 Reply received on UDP socket from 164.152.77.128 message: echoed by udpecho.pl: +sent by tuc.pl at Mon Aug 30 13:31:34 2010 ready 13:31:34 |
perl tuc.pl -i 172.16.1.116 -p 1830 ICMP Destination port unreachable message received from 172.16.1.116 ready 11:40:12 |
perl tuc.pl -i 172.16.1.116 -p 1830 ICMP Destination network unreachable message received from 164.152.77.171 ready 11:43:50 perl tuc.pl -i 172.16.1.116 -p 1830 ICMP Destination host unreachable message received from 164.152.77.171 ready 11:44:54 |
perl tuc.pl -i 172.16.1.116 -p 1830 ICMP Time exceeded , TTL expired in transit message received from 164.152.77.34 ready 11:45:39 |
perl tuc.pl -i 172.16.1.116 -p 1830 No response was received from 172.16.1.116 ready 16:43:26 |
perl tuc.pl -i 172.16.1.117 -p 1830 -t 10 No response was received from 172.16.1.117 ready 12:06:26 perl tuc.pl -i 172.16.1.117 -p 1830 -t 1 No response was received from 172.16.1.117 ready 12:06:32 |
Message
|
Meaning
|
---|---|
Application banner message
|
Can reach host and application
|
ICMP network/host message
|
Cannot reach host
|
ICMP port message from host
|
Can reach host but not application
|
No response, application sends banner message
|
Cannot reach host
|
No response, application does not send banner message
|
May or may not be able to reach host
|
tcplisten.pl
# tcplisten.pl begins here
# # Version 1.00 10-07-30 # This script has been tested on # Open VOS 17.0.2ah running Perl v5.8.0 built for i686-vos # Microsoft Windows XP Service Pack 3 running # ActiveState Perl v5.10.0 built for MSWin32-x86-multi-thread # Red Hat Linux 4AS-5.5 running # Perl v5.8.5 built for x86_64-linux-thread-multi # # use IO::Socket; use Getopt::Long; use Sys::Hostname; use strict; my ($result); my ($localPort, $message, $peerAddr); my ($newSock, $data); $result = GetOptions (‘port=s’ => $localPort, ‘message=s’ => $message); if (($result != 1) || !(defined($localPort))) { print “nnUsage:n”; print “tperl tcplisten.pl -port PORT-NUMBER [-message MESSAGE]nn”; exit; } if (!defined ($message)) { print “No message specified – creating messagen”; $message = “Connection accepted by tcplisten running on ” . hostname; } print “perl tcplisten.pl -port $localPort -message ‘” . $message . “‘n”; my $sock = IO::Socket::INET->new( Proto => ‘tcp’, LocalPort => $localPort, LocalAddr => ‘0.0.0.0’, Listen => 1, ) or die “Could not create socket for port $localPort: $!n”; while (1) { my $newSock = $sock->accept (); print “Connected accepted from ” . $newSock->peerhost . ” at ” . localtime () . “n”; print $newSock $message . “n”; $newSock -> shutdown(2); $sock->read($data, 1024); # wait to get a close indication */ $newSock->close(); } # # tcplisten.pl ends here |
tuc.pl
# tuc.pl begins here
# # Version 1.00 10-07-30 # This script has been tested on # Open VOS 17.0.2ah running Perl v5.8.0 built for i686-vos # Microsoft Windows XP Service Pack 3 running # ActiveState Perl v5.10.0 built for MSWin32-x86-multi-thread # Red Hat Linux 4AS-5.5 running # Perl v5.8.5 built for x86_64-linux-thread-multi # # use IO::Socket; use IO::Select; use Getopt::Long; use strict; my ($result); my ($destIP, $destPort, $timeout, $result, $message, $flags); my ($ready, $socket); my ($x, $c, $icmpAlready); $result = GetOptions (‘ip=s’ => $destIP, ‘port=s’ => $destPort, ‘timeout=s’ => $timeout); if (($result != 1) || !(defined($destIP) && defined($destPort))) { print “nnUsage:n”; print “tperl tuc.pl -ip DESTINATION-IP-ADDRESS ” . “-port DESTINATION-PORT-NUMBERnn”; exit; } if (!defined($timeout)) { $timeout = 5; } elsif ($timeout > 15) { print “OK, but ” . $timeout . ” seems unreasonably long.n”; } $message = “sent by tuc.pl at ” . localtime (); my $sock = IO::Socket::INET->new( Proto => ‘udp’, PeerPort => $destPort, PeerAddr => $destIP ) or die “Could not create socket for destination $destIP: $!n”; my $isock = IO::Socket::INET->new( Proto => ‘icmp’); $sock->send($message) or die “Send error: $!n”; $message = “”; my $read_set = new IO::Select(); $read_set->add($sock); $read_set->add($isock); ($ready) = IO::Select->select($read_set, undef, undef, $timeout); $icmpAlready = 0; $c = 0; foreach $socket (@$ready) { $c = $c + 1; if ($socket == $sock) { $x = “Reply received on UDP socket from “; $socket->recv($message, 100, $flags); if ($icmpAlready == 0) { if (length ($message) > 0) { print $x . $socket->peerhost . ” message: ” . $message . “n”; } else { print $x . $socket->peerhost . “n”; } } } else # icmp message received { $icmpAlready = 1; $socket->recv($message, 100, $flags); if (length ($message) > 98) { print “Unexpectedly long (” . length ($message) . “) ICMP message from ” . $socket->peerhost . ” message: ” . $message . “n”; } elsif (length ($message) < 52) { print “Unexpecedly short (” . length ($message) . “) ICMP message from ” . $socket->peerhost . “n”; } else # process icmp message { my $type = ord (substr ($message, 20, 1)); my $code = ord (substr ($message, 21, 1)); my $port = ord (substr ($message, 50, 1)) * 256 + ord (substr ($message, 51, 1)); if ($port != $destPort) { print “Unexpected ICMP message received from ” . $socket->peerhost . ” message : ” . substr ($message, 20) . “n”; } else # icmp message is good { if ($type == 3) { if ($code == 0) { print “ICMP Destination network ” . “unreachable message received from ” . $socket->peerhost . “n”; } elsif ($code == 1) { print “ICMP Destination host ” . “unreachable message received from ” . $socket->peerhost . “n”; } elsif ($code == 3) { print “ICMP Destination port ” . “unreachable message received from ” . $socket->peerhost . “n”; } elsif ($code == 6) { print “ICMP Destination network ” . “unknown message received from ” . $socket->peerhost . “n”; } elsif ($code == 7) { print “ICMP Destination host unknown ” . “message received from ” . $socket->peerhost . “n”; } elsif ($code == 8) { print “ICMP Source host isolated ” . “message received from ” . $socket->peerhost . “n”; } elsif ($code == 9) { print “ICMP Network administratively ” . “prohibited message received from ” . $socket->peerhost . “n”; } elsif ($code == 10) { print “ICMP Host administratively ” . “prohibited message received from ” . $socket->peerhost . “n”; } elsif ($code == 11) { print “ICMP Network unreachable for ” . “TOS message received from ” . $socket->peerhost . “n”; } elsif ($code == 12) { print “ICMP Host unreachable for ” . “TOS message received from ” . $socket->peerhost . “n”; } elsif ($code == 13) { print “ICMP Communication ” . “administratively prohibited message received from ” . $socket->peerhost . “n”; } else { print “Unexpected ICMP message received type = ” . $type . “, code = ” . $code . ” from ” . $socket->peerhost . “n”; } } # if ($type == 3) elsif (($type == 11) & ($code == 0)) { print “ICMP Time exceeded , TTL expired in transit ” . “message received from ” . $socket->peerhost . “n”; } else { print “Unexpected ICMP message received type = ” . $type . “, code = ” . $code . ” from ” . $socket->peerhost . “n”; } } # else # icmp message is good } # else # process icmp message } # else #icmp message received } # foreach $socket (@$ready) if ($c == 0) { print “No response was received from ” . $sock->peerhost . “n”; } # # tuc.pl ends here |
udpecho.pl
# udpecho.pl begins here
# # Version 1.00 10-07-30 # This script has been tested on # Open VOS 17.0.2ah running Perl v5.8.0 built for i686-vos # Microsoft Windows XP Service Pack 3 running # ActiveState Perl v5.10.0 built for MSWin32-x86-multi-thread # Red Hat Linux 4AS-5.5 running # Perl v5.8.5 built for x86_64-linux-thread-multi # # use IO::Socket; use IO::Select; use Getopt::Long; use strict; my ($result); my ($localPort, $debug, $result, $message, $flags); my ($ready, $socket); my ($x, $c); $result = GetOptions (‘port=s’ => $localPort, ‘debug’ => $debug); if (($result != 1) || !(defined($localPort))) { print “nnUsage:n”; print “tperl udpecho.pl -port LOCAL-PORT-NUMBER [-debug]nn”; exit; } if (defined($debug)) { print “local port number is ” . $localPort . “n”; } my $sock = IO::Socket::INET->new( Proto => ‘udp’, LocalPort => $localPort ) or die “Could not create socket $!n”; my $read_set = new IO::Select(); $read_set->add($sock); $message = “”; while (1) { ($ready) = IO::Select->select($read_set, undef, undef, 300); foreach $socket (@$ready) { $socket->recv($message, 100, $flags); if (defined ($debug)) { print “Message from ” . $socket->peerhost . ” message: ” . $message . “n”; } $socket->send(“echoed by udpecho.pl: ” . $message) or die “Send error: $! +n”; } } # # udpecho.pl ends here |