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