1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-09 10:00:57 +03:00
Commit Graph

358 Commits

Author SHA1 Message Date
Crystal Jin
fc6ca42bae Remove stream after onEOM is called
Summary: This change ensures that the stream is not destroyed before onEOM callback so that onEOM can access stream specific data.

Reviewed By: mjoras

Differential Revision: D42784838

fbshipit-source-id: ce619be1a2b6a542a517a7b4f32c2b3d37aa30fd
2023-02-13 18:46:23 -08:00
Joseph Beshay
4097c5c4c3 Decide whether to send knob frames based upon the transport parameter only and cache it for 0-rtt connections
Summary:
This removes the older method of deciding whether knob frames should be sent using the QuicVersion. With this change, the client can only send knobs when the server has signaled support using the `knob_frames_supported` transport parameter.

To make sure that knobs can be sent in 0-rtt connections, the transport parameter is now included in the client's cache of server transport parameters.

Reviewed By: mjoras

Differential Revision: D43014893

fbshipit-source-id: 204dd43b4551cd1c943153a3716e882fc80e6136
2023-02-07 18:06:27 -08:00
Joseph Beshay
239f2b5b55 Add transport parameter for knob frame support
Summary: Decide if knob frames are supported based upon a transport parameter instead of relying on the QUIC version. This is a cleaner approach, at the cost of an additional transport parameter.

Reviewed By: mjoras

Differential Revision: D42465442

fbshipit-source-id: bfd1d177bdbe198e5eb47e63113410b5738dcede
2023-01-26 12:22:38 -08:00
Konstantin Tsoy
424ab5c8c1 Remove useless func argument
Summary: Remove useless func argument

Reviewed By: jbeshay

Differential Revision: D42647239

fbshipit-source-id: d27b26391971ca31f8bf727e3648d1a0dbf124be
2023-01-24 14:53:27 -08:00
Brandon Schlinker
bddc599e62 ConnectionStartTime in TransportInfo
Summary:
Expose the time when the connection started in `QuicSocket::TransportInfo`.

This is imperfect for `QuicClientTransport` right now, as it marks the time when the transport was created — not the time when the connection was started. This is due to how the underlying value is being populated. Will address in a follow up diff.

Differential Revision: D42224019

fbshipit-source-id: c75dc2df10c252d18225df8508445e99ed5d788a
2023-01-05 15:20:44 -08:00
Matt Joras
1275798146 Make the AckState for Initial/Handshake a unique_ptr
Summary:
We don't need to carry these states after the handshake is confirmed, so make them pointers instead. This will facilitate adding a structure to the AckState for tracking duplicate packets.

(Note: this ignores all push blocking failures!)

Reviewed By: hanidamlaj

Differential Revision: D41626895

fbshipit-source-id: d8ac960b3672b9bb9adaaececa53a1203ec801e0
2022-12-20 11:08:43 -08:00
Brandon Schlinker
eb3009484a Application limited time in packet metadata
Summary:
Track the total (cumulative) amount of time that the connection has been application limited and store this information in `OutstandingPacketMetadata`. If this value is the same for two `OutstandingPacketMetadata` then we know that the transport did not become application limited between when those two packets were sent (or, less likely, the transport was application limited for less than one microsecond given the microsecond resolution of the timestamp).

We store the amount of time spent application limited instead of a count of the number of application limited events because the implications of being application limited are time dependent.

Tests show that we need to be able to inject a mockable clock. That's been an issue for some time; will work on in a subsequent diff.

Differential Revision: D41714879

fbshipit-source-id: 9fd4fe321d85639dc9fb5c2cd51713c481cbeb22
2022-12-08 18:55:22 -08:00
Alan Frindell
c4fbdf7eeb Fix a couple QuicTransportBase bugs
Summary:
1) unregistering a pending write callback from another callback was unsafe.  Follow the paradigm in the rest of this function.
2) Calling closeGracefully() nulls out the connection callback but keeps writing -- need to check that connCb_ is non-null before calling onAppLimited()

Reviewed By: kvtsoy

Differential Revision: D40811191

fbshipit-source-id: fa3512e4aa5ddda3dfc160a044b7d29b7aec8a8a
2022-11-16 18:25:26 -08:00
Hani Damlaj
c22ee0a8ab StopSending Closes Ingress
Summary: - transport settings to enable the following behaviour: invoking stopSending() now drops buffered ingress data and closes the ingress path

Reviewed By: mjoras

Differential Revision: D40678864

fbshipit-source-id: 7dd5c7843909d5ac8cc309292b31d1d87b97a2f5
2022-11-14 18:06:47 -08:00
Hani Damlaj
e1f8e0df1d No-op StopSending If Ingress Closed
Summary: - as title, we should just no-op ::StopSending when ingress is already closed

Reviewed By: jbeshay, mjoras

Differential Revision: D40990383

fbshipit-source-id: e0cd64facf78f510eabe8198e93a643c6ebfb89e
2022-11-04 19:00:24 -07:00
Matt Joras
953235fbc7 Track largest packet acked per DSR stream.
Summary:
The normal loss detection only considers the reordering threshold per packet by comparing it with the largest ACKed packet in the ACK. This is largely based on the fact that QUIC packet numbers are monotonically increasing.

However, when using DSR there is a potential for a different host to be writing the packets to the wire. When there are multiple hosts doing this, there is a degree of reordering that is expected to happen.

Thus we can change the loss detection logic to adjust the largest packet ACKed and use the largest packet ACKed for a given DSR stream when the packet is a DSR packet. This allows for the natural reordering while detecting loss within the DSR sender's timeline of sent packets.

Note that this probably doesn't catch all of the nuances that can happen with the reordering, but it is a good start.

Reviewed By: kvtsoy

Differential Revision: D40647572

fbshipit-source-id: d84c6cd8040fb8c044ddd68fb1abc049ccddfc44
2022-10-27 14:35:11 -07:00
Matt Joras
a65385f001 Control experimental pacing mode with TransportSettings.
Summary: As in title.

Reviewed By: hanidamlaj

Differential Revision: D40742259

fbshipit-source-id: 05e01ab2d9f89f63d06e24d2a74051a927c8b6c9
2022-10-26 20:44:56 -07:00
Matt Joras
3e57e82400 When using ACK_FREQUENCY, disable SRTT/4 heuristic.
Summary: We always use an SRTT/4 ACKing heuristic for the ACK delay. This has generally been a useful heuristic, but when using ACK_FREQUENCY we should defer to using the delay by the peer.

Reviewed By: jbeshay

Differential Revision: D40272530

fbshipit-source-id: c7a44e53233c97d0c96bc6f936a7318cf4676aba
2022-10-11 18:15:24 -07:00
Matt Joras
06aaca5fcd Add transport settings for disabling adaptive loss thresholds for DSR
Summary:
This is useful so we can run experiments that turn this feature off while we turn ACK_FREQUENCY policies on.

(Note: this ignores all push blocking failures!)

Reviewed By: yairgott

Differential Revision: D40148536

fbshipit-source-id: 84aa4a0639b43c8721db0db6885b6af6e1701bdd
2022-10-07 08:45:14 -07:00
Sharad Jaiswal (Eng)
520239e723 Add CongestionController::State to TransportInfo and BW info
Summary: Add a struct with `CongestionController::State` (if available) into `TransportInfo`, and expand the state structure to include the congestion controller's current bandwidth estimate (if available).

Reviewed By: bschlinker, mjoras

Differential Revision: D39413012

fbshipit-source-id: 3eb79cdf53cc37e2cf5e3729cf44557e8a0a3a45
2022-09-29 03:15:09 -07:00
Matt Joras
1e9db60a90 Add debug information to DSR CHECK.
Summary: Often the pointer can be hard to get back because Clang apparently can't produce DWARF symbols.

Reviewed By: kvtsoy

Differential Revision: D39787495

fbshipit-source-id: 81596f35843200e90d4786a70837cdf75cfc9cac
2022-09-26 10:08:10 -07:00
Joseph Beshay
74d9b24e86 Ensure stream is not null when the transport is getting it from the StreamManager
Summary: Ensure stream is not null when the transport is getting it from the StreamManager

Reviewed By: mjoras

Differential Revision: D39753796

fbshipit-source-id: bc2a870a26510267d972bb59758792696c99501d
2022-09-23 11:40:32 -07:00
Matt Joras
8ff931ec73 Explicitly unset DSR sender on detach.
Summary: This makes the unsetting of the DSR sender explicit. By doing this we can guarantee that a sender, if it has a dependency of the transaction lifetime, will be released before the transaction itself.

Reviewed By: kvtsoy

Differential Revision: D39525914

fbshipit-source-id: 6f0094b1ad1970ed603032469aede9ca1ed9c255
2022-09-16 16:25:20 -07:00
Brandon Schlinker
5b8e0de5bd Improve transport close handling and observability
Summary:
The current `close` observer event marks when `closeImpl` is called. However, the actual close of the socket may be delayed for some time while the socket drains. I've changed the existing event to `closeStarted` and added a new event `closing` that marks the close of the underlying `AsyncUDPSocket`.

Adding the `closeStarted` event required two other changes which are difficult to separate from this diff:
- When a transport is destroyed, `QuicTransportBase` was calling `closeImpl` and also closing the UDP socket. However, because the `folly::ObserverContainer` used to store observers is maintained in classes that derive from `QuicTransportBase`, the observers are gone by the time the UDP socket is closed in the base class destructor. Thus, the UDP socket should be closed by the derived classes in their respective destructors. This requirement is inline with the existing code: `closeImpl` is called by all derived classes in their destructors. Made this change and added `DCHECK` statements in the `QuicTransportBase` destructor to ensure that derived classes cleanup after themselves.
- Writing tests with draining enabled and disabled required being able to set the transport settings. However, all of the existing `QuicTypedTransportTest` test cases were designed to operate after the connection was accepted (for the server impls) or established (for client impls), and transport settings cannot be updated at this state. Resolving this required adding new test classes in which the accept/connect operation is delayed until requested by the test.

Reviewed By: mjoras

Differential Revision: D39249604

fbshipit-source-id: 0ebf8b719c4d3b01d4f9509cf2b9a4fc72c2e737
2022-09-10 10:39:11 -07:00
Hani Damlaj
6208eca47f Synchronously Query Socket For Max Writable
Summary: - adding an API to the QuicSocket to enable users to synchronously query the socket for the maximum amount of data that should be written.

Reviewed By: mjoras

Differential Revision: D37390086

fbshipit-source-id: 5dd64e28b7f841ba3e28a4bc2a79c1b1e5a95047
2022-07-13 12:08:47 -07:00
Ashkan Nikravesh
8419469204 Create a PacketProcessor abstract class
Summary: PacketProcessors process the packets that we send and their corresponding ack and loss events. We store a vector of packet processors inside `QuicConnectionStateBase` and we call `onPacketSent` and `onPacketAck` whenever their corresponding functions in `CongestionController` class are called. The plan is to make `CongestionController` class extend `PacketProcessor`.

Reviewed By: bschlinker

Differential Revision: D36404668

fbshipit-source-id: 52d63a6a74bfa2031131d31047da25a5e2be12aa
2022-07-05 11:09:03 -07:00
Matt Joras
64725f2200 Always turn on adaptive reordering thresholds for DSR.
Summary: When there are multiple different DSR senders, there can be a large degree of reordering present. We can partially mitigate this for now by using adaptive reordering thresholds all the time when DSR is on.

Reviewed By: shodoco

Differential Revision: D37400821

fbshipit-source-id: f456e447fd58154d26bd642c22e71457e0d27b7c
2022-06-24 09:44:23 -07:00
Konstantin Tsoy
e208ceffdd Implement group streams receiver api in transport
Summary: Implement group streams receiver api in transport

Reviewed By: mjoras

Differential Revision: D36419901

fbshipit-source-id: 98bfefa1a4205fde8764f2e4300f51156667e024
2022-06-06 17:11:39 -07:00
Konstantin Tsoy
ad6a0e9cbb Implement group streams sender api in transport
Summary: Implement group streams api in transport

Reviewed By: mjoras

Differential Revision: D36417214

fbshipit-source-id: dee93807fe061f2abd9c779da9a2cd1df1865c3e
2022-06-03 15:47:17 -07:00
Konstantin Tsoy
80b9c6274e Stream groups API
Summary: Add stream groups interface

Reviewed By: mjoras

Differential Revision: D36416440

fbshipit-source-id: 4a757428c9f38f52e4c8d0feb2149d598a748904
2022-06-03 15:47:17 -07:00
Konstantin Tsoy
5656e382e5 Create a reset() util function for outstandings
Summary: Create a reset() util function for outstandings

Reviewed By: jbeshay

Differential Revision: D36148759

fbshipit-source-id: 04473b959ec9024c27afac67aca9937b12d7edd0
2022-05-06 12:59:45 -07:00
Matt Joras
b48420185e Clear lastProcessedAckEvents in same loop
Summary: Deferring it to the next read causes a bunch of data to go out of cache, which guarantees a cache miss when we try to clear it. Instead, clear it immediately after the callbacks.

Reviewed By: bschlinker

Differential Revision: D36151205

fbshipit-source-id: 467a45e2ef901b5705fb3db38d2648ba97784c8d
2022-05-05 16:22:02 -07:00
Brandon Schlinker
a9cd97dbbf Packets received event for observer
Summary: Add observer event for packets received.

Differential Revision: D35708803

fbshipit-source-id: 7a58045c4153f797170731cfe31de60aef343036
2022-04-20 03:36:44 -07:00
Brandon Schlinker
744ae1f78e Use folly::ObserverContainer for socket observer [4/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Changes `LegacyObserver` to inherit from the new `Observer` class by adding a compatibility layer. This compatibility layer enables existing observers to continue to be supported.
- Changes generation of observer events so that they are routed through `ObserverContainer::invokeInterfaceMethod`
- Temporarily removes some of the reentrancy protection that previously existed, as it was not being applied consistently — some events had reentrancy protection, some did not. This will be reintroduced in the next diff.
- Improves some unit tests for observers during the transition process.

Differential Revision: D35268271

fbshipit-source-id: 5731c8a9aa8da8a2da1dd23d093e5f2e1a692653
2022-04-18 04:19:31 -07:00
Brandon Schlinker
f20eb76865 Use folly::ObserverContainer for socket observer [3/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Adds methods to `QuicSocket` to support adding and removing `ObserverContainer` observers. By default, `QuicSocket` implementations will not support observers as `QuicSocket::getSocketObserverContainer` returns `nullptr`, and this will cause `QuicSocket::addObserver` and `QuicSocket::removeObserver` to fail gracefully.
- Adds support in `QuicClientTransport` and `QuicServerTransport` for `ObserverContainer` observers by overriding `getSocketObserverContainer`. Each implementation creates an `ObserverContainer` on construction that is destroyed on destruction.
- Adds the `close` event to the new observer interface and adds corresponding support in `QuicTransportBase`. This allows both the old and new observers to receive the close event. The next diff will do a hard cutover of the rest of the events.

Differential Revision: D35000960

fbshipit-source-id: e75807c97f4385532bf36244591a259aa0a2f4cc
2022-04-18 04:19:31 -07:00
Brandon Schlinker
ea056eb960 Use folly::ObserverContainer for socket observer [2/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Renames `quic::Observer` to `quic::LegacyObserver`.
- Switches to using `quic::SocketObserverInterface` instead of `quic::Observer` when referencing structures used for the observer interface. For instance, `quic::Observer::WriteEvent` changes to `quic::SocketObserverInterface::WriteEvent`.

Differential Revision: D35000152

fbshipit-source-id: f387231fd58e8e763c3d7ed0a9c6fcec3b2324e2
2022-04-18 04:19:31 -07:00
Duc Nguyen
928c015171 Ensure socket is open when determining a socket is good
Summary:
Check `CloseState` to ensure the socket open when determining a socket is good.

`QuicSocket::good` notes that a socket is good iff the transport is open and ready.

Reviewed By: bschlinker

Differential Revision: D35661700

fbshipit-source-id: 46d4cf3ae57bd79c0efbea0d03dab7a92a43f33b
2022-04-15 13:16:11 -07:00
Brandon Schlinker
feb8455dc6 Add RTT with ACK delay removed to TransportInfo
Summary: Make `min(minRTT - ACK delay)` obsered so far over the life of the connection available in `TransportInfo`. In addition, expose the last RTT and last RTT's AckDelay value as well.

Reviewed By: mjoras

Differential Revision: D28385923

fbshipit-source-id: a58000ac8bd9fdc63caa0b636bdb83905cd6b448
2022-03-28 23:26:30 -07:00
Brandon Schlinker
6a1665ba74 PacketsWrittenEvent triggered when no congestion controller
Summary: Trigger `PacketsWrittenEvent` even if no congestion controller is installed. We previously had it require a congestion controller because it was related to the app limited event.

Differential Revision: D34541746

fbshipit-source-id: 3dc0930cbbc8b190fb63c31dffb76c8274c8e9d3
2022-03-28 23:26:30 -07:00
Brandon Schlinker
da71a15307 Add CWND and writable bytes to PacketsWrittenEvent
Summary: Extend `PacketsWrittenEvent` to include the CWND and number of writable bytes from the congestion controller after the write completed. If no congestion controller is installed, these values are left blank.

Differential Revision: D32588533

fbshipit-source-id: 4b8361937fcab36daa17e5f6dc4386762987d2b4
2022-03-28 23:26:30 -07:00
Brandon Schlinker
b243d2bdd8 Number bytes written in packets written event
Summary: Report all bytes written in observer packets written events.

Reviewed By: jbeshay

Differential Revision: D33086404

fbshipit-source-id: 1456cf23a420abd025f047f190cb2b8a9868826e
2022-03-23 08:50:12 -07:00
Joseph Beshay
a105868ecc Test for presence of traffic shapers using a token bucket in BbrTesting and use that to inform bandwidth estimates
Summary:
This is an experiment to improve BBR's performance with bursty traffic when a traffic shaper is present in the path. The change is fully contained within BbrTesting.

Currently, with every new request, BBR generates a high bandwidth estimate from the shaper's burst that is not valid once's the shaper's burst has expired. This causes BBR to introduce unnecessary queuing delay until the bandwidth estimate has reacted to the shaper's rate. When the requests are small enough and are separated by an interval of inactivity, this behavior repeats with every request causing bursts of queueing delay.

This change attempts to detect the presence of certain common shaper configurations. If the presence of a shaper is detected with sufficient confidence, the shaper's rate is used to limit the bandwidth estimate of BBR.

Reviewed By: bschlinker

Differential Revision: D34483728

fbshipit-source-id: 7d27b1383b01381140aa7cae340889fb49cb5a5e
2022-03-14 11:04:38 -07:00
Joseph Beshay
ba8b190a97 Knobs are supported in MVFST_EXPERIMENTAL too
Summary: Check for MVFST_EXPERIMENTAL when deciding whether knob frames are supported

Reviewed By: mjoras

Differential Revision: D34694138

fbshipit-source-id: b3563b0a5baf2fa7b060a494bb74402f43c7c3d1
2022-03-08 11:01:38 -08:00
Luca Niccolini
8d3bdbda25 Fix connection close stats callback
Reviewed By: afrind

Differential Revision: D34489976

fbshipit-source-id: ccf2645da524b36ab0fdea2b4bc4d23136838081
2022-02-25 18:43:46 -08:00
Joseph Beshay
f829871a07 Enable initializing BBR with guesses for cwnd and minrtt
Summary:
- Enable starting BBR with an initial cwnd and minrtt guesses.
- Add minrtt to QuicConnectionStats
- Add unit test for new BBR constructor

Reviewed By: mjoras

Differential Revision: D34438518

fbshipit-source-id: 58607cd3b1424a3f1f006dee94f910a29103826b
2022-02-25 11:43:48 -08:00
Matt Joras
360c211738 Keepalive timer support
Summary:
This implements a basic keepalive timer at the transport layer.

The basic idea is to leverage the same conditions as the idle timer. The keepalive timer will fire ~15% before the idle timer and trigger a PING frame. This has the effect of keeping the connection open if the PING is acknowledged.

Reviewed By: jbeshay

Differential Revision: D34256174

fbshipit-source-id: a8cee579f5b09bdfa23bcdc7cf4c70de299de3bd
2022-02-24 12:40:01 -08:00
Konstantin Tsoy
a70ffbeb29 Rename ConnectionCallbackNew back to ConnectionCallback
Summary: Rename ConnectionCallbackNew back to ConnectionCallback

Reviewed By: mjoras

Differential Revision: D33979956

fbshipit-source-id: 6c133a406c4bf6799838ffc36701267a938cb4a3
2022-02-23 12:57:31 -08:00
Konstantin Tsoy
bd6e117a56 Add a helper function to set default error code for close() and
Summary:
Add a helper function to set default error code for close() and
closeNow()

Reviewed By: mjoras

Differential Revision: D34191863

fbshipit-source-id: 8f818f471307ea64ed046ec5e93852566247faa3
2022-02-22 14:24:23 -08:00
Konstantin Tsoy
2e468b5e5d Add new connection end cb option to client/server transport
Summary: Add new connection end cb option to client/server transport

Reviewed By: mjoras

Differential Revision: D34190871

fbshipit-source-id: 375cf95bc8dbe4ab759140cfb4b33b732869953f
2022-02-22 14:24:23 -08:00
Konstantin Tsoy
3b6f2cf2c0 Simplify callback invocation on connection end/error
Summary: Simplify callback invocation on connection end/error

Reviewed By: mjoras

Differential Revision: D34190297

fbshipit-source-id: d0a124d392a96cc7596bf7feb45ec35a7e27dbbf
2022-02-16 09:49:35 -08:00
Konstantin Tsoy
54ce32396c get rid of callbacks indirection layer
Summary: get rid of callbacks indirection layer

Reviewed By: mjoras

Differential Revision: D34189595

fbshipit-source-id: e4a0aba768b17054f06091c12ef66f1a8019885f
2022-02-15 11:45:09 -08:00
Konstantin Tsoy
3872f0dd89 Remove unused function
Summary: Remove unused function

Reviewed By: mjoras

Differential Revision: D34184684

fbshipit-source-id: cd254c64790ad8024484bf91e68db6a47e054ce2
2022-02-15 11:45:09 -08:00
Konstantin Tsoy
cecc1ba279 Introduce QuicError struct
Summary: Instead of using std::pair everywhere

Reviewed By: mjoras

Differential Revision: D34146686

fbshipit-source-id: dfe48f43775de868aba06a5b9b5a004e5793bdbb
2022-02-14 16:00:21 -08:00
Elijah Staple
b57802721e Add ReadDatagram struct and update readDatagrams callback
Summary: In order to provide more information about datagrams when we receive them, I'm adding a wrapper around the BufQueue that we currently hold so we can include receiveTimePoint and any other metadata we might want to expose for the Datagram API.

Reviewed By: mjoras

Differential Revision: D33994358

fbshipit-source-id: 805f182cd350908320639bc07eb6f3b7349bbc05
2022-02-10 16:47:06 -08:00
Luca Niccolini
878ee7318b Fix shutdown when deleting eventbase
Reviewed By: kvtsoy

Differential Revision: D33908361

fbshipit-source-id: e133d9be0a744831586a213add98c5a4ae4457a2
2022-02-09 20:12:04 -08:00