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

195 Commits

Author SHA1 Message Date
Joseph Beshay
b45c82b884 ACK_EXTENDED frame support
Summary:
This introduces a new frame type for acks (ACK_EXTENDED) that can carry optional fields depending on the features supported by the peer. The currently supported features set will include ECN count fields, and Receive Timstamp fields. This enables a quic connection to report both ECN counts and receive timestamps, which is not possible otherwise because they use different frame types.

Support for the extended ack as well as the set of features that can be included in it is negotiated through a new transport parameter (extended_ack_supported = 0xff0a004). Its value indicates which features are supported by the local transport. The value is an integer which is evaluated against the following bitmasks:
```
  ECN_COUNTS = 0x01,
  RECEIVE_TIMESTAMPS = 0x02,
```

This diff introduces the transport parameter and negotiates the supported features between the peers of the connection. The parameter is cached in the psk cache so the client can remember the server config. It is also encoded inside the 0-rtt ticket so the server can reject it if its local config has changed.

The following diffs add reading and writing the frame itself.

The ACK_EXTENDED frame itself will have the following format
```
ACK_EXTENDED Frame {
  Type (i) = 0xB1
  // Fields of the existing ACK (type=0x02) frame:
  Largest Acknowledged (i),
  ACK Delay (i),
  ACK Range Count (i),
  First ACK Range (i),
  ACK Range (..) ...,
  Extended Ack Features (i),
  // Optional ECN counts (if bit 0 is set in Features)
  [ECN Counts (..)],
  // Optional Receive Timestamps (if bit 1 is set in Features)
  [Receive Timestamps (..)]
}

// Fields from the existing ACK_ECN frame
ECN Counts {
  ECT0 Count (i),
  ECT1 Count (i),
  ECN-CE Count (i),
}

// Fields from the existing ACK_RECEIVE_TIMESTAMPS frame
Receive Timestamps {
  Timestamp Range Count (i),
  Timestamp Ranges (..) ...,
}

Timestamp Range {
  Gap (i),
  Timestamp Delta Count (i),
  Timestamp Delta (i) ...,
}
```

Reviewed By: sharmafb

Differential Revision: D68931151

fbshipit-source-id: 44c8c83d2f434abca97c4e85f0fa7502736cddc1
2025-02-24 12:32:50 -08:00
Nicholas Ormrod
484898f61b facebook-unused-include-check in fbcode/quic
Summary:
Remove headers flagged by facebook-unused-include-check over fbcode.quic.

+ format and autodeps

This is a codemod. It was automatically generated and will be landed once it is approved and tests are passing in sandcastle.
You have been added as a reviewer by Sentinel or Butterfly.

Autodiff project: uiq
Autodiff partition: fbcode.quic
Autodiff bookmark: ad.uiq.fbcode.quic

Reviewed By: hanidamlaj

Differential Revision: D69864370

fbshipit-source-id: fb8f85599e1e12429f00dc2817dfc5ecf55bc482
2025-02-20 10:03:44 -08:00
Konstantin Tsoy
d98c90c48d Change onReadData() to return an error
Summary:
All according to plan: https://fburl.com/gdoc/pebccgi1
Changing function definitions to return errors while still throwing.

Reviewed By: sharmafb

Differential Revision: D69567329

fbshipit-source-id: 5d40ee32fe185d5674785632a9a13e4cef996988
2025-02-14 19:21:05 -08:00
Matt Joras
6a8f9bcb6b Add fixed short header padding
Summary: This adds a knob which puts a fixed amount of padding at the start of short header packets. This is useful to test the consequences of e.g. a larger CID or the impacts of a smaller packet size.

Reviewed By: jbeshay

Differential Revision: D69603113

fbshipit-source-id: b92ba78682eed21b7d75e38c9584a93481e2eb2f
2025-02-14 09:57:41 -08:00
Aman Sharma
f391bdac57 Make the QuicTransportBase -> QuicTransportBaseLite inheritance virtual
Summary: See title.

Reviewed By: mjoras

Differential Revision: D65688218

fbshipit-source-id: 1fcaf353f264191f411f0fd80be4cd7dbc3bb8ea
2024-12-04 18:39:15 -08:00
Alan Frindell
0c061201af Defer stream available callbacks until connCallback_ is set
Summary: If the peer sends higher stream limits in the settings, these callbacks may be invoked before the app has a chance to set the connection callback.

Reviewed By: sharmafb

Differential Revision: D64214648

fbshipit-source-id: 6a8a9b8d4d9e02a2baad672d69a43ba61daba918
2024-10-25 15:02:38 -07:00
Aman Sharma
c62dac180e Move core functionality to QuicTransportBaseLite [7/n]
Summary: See title.

Reviewed By: mjoras

Differential Revision: D64065113

fbshipit-source-id: 31f9a29a88bf763156d42c49df9db0f6f8e1a9d0
2024-10-09 17:37:33 -07:00
Matt Joras
cff1fd71dd Add option to adapt reordering threshold based on inflight packets.
Summary:
This is another attempt to have a more generous reordering threshold to avoid spurious loss. ngtcp2 has had this enabled by default for years.

The idea is basically to adapt it based on inflight packets, so allow up to half the inflight bytes of reordering at a time. This might be a better strategy than our existing code which uses spurious loss as lever to move reordering, since that can end up with cases where the threshold is permanently super high even if there's a period of quiescence.

Reviewed By: kvtsoy

Differential Revision: D64052908

fbshipit-source-id: 7cd80886c1de31a1056da827deb79f4d41313df8
2024-10-09 13:13:26 -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
55bf4a2d27 Move DSR-related APIs to QuicServerTransport
Reviewed By: mjoras

Differential Revision: D59768195

fbshipit-source-id: 8f0780019e5cd9bc3a3863fe30140b8da160c0bc
2024-07-31 10:48:06 -07:00
Roey Maor
9db087cada Fix: connectionId list destructed while in use in QuicServerWorker
Summary: When QuicServerWorker runs onConnectionUnbound, it gets a list of connections ids to erase. This list is passed by reference, and was destructed while being iterated on, resulting in invalid memory access.

Reviewed By: mjoras

Differential Revision: D58529542

fbshipit-source-id: fdec343d11c59174c8ab01a040c8dae2cbf9016f
2024-06-23 22:43:51 -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
Ido Shoshani
cee162311b Personalized CWND Initial Setup
Summary: Set up the foundation for personalized cwnd. During the `onReadData` method, the `cwndHint` from the client will be checked. At that point the client will be classified as a "weak", "moderate", or "strong" connectivity client. Assuming there is at least one sample RTT and the new cwnd value is larger than the current one, the congestion controller will be reinitialized with the higher cwnd value.

Reviewed By: jbeshay, pfarcasanu

Differential Revision: D57211407

fbshipit-source-id: 2157d02cf0baf1d7b31d617cf4801584d8e1c678
2024-05-16 23:49:06 -07:00
Hani Damlaj
125cd69ef4 introduce handleHandshakeWriteDataCommon
Summary: - as title, code de-dup

Reviewed By: sharmafb

Differential Revision: D55901184

fbshipit-source-id: c45cb07fc0f13360925bafce75f0a4e2d6910269
2024-05-16 20:45:24 -07:00
Hani Damlaj
9084526f80 introduce handleInitialWriteDataCommon
Summary: - as title; code de-dup

Reviewed By: sharmafb

Differential Revision: D55901183

fbshipit-source-id: 4eae4f2c87c16a413d92c5a724baa35a8f796810
2024-05-16 20:45:24 -07:00
Joseph Beshay
7f2cb16408 Refactor QuicClient and Server transports to process ReceivedUdpPackets with attached metadata
Summary: ReceivedUdpPacket has attached metadata (currently timings and later in the stack, tos values). Rather than passing the metadata separately in the read path for the client and the server, this propagates the ReceivedUdpPacket further up so this metadata is easier to use in the rest of the stack.

Reviewed By: mjoras

Differential Revision: D54912162

fbshipit-source-id: c980d5b276704f5bba780ac16a380bbb4e5bedad
2024-05-09 11:05:32 -07:00
Joseph Beshay
97f7515e65 Set a default congestion controller factory for client and server transports
Summary: As title.

Reviewed By: robspychala, mjoras

Differential Revision: D56717332

fbshipit-source-id: 73973a4a721cf4101a6cf441a006b7860ccf7f4e
2024-05-02 11:41:32 -07:00
Aman Sharma
875bca11da Make a getPeerTransportParams function
Summary: I'm putting this up to get some initial feedback. I'm writing a function to get the peer transport parameters so that we can get them in the HQSession and set the QUIC fingerprint.

Reviewed By: hanidamlaj

Differential Revision: D54399572

fbshipit-source-id: 594294c26a5b34bc99a8d286a66be9cdbe7fff02
2024-04-08 17:57:40 -07:00
Konstantin Tsoy
19908073de Add a knob for AUTOTUNE_RECV_STREAM_FLOW_CONTROL
Summary: Add a knob for AUTOTUNE_RECV_STREAM_FLOW_CONTROL

Reviewed By: mjoras

Differential Revision: D55538812

fbshipit-source-id: b9903b27b4d0f8814811547448b34619d11a8dc3
2024-04-04 16:11:54 -07:00
Konstantin Tsoy
b87afe5d93 Add a knob for USE_NEW_STREAM_BLOCKED_CONDITION
Summary: Add a knob for USE_NEW_STREAM_BLOCKED_CONDITION

Reviewed By: mjoras, sharmafb

Differential Revision: D55529514

fbshipit-source-id: ff578115141169e3f9710fd1b642b14c99251547
2024-04-04 16:11:54 -07:00
Phillip Prigozhiy
08ad34b2d6 Add getSelfCertificate to QuicServerTransport
Summary: Adding virtual method getSelfCertificate to QuicSocket that's overriden in QuicServerTransport that returns the server cert.

Reviewed By: mjoras

Differential Revision: D54234662

fbshipit-source-id: fcef6399bc660ff41243336aacdfadd6e8975193
2024-03-12 12:10:49 -07:00
Yedidya Feldblum
f8ccdde463 migrate from FOLLY_MAYBE_UNUSED to [[maybe_unused]]
Reviewed By: ot, Orvid, xinchenguo

Differential Revision: D54089810

fbshipit-source-id: c88eb520404590c9759e0e29966d1399c26a2244
2024-02-28 13:28:26 -08:00
Joseph Beshay
738178ea72 Client key update support: Expose a quic transport knob for enabling server-initiated key updates [4/x]
Summary: As title. Valid knob value range for KEY_UPDATE_INTERVAL is [1K, 8M] packets.

Reviewed By: mjoras

Differential Revision: D53335118

fbshipit-source-id: 2741763c34c07eb98c820c794c9aafe2625c00de
2024-02-26 20:25:11 -08:00
Max Motovilov
db6e2321f9 QuicServerTransport now accepts abstract socket and event base in constructor
Summary: Replaced folly-specific argument types in constructor with abstract interfaces. Existing code unaffected.

Reviewed By: jbeshay, sharmafb

Differential Revision: D53493336

fbshipit-source-id: 67f5ef4a38995a2554084f2d75399b13887eb500
2024-02-23 07:33:00 -08:00
Joseph Beshay
702ce9e410 Key update support: Add quic transport stats for key update [5/x]
Summary: Adds new stats for: key updates initiated, received and succeeded.

Reviewed By: mjoras

Differential Revision: D53109623

fbshipit-source-id: 1c9473590a54135662a9cdd8c240a3225246c432
2024-02-01 15:41:27 -08:00
Joseph Beshay
aeacf40ae8 Key update support: Add support for initiating periodic key updates for both client and server [4/x]
Summary:
Allow the server/client transport to initiate periodic key update. It's defaulted to being disabled.

The new logic for initiating and verifying a key update was handled correctly by the peer is consolidated in QuicTransportFunctions.

Reviewed By: mjoras

Differential Revision: D53109624

fbshipit-source-id: 0c3a944978fc0e0a84252da953dc116aa7c26379
2024-02-01 15:41:27 -08:00
Joseph Beshay
cf6f6b98ec Fix active connection counter in QuicStats, and make it work for the client too
Summary:
The current open connection counting is broken. To fix it this change:
- moves the counter to be for both the server and client transport
- calls onNewConnection() when the transport is ready.
- calls onConnectionClose() when the transport is closed after it was ready.

Reviewed By: lnicco, frankfeir

Differential Revision: D52638628

fbshipit-source-id: bcff7a8c671f8eede53c22e698e1b95332c56959
2024-01-12 08:59:15 -08:00
Joseph Beshay
ead139adef Move all mvfst use-cases to the new Eventbase, Timer, and Socket interfaces
Summary:
This is the major transition that updates mvfst code to use the new interfaces. The new Folly implementations of the interfaces maintain all the existing behavior of folly types so this should not introduce any functional change. The core changes are:
- Update the BatchWriters to use the new interfaces.
- Update the FunctionLooper to use the new interfaces.
- Change QuicServerTransport to take the folly types and wrap them in the new types for use in the QuicTransportBase.

The rest of the diff is for updating all the existing uses of the QuicTrasnport to initialize the necessary types and pass them to the QUIC transport instead of directly passing folly types.

Reviewed By: mjoras

Differential Revision: D51413481

fbshipit-source-id: 5ed607e12b9a52b96148ad9b4f8f43899655d936
2023-12-14 00:24:12 -08:00
Kyle Nekritz
8c68b18df3 Unconditionally defer control of writing session tickets to quic layer.
Summary: There is no reason to let the TLS layer control this.

Reviewed By: jbeshay

Differential Revision: D51267586

fbshipit-source-id: 6f70b7f6ba51a9a022195f7e2c1683b5323fde7a
2023-11-29 18:06:03 -08:00
Brandon Schlinker
83ad2ad99d Cleanup and modularize receive path, improve timestamp support [20/x]
Summary:
This diff renames `ReceivedPacket` to `ReceivedUdpPacket` to clarify that it maps to a UDP packet and not a QUIC packet. A single UDP packet can contain multiple QUIC packets due to coalescing.

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps.

Reviewed By: silver23arrow

Differential Revision: D48788809

fbshipit-source-id: 3793c30212d545e226f3e5337289bc2601dfa553
2023-11-28 07:47:57 -08:00
Joseph Beshay
c1432e1c7b Do not update handshake-related transport settings from the 0-rtt ticket
Summary:
When the server accepts a 0-rtt ticket, it updates the connection's transport settings with the contents of the ticket. This is the value used included in the next ticket it sends the client. However, the handshake layer has a copy of the original transport parameters that was created with the first received packet. This copy in the handshake layer does not get updated. This can cause a mismatch between the value sent to the client in the handshake, and the value encoded inside the ticket.

This change avoid using the 0-rtt ticket for updating any transport settings that are also included in the handshake transport params.

Reviewed By: hanidamlaj

Differential Revision: D51121317

fbshipit-source-id: 55e71965185dff553d16d4c5fbcb1e2f9acdc690
2023-11-10 14:27:23 -08:00
Brandon Schlinker
04facac67d Cleanup and modularize receive path, improve timestamp support [15/x]
Summary:
This diff drops `NetworkDataSingle` in favor of `ReceivedPacket`. The latter contains a `ReceivedPacket::Timings` field that has the same `receiveTimePoint` currently in `NetworkDataSingle`, while also providing other useful signals.

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps

Reviewed By: silver23arrow

Differential Revision: D48739219

fbshipit-source-id: fc2cdb7b425d68c729dd3bec00b6c6ff3c4bf8ec
2023-11-05 19:58:46 -08:00
Brandon Schlinker
05b98a99db Cleanup and modularize receive path, improve timestamp support [11/x]
Summary:
This diff:
1. Introduces a new `ReceivedPacket::Timings` structure, which will be expanded upon in subsequent diffs.
2. Adds a `ReceivedPacket::Timings` field to each `ReceivedPacket`
3. Uses the accessors added in the previous diff (D48724715) to populate the `ReceivedPacket::Timings` structure in each `ReceivedPacket` held by a `NetworkData` object. This is done by propagating the `NetworkData::receiveTimePoint` field to all `ReceivedPacket` held in a `NetworkData.` This propagation occurs each time a `ReceivedPacket` is added. The value is propagated again if the `NetworkData::receiveTimePoint` field is updated by looping over all previously added `ReceivedPacket`.

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps.

Reviewed By: jbeshay

Differential Revision: D48725209

fbshipit-source-id: 580e7d7d1f3587f9947774b5ed19e9985df404c9
2023-11-05 19:58:46 -08:00
Timm Böttger
5fca38ef00 Use MaybeManagedPtr for QuickSocket for optional lifetime management
Summary:
`connSetupCallback_` and `connCallback_` in `QuicTransportBase.h` are raw pointers, which delegates the responsibility to keep these callbacks alive to the caller.

There are use cases where it would be convenient to be able to tie the lifetime of the callback to the Quic transport, e.g,. as long as the Quic transport is alive, it keeps the callbacks alive as well.

This diff uses MaybeManagedPtr to achieve this lifetime tie if desired. A MaybeManagedPtr intialized with a shared pointer manages lifetime of the contained object, whereas a MaybeManagedPtr initialized with a raw pointer does not manage lifetime of the contained object. This way caller can decide to pass in a shared ptr or raw pointer and achieve the desired behavior.

Note that we cannot simply use a shared_ptr for that. Using a shared_ptr would potentially mean that callbacks passed are destroyed when the transport is destroyed. Callbacks would not be destroyed if they were managed by a shared_ptr already, but this is something we cannot assume for every case. This would thus be a change in semantics to the current implementation, where the callbacks can outlive the transport.

Reviewed By: mjoras

Differential Revision: D49502381

fbshipit-source-id: 771a9328b99dc4f94f8e9679f9caf98af9180428
2023-11-03 09:37:21 -07:00
Joseph Beshay
71e0934e13 Allow including a cwnd_hint in the 0-rtt app token
Summary: This enables the server to include a cwnd hint in the 0-rtt ticket it sends to the client.

Reviewed By: mjoras

Differential Revision: D43131826

fbshipit-source-id: 742e4e531027ec6618a1b761c450b507368e5a2f
2023-10-25 09:45:07 -07:00
Brandon Schlinker
a1445434b0 Cleanup and modularize receive path, improve timestamp support [5/x]
Summary:
This diff changes `QuicAsyncUDPSocketWrapper` so that it is an abstraction layer that inherits from `QuicAsyncUDPSocketType`, instead of simply being a container with aliases.
- Key changes in `QuicAsyncUDPSocketWrapper.h`, the rest of the updates switch us from using `QuicAsyncUDPSocketType` to `QuicAsyncUDPSocketWrapper`.
- It's difficult to mock the UDP socket today given that we expose the entire `folly::AsyncUDPSocket` type to the higher layers of the QUIC stack. This complicates testing and emulation because any mock / fake has to implement low level primitives like `recvmmsg`, and because the `folly::AsyncUDPSocket` interface can change over time.
- Pure virtual functions will be defined in `QuicAsyncUDPSocketWrapper` in a follow up diff to start creating an interface between the higher layers of the mvfst QUIC stack and the UDP socket, and this interface will abstract away lower layer details such as `cmsgs` and `io_vec`, and instead focus on populating higher layer structures such as `NetworkData` and `ReceivedPacket` (D48714615). This will make it easier for us to mock or fake the UDP socket.

This diff relies on changes to `folly::MockAsyncUDPSocket` introduced in D48717389.

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps.

Reviewed By: jbeshay, hanidamlaj

Differential Revision: D48717388

fbshipit-source-id: 4f34182a69ab1e619e454da19e357a6a2ee2b9ab
2023-09-21 07:57:58 -07:00
Brandon Schlinker
086822ca76 Cleanup and modularize receive path, improve timestamp support [2/x]
Summary:
This diff:
- Changes `NetworkDataSingle` to have `ReceivedPacket` instead of `Buf`, in line with earlier change to `NetworkData` in D48714615

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps.

Reviewed By: mjoras

Differential Revision: D48714796

fbshipit-source-id: d96c2abc81e7c27a01bcd0dd552f274a0c1ede26
2023-09-21 07:57:58 -07:00
Konstantin Tsoy
264bf20d9a Update flow control settings names to reflect that these are indeed flow
Summary: Update flow control settings names to reflect that these are indeed flow control

Reviewed By: jbeshay

Differential Revision: D48137685

fbshipit-source-id: a48372e21cdd529480e25785a9bd5de456427ef3
2023-08-18 10:21:24 -07:00
Joseph Beshay
db728cd1a3 Add CONN_MIGRATION knob to enable/disable connection migration at the server
Summary: As title.

Reviewed By: kvtsoy

Differential Revision: D48246018

fbshipit-source-id: 9d905035d11d8d34586b5a7deaf0c7b379a39048
2023-08-16 10:24:01 -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
Joseph Beshay
d85f726e36 Consolidate logic for setting the congestion controller in one function
Summary: Ensure all CCA-related settings are included in setCongestionControl(), and that it's called from the knob setting the congestion controller.

Reviewed By: kvtsoy

Differential Revision: D47741830

fbshipit-source-id: ff1d2347581c61a58f2caaff8189126930bf4e04
2023-07-25 19:48:01 -07:00
Facebook Community Bot
9d89b66485 Re-sync with internal repository 2023-07-25 09:45:22 -07:00
Joseph Beshay
cbc802ea1a Remove 3 unused quic transport knobs
Summary: As title.

Reviewed By: kvtsoy

Differential Revision: D47534110

fbshipit-source-id: f613c012004315134db114f9f0f026455c8d8d8d
2023-07-24 20:00:07 -07:00
Joseph Beshay
7db19c1f19 Add new CC_CONFIG knob to dynamically control CCA features
Summary:
Adds a new CC_CONFIG knob that carries a JSON blob that gets parsed into the transportSetting.ccaConfig struct.

Sample knob values:
```
{"52397": "{\"conservativeRecovery\": false}"}
{"52397": "{\"conservativeRecovery\": true, \"ackFrequencyConfig\":{\"minRttDivisor\": 77}}"}
```

Reviewed By: hanidamlaj

Differential Revision: D47309438

fbshipit-source-id: 0a4e941b9e4231bd333174472827044b1b49ac96
2023-07-14 14:55:29 -07:00
Joseph Beshay
471fa6f8dc Change BBRConfig to CongestionControlConfig
Summary: Rename transportSetting.BBRConfig to CongestionControlConfig to prepare it for being used by other CCAs too.

Reviewed By: hanidamlaj, mjoras

Differential Revision: D47309439

fbshipit-source-id: 56d0ddc9752789709c54a4f7cc595f94c656e49e
2023-07-14 14:55:29 -07:00
Konstantin Tsoy
4a0dd1e2a4 QuicAsyncUDPSocketWrapper
Reviewed By: jbeshay

Differential Revision: D46379200

fbshipit-source-id: f6a7c1cf68108872e05e6fd8adb7f00aae22b2ed
2023-07-11 15:21:15 -07:00
generatedunixname89002005287564
131da0d4bd quic_0
Reviewed By: DenisYaroshevskiy

Differential Revision: D47061673

fbshipit-source-id: c3e06ffc905015fa5e54a98dc67efe5732d700fe
2023-06-28 07:23:56 -07:00
Hani Damlaj
debb68639d remove WindowedCounter
Summary: as title, cleaning up some unused files & references

Reviewed By: mjoras

Differential Revision: D46843918

fbshipit-source-id: 08be5696d76f4f23df0f07bfd1ede5703d358691
2023-06-26 22:16:40 -07:00
Joseph Beshay
931abc64af Separate transport settings for pacing tick and the pacing timer resolution
Summary:
The pacingTimerTickInterval transport setting conflates two options: the minimum interval a pacer can use, and the resolution of the underlying timer. This means that a higher value leads to lower timer resolution and less pacing accuracy.

This change adds a separate parameter for the timer resolution to ensure that a larger pacing tick does not degrade the pacer accuracy.

Reviewed By: mjoras

Differential Revision: D46564066

fbshipit-source-id: 0d0e54077b80da03e6e6c9baaab49a4c969966b6
2023-06-20 15:18:38 -07:00