ping icmp和tcp区别:

情到浓时终转凉″ 提交于 2020-02-25 13:02:20

ping icmp和tcp区别:

tcpdump -i eth1 '((tcp) and (  host 2.2.2.2)))'




node1:/root/test#cat ping.pl 
use Net::Ping;
$p = Net::Ping->new("icmp");
if ($p->ping('2.2.2.2',20)){
      print '11111111111'
}
else{print '222222222'};
node1:/root/test#time perl ping.pl 
222222222
real	0m20.066s
user	0m0.035s
sys	0m0.008s

node1:/root# tcpdump -i eth1 '((icmp) and ( host 2.2.2.2))'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
17:57:04.217302 IP node1 > 2.2.2.2: ICMP echo request, id 2399, seq 1, length 8

此时发送icmp包,没有重连机制



发送tcp包:
use Net::Ping;
$p = Net::Ping->new("tcp");
if ($p->ping('2.2.2.2',20)){
      print '11111111111'
}
else{print '222222222'};

node1:/root/test#time perl ping.pl 
222222222
real	0m20.069s
user	0m0.032s
sys	0m0.025s

node1:/root# tcpdump -i eth1 '((tcp) and ( host 2.2.2.2))'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
17:59:31.590304 IP node1.50468 > 2.2.2.2.echo: Flags [S], seq 2053712909, win 14600, options [mss 1460,sackOK,TS val 2412269 ecr 0,nop,wscale 6], length 0
17:59:32.591743 IP node1.50468 > 2.2.2.2.echo: Flags [S], seq 2053712909, win 14600, options [mss 1460,sackOK,TS val 2413270 ecr 0,nop,wscale 6], length 0
17:59:34.593124 IP node1.50468 > 2.2.2.2.echo: Flags [S], seq 2053712909, win 14600, options [mss 1460,sackOK,TS val 2415271 ecr 0,nop,wscale 6], length 0
17:59:38.593417 IP node1.50468 > 2.2.2.2.echo: Flags [S], seq 2053712909, win 14600, options [mss 1460,sackOK,TS val 2419272 ecr 0,nop,wscale 6], length 0
17:59:46.593634 IP node1.50468 > 2.2.2.2.echo: Flags [S], seq 2053712909, win 14600, options [mss 1460,sackOK,TS val 2427272 ecr 0,nop,wscale 6], length 0





 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!