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

70 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
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
Konstantin Tsoy
7edd37b537 Remove useless include
Summary: Remove useless include

Reviewed By: JunqiWang

Differential Revision: D69568927

fbshipit-source-id: d635777f899915867d3538efe6bd31cb23755591
2025-02-14 19:21:05 -08:00
Joseph Beshay
cab3f2c3b4 Refactor ACK decoding for the different ACK types
Summary: Separate functionality for parsing receive timestamp and ecn fields in ACKs into their own functions.

Differential Revision: D68931150

fbshipit-source-id: 8031770b118138a0002999bca52c69f96f29b617
2025-02-13 17:48:18 -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
Aman Sharma
3f27fdebd9 Rename offset in RstStreamFrame to finalSize
Summary: This will make it easier to distinguish between the `finalSize` and the `reliableSize` when we implement reliable resets

Reviewed By: hanidamlaj

Differential Revision: D64836474

fbshipit-source-id: d811d64a2538d4d1acba1ea10a7790d5905f02a4
2024-11-14 11:36:01 -08:00
Giuseppe Ottaviano
cd4268b8f8 IOBuf moveToFbString().toStdString() -> to<std::string>()
Summary: Constructing an `fbstring` from an `IOBuf` and then converting that to `std::string` is inefficient: if the `IOBuf` is chained, that can end up copying the data twice. `to<std::string>()` does exactly one copy.

Reviewed By: mjoras

Differential Revision: D58379802

fbshipit-source-id: a1094dd63ae00fc123e0d695a800a017004562e9
2024-06-12 12:03:12 -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
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
Luca Niccolini
c276e9b2f8 Do not adjust delay when exponent is out of bounds
Summary: as title

Reviewed By: silver23arrow, kvtsoy

Differential Revision: D52737239

fbshipit-source-id: 9a9d37dc0cb11f009e3429dede8325b6690b3b46
2024-01-12 16:10:50 -08:00
Hani Damlaj
711f0e30fc Back out "BufQueue::trimAtMost"
Summary:
Original commit changeset: 0ace20d07d8b

Original Phabricator Diff: D46776767

Reviewed By: lnicco

Differential Revision: D47007928

fbshipit-source-id: 6c8760683692d1b50168f8f5d82d79c98ebe7c31
2023-06-25 16:44:20 -07:00
Hani Damlaj
aff02e01ee BufQueue::trimAtMost
Summary:
- trimAtMost() can be implemented via splitAtMost()

- trimAtMost() now releases owned IOBuf if the entire chain is consumed

Reviewed By: mjoras

Differential Revision: D46776767

fbshipit-source-id: 0ace20d07d8b9adc1a5171e39732b8278776c332
2023-06-21 10:07:07 -07:00
Sharad Jaiswal (Eng)
d42d303e9d Adjusted delay computation should flag long delay error only for ACK delays
Summary:
the helper function `Decode.cpp:computeAdjustedDelay()` function takes a delay value, applies an exponent adjustment, and performs checks for overflow and validity before returning the adjusted delay.

This function is used to decode both the ack_delay, as well as the relative time-gap between  RX time-stamps.

Additional logging collected via D41988681 and multiple long-running canaries indicate the "long ack delay error" that is flagged when the decoded value > 1000secs, occurs only when decoding rx timestamps.

The first rx timestamp in any ack_receive_timestamp range has a relative delay computed with the connection start time as a basis, hence on long lived connections this can exceed > 1000secs (the current threshold for the error message).

Therefore, we have moved the error statement (and the error check) to be only at the call site processing ack delays (and not rx timestamp relative delays).

Reviewed By: bschlinker, mjoras

Differential Revision: D46059268

fbshipit-source-id: 2637986d5919207b6c7d858a69b33139dad785e7
2023-05-23 16:35:59 -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
Matt Joras
bc1277caa0 Store less metadata for padding frames.
Summary:
Padding frames by definition have no semantics. There also can be quite a large number of them, which makes their storage expensive.

Optimize for this by effectively coalescing multiple contiguous padding frames into a single frame.

(Note: this ignores all push blocking failures!)

Reviewed By: kvtsoy

Differential Revision: D44636497

fbshipit-source-id: 4c1cd88123c4fdf40ec9c553885f46669f7326da
2023-04-18 11:47:11 -07: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
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
Joseph Beshay
1e594fe1ba Update ACK_FREQUENCY frame
Summary:
- Use varint reordering threshold (this is still being discussed, using varint until a decision is made)
- Track server's minAckDelay on client
- Track ack frequency frame sequence number
- Improve frame parsing error logs
- Add some unit tests

Reviewed By: hanidamlaj

Differential Revision: D38289108

fbshipit-source-id: 274e45115022ffd4e15b60dc57f77f1cce69bd82
2022-08-24 11:11:33 -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
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
Hani Damlaj
7233c55d29 Issue NewTokenFrame To Clients
Summary:
- Issuing NewTokenFrames to clients, allowing them to verify their address in subsequent connections by including the token.
- add NewTokenFrame struct in the union type QuicSimpleFrame.
- Issued only once when the crypto handshake is complete.
- Testing includes validating token serialization & deserialization and asserting that the NewTokenFrame is only issued once on handshake completeness.

Reviewed By: mjoras

Differential Revision: D31673160

fbshipit-source-id: 9401ab1a4b878d8b4380d55afa531ec768f5f4cd
2021-12-10 20:35:49 -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
Luca Niccolini
e39bf5f447 parse and write DATAGRAM Frames
Summary: This diff is the encode and decode support of Datagram frame.

Reviewed By: mjoras, yangchi

Differential Revision: D20983883

fbshipit-source-id: 1a72a87e6ce3601b71fececca872a9d20bf7820e
2021-05-04 10:53:00 -07:00
Eric Christoffersen
aac8f1ac91 Check for max streams id limits when decoding MAX_STREAMS frame
Summary:
Checks that MaxStreamsId is in range during MaxStreamsFrame decode, otherwise throws exception.

Added tests for MaxStreamsFrame decode.

Reviewed By: mjoras

Differential Revision: D27520634

fbshipit-source-id: f903763781639d078f92080b98f15b97e04a8d60
2021-04-05 16:22:01 -07:00
Matt Joras
382c1cdcc6 Remove partial reliability from mvfst.
Summary: As in title.

Reviewed By: yangchi

Differential Revision: D26701886

fbshipit-source-id: c7b36c616200b17fbf697eff4ba0d18695effb45
2021-03-03 15:30:21 -08:00
Matt Joras
21f190220e Implement basic ACK_FREQUENCY support.
Summary: As in title. This doesn't actually send any frames, but implements basic support for the transport parameter and responding to the frames.

Reviewed By: yangchi

Differential Revision: D26134787

fbshipit-source-id: 2c48e01084034317c8f36f89c69d172e3cb42278
2021-02-02 19:02:40 -08:00
Andres Suarez
05d07cbfd0 Apply clang-format update fixes
Reviewed By: igorsugak

Differential Revision: D25849213

fbshipit-source-id: a2a538230e769b2c328ae3dd0a19dfbfd693fe3b
2021-01-09 15:39:52 -08:00
Yang Chi
a3c78f7848 Use a sanitized ack delay value throughout packet handling
Summary:
the previous sanitizing of ack delay is too local. The bad value is
later on used again in another calculation. This diff moves the sanitization
code to the frame decoding site and overwrite the value to 0us if it's too ridiculous.

(Note: this ignores all push blocking failures!)

Reviewed By: lnicco

Differential Revision: D25515650

fbshipit-source-id: d18dc39e51bbbac24a6b271e67b79a82e9dc38a6
2020-12-15 10:51:38 -08:00
Alex Liu
7b607fd815 Add timestamp to retry token
Reviewed By: sharmafb

Differential Revision: D23588354

fbshipit-source-id: de5b8ef33f192e4cfcf9b129c4569142553d0576
2020-10-02 12:51:38 -07:00
Matt Joras
80c0b3185a Introducing the KnobFrame
Summary:
This introduces a new extension frame, the KnobFrame, and an implementation.

The idea with Knobs is that they are arbitrary key-values within a namespace that can be transmitted to the peer at any time. They provide an alternative to transport settings, by eschewing the standard transport setting space entirely.

The idea is simple, each knob has a "knobspace", "id", and value. The knobspace is a namespace in which the knob has semantic meaning (e.g. 0xfaceb00). The id and value are just that, arbitrary identifiers and values.

On receiving a knob it is the application's reponsibility to deal with it.

Reviewed By: mjoras

Differential Revision: D23601468

fbshipit-source-id: 63e5e4a7bdb76e11e8c952f1234f512a629ef348
2020-09-11 14:29:29 -07:00
Matt Joras
d2879a0e8b Frame types can be > one byte.
Summary: We need to internally represent them as uint64_t, in addition to parsing them as var ints.

Reviewed By: yangchi

Differential Revision: D21261466

fbshipit-source-id: 4ff7b9350cbf1dc0b58cb7ce00674430afd3ba53
2020-04-28 10:45:05 -07:00
Aman Sharma
84c1ed50f0 Functionality to encode/decode retry tokens
Summary: This diff defines functionality to encode and decode un-encrypted retry tokens.

Reviewed By: mjoras

Differential Revision: D21073343

fbshipit-source-id: 79c2e8ba3c743441edd4b162da69cc5e69873dd2
2020-04-21 22:36:31 -07:00
Aman Sharma
a84d2e5fcb Make client use new stateless retry
Summary: This makes the change for the client to use stateless retries

Reviewed By: mjoras

Differential Revision: D19657433

fbshipit-source-id: d4b34087d15e49153860a7833ed54e28c6cd6777
2020-04-08 20:58:41 -07:00
Matt Joras
a230720c3c Avoid throwing an exception on decoding Connection IDs
Summary: This can happen more often than we'd like, and there's no reason to force throwing the exception when we can instead validate the length first.

Reviewed By: udippant

Differential Revision: D20770869

fbshipit-source-id: 93e2349b02d6d2067f345b5fa9decee800c84ea6
2020-04-05 19:47:44 -07:00
Matt Joras
3b2ba3fe8b Implement handshake done
Summary: This is without cipher dropping, but the frame is parseable and the server will send it at the correct time.

Reviewed By: yangchi, lnicco

Differential Revision: D20235013

fbshipit-source-id: 696c11ec573a530b3ed9f4185a2f6847ee08819f
2020-03-04 22:08:33 -08:00
Matt Joras
61cd1a7289 Back out "Implement handshake done and cipher dropping."
Summary: This caused an increase in client errors.

Reviewed By: yangchi, lnicco

Differential Revision: D20186386

fbshipit-source-id: 737122a94c97498efba61292a6c292cfe482925c
2020-03-01 18:31:40 -08:00
Matt Joras
2b3b76cc4d Remove support for MVFST_OLD.
Summary:
This eliminatees some tech debt by completely removing the notion of version from the core transport parameters structure and the app token for zero rtt.

Note that for the draft-27 changes we will need to temporarily re-introduce it, but to a different layer (the extension encoding itself).

Reviewed By: JunqiWang

Differential Revision: D20073578

fbshipit-source-id: 2b55af621566bf1c20e21dd17251116de1788fa0
2020-02-28 09:52:34 -08:00
Matt Joras
472e40a902 Implement handshake done and cipher dropping.
Summary: This implements the handshake done signal and also cipher dropping.

Reviewed By: yangchi

Differential Revision: D19584922

fbshipit-source-id: a98bec8f1076393b051ff65a2d8aae7d572b42f5
2020-02-27 12:25:52 -08:00
TJ Yin
a396f62335 Replace folly::Optional::hasValue() by has_value()
Differential Revision: D19882830

fbshipit-source-id: 031217f9890351022bc8d171f0ccd7e045dd6972
2020-02-26 08:40:44 -08:00
Udip Pant
21a7efb2e3 remove constraints of 4-bytes minimum len for connection-id
Summary:
New QUIC draft no longer has this limitation for connection-id, and allows
connid of len 0 -> 20.

This diff removes the constraints. I still kept the requirement for
*server-chosen* conn-id

Reviewed By: mjoras, lnicco

Differential Revision: D19507366

fbshipit-source-id: 4c73f45617f40b29d47d2d86b7598f6c95588d0a
2020-01-23 21:59:49 -08:00
Anton Frolov
1482011db5 Remove UNLIKELY and LIKELY calls from mvfst
Summary:
All instancesi of LIKELY and UNLIKELY probably should be removed. We will
add them back in if we see pathologies in performance profiles.

Reviewed By: mjoras

Differential Revision: D19163441

fbshipit-source-id: c4c2494d18ecfd28f00af1e68ecaf1e85c1a2e10
2020-01-06 17:44:07 -08:00
Matt Joras
9dae0abe05 Fix appliication close writing/parsing
Summary: There's no triggering frame type for application closes.

Reviewed By: yangchi, raghunallamothu

Differential Revision: D19191873

fbshipit-source-id: 66cc2098e1f7671fabab0a2309deaabe7922a18e
2019-12-20 18:58:54 -08:00
Matt Joras
f8e162931b Use folly::small_vector in a few places
Summary: By using something which inlines some number of elements, we can avoid doing any mallocs from `std::vector` in the common cases. This also eliminates one layer of indirection in the common case.

Reviewed By: siyengar

Differential Revision: D18903523

fbshipit-source-id: 9f72e93f58a6b42777e5afe10e7ee6a13bf94c66
2019-12-12 12:06:30 -08:00
Subodh Iyengar
b7185a418b add missing check in decodepaddingframe
Summary: Add missing 0 bytes check in decodePaddingFrame

Reviewed By: mjoras

Differential Revision: D18921498

fbshipit-source-id: d02baf37cad090251c67e56140adfc734ecee5ef
2019-12-10 18:45:32 -08:00
Subodh Iyengar
7614e8e52e collapse most sequential padding frames
Summary:
For padding frames we don't really need to know the exact number of padding frames in the packet,
but just that a padding frame exists.

This diff tries to collapse multiple sequential padding frames into 1 frame while decoding the packet.
While this wont collapse all padding frames, the common case is that padding is sequential and at the
end of the packet.

Reviewed By: JunqiWang

Differential Revision: D18901925

fbshipit-source-id: 17b4eeabdbf4df01c900a9d5078891eb64bf254a
2019-12-09 21:02:23 -08:00
Subodh Iyengar
e524c0c069 iobufqueue diediedie
Summary:
Don't use IOBufQueue for most operations in mvfst and use BufQueue instead. Since BufQueue did not support a splitAtMost, added it in instead.

The only place that we still use IOBufQueue is in crypto because fizz still requires it

Reviewed By: mjoras

Differential Revision: D18846960

fbshipit-source-id: 4320b7f8614f8d2c75f6de0e6b786d33650e9656
2019-12-06 12:06:44 -08:00
Subodh Iyengar
17ee9aade0 dont clone during decode
Summary:
Don't clone during decoding a stream frame.

This uses a BufQueue to manage the data instead of passing around cursors.

Reviewed By: yangchi

Differential Revision: D18827718

fbshipit-source-id: 7874d308bb5f43b983b9965b2862e733a2107039
2019-12-05 14:15:11 -08:00