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

152 Commits

Author SHA1 Message Date
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
Misha Shneerson
3c350f5256 Revert D26260987: Update QUIC stream state after BufferMeta is written
Differential Revision:
D26260987 (78170a2f3b)

Original commit changeset: 15a4fa178264

fbshipit-source-id: 3942cea62eaf404d79da49310faf5d233de86cfa
2021-03-10 12:45:57 -08:00
Yang Chi
6594defc7c Merge QUIC new data and loss data scheduler
Summary: they need to be prioritized together

Reviewed By: mjoras

Differential Revision: D26918282

fbshipit-source-id: 061a6135fd7d31280dc4897b00a17371044cee60
2021-03-10 09:37:04 -08:00
Yang Chi
78170a2f3b Update QUIC stream state after BufferMeta is written
Summary:
Update retransmission queue in the stream after BufferMeta is written,
for both new data and lost data cases.

Reviewed By: mjoras

Differential Revision: D26260987

fbshipit-source-id: 15a4fa17826426b4b972b63cf370fe791b3101ff
2021-03-10 07:21:42 -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
Xiaoting Tang
96bf643f4f Require AppData packet number space when checking D6D packet
Summary: ^

Reviewed By: yangchi

Differential Revision: D25539225

fbshipit-source-id: 7d68917c73228c006ebec38be1ee86ccb12362f1
2020-12-17 10:11:47 -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
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
Matt Joras
007a4069c7 Use StringPiece for frame builder name.
Summary: As in title. No reason to make a string copy, these always refer to string literals.

Reviewed By: yangchi

Differential Revision: D25288518

fbshipit-source-id: 489f0ac22aa86aa4a4acb562245e98b6d33a10fd
2020-12-03 14:57:15 -08:00
Yang Chi
21167fdc66 Remove unused lastHandshakePacketSentTime from Quic
Summary: as title

Reviewed By: avasylev

Differential Revision: D25130929

fbshipit-source-id: 8e08007a29f7d4913921cee851f2cbe7a29b37fd
2020-12-01 09:26:42 -08:00
Matt Joras
7ee04756f7 Pad Initial closes from the client.
Summary: Otherwise the server can just discard them.

Reviewed By: yangchi

Differential Revision: D24208150

fbshipit-source-id: 75a7ab8156d1d0109538ffdbe8de34f6482f1c67
2020-10-08 22:47:22 -07:00
Xiaoting Tang
f9e916c194 Prepare metadata
Summary:
Here are some of the questions I guess we'd like to answer regarding d6d:
- How long, and how many probes does d6d take to find the PMTU upper bound for a
  given connection?
- If PMTU blackhole is detected, what's the packet size that triggers the
  signal? And what's the state of d6d when that happens? Also, if there's issue
  with the PMTU stability in the path, in what frequency does it oscillate?

This adds some meta data in d6d's lifecycle in order to provide info when those
events happen.

Reviewed By: mjoras

Differential Revision: D23972069

fbshipit-source-id: f6a2d1d656b33d94b41ecfbb0c06bdaf299caa8b
2020-09-29 11:47:20 -07:00
Xiaoting Tang
37cd692593 Refactor d6d pending events into a single struct
Summary: As a drive-by: fixed a bug where I didn't cancel the pending event when timeouts expire.

Reviewed By: mjoras

Differential Revision: D23910767

fbshipit-source-id: 233e590c17a6c6b7a5f4a251bd8f78f6dfae3c0b
2020-09-25 13:36:13 -07:00
vaz985
a8d5c156a1 Adding packet rtt sampling to instrumentationObserver (#178)
Summary:
Due to high number of RTT samples I refactored the OutstandingPacket to
split the packet data and packet metrics. We know have access to metrics
without the need of saving the packet data.

Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/178

Reviewed By: mjoras

Differential Revision: D23711641

Pulled By: bschlinker

fbshipit-source-id: 53791f1f6f6e184f37afca991a873af05909fbd2
2020-09-22 18:39:00 -07:00
Xiaoting Tang
5317134c84 Timeouts that drive d6d lifecycle
Summary:
This glues together the d6d lifecycle via probe timeout and raise timeout.
Had to put these two timeouts in the base transport because it has all the
necessary accountings (e.g. check close state, process callbacks) that should
happen before scheduling timeouts.

Other notable changes (included here because code is simple):
- Keep track of d6d probes in loss state. Upon second thought, it makes more
sense because we are reducing the available bandwidth as a result of sending
probes anyway. And not tracking them imposes a delay on congestion controller.
I think this does not violate the d6d spec's point of not penalizing congestion
window for d6d probes, because
    - 1. we don't put losses of d6d probes in loss event. Therefore from the POV of
congestion controller, d6d probes never get lost.
    - there will be at most kDefaultD6DMaxOutstandingProbes losses (i.e.  2)
that we don't tell congestion controller about. Even if those are actually
caused by congestion, it should have minimal impact because 2 is small and if there's really a congestion, the loss of normal packets should provide the signal.
- Pacing d6d probes
- Kick off d6d after a delay of 1s. This should filter out short-lived connections where probing is relatively expensive and less useful.

Reviewed By: mjoras

Differential Revision: D23736656

fbshipit-source-id: 8121fa8bcebab10a56a4e046c32c4e99ed6c3013
2020-09-22 08:44:25 -07:00
Xiaoting Tang
b703ab1306 Suppress error for oversized packets if it's d6d probe
Summary: This was missed D22551400 (9cdb922288).

Reviewed By: mjoras

Differential Revision: D23733719

fbshipit-source-id: d1226ccad932f0d3201ce23281ab08eda005a43b
2020-09-22 08:44:25 -07:00
Xiaoting Tang
1aec6b57f0 send d6d probe packets via writeD6DProbingDataToSocket
Summary:
This is the transport function that sends d6d probe to socket. It
- checks if there's the pending event `sendD6DProbePacket`, which will be set by upon d6d's probe timer expiration.
- uses the current probeSize to instantiate a D6DProbeScheduler, which will be changed by a small d6d state machine.

Reviewed By: yangchi

Differential Revision: D23193967

fbshipit-source-id: dfe6ce831cfd6ff0470e801644b95d4e8da34e87
2020-09-14 22:29:28 -07:00
Yang Chi
8616a9b3aa Consider ack delay in BBR bandwidth calculation
Summary:
it turns out some client can delay ack for long time, randomly, which
may make us miss a good bandwidth update

Reviewed By: mjoras

Differential Revision: D23686348

fbshipit-source-id: 6524d08b6db03ede59a72049b4af98609740463a
2020-09-14 22:04:28 -07:00
Matt Joras
8a98805d70 Ignore some updates on implicit ACK.
Summary: Implicit ACKs, while making code a little simpler/safer, are not real ACKs. One consequence of an implicit ACK is that it potentially ACKs bytes much earlier than they would be in reality, leading to inaccurate RTT measurements and inaccurate bandwidth estimations for BBR.

Reviewed By: yangchi

Differential Revision: D23675102

fbshipit-source-id: 64f779aceffa262515fe48deb18ff571b9a8c882
2020-09-14 16:54:37 -07:00
Xiaoting Tang
9cdb922288 Special treatment to d6d probe in tx/rx path via isD6DProbe flag in OutstandingPacket
Summary:
According to the spec, loss of d6d probe packet should not affect congestion
control, but AFAIU its ack should be considered a normal ack and has all the
implications of an ack (e.g. sample srtt, increment largest ack num).

Additionally, although d6d probe uses ping frame, neither sending a d6d probe
nor receiving the ack should have any bearing on either pendingEvents.sendPing
or pendingEvents.cancelPingTimeout.

To differentiate a d6d probe from a normal packet in tx/rx path, the isD6DProbe
flag is added. I also added a new struct to store d6d specific states (1 field
in this diff, more to come in subsequent diffs). In updateConnection, we
identify a d6d probe by comparing the packet sequence num with the sequence num
stored in the lastProbe field of the d6d state.

Reviewed By: mjoras

Differential Revision: D22551400

fbshipit-source-id: 85ec30c185666c3d5cf827bf03b4f92e6f22d4ec
2020-09-14 16:06:21 -07:00
Yang Chi
95f3730569 Fix bad probe sending condition in crypto writes
Summary: Wrong parenthesis

Reviewed By: mjoras

Differential Revision: D23655249

fbshipit-source-id: 03480601ed50053d7f19fe79d77f831d6349aa6e
2020-09-12 17:27:07 -07:00
Matt Joras
325a6465ec Always send flow control updates again when lost.
Summary: This was probably a premature optimization and introduces complexity for dubious gain. Additionally a sequence of losses could potentially cause multiple updates to be delayed.

Reviewed By: yangchi

Differential Revision: D23628058

fbshipit-source-id: d6cf70baec8c34f0209ea791dadc724795fe0c21
2020-09-10 14:58:59 -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
Yang Chi
b0dbab25ee Remove unnecessary folly/Overload.h in quic includes
Summary: we don't use it in most of our code any more

Reviewed By: sharmafb

Differential Revision: D23378968

fbshipit-source-id: 876c27e8dea0e82f939c5f1b52a1cb16bb13195d
2020-08-27 16:40:01 -07:00
Bharat Parekh
0b88f5dd6f Changes to implement sending connection blocked frames
Summary: Implemented necessary changes to emit DATA BLOCKED frame when a QUIC connection is write blocked.

Reviewed By: mjoras

Differential Revision: D23067313

fbshipit-source-id: f80d7425c9a3c4e9b81405716bcd944c83b97ac2
2020-08-27 15:43:43 -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
Yang Chi
5d74a54259 refactor setCipherOverhead -> accountForCipherOverhead
Summary: as title

Reviewed By: mjoras

Differential Revision: D22640467

fbshipit-source-id: 063dbd6aebd323ab6396d5e408057ce16aaf51b9
2020-07-22 15:16:12 -07:00
Yang Chi
7a45658bdb Reduce Quic packet size violation error logging
Summary: as title

Reviewed By: mjoras

Differential Revision: D22606264

fbshipit-source-id: dce2d1bbd79be00c71b87ef7140df3b2cc176dbd
2020-07-17 15:42:35 -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
Yang Chi
a7dc8cb4f7 Log an error when we write a packet larger than limit
Summary: as title

Reviewed By: bschlinker

Differential Revision: D22542572

fbshipit-source-id: 4f53a1c916b22e33f183208efb671c1d0883309c
2020-07-15 11:19:10 -07:00
Matt Joras
70f40cc1c2 Add some sanity checks around cipher dropping.
Summary: As in title, these shouldn't happen.

Reviewed By: oesh, yangchi

Differential Revision: D22138561

fbshipit-source-id: cb51f3e795a1784e3f2ece675a95ac18a4be2701
2020-06-22 09:10:22 -07:00
Yang Chi
51b917b0b3 PingFrame is not a simple frame
Summary:
The problem with Ping being a simple frame:
(1) All SimpleFrames are in the same scheduler. So sending ping means we may
also send other frames which can be problematic if we send in Initial or
Handshake space
(2) Ping isn't retranmisttable. But other Simple frames are. So we are
certainly setting this wrong when we send pure Ping packet today.

That being said, there are cases where we need to treat Ping as retransmittable.
One is when it comes to update ack state: If peer sends us Ping, we may want to
Ack early rather than late. so it makes sense to treat Ping as retransmittable.
Another place is insertion into OutstandingPackets list. When our API user sends
Ping, then also add a Ping timeout. Without adding pure Ping packets into OP list,
we won't be able to track the acks to our Pings.

Reviewed By: mjoras

Differential Revision: D21763935

fbshipit-source-id: a04e97b50cf4dd4e3974320a4d2cc16eda48eef9
2020-06-18 15:30:44 -07:00
Yang Chi
b8fef40c6d Clone Quic handshake packets
Summary:
On loss timer, currently we knock all handshake packets out of the OP
list and resend everything. This means miss RTT sampling opportunities during
handshake if loss timer fires, and given our initial loss timer is likely not a
good fit for many networks, it probably fires a lot.

This diff keeps handshake packets in the OP list, and add packet cloning
support to handshake packets so we can clone them and send as probes.

With this, the handshake alarm is finally removed. PTO will take care of all
packet number space.

The diff also fixes a bug in the CloningScheduler where we missed cipher
overhead setting. That broke a few unit tests once we started to clone
handshake packets.

The writeProbingDataToSocket API is also changed to support passing a token to
it so when we clone Initial, token is added correctly. This is because during
packet cloning, we only clone frames. Headers are fresh built.

The diff also changed the cloning behavior when there is only one outstanding
packet. Currently we clone it twice and send two packets. There is no point of
doing that. Now when loss timer fires and when there is only one outstanding
packet, we only clone once.

The PacketEvent, which was an alias of PacketNumber, is now a real type that
has both PacketNumber and PacketNumberSpace to support cloning of handshake
packets. I think in the long term we should refactor PacketNumber itself into a
real type.

Reviewed By: mjoras

Differential Revision: D19863693

fbshipit-source-id: e427bb392021445a9388c15e7ea807852ddcbd08
2020-06-18 15:30:44 -07:00
Yang Chi
4790a5792d Do not fallback to Ping if any probe is written, or if we don't have probe
Summary: as title.

Reviewed By: mjoras

Differential Revision: D22044917

fbshipit-source-id: 18a4c988633c04233591bc596fd811ebe98c1171
2020-06-18 15:30:44 -07:00
Xiaoting Tang
2d00d56fbd Put outstanding packets, events and associated counters in one class
Summary: ^

Reviewed By: yangchi

Differential Revision: D21956286

fbshipit-source-id: 305b879ad11df23aae8e0c3aac4645c0136b3012
2020-06-10 12:45:28 -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
Yang Chi
7bfeec366a Use QuicInplacePacketBuilder for write path
Summary: as title

Reviewed By: mjoras

Differential Revision: D21211415

fbshipit-source-id: 15814f951adca2eb4ded8228e2d291a9c1514011
2020-05-12 07:04:57 -07:00
Yang Chi
62d122a0c4 Fallback to write a Ping frame if Quic Probe doesn't write anything
Summary: as title

Reviewed By: mjoras

Differential Revision: D21464423

fbshipit-source-id: 48cec75f6c8ff0be1e41a5d5a6da0fabf064973a
2020-05-10 09:32:05 -07:00
Yang Chi
fd41b0e324 Quic Probing can write frames other than stream frames
Summary:
During PTO, when we try to write new data, we have been limiting to
only stream data and crypto data. This diff adds a few more types of data to
write during probes if they are available: Simple frame, Window updates, Rst
and Blocked frames.

Right now Acks won't be included here.

Reviewed By: mjoras

Differential Revision: D21460861

fbshipit-source-id: d75a296e96375690eee5e609efd7d1b5c103e8da
2020-05-10 09:32:05 -07:00
Matt Joras
b7389426dc Move retransmission buffer CHECK
Summary: This is just in wrong place. There can be multiple frames per packet that we may be implicitly ACKing.

Reviewed By: lnicco

Differential Revision: D21493553

fbshipit-source-id: 89befab01c5a27d400089478717110bca8137d99
2020-05-09 23:26:40 -07:00
Matt Joras
19dae4b3a0 Clear loss buffer on handshake done.
Summary: Without doing this the loss buffer can potentially carry data indefinitely.

Reviewed By: yangchi

Differential Revision: D21484470

fbshipit-source-id: 85ac9f274c9badb51eb431b85f67a654c399a018
2020-05-09 17:19:42 -07:00
Yang Chi
7bb0dddf34 Check cipher presence before decide to fire write looper for crypto
Summary: they now can be dropped

Reviewed By: mjoras

Differential Revision: D21476334

fbshipit-source-id: 646b993573fea460b0cd967bdb312cd849ac35d3
2020-05-08 16:17:44 -07:00
Yang Chi
46b9fb69f4 Skip a packet number for Quic probe packets
Summary: to elicit acks

Reviewed By: mjoras

Differential Revision: D21309835

fbshipit-source-id: fd56de66c806d5e03292298c79eab49014291b75
2020-05-08 11:41:04 -07:00
Matt Joras
50d5c29346 Cipher dropping take 2
Summary:
Now we won't have a zero PTO and we will properly clear out the outstanding packets.

Note that this cipher dropping is not what the draft prescribes, instead dropping both the initial and handshake ciphers when we know 1-rtt communication is functioning.

Reviewed By: yangchi

Differential Revision: D20388737

fbshipit-source-id: 0b89eb80c8faa796ab09eda3eaa10a00dcf7bae9
2020-05-06 11:14:20 -07:00
Yang Chi
014d50aa41 Quic socket write for the inplace buffer writing
Summary: as title

Reviewed By: mjoras

Differential Revision: D21211414

fbshipit-source-id: 5c4b8a747457e3f21da77541a35da1af1b1ac6e4
2020-05-05 09:53:07 -07:00
Yang Chi
c653133f93 Remove setContinueOnNetworkUnreachable API from IoBufQuicBatch
Summary: this API isn't necessary

Reviewed By: mjoras

Differential Revision: D21005961

fbshipit-source-id: e1be324102b3f9ff2a2d7ef2228711dea3119ebc
2020-04-29 20:37:00 -07:00
Yang Chi
6f71c2dda6 Quic CloningScheduler uses the correct packet builder to clone old packets
Summary: as title

Reviewed By: mjoras

Differential Revision: D20919831

fbshipit-source-id: 76e264780515bb98c32886d75dedd7902958e71e
2020-04-29 20:36:59 -07:00
Yang Chi
2a1529068d Move Quic packet header encoding out of builder constructor
Summary:
Currently the packet builder contructor will encode the packet
builder. This is fine when the builder creates its own output buffer. If later
on we decides not to use this builder, or it fails to build packet, the buffer
will be thrown away. But once the builder uses a buffer provided by caller, and
will be reused, we can no longer just throw it away if we decide not to use
this builder. So we have to delay the header encoding until we know we will use
the builder.

This is still not enough to solve the case where we want to use this builder,
it builds, then it fails . For that, we will need to retreat the tail position
of the IOBuf.

Reviewed By: mjoras

Differential Revision: D21000658

fbshipit-source-id: 4d758b3e260463b17c870618ba68bd4b898a7d4c
2020-04-28 22:14:21 -07:00
Dan Melnic
55443f2b16 Add support for thread local batch writers
Summary: Add support for thread local batch writers

Reviewed By: mjoras

Differential Revision: D21004810

fbshipit-source-id: 907a25f95afeab78fdc7e83cbab87b4f51adc3d3
2020-04-23 18:39:09 -07:00
Matt Joras
524bf84c44 Implement an explicit inplace encrypt in Aead.
Summary: This is useful when you want to ensure that the IOBuf you pass in is encrypted inplace, as opposed to potentially creating a new one.

Reviewed By: yangchi

Differential Revision: D21135253

fbshipit-source-id: 89b6e718fc8da1324685c390c721a564bb77d01d
2020-04-21 21:43:59 -07:00