How can TCP ACKs be used to measure latency to a server?
https://www.pico.net/kb/how-can-tcp-acks-be-used-to-measure-latency-to-a-server/
TCP ACKs can be used to measure the round-trip time to a TCP receiver, and they can do so very accurately: since ACKs are generated in the ISR (interrupt service routine), they involve only the lowest level of software and directly reflect the hardware path across the network and into the server NIC.
However it is far from trivial to use TCP ACKs to make a clean RTT measurement. First of all, TCP ACKs are invisible to the application layer, and so network capture must be used to timestamp the ACKs. Once a network capture point is chosen, the round-trip time can be measured by comparing the timestamp of when data is sent to the receiver to when an ACK matching that data is received. These raw measurements are not always reflective of the round-trip time:
The receiver may have delayed the acknowledgement, as per RFC 1122, 4.2.3.2, in the hope that the application will respond to the received data by sending a response, onto which it can piggy-back the ACK. The RFC allows the stack to delay the ACK by up to 500ms, but a more typical timeout is the Linux default of 50ms. RTT measured from a delayed ACK will be inflated by the length of the timeout.
TCP's cumulative ACK model allows a single ACK to acknowledge more than one received segment. In this case, the apparent RTT from an earlier segment to the ACK is inflated by the time difference between this earlier segment and the final one that triggers the ACK.
When a segment is retransmitted, the resulting RTT is ambiguous:
if the first transmission was actually dropped, then the ACK was generated in response to the retransmission, and measuring the RTT from the first transmission inflates the RTT;
if the first transmission was successful, and the ACK was simply delayed, then measuring the RTT from the second segment underestimates the true round-trip time.
Careful filtering of the raw RTT measurements is required to derive reliable RTT measurements. Corvil invented a method for doing this, which was granted patent protection under U.S. patent number US8493875B2 and European patent number EP2234333.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通