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

243 Commits

Author SHA1 Message Date
Jolene Tan
389dd667ed Add new QUIC version MVFST_EXPERIMENTAL5
Summary: Add new QUIC version MVFST_EXPERIMENTAL5 with same salt as MVFST_EXPERIMENTAL4

Reviewed By: mjoras

Differential Revision: D73285467

fbshipit-source-id: 2d4b8828574f604dab1072847149a5cff2964209
2025-04-23 20:59:46 -07:00
Aman Sharma
a934b46f49 Introduce a Cursor typealias
Summary: See title

Reviewed By: kvtsoy

Differential Revision: D73474979

fbshipit-source-id: 7048d75e79e619917b226bfc2b90bcd2248e44eb
2025-04-23 10:07:20 -07:00
Aman Sharma
41667ff7c5 Change Buf -> BufPtr and RawBuf -> Buf
Summary:
Previously,
* `RawBuf` was a typealias for `std::unique_ptr<folly::IOBuf>`
* `Buf` was a typealias for `folly::IOBuf`

In this diff,
* `Buf` is a typealias for `folly::IOBuf`
* `BufPtr` is a typealias for `std::unique_ptr<folly::IOBuf>`

Reviewed By: hanidamlaj

Differential Revision: D73206576

fbshipit-source-id: 454bf6ccfce3d6571e5e931889263ed98cc24af3
2025-04-21 20:14:02 -07:00
Matt Joras
1468b24044 Remove throws from handshake layers
Summary: Continuing the theme. This removes it from client and server handshakes.

Reviewed By: kvtsoy

Differential Revision: D73335422

fbshipit-source-id: 262bad17c1ebd2bcef623b1185e38e6a63ec714b
2025-04-21 12:06:59 -07:00
Matt Joras
4d621341ca Remove throws from ServerStateMachine
Summary: More in the theme.

Reviewed By: kvtsoy

Differential Revision: D73277850

fbshipit-source-id: 30afb267cb5b2d2df9ae90f2f93e34f092a09c91
2025-04-19 15:20:15 -07:00
Matt Joras
2a8fba588f Propagate error in scheduleFramesForPacket and writeData
Summary: As in title, this is more of a theme on adding an Expected return.

Reviewed By: kvtsoy

Differential Revision: D72579218

fbshipit-source-id: 25735535368838f1a4315667cd7e9e9b5df1c485
2025-04-08 21:06:35 -07:00
Matt Joras
67ce39cfdd Remove exception throwing from the stream manager and flow control.
Summary: I started with the QuicStreamManager, but it turns out that the path from the manager up to the close path touches a LOT, and so this is a big diff. The strategy is basically the same everywhere, add a folly::Expected and check it on every function and enforce that with [[nodiscard]]

Reviewed By: kvtsoy

Differential Revision: D72347215

fbshipit-source-id: 452868b541754d2ecab646d6c3cbd6aacf317d7f
2025-04-07 23:45:33 -07:00
Abdulbaki Aydin
9805b1f24d Add more initial packet and tls handshake logging
Summary:
Adds more logging for:
- Number of initial packets received
- Number of unique crypto frames received
- Time elapsed to get the last meaningful initial crypto frame.
- named groups, psk status, and ech status from TLS layer.

Reviewed By: mjoras

Differential Revision: D71910754

fbshipit-source-id: ea8524213ba296727079800bb167ec080143c10b
2025-04-04 15:48:09 -07:00
Matt Joras
58eb799ea0 Remove throws from read codec.
Summary: This is a step towards removing exceptions entirely from this path. Mostly involves a mass conversion to folly::Expected and adding a CodecResult that conveys the errors.

Reviewed By: kvtsoy

Differential Revision: D71704941

fbshipit-source-id: a35825b75bf53e252cef8cbf851e2e670209e8de
2025-03-27 11:13:33 -07:00
Joseph Beshay
7f65f36b62 Cache the negotiated config for ACKs once the transport parameters are received
Summary: Cache the negotiated config for what ACK type to write and which fields to use once the peer transport parameters are available. This avoids computing the config with every ack frame being written.

Reviewed By: sharmafb

Differential Revision: D70004436

fbshipit-source-id: 79354f5137c77353c3a97d4c41782a700622e986
2025-02-24 12:32:50 -08:00
Joseph Beshay
31fbb343d1 Decode ACK_EXTENDED frame
Summary:
Add functionality for decoding the new ACK_EXTENDED frame.

Frame 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: D68931149

fbshipit-source-id: 7eab52449db60fc41a5bf9aa48c0f695ccaca3f0
2025-02-24 12:32:50 -08:00
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
Konstantin Tsoy
93aff1cc9c Remove FrameType from QuicException
Summary: Not used

Reviewed By: hanidamlaj

Differential Revision: D69569612

fbshipit-source-id: 72e6c6a52dacbc06e825bc4123022dbc3c8af785
2025-02-14 19:21:05 -08:00
Aman Sharma
0411554224 Throw exception upon receiving reliable reset
Summary: For now, we're going to throw an exception when we get a RESET_STREAM_AT frame, which would terminate the connection. Later on, this logic is going to be gated on whether we and the peer support reliable resets (and we get to know this through the transport parameters).

Reviewed By: jbeshay

Differential Revision: D67866393

fbshipit-source-id: 6b2888c026fadf0f2aa5dad52314ed8250959cf6
2025-01-07 13:33:37 -08:00
Aman Sharma
ae011587d5 Add reliable_stream_reset transport parameter
Summary: This diff adds the reliable_stream_reset transport parameter to mvfst.

Reviewed By: hanidamlaj

Differential Revision: D65383676

fbshipit-source-id: cb2f6a1a90004ea489447b67ed3cfc12ca90b804
2024-12-17 11:53:15 -08:00
Aman Sharma
fca90d483b Keep track of the minimum reliable size ACKed
Summary:
With normal resets, we transition from `StreamSendState::ResetSent` to `StreamSendState::Closed` when we get an ACK for a RESET_STREAM frame.

With reliable resets, this is going to be a little more complicated. We can't automatically transition from `StreamSendState::ResetSent` to `StreamSendState::Closed` when we get an ACK for a RESET_STREAM_AT frame because it's possible that the peer hasn't yet received all data until the reliable reset offset.

My idea is the following: Keep track of the `minReliableSizeAcked`, which is the lowest value of the reliable size in any RESET_STREAM_AT frame that was ACKed by the peer. We set it to 0 if a RESET_STREAM frame was ACKed by the peer.

Then, we can transition from `StreamSendState::ResetSent` to `StreamSendState::Closed` if any one of the following two events happen:
* We get an ACK for a RESET_STREAM_AT or a RESET_STREAM frame, and all data until the `minReliableSizeAcked` has been ACKed by the peer.
* We get an ACK for stream data, and this puts us in a state where all data until the `minReliableSizeAcked` has been ACKed by the peer.

Note: This diff doesn't have any functional change. The only change is that we're keeping track of the `minReliableSizeAcked`, but aren't using it anywhere.

Reviewed By: mjoras

Differential Revision: D66781199

fbshipit-source-id: 2aa5138a18f70e9801e59e747460558ba706939c
2024-12-10 16:39:37 -08:00
Kyle Nekritz
abb06d9b95 Improve server packet drop logging.
Summary:
Provide a more detailed reason why we dropped a packet to the stats
callback and qlog.

Reviewed By: hanidamlaj

Differential Revision: D66171930

fbshipit-source-id: 4cf10b149d1184afb7b268ac8f229555d2ffb75d
2024-11-20 15:06:28 -08:00
Joseph Beshay
51c796444f Use MVFST_EXPERIMENTAL to override bbr with bbr2
Summary: As title.

Reviewed By: kvtsoy

Differential Revision: D65921195

fbshipit-source-id: 14b72b672f3b236ea5366827c199f8809a8900d1
2024-11-15 20:28:26 -08:00
Aman Sharma
efba61871f Create a RST_STREAM_AT frame type and decoding functionality
Summary:
You can find the format of the RST_STREAM_AT frame in the [RFC](https://datatracker.ietf.org/doc/html/draft-ietf-quic-reliable-stream-reset-06#name-reset_stream_at-frame). In this change, I'm adding RST_STREAM_AT to the FrameType enum and am also adding the functionality to decode such frames.

Note that we ignore the case when we receive RST_STREAM_AT frames (because we haven't implemented their handler yet).

Reviewed By: hanidamlaj

Differential Revision: D64836490

fbshipit-source-id: 5bd742b14c343ce2f26dd29d3a285a6fed60676a
2024-11-15 12:33:48 -08:00
Jolene Tan
1fa1a2adee Add new QUIC version MVFST_EXPERIMENTAL4 with new salt
Reviewed By: mjoras

Differential Revision: D63144092

fbshipit-source-id: ed6c2df8e6b3f87a3e8ee64859b765b6580d7207
2024-09-23 14:19:42 -07:00
Joseph Beshay
93d38a9d8d Schedule an ack immediately when a packet marked with ECN CE is received
Summary:
Timely reaction to congestion requires relaying any CE marks to the sender as soon as possible.

This change schedules an ack to be sent whenever incoming packets are received with CE marks. This will only happen when the readEcnOnIngress option is enabled.

Reviewed By: mjoras

Differential Revision: D58423959

fbshipit-source-id: 30f8cf8b11d0446985c2d87d7df67c24c0d5afdf
2024-06-12 12:08:04 -07:00
Matt Joras
e903f277da Introduce OptionalIntegral and OptionalMicros
Summary: We have a lot of optionals that are either integral values or std::chrono::microseconds. These end up wasting memory, where we can instead store sentinel values to encode whether the value is there or not. This reduces the effective range of the type by one value, but that is an acceptable tradeoff.

Reviewed By: kvtsoy

Differential Revision: D57684368

fbshipit-source-id: b406b86011f9b8169b6e5e925265f4829928cc63
2024-06-11 11:02:02 -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
ab89d67538 Change version to MVFST_EXPERIMENTAL
Reviewed By: pfarcasanu

Differential Revision: D57501391

fbshipit-source-id: 2552df59912470045741ae44e53b68cf1db01982
2024-05-20 10:27:47 -07:00
Konstantin Tsoy
9d16a6ebea Add another QUIC version alias
Summary: Add another QUIC version alias

Reviewed By: sharmafb

Differential Revision: D57233430

fbshipit-source-id: 7536e5bb13b84ca3e2de818fdc05adf894831ccb
2024-05-15 14:06:27 -07:00
Joseph Beshay
9add439090 Maitain ingress ECN counts in the AckState for writing ACKs
Summary:
Keep track of ECN values in incoming packets and update the AckState that is used for echoing the counts to the peer in ACK_ECN frames.

Reading and writing the ACK_ECN frames is in the next change.

Reviewed By: kvtsoy

Differential Revision: D54927783

fbshipit-source-id: 44471c6224ee8578aaacc0d1a1c54370ef6d2ffe
2024-05-15 11:51:15 -07:00
Joseph Beshay
3eef6d0e55 Add ToS field to ReceivedUdpPacket
Summary: Adds new field `tosValue` to  ReceivedUdpPacket so it is accessible in the rest of the read path.

Reviewed By: kvtsoy

Differential Revision: D54912161

fbshipit-source-id: ea4714fa2374d38e915fc850387e1094d1fb8adf
2024-05-15 11:51:15 -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
6e1db76335 Add ccaConfig param for startup pace gain
Summary: As title.

Reviewed By: mjoras

Differential Revision: D56425968

fbshipit-source-id: 79d6566ae66aa1c63d44d33e83565d9b11e8d329
2024-04-22 18:46:43 -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
Joseph Beshay
c18463599c Refactor ack visitor into separate packet and frame visitors
Summary:
The current ackVisitor passed to processAckFrame() gets executed with every acked frame.

Not every check in that visitor needs to be performed for every frame.

This refactors it into two different visitors, one that is called once per acked packet and another that is called once per acked frame.

Reviewed By: mjoras

Differential Revision: D56090734

fbshipit-source-id: 7b0877684e439f9e88c0aae7a294245570cf8309
2024-04-16 12:38:44 -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
Luca Niccolini
0aa19f6897 Use MVFST_EXPERIMENTAL for cwnd tuning
Reviewed By: mjoras

Differential Revision: D55938590

fbshipit-source-id: d8dd289aa18796343580db074b17c6d9d5ef8b68
2024-04-10 15:29:35 -07:00
Hani Damlaj
1730ed8a73 fix numMigrations increment
Summary: we should only increment numMigrations if the peer is attempting migration from a previously unseen addr

Reviewed By: kvtsoy, sharmafb

Differential Revision: D55884605

fbshipit-source-id: 9204ed785195a321d7f8f7497151b7cfe5f745f7
2024-04-09 10:47:55 -07:00
Luca Niccolini
70e6ffdd7d Release MVFST_EXPERIMENTAL version
Reviewed By: jbeshay

Differential Revision: D55318823

fbshipit-source-id: 08310dc49821f5604f062d42d6f3eb60e09d8a89
2024-03-25 12:57:16 -07:00
Matt Joras
9a3451228a Cap max send packet size at max instead of default.
Summary: We currently cap the max send size at the default instead of the max we support (1452). This is pretty conservative and I don't think it's needed, and causes issues when trying to use MASQUE + UDP proxying with QUIC.

Reviewed By: hanidamlaj

Differential Revision: D53440189

fbshipit-source-id: 1d5bbdbb4cc1abb677f85dff6bdf2841cb01c5e1
2024-02-06 12:14:59 -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
bff30c1f7a Key update support: Server response to key updates [1/x]
Summary:
This stack adds key update support to Mvfst client and server. This diff adds the main logic for detecting key updates in the QuicReadCodec. When an update is successful, the server transport reacts to it by updating the write phase and cipher.

The high level design is as follows:
- The QuicReadCodec is responsible for detecting incoming key update attempts by the peer, as well as tracking any ongoing locally-initiated key updates.
- Upon detecting a successful key update, the QuicReadCodec updates its state. The Server/Client transport reacts to this change by updating its write phase and cipher.
- A locally initiated key update starts with updating the write phase and key, and signaling the read codec that a key update has been initiated.
- The read codec keeps this in a pending state until a packet is successfully received in the new phase.
- Functions for syncing the read/write phase on incoming key updates, as well as initiating and verifying outgoing key updates are abstracted in QuicTransportFunctions and are used by both the client and server transports.
- Common handshake functions used for rotating the keys are now in HandshakeLayer that is shared by both client and server handshakes.

Reviewed By: mjoras

Differential Revision: D53016559

fbshipit-source-id: 134e965dabd62917193544a9655a4eb8868ab7f8
2024-02-01 15:41:27 -08:00
Hani Damlaj
6a3fd0b7f2 consolidate setSupportedExtensionTransportParameters
Summary: - remove duplicated function `setSupportedExtensionTransportParameters` in QuicClient & QuicServer

Reviewed By: jbeshay

Differential Revision: D50933970

fbshipit-source-id: f5ae1a9739d316165a5759c68076ec2152f641c6
2023-12-03 22:26:40 -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
Brandon Schlinker
d9f0575c62 Cleanup and modularize receive path, improve timestamp support [19/x]
Summary:
This diff renames `updateLargestReceivedPacketNum` to `addPacketToAckState`, and changes the function signature so that it takes the structure of `ReceivedPacket::Timings` instead of just a single receive timestamp. This allows us to plumb through steady clock and socket timestamps.

The current caller to `updateLargestReceivedPacketNum` had a `ReceivedPacket::Timings` and just passed the`receiveTimePoint` field from that structure to to `updateLargestReceivedPacketNum`

```
uint64_t distanceFromExpectedPacketNum = updateLargestReceivedPacketNum(
    conn, ackState, packetNum, readData.udpPacket.timings.receiveTimePoint);
```

Now, we just pass the entire `ReceivedPacket::Timings` structure and extract `receiveTimePoint` inside:

```
uint64_t distanceFromExpectedPacketNum = addPacketToAckState(
    conn, ackState, packetNum, readData.udpPacket.timings);
```

--

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.

Differential Revision: D48785086

fbshipit-source-id: 48a424e3e27918a8efe41918e0bcfa57337d9337
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
Hani Damlaj
4eefa3bebd remove QuicVersion::QUIC_DRAFT
Summary: - as title, deprecate QuicVersion::QUIC_DRAFT

Reviewed By: jbeshay

Differential Revision: D50466992

fbshipit-source-id: 2b2776d142142bc07fd27053a68dd635959a7f31
2023-11-09 19:30:07 -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
Paul Farcasanu
77b0940dc5 log cwnd hint bytes to ODS
Reviewed By: jbeshay

Differential Revision: D50753856

fbshipit-source-id: 6e2aba9138f96b175ecb4a7667579ca4547eaa70
2023-11-03 16:15:42 -07:00
Hani Damlaj
8f742114d9 remove CustomTransportParameter
Summary: deprecate CustomTransportParameter in favour of ::encodeIntegerParameter

Reviewed By: mjoras

Differential Revision: D50461613

fbshipit-source-id: 86ac95e6f871cef9cb819673387d65f5de42a0b8
2023-11-02 06:01:16 -07:00
Hani Damlaj
905554ecd3 remove setCustomTransportParameter helper function
Summary:
- Remove setCustomTransportParameter, which (based on the quic v19 rfc), verifies whether a parameter is within the private range [0xff00, 0xffff]

> Values with the first byte in the range 0x00 to 0xfe (in hexadecimal) are assigned via the Specification Required policy [RFC8126].

- Consolidating adding MaxStreamGroups transport parameter into all other transport parameters extension.

More specifically, `QuicClientTransport::maybeEnableStreamGroups()` logic is now moved into `QuicClientTransport::setSupportedExtensionTransportParameters()`

Reviewed By: mjoras

Differential Revision: D50461610

fbshipit-source-id: 802b546c8364586cdcf36a230b156ca140c57ce4
2023-11-02 06:01:16 -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