Android Ping TTL超出输出解密
我正在为Android创建一个traceroute服务,由于Android没有内置traceroute命令,所以我正在使用adb shell ping以不断增加的TTL值实现一个 这是请求/响应的示例:Android Ping TTL超出输出解密,android,networking,ping,traceroute,Android,Networking,Ping,Traceroute,我正在为Android创建一个traceroute服务,由于Android没有内置traceroute命令,所以我正在使用adb shell ping以不断增加的TTL值实现一个 这是请求/响应的示例: //Sample shellCommand: /system/bin/ping -c 1 -t 8 Runtime.getRuntime().exec(shellCommand + DESTINATION_URL); PING opf-www.google.com(xxx.xx
//Sample shellCommand: /system/bin/ping -c 1 -t 8
Runtime.getRuntime().exec(shellCommand + DESTINATION_URL);
PING opf-www.google.com(xxx.xxx.xxx.xxx)56(84)字节的数据。---opf-www.google.com ping统计数据--
发送1个数据包,接收0个,100%数据包丢失,时间0ms
int UID = myUid();
long mStartRX = TrafficStats.getUidRxBytes(UID);
long mStartTX = TrafficStats.getUidTxBytes(UID);
new TracerouteTask().run();
long rxBytes = TrafficStats.getUidRxBytes(UID)- mStartRX;
long txBytes = TrafficStats.getUidTxBytes(UID)- mStartTX;
使用此选项,我始终会收到rxBytes的0值,即收到的字节数。为什么会这样?我们收到一个ICMP TTL超出的数据包。我找到了答案,并进行了更新,以防将来对某人有所帮助:) in中的56(84)表示ICMP消息中包含的“虚拟数据”的有效负载为56字节,当与通知消息去向的28字节ICMP报头数据组合时,总数据包大小为(84)字节