Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcp: Add RTT estimation. #406

Merged
merged 2 commits into from
Jan 4, 2021
Merged

tcp: Add RTT estimation. #406

merged 2 commits into from
Jan 4, 2021

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Jan 4, 2021

  • Add a RTT estimator implementing the algorithm from Van Jacobson's original paper
  • Use its output as the retransmission timeout, instead of the previous hardcoded 100ms.

This massively improves performance in slow networks such as 3G/4G/LTE.

Tested against a Linux stack, simulating latency with netem. For example, to add a delay of 100ms with 40ms of jitter:

sudo tc qdisc replace dev tap0 root netem delay 100ms 40ms

Testing shows this eliminates all the unnecessary retransmissions:

Before:

3303	2758.061630482	192.168.69.1	192.168.69.100	TCP	1514	1234 → 36492 [PSH, ACK] Seq=81921 Ack=1 Win=2048 Len=1460
3304	2758.061769051	192.168.69.100	192.168.69.1	TCP	54	36492 → 1234 [ACK] Seq=1 Ack=81921 Win=107904 Len=0
3305	2758.061888699	192.168.69.1	192.168.69.100	TCP	642	1234 → 36492 [PSH, ACK] Seq=83381 Ack=1 Win=2048 Len=588
3306	2758.162142016	192.168.69.1	192.168.69.100	TCP	1514	[TCP Out-Of-Order] 1234 → 36492 [ACK] Seq=81921 Ack=1 Win=2048 Len=1460
3307	2758.162170291	192.168.69.1	192.168.69.100	TCP	642	[TCP Retransmission] 1234 → 36492 [PSH, ACK] Seq=83381 Ack=1 Win=2048 Len=588
3308	2758.177570006	192.168.69.100	192.168.69.1	TCP	66	[TCP Dup ACK 3304#1] 36492 → 1234 [ACK] Seq=1 Ack=81921 Win=107904 Len=0 SLE=79873 SRE=81333
3309	2758.189322198	192.168.69.100	192.168.69.1	TCP	66	[TCP Dup ACK 3304#2] 36492 → 1234 [ACK] Seq=1 Ack=81921 Win=107904 Len=0 SLE=81333 SRE=81921
3310	2758.219241882	192.168.69.100	192.168.69.1	TCP	66	[TCP Dup ACK 3304#3] 36492 → 1234 [ACK] Seq=1 Ack=81921 Win=107904 Len=0 SLE=79873 SRE=81333
3311	2758.219306221	192.168.69.1	192.168.69.100	TCP	1514	[TCP Fast Retransmission] 1234 → 36492 [ACK] Seq=81921 Ack=1 Win=2048 Len=1460
3312	2758.219313302	192.168.69.1	192.168.69.100	TCP	642	[TCP Retransmission] 1234 → 36492 [PSH, ACK] Seq=83381 Ack=1 Win=2048 Len=588
3313	2758.238660869	192.168.69.100	192.168.69.1	TCP	66	[TCP Dup ACK 3304#4] 36492 → 1234 [ACK] Seq=1 Ack=81921 Win=107904 Len=0 SLE=81333 SRE=81921
3314	2758.244392088	192.168.69.100	192.168.69.1	TCP	54	36492 → 1234 [ACK] Seq=1 Ack=83381 Win=110848 Len=0
3315	2758.244469607	192.168.69.1	192.168.69.100	TCP	1514	1234 → 36492 [PSH, ACK] Seq=83969 Ack=1 Win=2048 Len=1460
3316	2758.297758461	192.168.69.100	192.168.69.1	TCP	54	36492 → 1234 [ACK] Seq=1 Ack=83969 Win=113792 Len=0
3317	2758.297899404	192.168.69.1	192.168.69.100	TCP	642	1234 → 36492 [PSH, ACK] Seq=85429 Ack=1 Win=2048 Len=588
3318	2758.375412811	192.168.69.100	192.168.69.1	TCP	66	[TCP Dup ACK 3316#1] 36492 → 1234 [ACK] Seq=1 Ack=83969 Win=113792 Len=0 SLE=81921 SRE=83381
3319	2758.394315585	192.168.69.100	192.168.69.1	TCP	66	[TCP Dup ACK 3316#2] 36492 → 1234 [ACK] Seq=1 Ack=83969 Win=113792 Len=0 SLE=83381 SRE=83969
3320	2758.398778234	192.168.69.1	192.168.69.100	TCP	1514	[TCP Fast Retransmission] 1234 → 36492 [ACK] Seq=83969 Ack=1 Win=2048 Len=1460
3321	2758.398808674	192.168.69.1	192.168.69.100	TCP	642	[TCP Retransmission] 1234 → 36492 [PSH, ACK] Seq=85429 Ack=1 Win=2048 Len=588
3322	2758.493322989	192.168.69.100	192.168.69.1	TCP	66	[TCP Dup ACK 3316#3] 36492 → 1234 [ACK] Seq=1 Ack=83969 Win=113792 Len=0 SLE=81921 SRE=83381

After: 

2498	2712.377287021	192.168.69.1	192.168.69.100	TCP	642	1234 → 36480 [PSH, ACK] Seq=73141 Ack=1 Win=2048 Len=588
2499	2712.593987771	192.168.69.100	192.168.69.1	TCP	54	36480 → 1234 [ACK] Seq=1 Ack=73141 Win=81664 Len=0
2500	2712.594025393	192.168.69.1	192.168.69.100	TCP	1514	1234 → 36480 [PSH, ACK] Seq=73729 Ack=1 Win=2048 Len=1460
2501	2712.594416483	192.168.69.100	192.168.69.1	TCP	54	36480 → 1234 [ACK] Seq=1 Ack=73729 Win=84608 Len=0
2502	2712.594431805	192.168.69.1	192.168.69.100	TCP	642	1234 → 36480 [PSH, ACK] Seq=75189 Ack=1 Win=2048 Len=588
2503	2712.811480972	192.168.69.100	192.168.69.1	TCP	54	36480 → 1234 [ACK] Seq=1 Ack=75189 Win=87552 Len=0
2504	2712.811611744	192.168.69.1	192.168.69.100	TCP	1514	1234 → 36480 [PSH, ACK] Seq=75777 Ack=1 Win=2048 Len=1460
2505	2712.830381768	192.168.69.100	192.168.69.1	TCP	54	36480 → 1234 [ACK] Seq=1 Ack=75777 Win=90368 Len=0
2506	2712.830516297	192.168.69.1	192.168.69.100	TCP	642	1234 → 36480 [PSH, ACK] Seq=77237 Ack=1 Win=2048 Len=588
2507	2713.009748718	192.168.69.100	192.168.69.1	TCP	54	36480 → 1234 [ACK] Seq=1 Ack=77237 Win=93312 Len=0

Copy link
Contributor

@whitequark whitequark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is an excellent addition!

@Dirbaio Dirbaio merged commit 318ad8a into master Jan 4, 2021
@Dirbaio Dirbaio deleted the rto branch January 4, 2021 14:58
@jordens
Copy link

jordens commented Jan 4, 2021

Adding a line to the list in the README for this would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants