1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-07 22:46:22 +03:00
Commit Graph

95 Commits

Author SHA1 Message Date
Jolene Tan
599d410b01 Only skip cloned CRYPTO packet if same as most recent outstanding packet
Summary:
In CloningScheduler, in the loop for selecting a candidate packet for cloning under the "cloneAllPacketsWithCryptoFrame" mode of operation, skip a packet containing a CRYPTO frame only if both it and the most recent outstanding packet are clones of the same packet.

Otherwise, it would clone the CRYPTO packets no more than once.

Reviewed By: mjoras

Differential Revision: D64411438

fbshipit-source-id: eac9e3dbb4c6d2536b1259af08f3c9647ef06ad8
2024-10-15 18:04:35 -07:00
Jolene Tan
c2715ab822 Clone and schedule all packets containing CRYPTO frames
Summary:
A packet in the CloningScheduler can be in three states:

1. Not cloned yet
2. Cloned, not processed yet
3. Cloned and processed

Currently, CloningScheduler will clone a packet in state 1, moving it to state 2, and continue cloning the packet while it is in state 2 without proceeding to subsequent packets.

This change makes it so that a packet in state 2 that has a CRYPTO frame will be skipped over, so that the next packet (which will be in state 1) has a chance to also be cloned.

Extra: Fix `DoNotCloneProcessedClonedPacket` to have the first packet be the already-processed one. If the second packet is the only one already processed, then of course the first one would be scheduled, letting the test speciously pass.

Reviewed By: mjoras

Differential Revision: D62770483

fbshipit-source-id: 5b00958ab4a787615338debacbe9bd2a0f6f74a4
2024-09-23 13:09:46 -07:00
Konstantin Tsoy
7f00a211df Remove a dead method
Summary: Remove a dead method

Reviewed By: sharmafb

Differential Revision: D62256646

fbshipit-source-id: 153514882a39f0a99e7446bfeaebf514a041dfd2
2024-09-05 15:25:19 -07:00
Aman Sharma
8e650ed585 Rename PacketEvent -> ClonedPacketIdentifier [take 2]
Summary: This is my second attempt at D61871891. This time, I ran `xplat/cross_plat_devx/somerge_maps/compute_merge_maps.py`, which generated quic/somerge_defs.bzl

Reviewed By: kvtsoy

Differential Revision: D61975459

fbshipit-source-id: bec62acb2b400f4a102574e8c882927f41b9330e
2024-08-30 12:18:20 -07:00
Marshall Mann-Wood
457ae5b1ac Revert D61871891: Rename PacketEvent -> ClonedPacketIdentifier
Differential Revision:
D61871891

Original commit changeset: f9c626d900c8

Original Phabricator Diff: D61871891

fbshipit-source-id: afe88d4b7a2ca62b16e122d9f087df3caf3e0f41
2024-08-28 16:13:54 -07:00
Aman Sharma
6f13f404b0 Rename PacketEvent -> ClonedPacketIdentifier
Summary: `PacketEvent` is a very inaccurate and misleading name. We're basically using this as an identifier for cloned packets, so `ClonedPacketIdentifier` is a much better.

Reviewed By: kvtsoy

Differential Revision: D61871891

fbshipit-source-id: f9c626d900c8b7ab7e231c9bad4c1629384ebb77
2024-08-28 14:26:30 -07:00
Aman Sharma
bc386475e5 Integrate RangeChain into write path of QUIC stack
Summary: See title

Reviewed By: mjoras

Differential Revision: D58216871

fbshipit-source-id: 9afc08946a676ec967c998416a6470d4884af550
2024-08-15 05:46:08 -07:00
Aman Sharma
a84708be4b Less direct Buf access in BufAccessor
Summary:
**Context**
The `BufAccessor` is used to access a contiguous section of memory. Right now, it works with a `Buf` under the hood.

**Overall plan**
The plan is to change the `BufAccessor` to use a `uint8_t*` instead. Since we're using section of contiguous memory, there's no need to use a chained buffer abstraction here. This'll move us closer to deprecating the usage `folly::IOBuf`.

**What this diff is doing**
Most use cases of the `BufAccessor` look like the following:
```
auto buf = bufAccessor.obtain();
// Do something with buf, like calling trimEnd
bufAccessor.release(buf)
```
I'm adding APIs to the `BufAccessor` so that there's no need to `obtain()` and `release()` the `Buf`. We'd instead just call an API on the `BufAccessor`, which would call that same API on the underlying `folly::IOBuf`. Later on, we'll change the `BufAccessor` to use a `uint8_t*` under the hood.

I'm currently leaving in the `obtain()`, `release()`, and `buf()` APIs because Fizz and the AsyncUDPSocket expect `folly::IOBuf` as inputs in many of their APIs. Once those callsites are migrated off `folly::IOBuf`, we can remove these APIs.

Reviewed By: mjoras

Differential Revision: D60973166

fbshipit-source-id: 52aa3541d0c4878c7ee8525d70ac280508b61e24
2024-08-09 14:35:39 -07:00
Matt Joras
aefc9e369b Introduce quic::Optional
Summary:
The idea here is to make it so we can swap out the type we are using for optionality. In the near term we are going to try swapping towards one that more aggressively tries to save size.

For now there is no functional change and this is just a big aliasing diff.

Reviewed By: sharmafb

Differential Revision: D57633896

fbshipit-source-id: 6eae5953d47395b390016e59cf9d639f3b6c8cfe
2024-06-11 11:02:02 -07:00
Joseph Beshay
9f5d8c333a Read/write ECN counts in ACK_ECN frame
Summary:
Read echoed ECN counts from incoming ACK_ECN frames.
Write ECN counts from AckState into outgoing ACK_ECN frames.

This also logs both the ECN counts in the read/writter packets in qlog.

Reviewed By: kvtsoy

Differential Revision: D54967248

fbshipit-source-id: 68b910865515271abfd1fa61fc43ce1cb12f30a7
2024-05-15 11:51:15 -07:00
Alan Frindell
ee90db8520 Aggregate QUIC stats callbacks
Summary: This reduces the number of stats callbacks when processing multiple packets in rapid succession.

Reviewed By: mjoras

Differential Revision: D56315022

fbshipit-source-id: 750024301f28b21e3125c144ead6f115706736a4
2024-04-21 16:38:06 -07:00
Andres Suarez
71fac54812 Apply clang-format 18
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
2024-04-14 11:28:32 -07:00
Christian Clauss
b8396fc119 Fix typos discovered by codespell
Summary:
`codespell --ignore-words-list=arithmetics,atleast,crate,crated,deriver,ect,hel,onl,startin,whats --skip="*.lock"`
* https://pypi.org/project/codespell

X-link: https://github.com/facebookincubator/mvfst/pull/307

Reviewed By: hanidamlaj, lnicco

Differential Revision: D47809078

Pulled By: kvtsoy

fbshipit-source-id: 566557f2389746db541ff265a5dec8d6404b3701
2023-07-26 17:10:41 -07:00
Konstantin Tsoy
73edee8252 Back out "Fix typos discovered by codespell"
Summary:
Original commit changeset: 337824bc37bc

Original Phabricator Diff: D47722462

Reviewed By: jbeshay, terrelln, lnicco

Differential Revision: D47801753

fbshipit-source-id: 795ffcccbc2223608e2a707ec2e5bcc7dd974eb3
2023-07-26 12:49:13 -07:00
Facebook Community Bot
9d89b66485 Re-sync with internal repository 2023-07-25 09:45:22 -07:00
Matt Joras
6ecdb35ade Minimum packets per stream before next() moves forward
Summary:
The idea here is to allow a way to do incremental stream priorities while switching between streams as aggressively.

Achieving this is somewhat tricky. The easiest place to track this is to make it so the iterator in QuicPriorityQueue no-op next() until a counter reaches an increment.

This is especially impacftul for DSR, where round robining per packet is almost pathologically bad both for CPU impact but also spurious losses and low bandwidth estimates.

Thoughts?

(Note: this ignores all push blocking failures!)

Reviewed By: kvtsoy

Differential Revision: D46268308

fbshipit-source-id: cd5b924141365f61f8a3363bc9cb38a62e5c94cf
2023-06-01 14:11:31 -07:00
Matt Joras
35a2d34843 Use a single queue for scheduling DSR and non-DSR streams.
Summary:
The write loop functions for DSR or non-DSR are segmented today. As such, so are the schedulers. Mirroring this, we also currently store the DSR and non-DSR streams in separate write queues. This makes it impossible to effectively balance between the two without potential priority inversions or starvation.

Combining them into a single queue eliminates this possibility, but is not entirely straightforward.

The main difficulty comes from the schedulers. The `StreamFrameScheduler` for non-DSR data essentially loops over the control stream queue and the normal write queue looking for the next stream to write to a given packet. When the queues are segmented things are nice and easy. When they are combined, we have to deal with the potential that the non-DSR scheduler will hit a stream with only DSR data. Simply bailing isn't quite correct, since it will just cause an empty write loop. To fix that we need check, after we are finished writing a packet, if the next scheduled stream only has DSR data. If it does, we need to ensure `hasPendingData()` returns false.

The same needs to be done in reverse for the DSR stream scheduler.

The last major compication is that we need another loop which wraps the two individual write loop functions, and calls both functions until the packet limit is exhausted or there's no more data to write. This is to handle the case where there are, for example, two active streams with the same incremental priority, and one is DSR and the other is not. In this case each write loop we want to write `packetLimit` packets, flip flopping between DSR and non DSR packets.

This kind of round robining is pathologically bad for DSR, and a future diff will experiment with changing the round robin behavior such that we write a minimum number of packets per stream before moving on to the next stream.

This change also contains some other refactors, such as eliminating `updateLossStreams` from the stream manager.

(Note: this ignores all push blocking failures!)

Reviewed By: kvtsoy

Differential Revision: D46249067

fbshipit-source-id: 56a37c02fef51908c1336266ed40ac6d99bd14d4
2023-06-01 14:11:31 -07:00
Matt Joras
b257b1fe24 Unify and move receive timestamp config
Summary: We shouldn't have config in the codec types. Instead solve the plumbing problem more explicitly, and only define the config in one place.

Reviewed By: jbeshay

Differential Revision: D45881730

fbshipit-source-id: fab6c967a38172f16e57a8978b10460fd196902e
2023-05-17 11:59:53 -07:00
Paul Farcasanu
36c85fa724 Introduce an Iterator class in PriorityQueue
Summary: The abstraction layer here was not great

Reviewed By: afrind

Differential Revision: D43427138

fbshipit-source-id: 7fb7cfe278995e58f05bda3354ef53bc407af2a2
2023-03-23 10:43:24 -07:00
Konstantin Tsoy
377260f704 Remove d6d code
Summary: we're not using it

Reviewed By: mjoras

Differential Revision: D43482344

fbshipit-source-id: 05ac6792848e32e7c1bcf53a2df172852b5def62
2023-02-23 20:11:24 -08:00
Brandon Schlinker
87d00ece35 Fix dependency loop and improve namings
Summary:
Fixing dependency loop introduced by D37799050 (96abc8160d)

Running `autodeps` yields the following patch:

```
 --- a/xplat/quic/state/TARGETS
+++ b/xplat/quic/state/TARGETS
@@ -43,8 +43,8 @@
     exported_deps = [
         "//folly:random",
         "//quic:constants",
+        "//quic/codec:codec",
         "//quic/codec:types",
-        "//quic/common:circular_deque",
         "//quic/common:interval_set",
     ],
 )
```

If this patch is applied, there is a circular dependency loop between `//quic/codec:codec` and `//quic/state:ack_states` by way of `//quic/codec:types`; this loop was introduced by D37799050 (96abc8160d).

Fixed by separating out headers files and targets. In parallel, renamed structures used for writing ACK frames (which were the reason this loop occurred) to make their role clear.

Differential Revision: D42281359

fbshipit-source-id: 8514c99f3fe72ff1d942d7f303e4a209838c7623
2023-01-05 15:20:44 -08:00
Matt Joras
bdcffae366 Fix edgecase around writing FIN in a non-DSR stream frame.
Summary:
We previously made the decision to disallow the writing of a FIN on a DSR stream from a non-DSR stream frame as there's not really much value in allowing it.

The code that was previously allowing this to work has a bad bug. If the DSR bytes for a stream were written completely before the non-DSR bytes had been written, the scheduling code would set `canSetFin = true`, which would cause a FIN to be written at the `bufMetaStartingOffset`. This would race with the FIN sent by the backend and, if not cause a connection error, cause an HTTP truncated body of length 0.

We can avoid this by finishing the job of not allowing DSR streams to be FIN'd by non-DSR stream frames.

Reviewed By: hanidamlaj

Differential Revision: D41479274

fbshipit-source-id: 66b321db72fdb4a16378e33048e3fb97133ced92
2022-11-23 10:40:15 -08:00
Sharad Jaiswal (Eng)
96abc8160d Codec changes to support ACK_RECEIVE_TIMESTAMPS
Summary: Create a new ACK_RECEIVE_TIMESTAMPS frame, as outlined in https://www.ietf.org/archive/id/draft-smith-quic-receive-ts-00.html#name-ack_receive_timestamps-fram

Reviewed By: mjoras

Differential Revision: D37799050

fbshipit-source-id: 0157c7fa7c4e489bb310f7c9cd6c0c1877e4967f
2022-11-16 13:02:27 -08:00
Matt Joras
03e314a3a4 Separately track streams by DSR and non DSR data lost.
Summary: We need to do this to maintain consistency with the schedulers. Prior to this fix when we ran out of connection flow control and had lost DSR data the non-DSR stream scheduler would do an empty write _and_ the DSR stream scheduler would do an empty write. To fully resolve the issue we need to track the streams separately (note that the same stream can be in both sets).

Reviewed By: jbeshay

Differential Revision: D40003361

fbshipit-source-id: fd3e567bc8a2bc8b71d4c4543894053fa6e24dc4
2022-10-03 17:02:52 -07:00
Joseph Beshay
9b3a6c0249 If an initial packet is written, its padding should be allowed to bypass the cwnd
Summary:
When 0-rtt is used and an initial packet is lost, the retransmission of this packet may end up shorter than allowed because the padding frames are subject to the cwnd.

This change makes the padding of initial packets not subject to the cwnd.

Reviewed By: mjoras

Differential Revision: D39594390

fbshipit-source-id: 2d714c921f243f8a59577a6edaaeaa1c7e2be815
2022-09-19 17:39:32 -07:00
Joseph Beshay
abee1d8387 Add IMMEDIATE_ACK frame
Summary: Add the new IMMEDIATE_ACK frame from the ack frequency draft.

Reviewed By: mjoras

Differential Revision: D38523438

fbshipit-source-id: 79f4a26160ccf4333fb79897ab4ace2ed262fa01
2022-08-24 11:11:33 -07:00
Konstantin Tsoy
be0cd3dacc Minor clean up
Summary: Minor clean up

Reviewed By: mjoras

Differential Revision: D35510673

fbshipit-source-id: fcd6982dd49a08ac2c9e2148b1cfd5beec9f49dd
2022-06-15 19:03:04 -07:00
Konstantin Tsoy
4faaa83642 Codec writing/reading of stream group ids
Summary: Add writing and reading of stream group ids

Reviewed By: mjoras

Differential Revision: D36415929

fbshipit-source-id: 650bb8d6f81b2014741a517b165b4d27b7b6c0fe
2022-06-03 15:47:17 -07:00
Konstantin Tsoy
1a07e916eb Ship empty PTO fix
Summary: Ship empty PTO fix

Reviewed By: mjoras

Differential Revision: D36534424

fbshipit-source-id: a1ce2f8a48d947dccd96c677dec20bbc1659c150
2022-05-23 11:25:26 -07:00
Konstantin Tsoy
d31df23ca5 Do not add ack frames to packet when it was rebuilt in cloning scheduler
Summary:
We may end up writing acks after a length-less stream frame and it
will be considered garbage data by the peer. The acks will be written later as
usual, outside of cloning scheduler.

Reviewed By: mjoras

Differential Revision: D35561912

fbshipit-source-id: 9334523b984870fa525c856a504ae7d2ae4f34c3
2022-04-12 09:38:19 -07:00
Konstantin Tsoy
42d13f54ae Do not emit empty PTO packets
Summary: Do not emit empty PTO packets

Reviewed By: mjoras

Differential Revision: D34944343

fbshipit-source-id: a49d82cc3d137ed7f113a8e5adab54c84e0e72d0
2022-03-17 08:48:28 -07:00
Hani Damlaj
00e67c1bf9 mvfst License Header Update
Reviewed By: lnicco

Differential Revision: D33587012

fbshipit-source-id: 972eb440f0156c9c04aa6e8787561b18295c1a97
2022-01-18 13:56:12 -08:00
Hani Damlaj
2660a288b3 Update Company Name
Summary: - as title

Reviewed By: lnicco

Differential Revision: D33513410

fbshipit-source-id: 282b6f512cf83b9abb7990402661135b658f7bd1
2022-01-13 12:07:48 -08:00
Kyle Mirzakhanian
29ed688b58 Add padding to QUIC short header packets
Summary:
Adds paddingModulo to QuicPacketBuilder, which pads up short header packets so that the length remaining of a packet is a multiple of paddingModulo

ie a message of length 25 and max packet size of 40 with a paddingModulo of 8 will get 7 padding frames to a total length of 32. (and a message of length 26 will get 6 padding frames to also go up to a total length of 32)

Reviewed By: mjoras

Differential Revision: D32858254

fbshipit-source-id: 99ada01108429db9f9bba1e342daf99e80385179
2022-01-07 15:02:05 -08:00
Luca Niccolini
95ff9198dd Fix Datagram Write in case there is no space in the QUIC packet
Summary: When there is not enough space in the QUIC packet to write a datagram frame, we should not dequeue the datagram

Reviewed By: mjoras

Differential Revision: D33109603

fbshipit-source-id: 937a5a0ffe55c7f88e39faf224e7ad06ca599708
2021-12-16 11:45:07 -08:00
Matt Joras
ca4705af0b If there's lost data, we have data to write, take 2.
Summary:
This is a bug that could prevent us from writing data if we ran out of connection flow control while we had lost data.

The last attempt missed a mistake in the scheduling of sequential priority streams.

Reviewed By: kvtsoy

Differential Revision: D33030784

fbshipit-source-id: e1b82234346a604875a9ffe9ab7bc5fb398450ed
2021-12-14 09:18:01 -08:00
Matt Joras
5b9a9705a0 Back out "If there's lost data, we have data to write."
Summary: This is causing empty write loops for some reason.

Reviewed By: jbeshay, lnicco

Differential Revision: D32990291

fbshipit-source-id: 2a183d591de54c7fe0ca54aea828a697a4cd9af0
2021-12-09 14:35:24 -08:00
Matt Joras
d6a876f201 If there's lost data, we have data to write.
Summary: This is an edge case we weren't handling properly. This can lead to situations where we run out of conn flow control, the peer hasn't received all data, and then we never write the data to trigger a flow control update.

Reviewed By: afrind

Differential Revision: D32887140

fbshipit-source-id: df5dfad8e0775ef43e5ca6ab98b8ca6b5987ce31
2021-12-07 18:19:58 -08:00
Luca Niccolini
264610f1a1 c++ is hard
Reviewed By: mjoras

Differential Revision: D32854076

fbshipit-source-id: 2e6d4e4f349f80d9874aa47fd0426388b6639fbe
2021-12-03 16:28:53 -08:00
Luca Niccolini
324d819795 add stats for quic datagram
Summary: Add stats for quic datagrams

Reviewed By: afrind

Differential Revision: D32600300

fbshipit-source-id: 79ebcec5bd090dad16f81237b6b2c0fe4c0f2af6
2021-12-01 00:13:03 -08:00
Luca Niccolini
4a75224cc9 Don't drop datagrams if the frame has no room for them
Reviewed By: afrind, mjoras

Differential Revision: D32608442

fbshipit-source-id: fbd5de333571a2855d8243e7987b5e98ded527fb
2021-12-01 00:13:03 -08:00
Matt Joras
003f012cb7 TODO comment cleanup.
Summary:
These are either no longer relevant, are unlikely to be done, or are spculative enough that they don't deserve code space.

Hope here is to make our search for TODOs higher signal.

Reviewed By: lnicco

Differential Revision: D29769792

fbshipit-source-id: 7cfa62cdc15e72d8b7b0cd5dbb5913ea3ca3dc5a
2021-07-20 10:27:32 -07:00
Dead Code Bot
c85ec4dbd3 Remove dead includes in quic
Reviewed By: yangchi

Differential Revision: D29696307

fbshipit-source-id: 8cc3d23c792734a117caa7490e420c17fb869eb4
2021-07-14 11:16:20 -07:00
Luca Niccolini
4acc7dc355 Implement one Datagram Frame per packet, and discard policy on rx/tx paths
Reviewed By: mjoras

Differential Revision: D28167755

fbshipit-source-id: b589376800742dfe167f1efe193f0fe059b18ab4
2021-06-13 21:13:19 -07:00
Yang Chi
0e6a998e05 Fix QUIC EOF sending when DSR is used
Summary:
This is a bug fix. When a stream finished sending all it's BufMetas, it can
send EOF from frontend QUIC host. In that case, it will use
currentWriteOffset value which is wrong.

This diff changes it so that (1) frontend can only write FIN only frame if
writeBufMeta's offset is <= finalWriteOffset; (2) When it writes such frame
it will use finalWriteOffset as the offset value in the frame.

Reviewed By: lnicco

Differential Revision: D28727029

fbshipit-source-id: 8f963c2e2d66f921f8a9704ed4671ec4f7c04df7
2021-06-01 13:16:20 -07:00
Joseph Beshay
ffab50b5b7 Use fresh ACK state when rebuilding ACK frames
Summary:
When rebuilding outstanding packets, if the packet contains an ACK, use a fresh ACK state instead of the potentially stale one from the outstanding packet.

Collateral changes:
- The AckVisitor logic in processAckFrame now visits AckFrames all the time. This is to guarantee that they are visited even if they belong to cloned packets. The behavior for all other frame types remains unchanged.
- If rebuilding the AckFrame is not successful, it is ignored. The rest of the clone packet is still sent.

I have tried to address all the concerns that were previously raised on D27377752

Reviewed By: yangchi

Differential Revision: D28659967

fbshipit-source-id: fc3c76b234a6e7140dbf038b2a8a44da8fd55bcd
2021-05-26 13:41:43 -07:00
Luca Niccolini
f778cfb945 Quic Socket: Datagram APIs
Summary: quic socket API to send and receive datagrams

Reviewed By: mjoras, yangchi

Differential Revision: D20983884

fbshipit-source-id: 70332c5fb9c37c88150fc2f623521e7b0c991eae
2021-05-11 08:24:03 -07:00
Yang Chi
62b0d8b879 QUIC flow control accounts for DSR bytes
Summary:
This was completely missing previously, which led to Client quickly
shutting down a connection with flow control violation when server oversends in
DSR mode.

Reviewed By: mjoras

Differential Revision: D27940953

fbshipit-source-id: 5644c1a3da5217365df9de33258bb5b071ff8187
2021-05-05 09:47:46 -07:00
Yang Chi
cdacec015a QuicServerTransport write DSR packetization requests
Summary:
This diff hooks the DSR write function into QuicServerTransport's
write path.

Reviewed By: mjoras

Differential Revision: D27890711

fbshipit-source-id: ac4452373c0baafe091f93fb54fccf87be604a9c
2021-05-04 01:08:16 -07:00
Yang Chi
4ab385c216 Do not use the regular CloningScheduler to clone DSR packet
Summary: For now let it fallback to ping.

Reviewed By: mjoras

Differential Revision: D27481741

fbshipit-source-id: 874529a06ab882d9651e06f615bc82505c1c2872
2021-04-19 11:08:26 -07:00