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

143 Commits

Author SHA1 Message Date
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
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
Brandon Schlinker
68d660c46d Count number of packets sent and lost by type
Summary:
We currently have a count of the number of packets retransmitted, and the number of packets marked as lost spuriously, but we do *not* have the total number of packets sent or lost, which is necessary to calculate statistics such as % of packets retransmitted % of losses that are spurious.

At the moment, we do not count loss events for D6D packets. Will likely add a separate counter for those in a subsequent diff.

Reviewed By: xttjsn

Differential Revision: D25540531

fbshipit-source-id: 80db729eb8c91f7805d342f4aab302a5b3ca4347
2020-12-14 16:32:55 -08:00
Yang Chi
000a0e23ca Add stream prioritization
Summary: Adds a top level API to set stream priorities, mirroring what is currently proposed in httpbis.  For now, default all streams to the highest urgency, round-robin, which mirrors the current behavior in mvfst.

Reviewed By: mjoras

Differential Revision: D20318260

fbshipit-source-id: eec625e2ab641f7fa6266517776a2ca9798e8f89
2020-11-10 20:08:13 -08:00
Sridhar Srinivasan
1d65dd0eb7 API to find out if knobs are supported on a QUIC connection
Summary:
Knob Frames are supported only by peers who are on the QUIC::MVFST version.
Expose this information to the outside, so producers of Knob frames can check,
before constructing frames to exchange with the peer.

Reviewed By: bschlinker

Differential Revision: D24608694

fbshipit-source-id: 88a8ff892efc061ca755d3eeabaed83d27d8271f
2020-11-05 11:02:54 -08:00
Kanthi Nagaraj
327af996e2 Adding packet loss event detection to instrumentationobserver
Summary:
`InstrumentationObserver` is owned by `QuicSocket` now. However, to capture packet loss signal, we need it in `QuicConnectionState`. So, I refactored the code a little bit to make this easy. Changes in this code:
(a)  Moved the definition of `InstrumentationObserver` and `LifeCycleObserver` to
 a separate header `Observer.h`.
(b) Moved the vector of `InstrumentationObserver`s from `QuicSocket` to `QuicConnectionState`.
(c) Added a callback in `conn->pendingCallbacks` when a packet loss is detected

Reviewed By: bschlinker

Differential Revision: D23018569

fbshipit-source-id: e70d954839bdb70679ecd52d2bd1a6a6841f6778
2020-09-11 17:54:58 -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
Xiaoting Tang
3fac7d21f4 Count cumulative # of egress packets for a stream
Summary:
There are situations where application needs to know how many packets were transmitted for a stream on certain byte range. This diff provides *some* level of that information, by adding the `cumulativeTxedPackets` field in `StreamLike`, which stores the number of egress packets that contain new STREAM frame(s) for a stream.

~~To prevent double-counting, I added a fast set of stream ids.~~

Application could rely on other callbacks (e.g. ByteEventCallback or DeliveryCallback) to get notified, and use `getStreamTransportInfo` to get `packetsTxed` for a stream.

Reviewed By: bschlinker, mjoras

Differential Revision: D23361789

fbshipit-source-id: 6624ddcbe9cf62c628f936eda2a39d0fc2781636
2020-09-01 15:50:20 -07:00
Xiangyu Bu
54ec33e474 Add API to get client cert from QuicSocket.
Summary: This diff adds an API to expose client certificate from QuicSocket.

Reviewed By: mjoras, lnicco

Differential Revision: D20374792

fbshipit-source-id: 1b0691bba49ef57cb824aba8563644afc7b1962b
2020-08-31 12:25:05 -07:00
Matt Joras
3f4b4a668d Spurious loss detection
Summary:
It is useful to be able to account for when we detect packets as lost but actually receive an ACK for them later. This accomplishes that by retaining the packets in the outstanding packet list for a certain amount of time (1 PTO).

For all other purposes these packets are ignored.

Reviewed By: yangchi

Differential Revision: D22421662

fbshipit-source-id: 98e3a3750c79e2bcb8fcadcae5207f0c6ffc2179
2020-08-26 15:54:25 -07:00
Matt Joras
81756e3d13 Allow specifying error code in setReadCallback
Summary: We have an API behavior where setReadCalback will issue a StopSending on behalf of the app. This is useful but has confusing semantics as it always defaults to GenericApplicationError::NO_ERROR. Instead let the error be specified as part of the API.

Reviewed By: yangchi, lnicco

Differential Revision: D23055196

fbshipit-source-id: 755f4122bf445016c9b5adb23c3090fc23173eb9
2020-08-13 18:28:38 -07:00
Brandon Schlinker
b4df09831b Support for TX timestamping
Summary:
Adds support for timestamping on TX (TX byte events). This allows the application to determine when a byte that it previously wrote to the transport was put onto the wire.

Callbacks are processed within a new function `QuicTransportBase::processCallbacksAfterWriteData`, which is invoked by `writeSocketDataAndCatch`.

Reviewed By: mjoras

Differential Revision: D22008855

fbshipit-source-id: 99c1697cb74bb2387dbad231611be58f9392c99f
2020-07-16 22:45:34 -07:00
Brandon Schlinker
d332cc4e0c Generic ByteEvent infrastructure
Summary:
Introduces framework for handling callbacks when a `ByteEvent` occurs.

- Adds `ByteEventCallback`, a new class that can be used to notify a callback implementation about delivery (ACK) of a byte and is used in the subsequent diff for notifications about TX of a byte.
- Adds `ByteEvent` and `ByteEventCancellation`, both of which are used to communicate ancillary information when a ByteEvent happens to the callback implementation. This makes it easier to add additional fields (such as kernel timestamps, information about ACK delays, etc) in the future, without requiring the function signatures of all callback implementations to be updated.
- For the moment, `DeliveryCallback` inherits from `ByteEventCallback` so that existing implementations do not need to be adjusted; `DeliveryCallback` implements `ByteEventCallback`'s methods and transforms the received `ByteEvents` into the expected callback. I will deprecate `DeliveryCallback` in a subsequent diff.
- Refactors existing logic for handling delivery callbacks to be generic and capable of handling different types of byte events. This allows the same logic for registering and cancelling byte events to be reused for ACK and TX timestamps; custom logic is only required to decide when to trigger the callback.

Reviewed By: mjoras

Differential Revision: D21877803

fbshipit-source-id: 74f344aa9f83ddee2a3d0056c97c62da4a581580
2020-07-16 22:45:34 -07:00
Brandon Schlinker
ad8ca14760 Instrumentation callback foundation w/ app rate limited
Summary:
Adds `QuicSocket::InstrumentationObserver`, an observer that can be registered to receive various transport events.

The ultimate goal of this class is to provide an interface similar to what we have through TCP tracepoints. This means we need to be able to register multiple callbacks.

- Initially, the first event exposed through the callback is app rate limited. In the future, we will expose retransmissions (which are loss + TLP), loss events (confirmed), spurious retransmits, RTT measurements, and raw ACK / send operations to enable throughput and goodput measurements.
- Multiple callbacks can be registered, but a `folly::small_vector` is used to minimize memory overhead in the common case of between 0 and 2 callbacks registered.
- We currently have a few different callback classes to support instrumentation, including `QuicTransportStatsCallback` and `QLogger`. However, neither of these meet our needs:
  - We only support installing a single transport stats callback and QLogger callback, and they're both specialized to specific use cases. TransportStats is about understanding in aggregation how often an event (like CWND limited) is occurring, and QLogger is about logging a specific event, instead of notifying a callback about an event and allowing it to decide how to proceed.
  - Ideally, we can find a way to create a callback class that handles all three cases; we can start strategizing around that as we extend `InstrumentationObserver` and identify overlap.

Differential Revision: D21923745

fbshipit-source-id: 9fb4337d55ba3e96a89dccf035f2f6978761583e
2020-07-16 10:25:45 -07:00
Brandon Schlinker
e43eb2e8b4 Notify connection callback when app rate limited
Summary:
Notify connection callback implementation when the transport becomes app rate limited
- The callback implementation is not required to define a handler for this callback (not pure virtual).
- D21923745 will add an instrumentation callback class that can be used to allow other components to receive this signal. I'm extending to the connection callback because the overhead seems low, and we already have the connection callback registered for `HQSession`.

Reviewed By: mjoras, lnicco

Differential Revision: D21923744

fbshipit-source-id: 153696aefeab82b7fd8a6bc299c011dcce479995
2020-07-16 10:25:45 -07:00
Brandon Schlinker
98e0e4dc5d Socket lifecycle observer
Summary:
Adds `QuicSocket::LifecycleObserver`, an observer that is notified when a socket is closed and destroyed.

- Can be used by instrumentation that ties its lifetime to that of the socket.
- Multiple observer can be registered, but a `folly::small_vector` is used to minimize memory overhead in the common case of 0 - 2 being registered.
- `folly::AsyncSocket` has a matching interface being added (D21613750), so instrumentation can follow the same paradigm for both QUIC and TCP.
- In the future, will extend to also be triggered when a transport becomes connected, similar to what we have for `AsyncSocket`.

Reviewed By: mjoras

Differential Revision: D21653651

fbshipit-source-id: 0aa374cc0dd9b9c11d81b49597326bd53264531d
2020-07-16 10:25:45 -07:00
Andrii Vasylevskyi
311a408958 ConnectionCallback functions when local openable streams become available
Summary:
Callbacks notifying that max stream limit has been increased and new streams can be created.
This get triggered every time limit gets bumped, doesn't track if limit was previously exhausted or not.

Reviewed By: mjoras

Differential Revision: D22339814

fbshipit-source-id: 6bcd0b52adb61e1ac440d11559dc8544ad7aa1ac
2020-07-08 09:17:48 -07:00
Xiaoting Tang
03e3bb6547 make largestAckedByPeer and largestSent optional
Summary: 0 is now a valid packet number, so we should make these optional. In cases where they are needed to construct packet builder, it should be safe to use 0 as default since it's only used for computing `twiceDistance` in PacketNumber.cpp.

Reviewed By: yangchi

Differential Revision: D21948454

fbshipit-source-id: af9fdc3e28ff85f1594296c4d436f24685a0acd6
2020-06-10 10:30:10 -07:00
Andrii Vasylevskyi
7a50ca13c7 Refactor writeChain function signature not to reutrn IOBuf
Summary: Updating signature of writeChain to stop returning IOBuf, as implementation never actually returns back buffer and always writes full buffer.

Reviewed By: mjoras

Differential Revision: D21740607

fbshipit-source-id: f473ed8f3c6c6cbe2dd5db8f1247c912f3e77d0b
2020-06-02 05:16:00 -07:00
Carmi Grushko
cf729dbafb Don't schedule a PING timeout if callback is nullptr or timeout is 0
Reviewed By: yangchi

Differential Revision: D21249143

fbshipit-source-id: 690abd63272aa666caa7ebc5f3d41f49376281f1
2020-04-28 19:31:48 -07:00
Yang Chi
fc41c9964f New QuicSocket API to unregister stream WriteCallback
Summary:
Currnetly there isn't a way for apps to unregister a pending
WriteCallbacks for a stream. resetStream() does that if the transport isn't in
Closed state. This diff adds such support even if transport is already in
Closed state. This solves the problem where app has a class that's both stream
ReadCallback and stream WriteCallback and readError would kill the callback
object itself. The new API gives such class a chance to remove itself from the
transport.

Reviewed By: mjoras

Differential Revision: D20545067

fbshipit-source-id: 81d9f025310769aadef062711a49adc47a0639d0
2020-03-19 22:25:18 -07:00
Yang Chi
2405111e88 New QuicSocket::ConnectionCallback for first peer packet processed
Summary: as title

Reviewed By: JunqiWang

Differential Revision: D19434037

fbshipit-source-id: 7f2b6491fcce68840dc6ff57f99657dd5d535e9f
2020-01-18 13:36:04 -08:00
Yang Chi
332b3c340c Use original server cid chosen by client for source addr based routing
Summary:
Currently, before server generate the destination CID, we route packets with client's address, port and client's source connection ID. But now that client can use 0-len source connection ID, the different connections from the same client address and port will be routed to the same server connections.

This diff changes it to use client's initial destination connection ID as part of the routing key.

Reviewed By: udippant

Differential Revision: D19268354

fbshipit-source-id: 837f5bd2f1e3a74957afacf7aabad922b1719219
2020-01-06 08:58:12 -08:00
Viktor Chynarov
fe92d2a5ce Add onNetworkSwitch method to QuicSocket
Summary:
* Add onNetworkSwitch which is default no-op to QuicSocket
* rename replaceSocket to onNetworkSwitch()
* add unit tests

Reviewed By: JunqiWang

Differential Revision: D18572354

fbshipit-source-id: db304cd8369eb3a38272ab19e71854c62f2d37b7
2019-11-20 08:53:33 -08:00
Konstantin Tsoy
4cf5ea0c1a Expose setCongestionControl() in QuicSocket interface
Summary: Expose setCongestionControl() in QuicSocket interface

Differential Revision: D18209094

fbshipit-source-id: 0b1336e92a032dce464ee559d2559cf132d700e3
2019-11-11 12:26:22 -08:00
Alan Frindell
8b8131450e Remove pause/resume on session level buffer
Summary:
We currently pause all producers if the sum of the egress buffers of all transactions exceeds the write buffer limit.  This turns out to be deterimental to prioritization.

Now, we pass the underlying transport pause state or connection flow control state back to the handlers.  The previous diff in this stack introduces a per-stream buffer limit (64kb default).  To limit total session buffer size, limit the number of concurrent streams or lower the per-stream limit.

Reviewed By: lnicco

Differential Revision: D17097138

fbshipit-source-id: 9025c5be8b318963311c3aaad9ee9a03c0e2265e
2019-10-28 16:46:20 -07:00
Nitin Garg
95d02afb2b Expose CC type in transport info
Summary:
CC Type is not exposed anywhere else. This could be the source of truth and will be useful for logging.
Also added a helper to convert the enum to string.

Reviewed By: yangchi

Differential Revision: D17566664

fbshipit-source-id: 1e0e887a7c23617b174b240f5c636f6dcdfd42c4
2019-10-01 15:46:52 -07:00
Luca Niccolini
6efcef720f export current mss in transportinfo
Summary:
we were not setting the MSS.
populate it from the transport, compute the cwnd appropriately and check the netquality header

Reviewed By: yangchi

Differential Revision: D17385975

fbshipit-source-id: 3666728c48d3fc7a65827d526fbdd546449b2e1f
2019-09-16 10:41:36 -07:00
Yang Chi
5d9749cda6 Zero init a few durations in mvfst
Summary: Apparently they don't zero-init themselves

Reviewed By: sharma95

Differential Revision: D16973464

fbshipit-source-id: f7360790f2d34686cc2d03d651d26e3feb407a79
2019-08-22 18:41:24 -07:00
Junqi Wang
228b80b1a8 Make AppTokenValidator::validate const
Summary: prevent application from changing state

Reviewed By: knekritz

Differential Revision: D16448292

fbshipit-source-id: f1c065eec8556a5dd6ef75b2466b761beee82a40
2019-07-25 11:52:18 -07:00
Junqi Wang
4e9c9cd995 Remove old API to negotiate early data params with app
Summary: fully deprecate the old stateful API

Reviewed By: lnicco

Differential Revision: D16267317

fbshipit-source-id: a0adc83fb571e78ed68b370bb42d774004417d92
2019-07-19 08:54:39 -07:00
Junqi Wang
e92672d7ee Stateless API for APP to validate/write 0-RTT params
Summary:
Previously we tried to put this API in connectionCallback, but that has
some lifecycle problem. So we decided to make this API independent of mvfst's
state. Application (e.g. HTTP/3, QPACK) will have to either make the 2 functions
stateless or maintain the lifecycle of any captured objects.

Reviewed By: afrind, lnicco

Differential Revision: D16074471

fbshipit-source-id: b0a3baa6870bee56372797754972ab5c2c1f2232
2019-07-19 08:54:37 -07:00
Nitin Garg (MPK, Infra)
92a68aa968 Add pacing information to QUIC TransportInfo
Summary: This is useful information for the application to know about

Reviewed By: yangchi

Differential Revision: D15599964

fbshipit-source-id: da451f46238f68fe701d6f433701c569cfe2f47d
2019-06-07 22:02:58 -07:00
Nitin Garg (MPK, Infra)
559103f399 Add bytesAcked to QUIC
Summary: bytesAcked is a very useful stat for apps to know. Bytes written only tells me that data was written to socket but it may not have been acked.

Differential Revision: D15507105

fbshipit-source-id: 656ee45418a78c7e05d8e7979afa2c9a41976e85
2019-05-25 11:55:17 -07:00
Bonnie Xu
f4ae0a1efd Updated files to change syntax.
Summary: Changed existing chrono syntax to chrono_literals syntax.

Reviewed By: mjoras, sharma95

Differential Revision: D15374649

fbshipit-source-id: 40033e90cca226266ef85e4fec629f290bc5dae6
2019-05-20 12:10:46 -07:00
Yang Chi
c35e3d6e84 Rename RTO to PTO
Summary: To conform to the current specs.

Reviewed By: mjoras

Differential Revision: D15215018

fbshipit-source-id: 4dcc495aea1cd7cebf2bc84f7367cb2e4a55df19
2019-05-06 18:50:35 -07:00
Alan Frindell
a122063d22 Add helper to send a reset from a readError
Summary: The previous diff removed automatically sending a rst stream when receiving a reset stream.  This adds a helper to do that from the application layer.

Reviewed By: mjoras, pkir

Differential Revision: D15208997

fbshipit-source-id: b8d3898e85537e97df61cc66854299698a48c825
2019-05-06 14:05:32 -07:00
Aman Sharma
85fc503506 TRIP logging QUIC fields
Reviewed By: udippant

Differential Revision: D14627382

fbshipit-source-id: 573582a2936ffce31b12648c4ecea09ed59befbf
2019-05-06 12:15:38 -07:00
Konstantin Tsoy
6b49f4e42a Cancel delivery callbacks on skip
Summary:
For the sender, upon egress or ingress skip we must check registered
delivery callbacks and invoke `onCancel()` for each offset below the skipped
offset.

Reviewed By: mjoras

Differential Revision: D15113113

fbshipit-source-id: 221badce8e92abde48e8ab2c8f3c1da9e506f54e
2019-05-06 10:29:42 -07:00
udippant
163ce02a6f Sync changes to rename onNewStream and CongestionController factory 2019-04-24 17:44:31 -07:00
udippant
50d4939e9e Initial commit of mvfst 2019-04-22 23:42:46 -07:00