Closed tangxinfa closed 1 year ago
Good spot! As I see it there are a few ways to fix this:
Regarding number 3, the ICMP RFCs (RFC 792 for IPv4 and RFC 4443 for IPv6) make clear that you don't have to encode timestamps in your ICMP packets as we currently do. I think we may be better off storing the time a packet is emitted locally and matching against the packet's tracker when it returns, then doing a monotonic t.Sub
to get the delta.
timeToBytes()
callUnixNano()
on time.Time instance for get a integer timestamp, and serialized into binary, then send it to remote server, when response received, it convert it to time.Time instance for calculate rtt.When the system time(wall time) changed in the middle, such as by ntp time synchronization, the calculated result may incorrect.
May be we can get a monotonic timestamp like bellow: