ping 172.16.1.116Pinging host 172.16.1.116 : 172.16.1.116ping: 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 pingsready 12:26:32 |
telnet 172.16.1.116 1830Trying...Connected to 172.16.1.116.Escape character is '^]'. |
telnet 172.16.1.116 1830Trying...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 asciiready 12:16:34telnet 164.152.77.155 1830Trying...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 1830Trying 164.152.77.128...Connected to rigel.az.stratus.com (164.152.77.128).Escape character is '^]'.made it to m16Connection closed by foreign host.[ndav@phx-lab-lnx64 ~]$ |
telnet 172.16.1.116 1830Trying...telnet: Unable to connect to remote host: The connection was refused.ready 12:31:28 |
telnet 172.16.1.116 1830Trying...telnet: Unable to connect to remote host: Network trying to be reached is unreac+hable.ready 12:54:34 |
telnet 172.16.1.116 1830Trying...telnet: Unable to connect to remote host: No route to host.ready 12:55:44 |
telnet 172.16.1.116 1830Trying...telnet: Unable to connect to remote host: The operation timed out. |
|
消息
|
意义
|
|---|---|
|
互联(带横幅)
|
可访问主机和应用程序
|
|
互联(无横幅)
|
可能能够访问主机和应用程序
|
|
被拒绝
|
能连接主机但无法访问应用程序——可能是
|
|
无法接通
|
无法连接主机
|
|
超时
|
无法连接主机——可能是
|
perl tuc.pl -i 172.16.1.116 -p 1830Reply 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 2010ready 13:31:34 |
perl tuc.pl -i 172.16.1.116 -p 1830ICMP Destination port unreachable message received from 172.16.1.116ready 11:40:12 |
perl tuc.pl -i 172.16.1.116 -p 1830ICMP Destination network unreachable message received from 164.152.77.171ready 11:43:50 perl tuc.pl -i 172.16.1.116 -p 1830ICMP Destination host unreachable message received from 164.152.77.171ready 11:44:54 |
perl tuc.pl -i 172.16.1.116 -p 1830ICMP Time exceeded , TTL expired in transit message received from 164.152.77.34ready 11:45:39 |
perl tuc.pl -i 172.16.1.116 -p 1830No response was received from 172.16.1.116ready 16:43:26 |
perl tuc.pl -i 172.16.1.117 -p 1830 -t 10No response was received from 172.16.1.117ready 12:06:26 perl tuc.pl -i 172.16.1.117 -p 1830 -t 1 No response was received from 172.16.1.117ready 12:06:32 |
|
消息
|
意义
|
|---|---|
|
应用程序横幅消息
|
可访问主机和应用程序
|
|
ICMP网络/主机消息
|
无法连接主机
|
|
来自主机的ICMP端口消息
|
能连接到主机但无法访问应用程序
|
|
无响应,应用程序发送横幅消息
|
无法连接主机
|
|
无响应,应用程序未发送横幅消息
|
可能或可能无法连接到主机
|
tcplisten.pl
# tcplisten.pl begins here
# # 版本 1.00 2010-07-30 # 此脚本已在以下环境测试通过: # 运行在 i686-vos 架构上的 Open VOS 17.0.2ah 系统,搭载 Perl v5.8.0 版本 # 运行中的 Microsoft Windows XP Service Pack 3 # ActiveState Perl v5.10.0 专为 MSWin32-x86-multi-thread 构建 # 运行中的 Red Hat Linux 4AS-5.5 # Perl v5.8.5 构建于 x86_64-linux-thread-multi 架构 # #stratus # 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); 如果 (($result != 1) || !(defined($localPort))) { 打印“nn用法:n”; print "tperl tcplisten.pl -port 端口号 [-message 消息]nn"; 退出; } 如果未定义 ($message) { 打印“未指定消息——正在创建消息”; $message = "连接已由在" . hostname . "上运行的 tcplisten 接受"; } print "perl tcplisten.pl -port $localPort -message '" . $message . "'\n"; my $sock = IO::Socket::INET->new( Proto => ‘tcp’ 本地端口 => $localPort, 本地地址 => ‘0.0.0.0’ 听 => 1, ) 或终止 "无法为端口 $localPort 创建套接字:$!n"; while (1) { my $newSock = $sock->accept(); 打印 “已接受来自 ” . $newSock->peerhost . 在 ” . localtime() . “n”; print $newSock $message . "\n"; $newSock -> 关闭(2); $sock->read($data, 1024); # 等待收到关闭指示 */ $newSock->close(); } # # tcplisten.pl 到此结束 |
tuc.pl
# tuc.pl begins here
# # 版本 1.00 2010-07-30 # 此脚本已在以下环境测试通过: # 运行在 i686-vos 架构上的 Open VOS 17.0.2ah 系统,搭载 Perl v5.8.0 版本 # 运行中的 Microsoft Windows XP Service Pack 3 # ActiveState Perl v5.10.0 专为 MSWin32-x86-multi-thread 构建 # 运行中的 Red Hat Linux 4AS-5.5 # Perl v5.8.5 构建于 x86_64-linux-thread-multi 架构 # #stratus # use IO::Socket; use IO::Select; use Getopt::Long; use strict; my ($result); my ($目标IP, $目标端口, $超时时间, $结果, $消息, $标志); my ($ready, $socket); my ($x, $c, $icmpAlready); $result = GetOptions('ip=s' => $destIP, ‘port=s’ => $destPort, 'timeout=s' => $timeout); 如果 (($result != 1) || !(定义了($destIP) 且 定义了($destPort))) { 打印“nn用法:n”; 打印“tperl tuc.pl -ip 目标IP地址” “-端口目标端口号nn”; 退出; } if (!defined($timeout)) { $timeout = 5; } elsif ($timeout > 15) { print "OK,但 " . $timeout . “似乎过长了。”; } $message = “由 tuc.pl 在 ” . localtime() . " 发送"; my $sock = IO::Socket::INET->new( Proto => ‘udp’ PeerPort => $destPort, PeerAddr => $destIP ) 或死亡 “无法为目标 $destIP 创建套接字:$!n”; my $isock = IO::Socket::INET->new( Proto => 'icmp'); $sock->send($message) 或 die "发送错误: $!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; 如果 ($socket == $sock) { $x = “从 UDP 套接字接收到的回复来自 “; $socket->recv($message, 100, $flags); 如果 ($icmpAlready == 0) { 如果 (消息长度 > 0) { print $x . $socket->peerhost . ” message: ” . $message . “n”; } else { print $x . $socket->peerhost . “n”; } } } else # 收到icmp消息 { $icmpAlready = 1; $socket->recv($message, 100, $flags); 如果 (消息长度 > 98) { print "意外地长(" . length($message) . “来自” . $socket->peerhost . “的ICMP消息” 消息:". $message . "\n"; } elsif (length ($message) < 52) { print "出乎意料地短(" . length($message) . ") ICMP消息来自 " . $socket->peerhost . "n"; } else # 处理icmp消息 { 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)); 如果 ($port != $destPort) { print “意外收到来自 ” 的 ICMP 消息。 $socket->peerhost . " 消息:" . substr($message, 20) . “n”; } 否则 # icmp 消息正常 { 如果 ($type == 3) { if ($code == 0) { print "ICMP 目标网络 " . “收到无法送达的消息,来自 ”。 $socket->peerhost . "n"; } elsif ($code == 1) { print "ICMP 目标主机 " . “收到无法送达的消息,来自 ”。 $socket->peerhost . "n"; } elsif ($code == 3) { print "ICMP 目标端口 " . “收到无法送达的消息,来自 ”。 $socket->peerhost . "n"; } elsif ($code == 6) { print "ICMP 目标网络 " . “收到来自”的未知消息。 $socket->peerhost . "n"; } elsif ($code == 7) { print "ICMP 目标主机未知 " . “收到来自 ” . $socket->peerhost . “ 的消息”; } elsif ($code == 8) { print "ICMP 源主机被隔离" . “来自 的消息已收到”。 $socket->peerhost . "n"; } elsif ($code == 9) { print "ICMP 网络管理层级 " . “收到来自的禁止消息”。 $socket->peerhost . "n"; } elsif ($code == 10) { print "ICMP 主机管理上已禁用" . “收到来自的禁止消息”。 $socket->peerhost . "n"; } elsif ($code == 11) { print “ICMP 网络不可达,目标为 ” . “收到来自的TOS消息”。 $socket->peerhost . "n"; } elsif ($code == 12) { print "ICMP 主机不可达,地址为 " . “收到来自的TOS消息”。 $socket->peerhost . "n"; } elsif ($code == 13) { print "ICMP 通信 " . “收到来自的行政禁止消息”。 $socket->peerhost . "n"; } else { print "收到意外的ICMP消息,类型为: " . $type . “,代码 = ” . $code . ” 来自 ” . $socket->peerhost . "n"; } } # 如果 ($type == 3) elsif (($type == 11) & ($code == 0)) { 打印“ICMP超时,传输过程中TTL已过期”。 “收到来自 ” . $socket->peerhost . “ 的消息”; } else { print "收到意外的ICMP消息,类型为: " . $type . “,代码 = ” . $code . ” 来自 ” . $socket->peerhost . "n"; } } # 否则 # icmp 消息正常 } # 否则 # 处理icmp消息 } # 否则 #收到icmp消息 } # 遍历所有已就绪套接字 $socket (@$ready) if ($c == 0) { print “未收到来自 ” . $sock->peerhost . "n"; } # # tuc.pl 结束于此 |
udpecho.pl
# udpecho.pl begins here
# # 版本 1.00 2010-07-30 # 此脚本已在以下环境测试通过: # 运行在 i686-vos 架构上的 Open VOS 17.0.2ah 系统,搭载 Perl v5.8.0 版本 # 运行中的 Microsoft Windows XP Service Pack 3 # ActiveState Perl v5.10.0 专为 MSWin32-x86-multi-thread 构建 # 运行中的 Red Hat Linux 4AS-5.5 # Perl v5.8.5 构建于 x86_64-linux-thread-multi 架构 # #stratus # 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); 如果 (($result != 1) || !(defined($localPort))) { 打印“nn用法:n”; print "tperl udpecho.pl -port 本地端口号 [-debug]nn"; 退出; } if (defined($debug)) { print “local port number is ” . $localPort . “n”; } my $sock = IO::Socket::INET->new( Proto => ‘udp’ 本地端口 => $localPort ) 或 死亡 “无法创建套接字 $!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 "来自 " . $socket->peerhost . " 的消息" . 消息:". $message . "\n"; } $socket->send("由 udpecho.pl 发送:" . $message) or die("发送错误:$!"); +n"; } } # # udpecho.pl 到此结束 |
