Java简单实现Ping功能

基本需求: 定时测试被监控的设备是否可以ping通,如果ping不通的需要发出告警信息。

方案思路: 运用java调用服务器的自身命令来简单实现ping功能 ,本文只是讲述如何运用Java简单实现Ping的功能,至于告警信息的发送方式有很多种(比如短信 、邮件 、Syslog 、MSN 等等),在以前的文章中已经描述过,这里就不再一一详述了。

实现方式 : 根据不同的情况可分为如下两种
直接调用监控服务器的ping命令去测试需要监控的设备
通过指定服务器测试能否ping通 需要监控的设备 (运用Mina实现 )
下面将给出上述的两种实现的详细过程:

一、直接调用服务器本身的ping命令
TestPingCmd.java
Java代码
package michael.net;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
* @blog http://sjsky.iteye.com
* @author Michael
*/
public class TestPingCmd {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {

// 读取txt文件中的IP列表
TestPingCmd pinger = new TestPingCmd();
List<String> iplist = pinger
.getIpListFromTxt("d:/test/idc_ping_ip.txt");

// List<String> iplist = new ArrayList<String>();
// iplist.add("222.*.*.*");
// iplist.add("222.*.*.*");
// iplist.add("222.*.*.*");
// iplist.add("222.*.*.*");
// iplist.add("222.*.*.*");
ThreadPoolExecutor executorPool = new ThreadPoolExecutor(50, 60, 60,
TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(50),
new ThreadPoolExecutor.CallerRunsPolicy());
long startTime = System.currentTimeMillis();
final int maxCount = 4;
for (final String ip : iplist) {
executorPool.execute(new Runnable() {
public void run() {
TestPingCmd pinger = new TestPingCmd();
Integer countSucce = pinger.doPingCmd(ip, maxCount);
if (null != countSucce) {
System.out.println("host:[ " + ip + " ] ping cout: "
+ maxCount + " success: " + countSucce);

} else {
System.out
.println("host:[ " + ip + " ] ping cout null");
}
}

});
}
while (executorPool.getActiveCount() > 0) {
Thread.sleep(100);
}
System.out.println("complete ping jobs count = " + iplist.size()
+ " , total used time(ms) = "
+ (System.currentTimeMillis() - startTime));
executorPool.shutdown();
}

/**
* @param destIp
* @param maxCount
* @return
*/
public Integer doPingCmd(String destIp, int maxCount) {
LineNumberReader input = null;
try {
String osName = System.getProperties().getProperty("os.name");
String pingCmd = null;
if (osName.startsWith("Windows")) {
pingCmd = "cmd /c ping -n {0} {1}";
pingCmd = MessageFormat.format(pingCmd, maxCount, destIp);
} else if (osName.startsWith("Linux")) {
pingCmd = "ping -c {0} {1}";
pingCmd = MessageFormat.format(pingCmd, maxCount, destIp);
} else {
System.out.println("not support OS");
return null;
}
Process process = Runtime.getRuntime().exec(pingCmd);
InputStreamReader ir = new InputStreamReader(process
.getInputStream());
input = new LineNumberReader(ir);
String line;
List<String> reponse = new ArrayList<String>();

while ((line = input.readLine()) != null) {
if (!"".equals(line)) {
reponse.add(line);
// System.out.println("====:" + line);
}
}
if (osName.startsWith("Windows")) {
return parseWindowsMsg(reponse, maxCount);
} else if (osName.startsWith("Linux")) {
return parseLinuxMsg(reponse, maxCount);
}

} catch (IOException e) {
System.out.println("IOException " + e.getMessage());

} finally {
if (null != input) {
try {
input.close();
} catch (IOException ex) {
System.out.println("close error:" + ex.getMessage());

}
}
}
return null;
}

private int parseWindowsMsg(List<String> reponse, int total) {
int countTrue = 0;
int countFalse = 0;
for (String str : reponse) {
if (str.startsWith("来自") || str.startsWith("Reply from")) {
countTrue++;
}
if (str.startsWith("请求超时") || str.startsWith("Request timed out")) {
countFalse++;
}
}
return countTrue;
}

private int parseLinuxMsg(List<String> reponse, int total) {
int countTrue = 0;
for (String str : reponse) {
if (str.contains("bytes from") && str.contains("icmp_seq=")) {
countTrue++;
}
}
return countTrue;
}

/**
* @param filepath
* @return list
*/
public List<String> getIpListFromTxt(String filepath) {
BufferedReader br = null;
List<String> iplist = new ArrayList<String>();
try {
File file = new File(filepath);
br = new BufferedReader(new FileReader(file));
while (br.ready()) {
String line = br.readLine();
if (null != line && !"".equals(line)) {
iplist.add(line);
}
}
} catch (Exception e) {
e.printStackTrace(System.out);

} finally {
if (null != br) {
try {
br.close();
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
}
}
return iplist;
}

}

读取文件中IP列表(1001个IP)运行结果:
complete ping jobs count = 1001 , total used time(ms) = 483536


二、通过指定服务器去ping测试

主要思路:利用Mina在指定的第三方服务器上运行server端,然后实现客户端和 第三方 服务器建立socket连接,发送ping任务的消息给第三方服务器,第三方服务器再把执行结果实时反馈给客户端。
代码包括四个类:
服务端:PingServerIoHandler.java PingServer.java
客户端:PingClientIoHandler.java PingClient.java
Java代码
package michael.mina.ping;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.text.MessageFormat;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

/**
* @blog http://sjsky.iteye.com
* @author Michael
*/
public class PingServerIoHandler extends IoHandlerAdapter {
private String logId = "SERVER:: ";
private int msgCount = 0;

@Override
public void exceptionCaught(IoSession pSession, Throwable pCause)
throws Exception {
System.out.println(logId + "发生异常:" + pCause.getLocalizedMessage());
}

@Override
public void messageReceived(IoSession pSession, Object pMessage)
throws Exception {
String msg = String.valueOf(pMessage);
msgCount++;
System.out.println(logId + "收到客户端第 " + msgCount + " 条消息:" + msg);
pSession.write(msgCount);

if (msg.startsWith("ping")) {
String destIp = msg.split(" ")[1];
doPingCmd(pSession, destIp);
}

}

@Override
public void messageSent(IoSession pSession, Object pMessage)
throws Exception {
System.out.println(logId + "发出消息:" + pMessage);
}

@Override
public void sessionClosed(IoSession pSession) throws Exception {
System.out.println(logId + "one client closed ");
}

@Override
public void sessionCreated(IoSession pSession) throws Exception {
System.out.println(logId + "sessionCreated ");
}

@Override
public void sessionIdle(IoSession pSession, IdleStatus pStatus)
throws Exception {
super.sessionIdle(pSession, pStatus);
}

@Override
public void sessionOpened(IoSession pSession) throws Exception {
System.out.println(logId + "sessionOpened ");
}

private Integer doPingCmd(IoSession pSession, String destIp) {
LineNumberReader input = null;
int maxCount = 4;
try {
String osName = System.getProperties().getProperty("os.name");
String pingCmd = null;
if (osName.startsWith("Windows")) {
pingCmd = "cmd /c ping -n {0} {1}";
pingCmd = MessageFormat.format(pingCmd, maxCount, destIp);
} else if (osName.startsWith("Linux")) {
pingCmd = "ping -c {0} {1}";
pingCmd = MessageFormat.format(pingCmd, maxCount, destIp);
} else {
System.out.println("not support OS");
return null;
}
Process process = Runtime.getRuntime().exec(pingCmd);
InputStreamReader ir = new InputStreamReader(process
.getInputStream());
input = new LineNumberReader(ir);
String line;

while ((line = input.readLine()) != null) {
if (!"".equals(line)) {
pSession.write(line);
}
}
} catch (IOException e) {
System.out.println("IOException " + e.getMessage());

} finally {
if (null != input) {
try {
input.close();
} catch (IOException ex) {
System.out.println("close error:" + ex.getMessage());

}
}
}
return null;
}
}

Java代码
package michael.mina.ping;

import java.net.InetSocketAddress;
import java.nio.charset.Charset;

import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.filter.logging.LoggingFilter;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

/**
* @blog http://sjsky.iteye.com
* @author Michael
*/
public class PingServer {

private static final int PORT = 54321;

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
IoAcceptor acceptor = new NioSocketAcceptor();

acceptor.getFilterChain().addLast("logger", new LoggingFilter());
acceptor.getFilterChain().addLast(
"codec",
new ProtocolCodecFilter(new TextLineCodecFactory(Charset
.forName("UTF-8"))));
acceptor.setHandler(new PingServerIoHandler());
acceptor.bind(new InetSocketAddress(PORT));

System.out.println("服务端已启动,监听端口:" + PORT);

}

}


Java代码
package michael.mina.ping;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

/**
* @blog http://sjsky.iteye.com
* @author Michael
*/
public class PingClientIoHandler extends IoHandlerAdapter {

private String logId = "CLIENT:: ";

@Override
public void exceptionCaught(IoSession pSession, Throwable pCause)
throws Exception {
System.out.println(logId + "发生异常:" + pCause.getLocalizedMessage());
}

@Override
public void messageReceived(IoSession pSession, Object pMessage)
throws Exception {
String count = String.valueOf(pMessage);
System.out.println(logId + "服务端收到的消息数 = " + count);
}

@Override
public void messageSent(IoSession pSession, Object pMessage)
throws Exception {
System.out.println(logId + "发出消息:" + pMessage);
}

@Override
public void sessionClosed(IoSession pSession) throws Exception {
System.out.println(logId + "one client closed ");
}

@Override
public void sessionCreated(IoSession pSession) throws Exception {
System.out.println(logId + "sessionCreated ");
}

@Override
public void sessionIdle(IoSession pSession, IdleStatus pStatus)
throws Exception {
super.sessionIdle(pSession, pStatus);
}

@Override
public void sessionOpened(IoSession pSession) throws Exception {
System.out.println(logId + "sessionOpened ");
}
}

Java代码
package michael.mina.ping;

import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
import org.apache.mina.core.future.ConnectFuture;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.SocketConnector;
import org.apache.mina.transport.socket.nio.NioSocketConnector;

/**
* @blog http://sjsky.iteye.com
* @author Michael
*/
public class PingClient {

private static final int PORT = 54321;

/**
* IP列表
* @param ipList
*/
public void createPingClient(List<String> ipList) {
SocketConnector connector = new NioSocketConnector();

DefaultIoFilterChainBuilder chain = connector.getFilterChain();

// 设定过滤器一行一行读取数据
chain.addLast("codec", new ProtocolCodecFilter(
new TextLineCodecFactory(Charset.forName("UTF-8"))));

// 注册消息处理器
connector.setHandler(new PingClientIoHandler());
connector.setConnectTimeoutMillis(30 * 1000L);
// 连接服务器
ConnectFuture cf = connector.connect(new InetSocketAddress("127.0.0.1",
54321));
cf.awaitUninterruptibly();
IoSession session = cf.getSession();
for (String ip : ipList) {
session.write("ping " + ip);
}
session.getCloseFuture().awaitUninterruptibly();
connector.dispose();
System.out.println("-------------------");
}

/**
* 控制台输入
* @param ipList
*/
public void createPingClient() {
SocketConnector connector = new NioSocketConnector();

DefaultIoFilterChainBuilder chain = connector.getFilterChain();

// 设定过滤器一行一行读取数据
chain.addLast("codec", new ProtocolCodecFilter(
new TextLineCodecFactory(Charset.forName("UTF-8"))));

// 注册消息处理器
connector.setHandler(new PingClientIoHandler());
connector.setConnectTimeoutMillis(30 * 1000L);
// 连接服务器
ConnectFuture cf = connector.connect(new InetSocketAddress("127.0.0.1",
54321));
cf.awaitUninterruptibly();
IoSession session = cf.getSession();
Scanner input = new Scanner(System.in).useDelimiter("\\r\\n");
while (input.hasNext()) {
String s = input.next();
if (s.equals("quit")) {
break;
}
session.write(s);
}
// cf.getSession().getCloseFuture().awaitUninterruptibly();
connector.dispose();
}

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
PingClient tester = new PingClient();
List<String> iplist = new ArrayList<String>();
iplist.add("192.168.8.89");
iplist.add("192.168.8.93");
iplist.add("192.168.8.109");
iplist.add("192.168.8.117");
iplist.add("192.168.8.118");
tester.createPingClient(iplist);
}

}

BTW:先运行server端,在运行client端( )。
server端日志如下:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
服务端已启动,监听端口:54321
SERVER:: sessionCreated
SERVER:: sessionOpened
SERVER:: 收到客户端第 1 条消息:ping 192.168.8.89
SERVER:: 发出消息:1
SERVER:: 收到客户端第 2 条消息:ping 192.168.8.93
SERVER:: 收到客户端第 3 条消息:ping 192.168.8.109
SERVER:: 收到客户端第 4 条消息:ping 192.168.8.117
SERVER:: 收到客户端第 5 条消息:ping 192.168.8.118
SERVER:: 发出消息:正在 Ping 192.168.8.89 具有 32 字节的数据:
SERVER:: 发出消息:来自 192.168.8.89 的回复: 字节=32 时间=5ms TTL=60
SERVER:: 发出消息:来自 192.168.8.89 的回复: 字节=32 时间=3ms TTL=59
SERVER:: 发出消息:来自 192.168.8.89 的回复: 字节=32 时间=4ms TTL=59
SERVER:: 发出消息:来自 222.73.88.89 的回复: 字节=32 时间=41ms TTL=59
SERVER:: 发出消息:192.168.8.89 的 Ping 统计信息:
SERVER:: 发出消息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
SERVER:: 发出消息:往返行程的估计时间(以毫秒为单位):
SERVER:: 发出消息: 最短 = 3ms,最长 = 41ms,平均 = 13ms
SERVER:: 发出消息:2
SERVER:: 发出消息:正在 Ping 192.168.8.93 具有 32 字节的数据:
SERVER:: 发出消息:来自 192.168.8.93 的回复: 字节=32 时间=4ms TTL=59
SERVER:: 发出消息:来自 192.168.8.93 的回复: 字节=32 时间=4ms TTL=59
SERVER:: 发出消息:来自 192.168.8.93 的回复: 字节=32 时间=4ms TTL=59
SERVER:: 发出消息:来自 192.168.8.93 的回复: 字节=32 时间=3ms TTL=59
SERVER:: 发出消息:192.168.8.93 的 Ping 统计信息:
SERVER:: 发出消息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
SERVER:: 发出消息:往返行程的估计时间(以毫秒为单位):
SERVER:: 发出消息: 最短 = 3ms,最长 = 4ms,平均 = 3ms
SERVER:: 发出消息:3
SERVER:: 发出消息:正在 Ping 192.168.8.109 具有 32 字节的数据:
SERVER:: 发出消息:来自 192.168.8.109 的回复: 字节=32 时间=13ms TTL=249
SERVER:: 发出消息:来自 192.168.8.109 的回复: 字节=32 时间=36ms TTL=249
SERVER:: 发出消息:来自 192.168.8.109 的回复: 字节=32 时间=61ms TTL=249
SERVER:: 发出消息:来自 192.168.8.109 的回复: 字节=32 时间=83ms TTL=249
SERVER:: 发出消息:192.168.8.109 的 Ping 统计信息:
SERVER:: 发出消息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
SERVER:: 发出消息:往返行程的估计时间(以毫秒为单位):
SERVER:: 发出消息: 最短 = 13ms,最长 = 83ms,平均 = 48ms
SERVER:: 发出消息:4
SERVER:: 发出消息:正在 Ping 192.168.8.117 具有 32 字节的数据:
SERVER:: 发出消息:来自 192.168.8.117 的回复: 字节=32 时间=4ms TTL=249
SERVER:: 发出消息:来自 192.168.8.117 的回复: 字节=32 时间=4ms TTL=249
SERVER:: 发出消息:来自 192.168.8.117 的回复: 字节=32 时间=4ms TTL=249
SERVER:: 发出消息:来自 192.168.8.117 的回复: 字节=32 时间=5ms TTL=249
SERVER:: 发出消息:192.168.8.117 的 Ping 统计信息:
SERVER:: 发出消息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
SERVER:: 发出消息:往返行程的估计时间(以毫秒为单位):
SERVER:: 发出消息: 最短 = 4ms,最长 = 5ms,平均 = 4ms
SERVER:: 发出消息:5
SERVER:: 发出消息:正在 Ping 192.168.8.118 具有 32 字节的数据:
SERVER:: 发出消息:来自 192.168.8.118 的回复: 字节=32 时间=3ms TTL=251
SERVER:: 发出消息:来自 192.168.8.118 的回复: 字节=32 时间=3ms TTL=251
SERVER:: 发出消息:来自 192.168.8.118 的回复: 字节=32 时间=5ms TTL=251
SERVER:: 发出消息:来自 192.168.8.118 的回复: 字节=32 时间=4ms TTL=251
SERVER:: 发出消息:192.168.8.118 的 Ping 统计信息:
SERVER:: 发出消息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
SERVER:: 发出消息:往返行程的估计时间(以毫秒为单位):
SERVER:: 发出消息: 最短 = 3ms,最长 = 5ms,平均 = 3ms

client端日志如下 :
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
CLIENT:: sessionCreated
CLIENT:: sessionOpened
CLIENT:: 发出消息:ping 192.168.8.89
CLIENT:: 发出消息:ping 192.168.8.93
CLIENT:: 发出消息:ping 192.168.8.109
CLIENT:: 发出消息:ping 192.168.8.117
CLIENT:: 发出消息:ping 192.168.8.118
CLIENT:: 服务端收到的消息数 = 1
CLIENT:: 服务端收到的消息数 = 正在 Ping 192.168.8.89 具有 32 字节的数据:
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.89 的回复: 字节=32 时间=5ms TTL=60
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.89 的回复: 字节=32 时间=3ms TTL=59
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.89 的回复: 字节=32 时间=4ms TTL=59
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.89 的回复: 字节=32 时间=41ms TTL=59
CLIENT:: 服务端收到的消息数 = 192.168.8.89 的 Ping 统计信息:
CLIENT:: 服务端收到的消息数 = 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
CLIENT:: 服务端收到的消息数 = 往返行程的估计时间(以毫秒为单位):
CLIENT:: 服务端收到的消息数 = 最短 = 3ms,最长 = 41ms,平均 = 13ms
CLIENT:: 服务端收到的消息数 = 2
CLIENT:: 服务端收到的消息数 = 正在 Ping 192.168.8.93 具有 32 字节的数据:
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.93 的回复: 字节=32 时间=4ms TTL=59
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.93 的回复: 字节=32 时间=4ms TTL=59
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.93 的回复: 字节=32 时间=4ms TTL=59
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.93 的回复: 字节=32 时间=3ms TTL=59
CLIENT:: 服务端收到的消息数 = 192.168.8.93 的 Ping 统计信息:
CLIENT:: 服务端收到的消息数 = 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
CLIENT:: 服务端收到的消息数 = 往返行程的估计时间(以毫秒为单位):
CLIENT:: 服务端收到的消息数 = 最短 = 3ms,最长 = 4ms,平均 = 3ms
CLIENT:: 服务端收到的消息数 = 3
CLIENT:: 服务端收到的消息数 = 正在 Ping 192.168.8.109 具有 32 字节的数据:
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.109 的回复: 字节=32 时间=13ms TTL=249
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.109 的回复: 字节=32 时间=36ms TTL=249
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.109 的回复: 字节=32 时间=61ms TTL=249
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.109 的回复: 字节=32 时间=83ms TTL=249
CLIENT:: 服务端收到的消息数 = 192.168.8.109 的 Ping 统计信息:
CLIENT:: 服务端收到的消息数 = 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
CLIENT:: 服务端收到的消息数 = 往返行程的估计时间(以毫秒为单位):
CLIENT:: 服务端收到的消息数 = 最短 = 13ms,最长 = 83ms,平均 = 48ms
CLIENT:: 服务端收到的消息数 = 4
CLIENT:: 服务端收到的消息数 = 正在 Ping 192.168.8.117 具有 32 字节的数据:
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.117 的回复: 字节=32 时间=4ms TTL=249
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.117 的回复: 字节=32 时间=4ms TTL=249
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.117 的回复: 字节=32 时间=4ms TTL=249
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.117 的回复: 字节=32 时间=5ms TTL=249
CLIENT:: 服务端收到的消息数 = 192.168.8.117 的 Ping 统计信息:
CLIENT:: 服务端收到的消息数 = 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
CLIENT:: 服务端收到的消息数 = 往返行程的估计时间(以毫秒为单位):
CLIENT:: 服务端收到的消息数 = 最短 = 4ms,最长 = 5ms,平均 = 4ms
CLIENT:: 服务端收到的消息数 = 5
CLIENT:: 服务端收到的消息数 = 正在 Ping 192.168.8.118 具有 32 字节的数据:
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.118 的回复: 字节=32 时间=3ms TTL=251
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.118 的回复: 字节=32 时间=3ms TTL=251
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.118 的回复: 字节=32 时间=5ms TTL=251
CLIENT:: 服务端收到的消息数 = 来自 192.168.8.118 的回复: 字节=32 时间=4ms TTL=251
CLIENT:: 服务端收到的消息数 = 192.168.8.118 的 Ping 统计信息:
CLIENT:: 服务端收到的消息数 = 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
CLIENT:: 服务端收到的消息数 = 往返行程的估计时间(以毫秒为单位):
CLIENT:: 服务端收到的消息数 = 最短 = 3ms,最长 = 5ms,平均 = 3ms
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值