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

59 Commits

Author SHA1 Message Date
Aman Sharma
c10bf16cfc Move core functionality to QuicTransportBaseLite [23/n][take 2]
Summary: This is pretty much the same as D65605100, which was reverted due to a cycle detection ([link](https://fb.workplace.com/groups/mobile.sheriffs/posts/27342968238658432/?comment_id=27343054638649792)). It turns out that the issue was that I didn't run `xplat/cross_plat_devx/somerge_maps/compute_merge_maps.py`.

Reviewed By: jbeshay

Differential Revision: D65761171

fbshipit-source-id: fc852ec13e54ea6ea45b4fda6b4556a78f38fc7f
2024-11-11 18:44:57 -08:00
Alex Jackson Lambert
f8a5876111 Revert D65605100: Move core functionality to QuicTransportBaseLite [23/n]
Differential Revision:
D65605100

Original commit changeset: aaa7f394b669

Original Phabricator Diff: D65605100

fbshipit-source-id: a087043af67d5ea30ab6d040162d1e72fdf67425
2024-11-08 19:24:37 -08:00
Aman Sharma
3f7555ae98 Move core functionality to QuicTransportBaseLite [23/n]
Summary: See title.

Reviewed By: hanidamlaj

Differential Revision: D65605100

fbshipit-source-id: aaa7f394b6699401ff84c1e5ed010e42670e39f0
2024-11-08 18:08:32 -08:00
Aman Sharma
8e650ed585 Rename PacketEvent -> ClonedPacketIdentifier [take 2]
Summary: This is my second attempt at D61871891. This time, I ran `xplat/cross_plat_devx/somerge_maps/compute_merge_maps.py`, which generated quic/somerge_defs.bzl

Reviewed By: kvtsoy

Differential Revision: D61975459

fbshipit-source-id: bec62acb2b400f4a102574e8c882927f41b9330e
2024-08-30 12:18:20 -07:00
Marshall Mann-Wood
457ae5b1ac Revert D61871891: Rename PacketEvent -> ClonedPacketIdentifier
Differential Revision:
D61871891

Original commit changeset: f9c626d900c8

Original Phabricator Diff: D61871891

fbshipit-source-id: afe88d4b7a2ca62b16e122d9f087df3caf3e0f41
2024-08-28 16:13:54 -07:00
Aman Sharma
6f13f404b0 Rename PacketEvent -> ClonedPacketIdentifier
Summary: `PacketEvent` is a very inaccurate and misleading name. We're basically using this as an identifier for cloned packets, so `ClonedPacketIdentifier` is a much better.

Reviewed By: kvtsoy

Differential Revision: D61871891

fbshipit-source-id: f9c626d900c8b7ab7e231c9bad4c1629384ebb77
2024-08-28 14:26:30 -07:00
Aman Sharma
bc386475e5 Integrate RangeChain into write path of QUIC stack
Summary: See title

Reviewed By: mjoras

Differential Revision: D58216871

fbshipit-source-id: 9afc08946a676ec967c998416a6470d4884af550
2024-08-15 05:46:08 -07:00
Joseph Beshay
93d38a9d8d Schedule an ack immediately when a packet marked with ECN CE is received
Summary:
Timely reaction to congestion requires relaying any CE marks to the sender as soon as possible.

This change schedules an ack to be sent whenever incoming packets are received with CE marks. This will only happen when the readEcnOnIngress option is enabled.

Reviewed By: mjoras

Differential Revision: D58423959

fbshipit-source-id: 30f8cf8b11d0446985c2d87d7df67c24c0d5afdf
2024-06-12 12:08:04 -07:00
Matt Joras
aefc9e369b Introduce quic::Optional
Summary:
The idea here is to make it so we can swap out the type we are using for optionality. In the near term we are going to try swapping towards one that more aggressively tries to save size.

For now there is no functional change and this is just a big aliasing diff.

Reviewed By: sharmafb

Differential Revision: D57633896

fbshipit-source-id: 6eae5953d47395b390016e59cf9d639f3b6c8cfe
2024-06-11 11:02:02 -07:00
Matt Joras
3cac323c08 Remove cmsgs from the outstanding packet.
Summary:
Remove cmsgs from each outstanding packet. Storing this as a map is excessive. Instead store it as a packed enum. This supports one kind of mark per packet.

If we ned to we could in the future support multiple types of marks per packet by using a bitset-style flag, e.g. each bit index representing a different mark. For now just use an enum.

Reviewed By: jbeshay

Differential Revision: D57397865

fbshipit-source-id: 6d34215c9d7e39537c44c6c304a8ce3a5883541e
2024-06-11 11:02:02 -07:00
Joseph Beshay
71b8af4b1a Add new batch writer SinglePacketBackpressureBatchWriter to retry failed writes
Summary:
The existing batch writers do not handle failed writes to the AsyncUDPSocket. A packet that fails to be written is detected as a packet loss later when feedback is received from the peer. This negatively impacts the congestion controller because of the fake loss signal, and artificially inflates the number of retransmitted packets/bytes.

This change adds a new batch writer (SinglePacketBackpressuretBatchWriter) that retains the buffers when a write fails. For subsequent writes, the writer retries the same buffer. No new packets are scheduled until the retried buffer succeeds.

Notes:
- To make sure that retry writes are scheduled, the write callback is installed on the socket when a buffer needs to be retried.
- The retries are for an already scheduled packet. The connection state reflects the timing of the first attempt. This could still have an impact on rtt samples, etc. but it this is a milder impact compared to fake losses/retranmissions.
- Any changes outside of the batch writer only impact the new batch writer. Existing batch writers do not use the fields and are not affected by the changes in this diff.

Reviewed By: kvtsoy

Differential Revision: D57597576

fbshipit-source-id: 9476d71ce52e383c5946466f64bb5eecd4f5d549
2024-05-22 15:35:32 -07:00
Hani Damlaj
9084526f80 introduce handleInitialWriteDataCommon
Summary: - as title; code de-dup

Reviewed By: sharmafb

Differential Revision: D55901183

fbshipit-source-id: 4eae4f2c87c16a413d92c5a724baa35a8f796810
2024-05-16 20:45:24 -07:00
Matt Joras
d74250d7a6 Use CircularDeque in streams and datagram state.
Summary:
std::deque by default allocates a large block on the heap for managing its state. This has a fixed memory cost both per connection (because of the crypto streams) and per stream. CircularDeque by comparison does not have this overhead and is only 32 bytes per structure.

For example:
```
                          "size": 656,
                          "name": "readBuffer",
                          "typePath": ["a0", "conn_", "ptr_val", "cryptoState", "ptr_val", "initialStream", "readBuffer"],
                          "typeNames": ["std::deque<quic::StreamBuffer, std::allocator<quic::StreamBuffer>>"],
```
This should save about 6kB per connection with no streams, and additional memory per stream.

Reviewed By: jbeshay, hanidamlaj

Differential Revision: D56578219

fbshipit-source-id: ab2b529fa9a4169bea6862b11ccbf178c6f5abb1
2024-04-25 09:34:27 -07:00
Jake Bolam
3570f0122f Revert D56496459: Use CircularDeque in streams and datagram state.
Differential Revision:
D56496459

Original commit changeset: ec4049614939

Original Phabricator Diff: D56496459

fbshipit-source-id: 5b1ee6dcfe59ae2e62a6d818f5839d95d26d4431
2024-04-25 04:37:33 -07:00
Matt Joras
01690c4159 Use CircularDeque in streams and datagram state.
Summary:
std::deque by default allocates a large block on the heap for managing its state. This has a fixed memory cost both per connection (because of the crypto streams) and per stream. CircularDeque by comparison does not have this overhead and is only 32 bytes per structure.

For example:
```
                          "size": 656,
                          "name": "readBuffer",
                          "typePath": ["a0", "conn_", "ptr_val", "cryptoState", "ptr_val", "initialStream", "readBuffer"],
                          "typeNames": ["std::deque<quic::StreamBuffer, std::allocator<quic::StreamBuffer>>"],
```
This should save about 6kB per connection with no streams, and additional memory per stream.

Reviewed By: kvtsoy

Differential Revision: D56496459

fbshipit-source-id: ec4049614939f885f64481bd374c81e74ad47c66
2024-04-25 00:43:04 -07:00
Joseph Beshay
aeacf40ae8 Key update support: Add support for initiating periodic key updates for both client and server [4/x]
Summary:
Allow the server/client transport to initiate periodic key update. It's defaulted to being disabled.

The new logic for initiating and verifying a key update was handled correctly by the peer is consolidated in QuicTransportFunctions.

Reviewed By: mjoras

Differential Revision: D53109624

fbshipit-source-id: 0c3a944978fc0e0a84252da953dc116aa7c26379
2024-02-01 15:41:27 -08:00
Joseph Beshay
bff30c1f7a Key update support: Server response to key updates [1/x]
Summary:
This stack adds key update support to Mvfst client and server. This diff adds the main logic for detecting key updates in the QuicReadCodec. When an update is successful, the server transport reacts to it by updating the write phase and cipher.

The high level design is as follows:
- The QuicReadCodec is responsible for detecting incoming key update attempts by the peer, as well as tracking any ongoing locally-initiated key updates.
- Upon detecting a successful key update, the QuicReadCodec updates its state. The Server/Client transport reacts to this change by updating its write phase and cipher.
- A locally initiated key update starts with updating the write phase and key, and signaling the read codec that a key update has been initiated.
- The read codec keeps this in a pending state until a packet is successfully received in the new phase.
- Functions for syncing the read/write phase on incoming key updates, as well as initiating and verifying outgoing key updates are abstracted in QuicTransportFunctions and are used by both the client and server transports.
- Common handshake functions used for rotating the keys are now in HandshakeLayer that is shared by both client and server handshakes.

Reviewed By: mjoras

Differential Revision: D53016559

fbshipit-source-id: 134e965dabd62917193544a9655a4eb8868ab7f8
2024-02-01 15:41:27 -08:00
Joseph Beshay
ead139adef Move all mvfst use-cases to the new Eventbase, Timer, and Socket interfaces
Summary:
This is the major transition that updates mvfst code to use the new interfaces. The new Folly implementations of the interfaces maintain all the existing behavior of folly types so this should not introduce any functional change. The core changes are:
- Update the BatchWriters to use the new interfaces.
- Update the FunctionLooper to use the new interfaces.
- Change QuicServerTransport to take the folly types and wrap them in the new types for use in the QuicTransportBase.

The rest of the diff is for updating all the existing uses of the QuicTrasnport to initialize the necessary types and pass them to the QUIC transport instead of directly passing folly types.

Reviewed By: mjoras

Differential Revision: D51413481

fbshipit-source-id: 5ed607e12b9a52b96148ad9b4f8f43899655d936
2023-12-14 00:24:12 -08:00
Hani Damlaj
905554ecd3 remove setCustomTransportParameter helper function
Summary:
- Remove setCustomTransportParameter, which (based on the quic v19 rfc), verifies whether a parameter is within the private range [0xff00, 0xffff]

> Values with the first byte in the range 0x00 to 0xfe (in hexadecimal) are assigned via the Specification Required policy [RFC8126].

- Consolidating adding MaxStreamGroups transport parameter into all other transport parameters extension.

More specifically, `QuicClientTransport::maybeEnableStreamGroups()` logic is now moved into `QuicClientTransport::setSupportedExtensionTransportParameters()`

Reviewed By: mjoras

Differential Revision: D50461610

fbshipit-source-id: 802b546c8364586cdcf36a230b156ca140c57ce4
2023-11-02 06:01:16 -07:00
Brandon Schlinker
a1445434b0 Cleanup and modularize receive path, improve timestamp support [5/x]
Summary:
This diff changes `QuicAsyncUDPSocketWrapper` so that it is an abstraction layer that inherits from `QuicAsyncUDPSocketType`, instead of simply being a container with aliases.
- Key changes in `QuicAsyncUDPSocketWrapper.h`, the rest of the updates switch us from using `QuicAsyncUDPSocketType` to `QuicAsyncUDPSocketWrapper`.
- It's difficult to mock the UDP socket today given that we expose the entire `folly::AsyncUDPSocket` type to the higher layers of the QUIC stack. This complicates testing and emulation because any mock / fake has to implement low level primitives like `recvmmsg`, and because the `folly::AsyncUDPSocket` interface can change over time.
- Pure virtual functions will be defined in `QuicAsyncUDPSocketWrapper` in a follow up diff to start creating an interface between the higher layers of the mvfst QUIC stack and the UDP socket, and this interface will abstract away lower layer details such as `cmsgs` and `io_vec`, and instead focus on populating higher layer structures such as `NetworkData` and `ReceivedPacket` (D48714615). This will make it easier for us to mock or fake the UDP socket.

This diff relies on changes to `folly::MockAsyncUDPSocket` introduced in D48717389.

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps.

Reviewed By: jbeshay, hanidamlaj

Differential Revision: D48717388

fbshipit-source-id: 4f34182a69ab1e619e454da19e357a6a2ee2b9ab
2023-09-21 07:57:58 -07:00
Konstantin Tsoy
4a0dd1e2a4 QuicAsyncUDPSocketWrapper
Reviewed By: jbeshay

Differential Revision: D46379200

fbshipit-source-id: f6a7c1cf68108872e05e6fd8adb7f00aae22b2ed
2023-07-11 15:21:15 -07:00
Matt Joras
d31f2f7f16 Fix bytesWritten return
Summary: Turns out these functions have been returning 0 for bytes written for a while. Nothing was using them (yet), so there wasn't any functional breakage.

Reviewed By: kvtsoy

Differential Revision: D46653336

fbshipit-source-id: 765b3363c1fc0729e8239d1293ddcc4ae4bb9c79
2023-06-12 17:02:16 -07:00
Joseph Beshay
24f00aad4a Allow Packet Processors to specify prewrite requests that apply to each write loop
Summary:
Adds a prewrite function in packet processors that can be used to set PreWrite Reuqests that will apply apply to the next write loop in the QuicSocket.

Currently, the PrewriteRequest only contains a list of cmsgs but it can be expanded when needed.

This replaces the setAdditionalCmsgs callback that was previously passed down directly to AsyncUDPSocket, allowing multiple processors to affect the additionalCmsgs sent to the AsyncUDPSocket.

Reviewed By: bschlinker

Differential Revision: D44233700

fbshipit-source-id: 799357ee5df89b2a526611bd83d0b4a9a13b71d5
2023-03-24 16:14:59 -07:00
Hani Damlaj
6cd4f47735 elide malloc calls
Summary: - optimizing `setSupportedExtensionTransportParameters()` to elide invocations to malloc()

Reviewed By: mjoras

Differential Revision: D43844018

fbshipit-source-id: 38da5c62786f795a3a79e7592d06d4da1d7487ba
2023-03-15 15:58:02 -07:00
Konstantin Tsoy
377260f704 Remove d6d code
Summary: we're not using it

Reviewed By: mjoras

Differential Revision: D43482344

fbshipit-source-id: 05ac6792848e32e7c1bcf53a2df172852b5def62
2023-02-23 20:11:24 -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
Konstantin Tsoy
003c12fb22 Move setCustomTransportParameter() to free functions
Summary: Move setCustomTransportParameter() to free functions

Reviewed By: mjoras

Differential Revision: D36204576

fbshipit-source-id: 513c11852a339d441af9f3fc948679814da98900
2022-05-19 20:01:28 -07:00
Hani Damlaj
747c41c30d Fix Probing Bytes Limit
Summary:
- PTOs should not be subject to congestion control limits
- Quickly recover from PTOs being writableBytesLimited by calling onPTOAlarm() as soon as we become unblocked

Reviewed By: mjoras

Differential Revision: D35480409

fbshipit-source-id: 51500db6fff17a7badefea8bda7f63141e97f746
2022-04-19 00:50:36 -07: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
Hani Damlaj
00e67c1bf9 mvfst License Header Update
Reviewed By: lnicco

Differential Revision: D33587012

fbshipit-source-id: 972eb440f0156c9c04aa6e8787561b18295c1a97
2022-01-18 13:56:12 -08:00
Hani Damlaj
2660a288b3 Update Company Name
Summary: - as title

Reviewed By: lnicco

Differential Revision: D33513410

fbshipit-source-id: 282b6f512cf83b9abb7990402661135b658f7bd1
2022-01-13 12:07:48 -08:00
Hani Damlaj
f60c254c49 Log Server Handshake Size
Summary: - logging number of bytes the server sent during the handshake for insight.

Reviewed By: mjoras

Differential Revision: D33069800

fbshipit-source-id: e7e8f25183ee30de99e2971bae3c6b93882f6e63
2022-01-06 10:34:06 -08:00
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
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
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
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
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
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
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
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
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
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
7d52f280f8 Quic Refactor to move Build->Schedule->Encrypt operation into a functor
Summary:
To prepare for another configuration of this chain. With this, now we
can land all the outstanding GSO optimization diffs without having to worry
about breaking the production code.

Reviewed By: mjoras

Differential Revision: D20838453

fbshipit-source-id: 807a0c546305864e0d70f8989f31d3de3b812278
2020-04-10 09:16:14 -07:00
Matt Joras
46e9228420 Use inplace encryption from fizz.
Summary:
The fizz `encrypt` API will opportunistically use inplace encryption if the `IOBuf` you pass it is correctly sized. If it is not it will manually create the output buffer.

It turns out doing inplace versus encrypting with a given target output is a bit faster in microbenchmarks, and it will also allow experimenting with caching `IOBuf`s on the send path.

Reviewed By: knekritz

Differential Revision: D19506291

fbshipit-source-id: 3ef41290538ceac34a344114badbd167e2c25a50
2020-01-29 15:07:26 -08:00