Commit Graph

2689 Commits

Author SHA1 Message Date
Dirkjan Ochtman e1df56f40c quinn-proto: move PacketBuilder into a separate module 2021-03-01 13:06:10 -08:00
Dirkjan Ochtman 6bddfdea1a quinn-proto: handle handshake packets separately 2021-03-01 13:06:10 -08:00
Dirkjan Ochtman 816e570151 quinn-proto: inline single-use reject_0rtt() method 2021-03-01 13:06:10 -08:00
Dirkjan Ochtman 18ed973568 quinn-proto: refactor how ACKs are passed to the congestion controller 2021-03-01 13:06:10 -08:00
Dirkjan Ochtman 4e6b8c6fe4 quinn-proto: add comment to clarify need for custom iteration 2021-03-01 13:06:10 -08:00
Dirkjan Ochtman c4af9ecb1c fuzz: change config syntax to allow merging 2021-03-01 13:06:10 -08:00
Matthias Einwag 0020e1ee39 Add a Bytes array based send interface to quinn-proto
This change modifies quinn-proto to allow callers to submit a list
of one or more owned `Bytes` chunks for transmission instead of
pure byte slices. This will provide a more efficient zero-copy
interface for applications which already make use of owned
`Bytes` buffers.

The internals of quinn-proto have been refactored in order to keep
the ability to pass `&[u8]` buffers and defer the conversion into
`Bytes` as long as possible, in order to avoid unnecessary allocations
if no data can be stored due to flow control.
2021-03-01 09:20:20 +01:00
Matthias Einwag eb1911d416 Write Bytes into SendBuffer
This changes the interface from SendBuffer to directly accept owned
`Bytes` buffers, instead of converting to them.
2021-03-01 09:20:20 +01:00
Benjamin Saunders a9aaf40943 Implement perf protocol for standardized benchmarking 2021-02-28 22:31:43 +01:00
Dirkjan Ochtman 14db88562d quinn: split streams module in send/recv parts 2021-02-25 12:06:38 -08:00
Dirkjan Ochtman 24cf82ef83 Expose iterator-like read API 2021-02-25 12:06:38 -08:00
Dirkjan Ochtman dd23094007 quinn-proto: remove unnecessary RecvState::Closed 2021-02-25 12:06:38 -08:00
Benjamin Saunders 241cc9cad1 Fix premature abandoment of STOP_SENDING transmission 2021-02-25 16:02:00 +01:00
Benjamin Saunders dd67e91425 Fix state leak for receive streams stopped after being finished 2021-02-25 16:02:00 +01:00
Benjamin Saunders 589534ff4e Tweak method name to avoid confusion with having received FIN 2021-02-25 16:02:00 +01:00
Joshua Koo b54e363cff Fixed typo allow_wpin -> allow_spin 2021-02-25 05:13:00 +01:00
Matthias Einwag be27d52134 Do not send any packets after a close frame
Since the loop was not exited after a close frame was transmitted,
other data in the same space could have been transmitted after
the frame. This adds a `break` to fix this.
2021-02-24 21:04:30 +01:00
Matthias Einwag 8e7c970e83 Make TestEndpoint GSO compatible
The TestEndpoint so far tried to send a single big datagram instead of using
proper GSO sending to emit multiple datagrams.

In order to avoid relying on platform GSO support, this change will simply
split up GSO transmissions into multiple Transmits in the endpoint.
2021-02-24 09:27:57 +01:00
Benjamin Saunders 2adc1bc3cc Remove unnecessary send stream state 2021-02-24 07:09:51 +01:00
Benjamin Saunders c2467fa61d Apply client initial padding consistently
Fixes unconditional padding of close packets
2021-02-24 07:08:26 +01:00
Benjamin Saunders 4d3a57cfaf Fix regression in application of padding to congestion control
These was broken in 095f402a9f, and
rendered needlessly complex by
f1628f87a2 before it.
2021-02-24 07:08:26 +01:00
Benjamin Saunders 799b5bb2b4 Fix mangled error Display impls
These were formatting the literal integer 0 instead of the inner data.
2021-02-24 07:08:26 +01:00
Benjamin Saunders 05ace6a111 Padding application style tweak
Deduplicates some logic and adds a sanity-check.
2021-02-24 07:08:26 +01:00
Timon ad16714b35 Networking Introduction Book Chapter (#917) 2021-02-23 09:52:40 +01:00
Timon 1a62da82a0 Quinn Introduction Chapter, Data transfer (#922) 2021-02-23 09:51:23 +01:00
Benjamin Saunders 696d511ca9 Fix possible handshake deadlock on loss of first server flight 2021-02-23 07:05:29 +01:00
Benjamin Saunders 7217d428d4 Remove redundant anti-amplification check
We check this during the packet encoding loop below.
2021-02-23 07:05:29 +01:00
Benjamin Saunders 633e5a6c81 Formatting tweak 2021-02-22 20:24:50 +01:00
Benjamin Saunders e6e1019725 String panic messages
These can be more reliably displayed in useful ways.
2021-02-22 20:24:50 +01:00
Benjamin Saunders ef91537e73 Remove dead state 2021-02-22 20:24:50 +01:00
Benjamin Saunders 0968a34ac0 Remove dead stream state
We immediately dispose send streams when their reset is ACKed, so we
don't need to represent this explicitly.
2021-02-22 20:24:50 +01:00
Dirkjan Ochtman 095f402a9f quinn-proto: inline single-use method 2021-02-22 10:44:51 -08:00
Dirkjan Ochtman 8630946571 quinn-proto: return early from finish_and_track_packet() 2021-02-22 10:44:51 -08:00
Dirkjan Ochtman 34f910bae6 quinn-proto: unpack logic for Connection::space_can_send() 2021-02-22 10:44:51 -08:00
Matthias Einwag f830910ea2 Generic Send Offload (GSO) Support
This change implements an initial version of GSO support [1][2][3]
for Linux, which improves the effiency of sending data.

The approach taken in this change is to create a buffer which contains
multiple datagrams in `Connection::poll_transmit`. This was picked
over trying to merge packets in the endpoint task, since packets
seem to need to be padded to a common segment size in order to
make them sendable via GSO.

In order to to this in an efficient fashion, the `poll_transmit`
method was restructred. Instead of selecting spaces upfront, it
will now loop through all possible packet spaces, check if there is
pending data to send and create packets and datagrams out of this.

The last packet which was written to a datagram buffer is not
finalized until it is clear whether follow-up packets need to be
written, since we need to know whether this packet should get padded
to MTU length or not.

This change doesn't enable GSO yet, since it will only produce a
single datagram. I will create a separate change for this.

Performance measurements:

**No GSO:**

```
Sent 1073741824 bytes on 1 streams in 4.31s (237.66 MiB/s)
```

**With GSO (up to 8 packets):**

```
Sent 1073741824 bytes on 1 streams in 3.02s (339.18 MiB/s)
```

[1] http://vger.kernel.org/lpc_net2018_talks/willemdebruijn-lpc2018-udpgso-paper-DRAFT-1.pdf
[2] http://vger.kernel.org/lpc_net2018_talks/willemdebruijn-lpc2018-udpgso-presentation-20181104.pdf
[3] https://lwn.net/Articles/752956/
2021-02-22 13:24:38 +01:00
Matthias Einwag f1628f87a2 Change padding logic
This change defers padding packets as a runtime decision
while the packet is populated.

For individual packets, we store in `SentFrames` whether a padding is
required. If padding is required a `min_datagram_size` variable is
increased, which will later on assure that only the last packet in a
datagram gets padded.
2021-02-22 13:24:38 +01:00
Matthias Einwag 5cff9ab5f7 Set segment_size based on the amount of sent datagrams
The option only needs to be sent for GSO (multiple datagrams
in a buffer).
2021-02-22 13:24:38 +01:00
Matthias Einwag 97c0bb0869 Update stats for GSO
This adds a new stat for the number of transmit calls
and fixes the metrics for path challenges.
2021-02-22 13:24:38 +01:00
Matthias Einwag aca3d38e0c Move packet finalization into a seperate function
`finish_and_track_packet` will now take information from the builder
when finalizing the packet.
2021-02-22 13:24:38 +01:00
Matthias Einwag afc999a415 Store the transmit buffer outside of PacketBuilder
With GSO storing the buffer inside the builder does not work
due to lifetime issues - we need to hold the buffer across various packets.
This keeps the buffer outside of the builder and just references the
start of a packet via an offset.
This also removes the lifetime from `PacketBuilder`.
2021-02-22 13:24:38 +01:00
Matthias Einwag 7f50989987 Store tag_len and ack_eliciting in PacketBuilder
This allows easy access the information later on.
2021-02-22 13:24:38 +01:00
Matthias Einwag 679d8f9fd4 Update congestion_blocked function for multiple datagrams
With GSO we need to be able to check whether multiple datagrams
are sendable.
2021-02-22 13:24:38 +01:00
Matthias Einwag 6393e85102 Move the check for sendable data in a space
`space_can_send` is now a separate function which returns whether there
is sendable data in a certain space.
2021-02-22 13:24:38 +01:00
Matthias Einwag 9cb0c7b1c9 Update CMSG_LEN
Wit GSO activated, encoding cmsgs paniced since not enough
space was available. We need a minimum of 88 bytes.
2021-02-22 13:24:38 +01:00
Matthias Einwag 7575f53639 Allow to query for more data than "mtu" in the pacing module
With GSO, we need to ask whether we can send 2 additional datagrams.
2021-02-22 13:24:38 +01:00
Benjamin Saunders 08d094c153 Reexport ReadChunk(s) 2021-02-21 21:11:20 +01:00
Matthias Einwag 80376ff305 Allow to specify the cipher suite in bulk test
rustls defaults to CHACHA20, which is rather slow on desktop hardware.
This change allows to specify a single cipher suite for this test, and
sets the default to AES128.

CHACHA20 (default):
> Sent 4294967296 bytes on 1 streams in 14.86s (275.68 MiB/s)

AES128:
> Sent 4294967296 bytes on 1 streams in 12.21s (335.59 MiB/s)
2021-02-16 19:14:36 +01:00
Matthias Einwag e9a799676f Prefer AES cipher suites
Testing showed that there is a huge performance boost using AES ciphers
due to hardware acceleration. Therefore those should be preferred.

As an example, a benchmark run using CHACHA20 reached a throughput
of 350MB/s, whereas the same configuration using AES128 reached 520MB/s.

While CHACHA20 might have higher performance on devices without
hardware acceleration for AES, this set of devices might now be tiny.
2021-02-16 10:06:33 +01:00
Edgar Geier b9eb42ee75 quinn-proto: trigger defragmentation based on over-allocation (fix #981) 2021-02-15 20:11:18 +01:00
Matthias Einwag cd974a7945 Disable hdrhistogram features
This causes nom to be pulled in, which currently causes the CI error and build
conflict between `funty` and `bitvec`: https://github.com/myrrlyn/funty/issues/3

We don't need the feature in this scenario anyway.
2021-02-15 07:13:59 +01:00