命令格式:
ping ip地址 -l 字节数
注:上面的命令中 l 是字母l,不是数字1
网速等于≈(发送的字节数/返回的时间[毫秒])K字节
以上计算的结果速为字节(byte),不是我们通常说的位(bps)
如:
C:\Documents and Settings\Administrator>ping 202.101.224.68 -l 1000
Pinging 202.101.224.68 with 1000 bytes of data:
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Ping statistics for 202.101.224.68:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 38ms, Maximum = 38ms, Average = 38ms
根据上述发送及返回的信息可以简单得出到地址202.101.224.68的网速为:
网速等于≈(发送的字节数/返回的时间[毫秒])K字节
≈1000/38K字节
≈26.32K字节
附:ping命令帮助说明
-l size Send buffer size
-w timeout Timeout in milliseconds to wait for each reply.
-n count Number of echo requests to send.
PING与网速的关系:
由于PING包的大小前面已经讲了,PING包的默认大小为32字节,对于现在的网络,你的网速大小并不能对你PING的大小起到绝对的影响,最主要的影响因素是地区。
1:距离越远PING越高。
2:本地运营商机房质量以及承载能力,也就是所谓暴PING的问题。
3:游戏运营商服务器机房质量以及承载能力,也就是是否为专线的问题以及服务器所在地网络情况。
4:全国网络大环境。也就是高峰段以及各运营商之间竞争的问题。
ping ip地址 -l 字节数
注:上面的命令中 l 是字母l,不是数字1
网速等于≈(发送的字节数/返回的时间[毫秒])K字节
以上计算的结果速为字节(byte),不是我们通常说的位(bps)
如:
C:\Documents and Settings\Administrator>ping 202.101.224.68 -l 1000
Pinging 202.101.224.68 with 1000 bytes of data:
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Reply from 202.101.224.68: bytes=1000 time=38ms TTL=251
Ping statistics for 202.101.224.68:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 38ms, Maximum = 38ms, Average = 38ms
根据上述发送及返回的信息可以简单得出到地址202.101.224.68的网速为:
网速等于≈(发送的字节数/返回的时间[毫秒])K字节
≈1000/38K字节
≈26.32K字节
附:ping命令帮助说明
-l size Send buffer size
-w timeout Timeout in milliseconds to wait for each reply.
-n count Number of echo requests to send.
PING与网速的关系:
由于PING包的大小前面已经讲了,PING包的默认大小为32字节,对于现在的网络,你的网速大小并不能对你PING的大小起到绝对的影响,最主要的影响因素是地区。
1:距离越远PING越高。
2:本地运营商机房质量以及承载能力,也就是所谓暴PING的问题。
3:游戏运营商服务器机房质量以及承载能力,也就是是否为专线的问题以及服务器所在地网络情况。
4:全国网络大环境。也就是高峰段以及各运营商之间竞争的问题。
public class PingTest {
public static void main(String args[])
{
String[] addrs= {"www.baidu.com"};
if (addrs.length < 1)
{
System.out.println("syntax Error!");
}
else
{
for(int i=0;i<addrs.length;i++){
String line = null;
try
{
Process pro = Runtime.getRuntime().exec("ping " + addrs[i]+" -l 1000 -n 4");
BufferedReader buf = new BufferedReader(new InputStreamReader(pro.getInputStream()));
while((line = buf.readLine()) != null){
int position=0;
if((position=line.indexOf("Average"))>=0)
{ System.out.println(line);
String value="/blog/line.substring(position+10,line.lastIndexOf(""ms"));
System.out.println("your speed is:"+(1000/Integer.parseInt(value))+"KB");
}
}
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
}
}
}