TL;DR
Round-trip time (RTT) is the time from when a sender transmits a message until it gets back the reply that confirms the message arrived. It is made of the one-way latency to the receiver, a short wait while the receiver handles the message, and the one-way latency of the reply. Senders keep taking samples of it, and they use the samples to decide how long to wait before giving up and sending again.
Builds on: Network Latency · Leads to: Retransmission Timeout
Where it's used
Web browsing. When you open a web page, your browser opens a connection to the server, and each request waits for a reply. The time from sending a request to receiving the first byte of the answer is a round trip, and a page that needs many round trips feels slow even on a fast connection.
Ping. The ping tool sends a small packet to a host and prints how long the reply took. That printed time is the round-trip time for that one exchange, and it is the number people quote when they say a server is "80 milliseconds away".
Reliable transfer. A file sent over TCP is cut into packets, and the receiver sends back an acknowledgement for each one. The sender measures the time between sending a packet and getting its acknowledgement, and it uses those times to decide when a packet has been lost and should be sent again. This is the setting where round-trip time matters most, because a timer set wrongly either wastes bandwidth on needless resends or waits too long after a real loss.
How it works
Follow one packet through a path with a fibre link of 2,000 kilometres each way. Light in the fibre travels at about 200,000 kilometres per second, and the link moves 1,000,000 bytes per second. The sender transmits a 1,000-byte data packet. The receiver takes 2 milliseconds to handle it and sends back a 40-byte acknowledgement. No router queues anything.
-
Send the packet. The sender records the time, ms. Check: this is the start of the clock for this round trip.
-
Put the packet on the link. Sending 1,000 bytes at 1,000,000 bytes per second takes 1 millisecond. Check: the packet has finished leaving the sender at 1 ms.
-
Travel to the receiver. The distance is 2,000 kilometres, so the signal takes seconds, which is 10 milliseconds. Check: the packet arrives at ms.
-
The receiver handles it. It takes 2 milliseconds, so the acknowledgement is ready to send at 13 ms. Check: this wait is part of the round trip, even though no data is moving.
-
Send the acknowledgement back. The 40 bytes take seconds, which is 0.04 milliseconds, and the return travel takes another 10 milliseconds. Check: the acknowledgement arrives at ms.
-
Read the clock. The sender subtracts its start time, ms. That is this packet's round-trip sample. Check: the parts add up, since ms of travel, ms of sending and ms of handling make ms.
-
Repeat with a queue. Suppose the next packet waits 8 milliseconds behind other traffic at a router on the way out. Its sample is ms. Check: the only new part is the queue, which the sender cannot see directly and which shows up only as a longer round trip.
sequenceDiagram
participant S as Sender
participant R as Receiver
S->>R: data packet (sent at 0 ms)
Note over R: handles it for 2 ms
R-->>S: acknowledgement (arrives at 23.04 ms)
The math
Let be the time a packet leaves the sender and the time its acknowledgement arrives. A single round-trip sample is
The round-trip time of a packet is the interval between sending it and receiving the reply that confirms it. It has four parts: the one-way trip out, any handling at the receiver, the one-way trip back, and any queueing or transmission along the way.
Each part is the kind of latency described in Network Latency. In the walkthrough, ms, where the three numbers are travel, sending and handling. Written as a sum over the trip out and back, .
One sample is noisy
The sample changes from packet to packet. In the walkthrough the second sample is 31.04 ms, because of the queue, although the path has not changed. A sender therefore keeps a smoothed value (smoothed round-trip time) that moves a small fraction of the way toward each new sample:
The weights and add up to 1, so the estimate is always a blend of what it was and what was just measured. This is an Exponential Moving Average with weight on each new sample. One slow sample therefore moves the estimate only a little, while a sustained change shows up after several packets.
Karn's rule: skip resent packets
If the sender has to send a packet again, it cannot tell whether the acknowledgement answers the first copy or the second. A sample from a resent packet is therefore ambiguous, and the sender leaves it out of the estimate. This is Karn's rule.
Worked examples
A packet leaves at time 0. The sending time is 1 ms, the travel out is 5 ms, the receiver handles it for 1 ms, the acknowledgement travels back in 5 ms, and nothing else happens.
- Add the parts: ms.
- Compute the sample: ms.
- Interpretation: the travel parts are most of the time, so a shorter cable would help more than a faster sender.
Start with ms, the first sample. Then two more samples arrive: ms (after the queue) and ms.
- Second sample: ms.
- Third sample: ms.
- Check: the estimate rose from 23.04 to 24.16 ms over the three samples, while the largest single sample was 31.04 ms.
- Interpretation: the 8 ms queue barely moved the estimate, which is what a sender wants, because one busy moment should not change how long it waits for every later packet.
A connection goes over a geostationary satellite. Each leg of the radio path is about 240 ms of travel, so the travel alone is about 480 ms per round trip. The receiver handles each packet in 20 ms.
- Travel: ms.
- Handling: 20 ms.
- Sample: ms, before any queueing.
- Interpretation: a sender that expects 50 ms replies would time out on every packet, though none were lost. The round-trip time must be measured on the path actually in use.
Try it: a path has 60 ms of travel each way and 5 ms of handling. What is the round-trip sample? If the next sample is 130 ms, what does become, if it was 125 ms before?
Answer: the sample is ms. Then ms.
Common mistakes and tradeoffs
It is tempting to think that round-trip time is the same as one-way latency. In fact it includes both directions and the receiver's handling time, so it is roughly twice the one-way trip plus a little more. A sender that uses one-way figures will time out too early.
It is tempting to think that one measurement is enough. In fact a single sample can be high because of a queue or low because the path was briefly empty. Smoothing gives a steadier number that reflects the path rather than the moment.
It is tempting to think that the round trip is always the same on a given path. In fact the queue changes it from packet to packet, and the receiver can add delay. An acknowledgement may be held briefly so it can be sent with data, which makes that reply look slower than the network really was.
When to use it. Use round-trip time to judge how responsive a link is, to set timeouts, and to decide how many requests to send before waiting for replies. When it is not enough. It does not tell you the one-way speed of each direction, nor how much data the path can carry per second; those need Network Latency and the link rate.
History
In 1981 the TCP specification in RFC 793 kept a smoothed round-trip estimate and set the timeout as a multiple of it. In 1987 Phil Karn and Craig Partridge pointed out that resent packets must not feed into that estimate, which became Karn's rule. RFC 6298, published in 2011, standardised the method used today, including the smoothing weights of one eighth and one quarter. Measuring round trips is simple, but getting the estimate right took years, because the wrong samples could cause a flood of needless resends.
Recap
- Round-trip time is the time from sending a packet to receiving its acknowledgement.
- It is made of travel out, handling at the receiver, and travel back, plus any queueing or sending time along the way.
- Single samples are noisy, so senders keep a smoothed estimate that moves one eighth of the way toward each sample.
- Samples from resent packets are ignored, because the acknowledgement could answer either copy.
- What comes next: Retransmission Timeout uses the smoothed round-trip time, with a margin for variation, to decide when to resend. TCP is the protocol that runs this loop.