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

378 Commits

Author SHA1 Message Date
Matt Joras
07af79fc65 Don't remove stream from readable if the read callback isn't set.
Summary: This probably never made much sense as a policy. The application can reasonably expect to be able to set a read callback after the stream first becomes readable.

Reviewed By: afrind

Differential Revision: D29563483

fbshipit-source-id: 215a6aed130108248a0b4cbc36c02c8da70bf721
2021-07-08 10:30:23 -07:00
Joseph Beshay
9d01dd7ef7 Add a new API to set MAX_PACING_RATE on a QuicSocket
Summary:
Add a new QuicSocket API that sets the maximum pacing rate in Bytes per second to be used if pacing is enabled. This setting is passed down to the Pacer which enforces it.

The change also includes:
- Refactoring the setPacingRate function of the Pacer to make it more consistent with the other refreshPacingRate function.
- A new flag for testing the MAX_PACING_RATE using tperf.

Reviewed By: mjoras

Differential Revision: D29276789

fbshipit-source-id: 818d86707084b2697f7417b4a47e62cbbce65c73
2021-06-30 13:46:59 -07:00
Luca Niccolini
7fa3a9fc8e schedule write to send datagrams
Summary: invoke updateWriteLooper to make sure a datagram can be sent when it's the only thing to send

Reviewed By: mjoras

Differential Revision: D29416414

fbshipit-source-id: 77cbfc655415b589839bc8e642720498b45ceb85
2021-06-28 11:39:55 -07:00
Joseph Beshay
db4121c5f6 Allow receiver to get/set receive window on unidirectional stream
Summary: Remove a check that only allowed getting and setting the receive window on writable streams. This had prevented a receiver from getting/setting the receive window of a unidirectional stream initiated by the peer.

Reviewed By: mjoras

Differential Revision: D29366097

fbshipit-source-id: 3bc5cba826663b3499c19fe26bdd9a070682e533
2021-06-25 14:04:46 -07:00
Luca Niccolini
99110ccf83 consider max packet header and datagram frame payload
Summary:
make getDatagramSizeLimit return the maximum datagram payload size that the
peer can accept.
This is currently the most conservative length, considering the maximum length
of a QUIC short header packet and a datagram frame header

Reviewed By: mjoras

Differential Revision: D28784866

fbshipit-source-id: cce8944a77f6f7b2d3535758c3c29ad88382710f
2021-06-13 21:13:19 -07:00
Luca Niccolini
4acc7dc355 Implement one Datagram Frame per packet, and discard policy on rx/tx paths
Reviewed By: mjoras

Differential Revision: D28167755

fbshipit-source-id: b589376800742dfe167f1efe193f0fe059b18ab4
2021-06-13 21:13:19 -07:00
Alan Frindell
4afac7446c DeliveryCallback -> ByteEventCallback in all QuicSocket APIs
Summary: DeliveryCallback is a ByteEventCallback, so callers shouldn't need to change.

Reviewed By: bschlinker, mjoras

Differential Revision: D28562237

fbshipit-source-id: d7d41bbc3cbc708f7ecda5086fcba46b6a7847b0
2021-05-24 15:05:49 -07:00
Andres Suarez
d85b99cf0e Apply clang-format
Reviewed By: igorsugak

Differential Revision: D28477071

fbshipit-source-id: e844e0fad2f5599fd27e0fd113a328031cb63aa7
2021-05-20 21:25:23 -07:00
Brandon Schlinker
040b68c22d Fix removeObserver and removeAcceptObserver
Summary: When multiple observers attached and one is removed, removal code can end up calling `observerDetach` on the wrong observer. Simplified and fixed removal logic and added new tests.

Reviewed By: yangchi

Differential Revision: D27033221

fbshipit-source-id: d200fd2243a678890758b2652b61d16887f073dd
2021-05-13 12:51:21 -07:00
Luca Niccolini
026568e692 max_datagram_frame_size transport setting
Summary:
conditionally enable datagram support and communicate it to the peer via max_datagram_frame_size transport setting

https://quicwg.org/datagram/draft-ietf-quic-datagram.html#name-transport-parameter

Reviewed By: mjoras

Differential Revision: D27385012

fbshipit-source-id: 8c61765b6e044105409b0c638a8d6d16319ca21b
2021-05-11 08:24:03 -07:00
Luca Niccolini
f778cfb945 Quic Socket: Datagram APIs
Summary: quic socket API to send and receive datagrams

Reviewed By: mjoras, yangchi

Differential Revision: D20983884

fbshipit-source-id: 70332c5fb9c37c88150fc2f623521e7b0c991eae
2021-05-11 08:24:03 -07:00
Yang Chi
38c903ba2f Remove all QUIC_TRACEs
Summary: no longer used

Reviewed By: lnicco

Differential Revision: D28141008

fbshipit-source-id: 870d6574cc1657914a08f1ef5ee581cfef96aad1
2021-05-10 12:46:08 -07:00
Brandon Schlinker
5590b9f573 Track stream bytes written
Summary:
Track the number of stream bytes written to the wire and expose in `quic::TransportInfo`.

Implemented as two counters:
- `totalStreamBytesSent` is a count of all stream bytes written to the wire; the sum of the lengths of stream frames in all packets sent
- `totalNewStreamBytesSent` is a count of all *new* stream bytes written to the wire -- a stream byte is new if it has not been transmitted before; the sum of the lengths of stream frames that have never been transmitted before in all packets sent

We can derive the total number of stream bytes retransmitted as `totalStreamBytesSent - totalNewStreamBytesSent`. We may want to deprecate the existing `totalBytesRetransmitted` counter because the name of that counter does not make it clear that it is stream bytes, and because only includes some types of retransmissions.

While `totalNewStreamBytesSent` is already captured as `flowControlState.sumCurWriteOffset`, I am not reusing that counter here to avoid having a dependency on the information we track for flow control, and to allow all relevant information to be captured in `LossState` (where other relevant fields already exist).

Reviewed By: yangchi

Differential Revision: D28061085

fbshipit-source-id: 73486a4ba3fc8f12959f68702dc58e61fdc21b65
2021-05-04 23:24:06 -07:00
Sridhar Srinivasan
3a4783713a Use separate flags to enable app data sent callbacks
Summary:
Previously we were using a single flag appDataSentEvents to enable 3 callbacks
(startWritingFromAppLimited, packetsWritten and appRateLimited). This commit
creates separate flags to enable each of these callbacks, we have use-cases
where Observers might want only packetsWritten events and not the others.

Also, this commit refactors the logic to deliver these 3 callbacks to all
observers into a separate method so they can be unit tested easily.

Reviewed By: bschlinker

Differential Revision: D27925011

fbshipit-source-id: 7f7436dfc3d50c3abcb8ec121b221d20e30b0c4b
2021-05-02 23:07:47 -07:00
Alan Frindell
5a0451760a error peek callbacks on connection closure
Summary: This was missed when peekError was added

Reviewed By: mjoras, lnicco

Differential Revision: D27973063

fbshipit-source-id: dbf1112a4ce6822401ba5125de853fe922acd85e
2021-04-26 16:45:51 -07:00
Sridhar Srinivasan
967b240bc9 Disallow non-consecutive duplicate byte event registrations
Summary:
As per design, we are not supposed to honor duplicate byte event registrations. Duplicate is defined by a registration for the same <stream ID, stream offset, callback*> tuple twice.
Currently, there is a bug where-in we can register the same byte event a second time *if* there is another byte event for a higher offset that is registered in-between, for the same stream.
Example Sequence that triggers the bug:
1. Registration for Stream ID =10, offset = 50, callback = A. This will be successful.
2. Registration for Stream ID = 10, offset = 55, callback = <doesn't matter>. This will be successful.
3. Registration for Stream ID = 10, offset = 50, callback = A. This is a duplicate of #1. This *should not* be honored, but it was being honored (this was the bug).

This commit fixes the bug, #3 will return INVALID_OPERATION.

Reviewed By: bschlinker, lnicco

Differential Revision: D27946237

fbshipit-source-id: f9751ac90159284f86a285e5e0ebb23b83041d2a
2021-04-26 11:24:42 -07:00
Sridhar Srinivasan
834ea800cb Revert the fix for duplicate byte event registrations
Summary:
Diff D27846813 (98b5e2aa8f) introduced a fix for a corner case in the ByteEventRegistration logic where-in it was possible to register a byte event for the same stream ID, offset and ByteEvent type as long as they were not consecutive registrations. If there was a different byte event registration for the same stream ID in-between, then duplicates were being allowed.
However, that fix causes an unexpected crash in HQSession::dropConnectionSync().

This commit reverts the fix for duplicate byte event registrations until we are able to find the root cause for the crash and come up with a better fix. Note that we are still able to catch duplicate registrations as long as they are consecutive registrations for the same <stream ID, offset, callback>. With this fix reverted, we will not be able to catch non-consecutive duplicate registrations.

Reviewed By: bschlinker

Differential Revision: D27903179

fbshipit-source-id: b4da3128d5ba14fc764e1768fd27982553968997
2021-04-21 02:24:25 -07:00
Yang Chi
aa59f9ef32 QuicSocket::setDSRPacketizationRequestSender API
Summary:
This assigns a DSRPacketizationRequestSender to a QUIC stream, and let
it own it.

Reviewed By: mjoras

Differential Revision: D27668523

fbshipit-source-id: 4beba6ddf247801368c3e1c24a0a4956490d45cd
2021-04-20 20:09:10 -07:00
Sridhar Srinivasan
98b5e2aa8f Fix bug in registerByteEvent
Summary:
When registerByteEvent is called for a particular stream ID and offset, it is
possible that the byte event has already occurred in the past. In this case, we
schedule a lambda to be executed in the *next* iteration of the event loop, to
deliver the byte event to the callback.

There are 2 bugs in the current implementation of runEvbAsync which executes
the scheduled lambda.
1. It is possible that multiple recipients register for the same byte event on
the same stream ID and offset. If one of the recipients is already delivered
the byte event, then there is a possibility that the lambda can redeliver the
same notification a second time, which is not desirable.

2. There is a race condition where-in between the time the lambda was scheduled to
the time the lambda was excecuted, it is possible that the byte event gets
delivered when we process callbacks on receiving network data. In this
situation, there is a bug in the lambda where-in if there is another byte event
registered for any other offset for the same stream ID (regardless of the
callback), we will falsely deliver the byte event that was requested, resulting
in double delivery of the same byte event.

This commit fixes both bugs by checking that the requested byte event still
exists in the ByteEventDetail deque (comparing the offset as well as callback),
before erasing and delivering it.

Reviewed By: bschlinker

Differential Revision: D27846813

fbshipit-source-id: 099b79af2580fba5561ec33c4be45a8cf84c39e8
2021-04-20 15:22:21 -07:00
Matt Joras
19339ef38f Add quic version to transport summary.
Summary: The kitchen sink must grow. Nice to know when the conn ends what the version was.

Reviewed By: lnicco

Differential Revision: D27868680

fbshipit-source-id: 2770ed2c647d76affbb52597a5a2a6720eabfe66
2021-04-19 17:58:35 -07:00
Matt Joras
98298496a2 Add some more info to transport summary qlog
Summary: Same as before!

Reviewed By: lnicco

Differential Revision: D27785992

fbshipit-source-id: 0160fb1572c8afc3dbbcf1dac50fc73ddbfbad83
2021-04-14 20:05:53 -07:00
Chetan Ambekar
cd754c2499 Revert D27768829: Add some more info to transport summary qlog
Differential Revision:
D27768829 (3ed777d04f)

Original commit changeset: 43cbf88f38ce

fbshipit-source-id: 4c678ebccbb7c9c33b1c7ab9ed98f6bdbc9c7e49
2021-04-14 18:45:06 -07:00
Matt Joras
3ed777d04f Add some more info to transport summary qlog
Summary: Specifically interested in seeing whether 0RTT was used, writable bytes, and conn flow control.

Reviewed By: yangchi

Differential Revision: D27768829

fbshipit-source-id: 43cbf88f38ce56065cad785344dedc279a0af7d1
2021-04-14 18:08:13 -07:00
Jason Jiang
3ea632ee61 Add peekError into PeekCallback
Summary:
This diff adds error callback API during the time PeekCallback() is applied, following D9724616, D988728, D15312250, design doc https://fb.quip.com/8P9WAaF43VOn

The peekError() API implementation is added into unidirectional stream dispatcher, class HQUnidirStreamDispatcher.

Reviewed By: mjoras

Differential Revision: D27514260

fbshipit-source-id: b65cc0e46a5d520f46f9dc218c9a65be99e6df55
2021-04-09 09:46:59 -07:00
Matt Joras
55e0fa070e Send probes on all spaces take 2.
Summary:
As before we will now aggressively send probes on all spaces with probes available when the PTO timer fires.

This time with more unit tests and some bug fixes.

Reviewed By: yangchi

Differential Revision: D27338523

fbshipit-source-id: 8a9ccb90ed691e996fab4afa2f132c0f99044fbc
2021-04-02 14:59:57 -07:00
Sridhar Srinivasan
ac468ad891 Use ByteEvent as a key in maps and sets
Summary:
This commit demonstrates the use of ByteEvents in maps. Intentionally didn't define the custom comparator and hash function inside the quic library because we want consumers of ByteEvents to define equality of 2 ByteEvents in their own way.
This will help recipients of ByteEventCallback keep track of pending,
received and cancelled ByteEvents easily.

In addition, the behavior of registerByteEventCallback was modified to NOT allow duplicate registrations. A pair of registrations is considered duplicate if they both have the same stream ID, stream offset, ByteEvent type and recipient callback pointer. In such cases, registerByteEventCallback returns an INVALID_OPERATION error.
This is critical to make sure that ByteEvents work well in maps, which may be used by recipients.

Reviewed By: bschlinker

Differential Revision: D27100623

fbshipit-source-id: 084a4765fa6c98fdc1b98414fbd30582cf1e5139
2021-03-30 19:52:19 -07:00
Sridhar Srinivasan
f7a08066ce Track body bytes sent and acked
Summary:
Previously, we maintained state and counters to count both, header and body
bytes together. This commit introduces additional counters and state to keep
track of just the body bytes that were sent and acked etc. Body bytes received
will be implemented later.

Reviewed By: bschlinker

Differential Revision: D27312049

fbshipit-source-id: 33f169c9168dfda625e86de45df7c00d1897ba7e
2021-03-29 16:58:04 -07:00
Matt Joras
a92a24bdd5 Back out "Send probes for all spaces."
Summary: As in title. There's a bug here somewhere with empty write loops we need to find.

Reviewed By: yangchi

Differential Revision: D27279100

fbshipit-source-id: e1d26fbf8d6df1590d464a6504a8b940b46794e0
2021-03-23 16:10:12 -07:00
Matt Joras
bceb00346b Send probes for all spaces.
Summary:
Previously we would only send probes for the first space which had one available, i.e. Initial before Handshake before AppData. Since we only have one PTO timer this can lead to situations where we perpetually probe with only Initials, which can significantly delay the handshake if we should have probed with Handshakes.

With this diff we will keep the single PTO timer but aggressively write more probes from all spaces if they are available.

Additionally this refactors some counters into EnumArrays

Reviewed By: yangchi

Differential Revision: D27235199

fbshipit-source-id: ef3614a833bf0f02f5806846a1335fa7ac2a4dc8
2021-03-23 12:51:36 -07:00
Sridhar Srinivasan
0ddb6e77b5 add onByteEventRegistered callback
Summary:
Add an onByteEventRegistered callback that will be invoked when the
registration for a ByteEvent callback is successful.
This makes it easy for recipients of the callback to track the successful
registration AND callback recipt in a single place (the recipient class). For
example, if all successfully registered ByteEvents have been received, the
recipient can destroy itself safely, knowing that no more ByteEvents will be
sent to it.

Reviewed By: bschlinker

Differential Revision: D27100624

fbshipit-source-id: dbfeff1f4cf2367587fdb73cbd334165b3b159de
2021-03-18 18:13:42 -07:00
Matt Joras
386f6a840e Add number of streams to idle timeout error.
Summary: If we idle timeout when there are non control streams open, there could be some sort of issue especially with protocols like HTTP/3.

Reviewed By: yangchi

Differential Revision: D27017861

fbshipit-source-id: 319b839a641fa417a5026adf607c7bd0070cb66c
2021-03-15 07:50:00 -07:00
Sridhar Srinivasan
d2f005dc00 Add support for detecting start and stop of app rate limited scenarios
Summary:
Previously, we only had support for notifying observers when a QUIC socket
became application rate limited.

This change adds a similar notification when a socket does not become
application rate limited, i.e when the application *starts* writing data to the
socket - either for the first time on a newly established socket or after a
previous block of writes were written and the app had no more to write.
In addition, we include the number of outstanding packets (only those that are
carrying app data in them) so that observers can use this data to timestamp the
start and end of periods where the socket performs app data writes.

Reviewed By: yangchi

Differential Revision: D26559598

fbshipit-source-id: 0a8df7082b83e2ffad9b5addceca29cc03897243
2021-03-10 13:05:10 -08:00
Yang Chi
adc1e15eff Write a buffer's meta data into QUIC
Summary:
Instead of writing real data into the transport, we want to support a
use case where only its metadata is written to the transport. Sending of the
real data is delegated to another entity in such setup.

Reviewed By: mjoras

Differential Revision: D26131772

fbshipit-source-id: 4fcfa3a1626203f63c61898e6de089a3079d043d
2021-03-03 23:50:02 -08: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
Yang Chi
0b42e07216 Getter API of Quic stream priority
Summary: as title

Reviewed By: afrind, avasylev

Differential Revision: D26744365

fbshipit-source-id: 5c5d104ca76c77f14371c20d6f791fca8d7cfe38
2021-03-03 07:26:28 -08:00
Duc Nguyen
a38156a83d Add knob frame event to Observer
Summary: Extend the Observer to record events for all knob frame received.

Reviewed By: bschlinker

Differential Revision: D26325312

fbshipit-source-id: 810589d08be3614c8c091cccb7bb9fbdb5c65402
2021-03-03 07:26:27 -08:00
Matt Joras
1b86b23d65 Check read callback for nullptr.
Summary: It's legit to set this to nullptr before the callback is removed.

Reviewed By: yangchi, lnicco

Differential Revision: D26582589

fbshipit-source-id: 0119e06e6e5347a9080dc5a814551e7b44d64c74
2021-02-22 12:52:24 -08:00
Andrii Vasylevskyi
10a6feed49 Reset congestion controller after setting factory
Summary:
Before the change, there's no good way to recreate Cubic CC instance with custom CC factory, because Cubic is created by default.

On client side this requires calling setCongestionControl() or setTransportSettings() after calling setCongestionControllerFactory(), which is normally the case.

Reviewed By: yangchi

Differential Revision: D26401996

fbshipit-source-id: dfda39be835c67b9db42f726b3ac64c7b3d37c2f
2021-02-19 17:55:10 -08:00
Andrii Vasylevskyi
1303281a51 Create pacer before congestion controller
Summary: Allows CongestionControllerFactor to access Pacer and update it's state if needed

Reviewed By: yangchi

Differential Revision: D26382984

fbshipit-source-id: fd73fbb6f0989c52a1a2061670fb9e6b188049d6
2021-02-19 17:55:10 -08:00
Andrii Vasylevskyi
b1a364b9dd QuicConnectionStats type change from string to the "native"
Reviewed By: lnicco

Differential Revision: D26379617

fbshipit-source-id: 308d53ca86c2a2e774e3618038eece7091482ed8
2021-02-19 10:47:02 -08:00
Andrii Vasylevskyi
ba71671bb2 QuicConnectionStats for client socket
Summary: Adding QuiConnectionStats to client transport. Moving getConnectionsStats() logic from server worker into transport base class.

Reviewed By: lnicco

Differential Revision: D26316635

fbshipit-source-id: a384eee5d1bc7b23d908e0b03fafcc4ee962b0b9
2021-02-19 10:47:02 -08:00
Matt Joras
f29e003ee4 Introduce resetNonControlStreams
Summary: This function is useful for when an application wants to explicitly reset all its non-control streams in one go.

Reviewed By: yangchi

Differential Revision: D26490209

fbshipit-source-id: 747449938e4dcd58bee028835f34776e5314cdf9
2021-02-18 14:07:20 -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
Yang Chi
7c23fc75cc remove the unsupported cork param from QUIC writeChain interface
Summary: this param is passed to transport then ignored

Reviewed By: avasylev

Differential Revision: D26133327

fbshipit-source-id: 459dd0132185513215ba034f213d4137d7b56ba1
2021-01-29 10:50:45 -08:00
Brandon Schlinker
f206c5125b Packets inflight, packets sent in OutstandingPacketMetadata
Summary:
- Adds counter of the number of ack-eliciting packets sent; useful for understanding lost / retransmission numbers
- Adds the following to `OutstandingPacketMetadata`
  - # of packets sent and # of ack-eliciting packets sent; this enables indexing of each packet when processed by an observer on loss / RTT event, including understanding its ordering in the flow of sent packets.
  - # of packets in flight; useful during loss analysis to understand if self-induced congestion could be culprit
- Fixes the inflightBytes counter in `OutstandingPacketMetadata`; it was previously _not_ including the packets own bytes, despite saying that it was.

Right now we are passing multiple integers into the `OutstandingPacket` constructor. I've switched to passing in `LossState` to avoid passing in two more integers, although I will need to come back and clean up the existing ones.

Differential Revision: D25861702

fbshipit-source-id: e34c0edcb136bc1a2a6aeb898ecbb4cf11d0aa2c
2021-01-21 21:11:56 -08:00
Brandon Schlinker
4c5874e062 Fix spurious loss count in TransportInfo
Summary: `QuicSocket::TransportInfo::packetsSpuriouslyLost` is not currently being set (always zero). Fixed this and renamed it to more closely match the other counters.

Differential Revision: D25999285

fbshipit-source-id: 34fd380a2e56f110234987e08f3a0220669afde8
2021-01-21 18:09:54 -08:00
Sridhar Srinivasan
bd1ed4b7c0 Make the important Observer callbacks configurable
Summary:
Given the large number of callbacks that are being triggered from the Observer
this change makes it possible to enable through a simple config, just the
subset of callbacks that a consumer is interested in receiving.

Observer and Socket Lifecycle callbacks are enabled by default, they are not
configurable.

Reviewed By: bschlinker

Differential Revision: D25879382

fbshipit-source-id: abe79ed92e958ddc96475c347f8ec7204400cdfa
2021-01-13 15:35:06 -08:00
Sridhar Srinivasan
27fe474171 Migrate the QUIC and TransportMonitor libraries to use the new unified Observer callback class
Summary:
We were using the LifecycleObserver and InstrumentationObserver classes
separately, to generate and receive callbacks.

This change migrates both these to use the unified Observer callback class and
adjusts the unit tests.

Reviewed By: bschlinker

Differential Revision: D25845845

fbshipit-source-id: c489400f5d70bccadbcc1d957136c5ade36b65ff
2021-01-13 15:35:06 -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
c1223a2f78 Remove trailing _E from QUIC variant type
Summary:
I think this should just work without the trailing `_E`. It was added
when we mixed up our own union based variant and boost::variant. Some compiler
flags didn't like that. Now we no longer have mixed up cases, this should be
fine

Reviewed By: lnicco

Differential Revision: D25589393

fbshipit-source-id: 6430dc20f8e81af0329d89e6990c16826da168b8
2020-12-16 18:03:05 -08:00