教你正确使用Windows的Ping命令
对于Windows下ping命令相信大家已经再熟悉不过了,但是能把ping的功能发挥到最大的人却并不是很多,当然我也并不是说我可以让ping发挥最大的功能,我也只不过经常用ping这个工具,也总结了一些小经验,现在和大家分享一下。 $ x N: ~! J/ c6 W @( j
. U y9 _$ H1 v% x4 B
现在我就参照ping命令的帮助说明来给大家说说我使用ping时会用到的技巧,ping只有在安装了TCP/IP协议以后才可以使用: 6 q/ Z- \+ |. U" Y; b* M3 L
5 h" I, I2 R+ x8 ^: g: h; N) Y9 E: n ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-v tos] [-r count] [-s count] [[-j computer-list] [-k computer-list]] [-w timeout] destination-list
% H3 y9 U8 T) L) g6 u9 C
3 U9 V% E+ d/ S% R. |' r) j5 j7 J Options: 5 @1 N* d& ?6 \. {* d2 a2 ^
7 c) h# b' o _# A$ Y -t Ping the specified host until stopped.To see statistics and continue - type Control-Break;To stop - type Control-C. : v; z1 u+ b4 f$ k/ a- [/ J& d
) X5 F3 U& K; A# q! v/ j
不停的ping地方主机,直到你按下Control-C。
2 r3 K# K+ }+ u % D% V6 R- Y4 G: }/ z
此功能没有什么特别的技巧,不过可以配合其他参数使用,将在下面提到。 5 R# f8 Q0 ?3 t B5 F
, N* T# O. v. R
-a Resolve addresses to hostnames. % X0 g/ u* ]" k, u3 r; n. |
0 `0 Y9 X) ~+ B2 A! l 解析计算机NetBios名。
' N2 l* d: C2 {4 z9 r
& X3 R% @, F; ~4 k2 d 示例:C:\>ping -a 192.168.1.21
# j: D% ?+ P6 L ' T) ?" W/ m* m/ }5 `
Pinging iceblood.yofor.com [192.168.1.21] with 32 bytes of data: 4 {: G! T$ f4 E" N! h
" s% f) A; Y5 P# _( B; V8 i# a4 c
Reply from 192.168.1.21: bytes=32 time<10ms TTL=254
/ s8 ]* r |; D2 }, h ( t7 h: p, j/ @) I
Reply from 192.168.1.21: bytes=32 time<10ms TTL=254
6 k" H) U% t+ K7 M2 z% S- }. g
: M$ E+ }. h9 x Reply from 192.168.1.21: bytes=32 time<10ms TTL=254
; a9 O$ `' X: _& x1 y" ^9 r
+ ?! b( V A, b4 x& l
4 \4 v3 `0 |3 e* @( `. j Reply from 192.168.1.21: bytes=32 time<10ms TTL=254
& {. L _/ l* i" Z o# r$ c: s 9 u" E4 H8 F7 z0 S" I
Ping statistics for 192.168.1.21:
, X, C( G! m$ N$ d- \) ^. ~ . e) {0 j$ F. s, i' Q
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: 5 g( U5 R4 Y- j7 T9 o i
/ W# |. b9 n9 S/ M* X' Y& L; A6 Q
Minimum = 0ms, Maximum = 0ms, Average = 0ms
4 ]; Z0 w! | u. a; M: v% d 4 S* c8 _! Y+ C
从上面就可以知道IP为192.168.1.21的计算机NetBios名为iceblood.yofor.com。 - D5 C9 N7 Y$ D* A, r" ]
* c! l- c4 P" _5 Z. f4 E, o$ r" f -n count Number of echo requests to send. # X/ T: h2 C) H4 H8 ]
( V( ]) e& J9 m8 P/ _5 S7 ? 发送count指定的Echo数据包数。
5 o4 A2 }* U( z3 ^1 Q
- @4 K0 ?- d4 D 在默认情况下,一般都只发送四个数据包,通过这个命令可以自己定义发送的个数,对衡量网络速度很有帮助,比如我想测试发送50个数据包的返回的平均时间为多少,最快时间为多少,最慢时间为多少就可以通过以下获知:
x3 i; M( e& k l 2 I/ h7 f9 C9 [4 s' A/ f
C:\>ping -n 50 202.103.96.68 # y Z o8 ]$ v
: W5 u4 |, A- N4 M( D7 E1 ] Pinging 202.103.96.68 with 32 bytes of data:
8 i& [, c% n; V3 j- A7 ?9 F# \ * A4 w# Z. d* I2 N' Z p( U" D
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241 $ p$ L# e2 J# ~6 S
0 x1 j8 }5 i( {1 [4 y Reply from 202.103.96.68: bytes=32 time=50ms TTL=241 6 [$ i0 E! b8 f, h; c1 i- I
' _; @$ {4 w6 Y
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241 # \, N3 w5 R# |( ?! _1 d6 `
* R0 n, p7 A! @% ^ Request timed out. ( F2 x$ q5 [: F
& h; k2 [0 z, g- v, }8 g ………………
; q5 E9 `0 i# z, P% u4 I+ [; x
$ G: x e3 ]2 l' V I2 n" }9 c Reply from 202.103.96.68: bytes=32 time=50ms TTL=241 5 e1 W7 v$ c0 H7 s
- s4 ~; a2 C7 u. O' y Reply from 202.103.96.68: bytes=32 time=50ms TTL=241 & u7 X# Y9 X% m9 S* o
' L6 b% L! ^# u3 v! E# l Ping statistics for 202.103.96.68: 5 H8 h, O( C0 [- X$ g
/ K& c$ A1 x ]6 z5 c; O; ^9 F
Packets: Sent = 50, Received = 48, Lost = 2 (4% loss),Approximate round trip times in milli-seconds:
- ]$ ~8 a# g0 P3 P# t
& O% z9 C% ?7 q9 G0 ] Minimum = 40ms, Maximum = 51ms, Average = 46ms & T2 b+ I" P9 [- g
: f9 `0 s, y9 K% P# ~5 n; U 从以上我就可以知道在给202.103.96.68发送50个数据包的过程当中,返回了48个,其中有两个由于未知原因丢失,这48个数据包当中返回速度最快为40ms,最慢为51ms,平均速度为46ms。 {: D" P3 T- y& \! d1 j" c
8 N6 @6 w6 W' N1 l* B# ^- j
-l size Send buffer size.
. ]6 s0 K4 g" ^$ j! u0 G 0 s N! n3 U' U/ b6 t9 [
定义echo数据包大小。