Search

Search papers and lessons

Round-Trip Time

Level 1 · 9 min read

Round-trip time is how long it takes for a message to reach the other side and for its reply to come back, and it is the number a sender uses to decide how long to wait.

On this page

  • Colour = topic mix
  • Algorithms
  • Networking
  • ReadReady to readNot yet

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.

  1. Send the packet. The sender records the time, t=0t = 0 ms. Check: this is the start of the clock for this round trip.

  2. 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.

  3. Travel to the receiver. The distance is 2,000 kilometres, so the signal takes 2,000÷200,000=0.012{,}000 \div 200{,}000 = 0.01 seconds, which is 10 milliseconds. Check: the packet arrives at 1+10=111 + 10 = 11 ms.

  4. 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.

  5. Send the acknowledgement back. The 40 bytes take 40÷1,000,000=0.0000440 \div 1{,}000{,}000 = 0.00004 seconds, which is 0.04 milliseconds, and the return travel takes another 10 milliseconds. Check: the acknowledgement arrives at 13+0.04+10=23.0413 + 0.04 + 10 = 23.04 ms.

  6. Read the clock. The sender subtracts its start time, 23.04−0=23.0423.04 - 0 = 23.04 ms. That is this packet's round-trip sample. Check: the parts add up, since 2020 ms of travel, 1.041.04 ms of sending and 22 ms of handling make 23.0423.04 ms.

  7. Repeat with a queue. Suppose the next packet waits 8 milliseconds behind other traffic at a router on the way out. Its sample is 23.04+8=31.0423.04 + 8 = 31.04 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 tsentt_{\text{sent}} be the time a packet leaves the sender and tackt_{\text{ack}} the time its acknowledgement arrives. A single round-trip sample is

R=tack−tsent.R = t_{\text{ack}} - t_{\text{sent}}.
Definition: Round-trip time

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, R=20+1.04+2=23.04R = 20 + 1.04 + 2 = 23.04 ms, where the three numbers are travel, sending and handling. Written as a sum over the trip out and back, R=(out)+(handling)+(back)R = (\text{out}) + (\text{handling}) + (\text{back}).

One sample is noisy

The sample RR 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 SRTT\text{SRTT} (smoothed round-trip time) that moves a small fraction of the way toward each new sample:

SRTT←78 SRTT+18 R.\text{SRTT} \leftarrow \tfrac78\,\text{SRTT} + \tfrac18\,R.

The weights 78\tfrac78 and 18\tfrac18 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 18\tfrac18 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

Example
1. One round trip, by hand (tiny)

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.

  1. Add the parts: 1+5+1+5=121 + 5 + 1 + 5 = 12 ms.
  2. Compute the sample: R=12−0=12R = 12 - 0 = 12 ms.
  3. Interpretation: the travel parts are most of the time, so a shorter cable would help more than a faster sender.
Example
2. Smoothing three samples (standard)

Start with SRTT=23.04\text{SRTT} = 23.04 ms, the first sample. Then two more samples arrive: R=31.04R = 31.04 ms (after the queue) and R=25R = 25 ms.

  1. Second sample: SRTT=78×23.04+18×31.04=20.16+3.88=24.04\text{SRTT} = \tfrac78 \times 23.04 + \tfrac18 \times 31.04 = 20.16 + 3.88 = 24.04 ms.
  2. Third sample: SRTT=78×24.04+18×25=21.035+3.125=24.16\text{SRTT} = \tfrac78 \times 24.04 + \tfrac18 \times 25 = 21.035 + 3.125 = 24.16 ms.
  3. Check: the estimate rose from 23.04 to 24.16 ms over the three samples, while the largest single sample was 31.04 ms.
  4. 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.
Example
3. A satellite path (realistic)

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.

  1. Travel: 240+240=480240 + 240 = 480 ms.
  2. Handling: 20 ms.
  3. Sample: R=480+20=500R = 480 + 20 = 500 ms, before any queueing.
  4. 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 SRTT\text{SRTT} become, if it was 125 ms before?

Answer: the sample is 60+60+5=12560 + 60 + 5 = 125 ms. Then SRTT=78×125+18×130=109.375+16.25=125.625\text{SRTT} = \tfrac78 \times 125 + \tfrac18 \times 130 = 109.375 + 16.25 = 125.625 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.

Check yourself

QuestionA packet is sent at time 0, and its acknowledgement arrives at 40 ms. What is the round-trip sample?Show answer
The round-trip sample is 40−0=4040 - 0 = 40 ms. It is the full time from sending to acknowledgement, including both directions and the receiver's handling.
QuestionA sender's current smoothed estimate is 100 ms. A new sample is 200 ms. Using the rule that moves one eighth of the way toward the sample, what is the new estimate?Show answer
The new estimate is 78×100+18×200=87.5+25=112.5\tfrac78 \times 100 + \tfrac18 \times 200 = 87.5 + 25 = 112.5 ms. The estimate moved 12.5 ms toward the sample, which is one eighth of the 100 ms gap.
QuestionWhy does a sender ignore the round-trip sample of a packet it has already resent?Show answer
The acknowledgement could be answering the first copy or the second, and the sender cannot tell which. The sample could be too short or too long, so using it would pull the estimate away from the true path delay.
QuestionTwo paths have the same travel time, but one has a busy router that adds 30 ms of queueing. Which path has the larger round-trip time, and what does the sender see?Show answer
The busy path has the larger round-trip time, by about 30 ms. The sender sees only the total, not which part is queueing, so its smoothed estimate rises and it waits longer before deciding a packet is lost.

Sources