大网数据广告活动
服务器运维问答

Get remote system time from ICMP timestamp

· 52CE 我爱测

I read from an article that ICMP Timestamp can be used to determine system time so I tried hping3 192.168.1.x --icmp --icmp-ts -V . The output shows len=46 ip=192.168.1.x ttl=xx id=xxxx tos=0 iplen=40 icmp_seq=x rtt=x.xms ICMP ti…

问题原文

原帖链接 · akgren_soar · CC BY-SA 3.0

I read from an article that ICMP Timestamp can be used to determine system time so I tried hping3 192.168.1.x --icmp --icmp-ts -V. The output shows

len=46 ip=192.168.1.x ttl=xx id=xxxx tos=0 iplen=40 icmp_seq=x rtt=x.xms
ICMP timestamp: Originate=27494134 Receive=27316024 Transmit=27316024
ICMP timestamp RTT tsrtt=xx

The problem is that I can't seem to make sense of the output...how do I derive the system time from the above results? Or am I doing something wrong here?


Solution

The timestamp of the remote host can be calculate fromTransmit=27316024

  1. Converting 27316024 milliseconds to hours, you get 7.59 hours
  2. 7.59 hours translates to 07:35 Universal Time
  3. Change the time according to your local time zone

Extras

Timestamp is the number of milliseconds since midnight, universal time.

Originate is the time that your local machine crafts the request packet
Receive is the time that the remote machine receives the packet
Transmit is the time that the remote machine crafts the response packet

已采纳解答

原帖链接 · John Mahowald · CC BY-SA 3.0

Read about the protocol and you will find this to be in the format of milliseconds since UT. https://www.ietf.org/rfc/rfc0792.txt

Except for when the device can't provide this and the time is bogus - read the RFC. Clever trick but this will not be a reliable way to get time.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-12-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。