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

128 Commits

Author SHA1 Message Date
Matt Joras
6afecccd25 Track loop limit time across functions.
Summary: Otherwise we can end up in a situation where the non-DSR scheduler was limited by the loop time while the DSR scheduler is not, leading to an inconsistency.

Reviewed By: lnicco

Differential Revision: D32570027

fbshipit-source-id: f43d2517589c22bac0f2bb76626cc55c2a21fa5d
2021-11-19 19:04:37 -08:00
Matt Joras
612a00c3f9 Move happy eyeballs state to client state.
Summary: This doesn't belong in the generic state. Untangling it is a little difficult, but I think this solution is cleaner than having it in the generic state.

Reviewed By: JunqiWang

Differential Revision: D29856391

fbshipit-source-id: 1042109ed29cd1d20d139e08548d187b469c8398
2021-07-23 14:21:16 -07:00
Matt Joras
7402dbe6c9 Move zero RTT ciphers to client state.
Summary: As in title, this doesn't need to be in the base state.

Reviewed By: JunqiWang

Differential Revision: D29855140

fbshipit-source-id: 8d3a4b12fd6b93b2277020d56862915e084f1c05
2021-07-23 14:21:16 -07: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
5dd53e6e2c Datagram frames are not rtx-able
Summary: We are now adding them to the outstanding packet list, for not good reason.

Reviewed By: mjoras

Differential Revision: D29469128

fbshipit-source-id: b279774b6ef5bbb436b3c9d7bcdad39eea8f1079
2021-07-01 19:45:37 -07:00
Matt Joras
e848899795 Fix accounting bug in closes.
Summary:
We didn't actually ensure there was enough room for the tag here, which means we'd fail to encrypt the close.

(Note: this ignores all push blocking failures!)

Reviewed By: yangchi, lnicco

Differential Revision: D29187670

fbshipit-source-id: 97e4f60feaf6b1998ffafe3b1289df94586e9c5e
2021-06-17 19:57:43 -07:00
Luca Niccolini
dc3b4dded0 Write DATAGRAM frames when available
Summary:
Right now we are waiting for another write event to write datagrams.
Introduced a Write Reason for the case when only DATAGRAMS are pending

Reviewed By: mjoras

Differential Revision: D29091822

fbshipit-source-id: 0de6b88d93acae0ba240b9cdf9dbc8e74feaf5ac
2021-06-13 21:13:19 -07:00
Yang Chi
0e6a998e05 Fix QUIC EOF sending when DSR is used
Summary:
This is a bug fix. When a stream finished sending all it's BufMetas, it can
send EOF from frontend QUIC host. In that case, it will use
currentWriteOffset value which is wrong.

This diff changes it so that (1) frontend can only write FIN only frame if
writeBufMeta's offset is <= finalWriteOffset; (2) When it writes such frame
it will use finalWriteOffset as the offset value in the frame.

Reviewed By: lnicco

Differential Revision: D28727029

fbshipit-source-id: 8f963c2e2d66f921f8a9704ed4671ec4f7c04df7
2021-06-01 13:16:20 -07:00
Sridhar Srinivasan
7246cd5e3c Record stream details in packet metadata
Summary:
Introruced a new DetailsPerStream struct inside the outstanding packet metadata
so we can easily track all streams carrying app data within a packet and each
stream's bytes sent (both new and total).

With this, consumers can easily deduce the number of retransmitted bytes per
stream using the StreamDetails members:
newStreamBytesSent - streamBytesSent.

Reviewed By: bschlinker

Differential Revision: D28063916

fbshipit-source-id: d915514f85f24f4889cfac2f7a66bfd2d6b0a4af
2021-05-14 11:55:17 -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
Yang Chi
64eb5991e3 Add isDSRPacket into the updateConnection logline
Summary: for debug purpose

Reviewed By: mjoras

Differential Revision: D27940904

fbshipit-source-id: 973b882ab05f8770999e3bc54f9d06957d62a2b0
2021-05-04 18:38:59 -07:00
Yang Chi
cdacec015a QuicServerTransport write DSR packetization requests
Summary:
This diff hooks the DSR write function into QuicServerTransport's
write path.

Reviewed By: mjoras

Differential Revision: D27890711

fbshipit-source-id: ac4452373c0baafe091f93fb54fccf87be604a9c
2021-05-04 01:08:16 -07:00
Yang Chi
efa466158e QUIC IoBufQuicBatch no need to have a ref to connection state
Summary:
all it wants is just a pointer to the statsCallback member

(Note: this ignores all push blocking failures!)

Reviewed By: mjoras

Differential Revision: D27786211

fbshipit-source-id: 3364681348ee01684d6cb8d2837bee9549f64e3a
2021-04-28 08:06:27 -07:00
Yang Chi
da8a74d427 Move QUIC WriteBufferMeta related members to QuicStreamState
Summary: QuicStreamLike can crypto streams which won't support DSR

Reviewed By: mjoras

Differential Revision: D27668524

fbshipit-source-id: 3ae5e11618a5be08a1ba20092293b80f61ce89eb
2021-04-20 20:09:10 -07:00
Yang Chi
4ab385c216 Do not use the regular CloningScheduler to clone DSR packet
Summary: For now let it fallback to ping.

Reviewed By: mjoras

Differential Revision: D27481741

fbshipit-source-id: 874529a06ab882d9651e06f615bc82505c1c2872
2021-04-19 11:08:26 -07:00
Matt Joras
b16c3b306b Clean up initial/handshake ciphers a little more intelligently.
Summary: Right now we are running the handshakeConfirmed code a lot on the client. This is excessive. We only need to run the code if we haven't already dropped the cipher.

Reviewed By: yangchi

Differential Revision: D27725974

fbshipit-source-id: ca325c132debdd280e447ca30876488b879ff13c
2021-04-13 10:11:47 -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
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
Yang Chi
2d061aa464 Mark DSR outstanding packets in QUIC outstanding packets queue
Summary: as title

Reviewed By: mjoras

Differential Revision: D26986163

fbshipit-source-id: 2a90689650e6dfab1a88830188ae76fcddb894da
2021-03-19 08:48:14 -07:00
Yang Chi
abfafda50f Write SendInstruction to DSRPacketizationRequestSender
Summary:
(1) Check if stream has DSR data
(2) Write them to the packet builder
(3) Guard against flow control and congestion control limit
(4) Add the instruction to the DSRPacketizationRequestSender
(5) Flush
(6) update connection state

Reviewed By: mjoras

Differential Revision: D26851557

fbshipit-source-id: 850958995ef10744826ee892fdea211ac441b078
2021-03-19 08:48:14 -07:00
Yang Chi
cf4f6f8d1d Make Quic Write loop time limit helper lambda into a function
Summary: as title

Reviewed By: yairgott

Differential Revision: D26851411

fbshipit-source-id: 37a5573d7d3c6a4320ec15e437312a3bb82ba75a
2021-03-12 08:16:34 -08:00
Yang Chi
cabbdfa0d7 Redo "Update QUIC stream state after BufferMeta is written "
Summary: try to land this again without the compiler flags change

Differential Revision: D26958681

fbshipit-source-id: d00659aaf819dbb2942da8b41deab3d108a19f0f
2021-03-10 17:46:24 -08: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
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