1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-09 20:42:44 +03:00
Commit Graph

34 Commits

Author SHA1 Message Date
Subodh Iyengar
e524c0c069 iobufqueue diediedie
Summary:
Don't use IOBufQueue for most operations in mvfst and use BufQueue instead. Since BufQueue did not support a splitAtMost, added it in instead.

The only place that we still use IOBufQueue is in crypto because fizz still requires it

Reviewed By: mjoras

Differential Revision: D18846960

fbshipit-source-id: 4320b7f8614f8d2c75f6de0e6b786d33650e9656
2019-12-06 12:06:44 -08:00
Raghu Nallamothu
e06de27550 Merge Application Close Frame and Connection Close Frame
Summary: As a part of Draft 17, application close frame has been removed, we use connection close frame to represent both application close and connection close.

Reviewed By: mjoras

Differential Revision: D18580856

fbshipit-source-id: d274fa2d3dbc59b926bca5a2b8a20328ae582703
2019-12-03 15:02:06 -08:00
Yang Chi
7229ad4fd7 Remove packet_sent for non-close packets from quic trace
Summary:
As the first step of deprecating quic trace in favor of qlog, this
diff removes the packet_sent event

Reviewed By: sharma95

Differential Revision: D18708001

fbshipit-source-id: 5c12c13b284f00cc7d3075086e10f517ede904cb
2019-11-27 00:25:26 -08:00
Matt Joras
b6e134fdee Use F14FastMap as the retranmission buffer.
Summary:
The retransmission buffer tracks stream frame data we have sent that is currently unacked. We keep this as a sorted `deque`. This isn't so bad for performance, but we can do better if we break ourselves of the requirement that it be sorted (removing a binary search on ACK).

To do this we make the buffer a map of offset -> `StreamBuffer`.

There were two places that were dependent on the sorted nature of the list.

1. For partial reliablity we call `shrinkBuffers` to remove all unacked buffers less than an offset. For this we now have to do it with a full traversal of the retransmission buffer instead of only having to do an O(offset) search. In the future we could make this better by only lazily deleting from the retransmission buffer on ACK or packet loss.

2. We used the start of the retransmission buffer to determine if a delivery callback could be fired for a given offset. We need some new state to track this. Instead of tracking unacked buffers, we now track acked ranges using the existing `IntervalSet`. This set should be small for the typical case, as we think most ACKs will come in order and just cause existing ranges to merge.

Reviewed By: yangchi

Differential Revision: D18609467

fbshipit-source-id: 13cd2164352f1183362be9f675c1bdc686426698
2019-11-27 00:25:25 -08:00
Viktor Chynarov
7504453972 Use Path Rate Limiter for conn migration
Summary:
Use the Path rate limiter introduced in the previous diff.

When we initialize path validation of an unvalidated peer address,
enable pathValidationRateLimit.

When we receive a proper PATH_RESPONSE frame, disable this limit.

If this limit is enabled, we will check the pathValidationLimiter for
the amount of bytes we are allowed to write.

Change the migration tests in QuicServerTransportTest to use this new limiter
instead of writableByteLimits.

Update shouldWriteData to directly use the new congestionControlWritableBytes
function.

Reviewed By: yangchi

Differential Revision: D18145774

fbshipit-source-id: 1fe4fd5be7486077c58b0d1285dfb03f6c62831c
2019-11-14 13:48:17 -08:00
Matt Joras
027fedad5b Search loss buffer before retransmission buffer when determining if a write is a clone.
Summary:
We maintain the invariant that a buffer cannot be in the loss buffer and retransmission buffers at the same time. As the retransmission buffer holds all unacknowledged data that isn't marked lost, it is very likely to be larger than the loss buffer. This makes the existing case to check for cloning very expensive.

Instead search the loss buffer first, change the search of the loss buffer to a binary search, and elide the double search.

Reviewed By: yangchi

Differential Revision: D18203444

fbshipit-source-id: 66a4e424d61c4b0e3cad12c7eca009ad3d6c5a0d
2019-10-29 12:33:34 -07:00
Yang Chi
537e178a5f Introduce Tokens in Quic Pacer
Summary:
Add a token value into the pacer. This is so that when there is not
enough application data to consume all the burst size in current event loop, we
can accumulate the unused sending credit and use the later when new data comes
in. Each time a packet is sent, we consume 1 token. On pakcet loss, we clear
all tokens. Each time there is an ack and we refresh pacing rate, token
increases by calculated burst size. It is also increased when timer drifts
during writes. When there is available tokens, there is no delay of writing out
packets, and the burst size is current token amount.

Reviewed By: siyengar

Differential Revision: D17670053

fbshipit-source-id: 6abc3acce39e0ece90248c52c3d73935a9878e02
2019-10-10 22:08:11 -07:00
Subodh Iyengar
8ad7d05693 use custom variant type for errors
Summary: Use the custom variant type for errors.

Reviewed By: yangchi

Differential Revision: D17826935

fbshipit-source-id: 2bf0c3e1cc8ca84b504d201fd6c2a4266878b715
2019-10-09 22:37:40 -07:00
Subodh Iyengar
68c332acb1 Use custom variant type for write frames
Summary:
Use the custom variant type for write frames as well, now that
we use them for read frames.

Reviewed By: mjoras

Differential Revision: D17776862

fbshipit-source-id: 47093146d0f1565c22e5393ed012c70e2e23d279
2019-10-07 22:43:31 -07:00
Yang Chi
f5ca7ef590 Add new retransmission buffer directly at the end of buffer list
Summary:
The retransmission buffer list is sorted by offset. New written
always has higher offset than existing ones. Thus the binary search isn't
necessary.

Reviewed By: mjoras

Differential Revision: D17477354

fbshipit-source-id: d413a5c84c3831b257d5c1e6375bec56a763926b
2019-09-24 15:15:54 -07:00
Yang Chi
be741704a1 Reverse linear search for outstanding packet insert point
Summary: Beside the beginning of a connection where we do handshake and have packets from all 3 spaces can possibly in the outstanding packet list, for most parf of the connection, this list only has packets from AppData space. That means the packet numbers are strictly ascending for most parf of a connection. Then linear search from back can potentially reduce the number of times we do the packet number compare.

Reviewed By: mjoras

Differential Revision: D17500221

fbshipit-source-id: 15eafa439e889e45d3e4a84d9e9dad0e2c743c9d
2019-09-23 21:38:34 -07:00
Yang Chi
e9fa2d05f3 Guard QuicConnectionStateBase::DebugState value updates with
Summary: Only update DebugState values when LoopDetectorCallback is present.

Reviewed By: mjoras

Differential Revision: D17486165

fbshipit-source-id: ce88fc66318b9d603fe4b93d865ba307fe9b9d2b
2019-09-23 21:38:34 -07:00
Yang Chi
b74a9b4e6d Move packet header builder into write function when possible
Summary:
We always generate a new std::function object for such header
builders. It's ok to move them.

Reviewed By: mjoras

Differential Revision: D17479758

fbshipit-source-id: 88fbdbc5c7b7403fffd642d8f1f84e1cd57115fa
2019-09-23 21:38:33 -07:00
Subodh Iyengar
04baa15a04 Custom variant type for packetheader
Summary:
Make a custom variant type for PacketHeader. By not relying on boost::variant
this reduces the code size of the implementation.

This uses a combination of a union type as well as a enum type to emulate a variant

Reviewed By: yangchi

Differential Revision: D17187589

fbshipit-source-id: 00c2b9b8dd3f3e73af766d84888b13b9d867165a
2019-09-19 17:31:47 -07:00
Matt Joras
72e677df33 Send windowed stream limit updates
Summary:
Implement sending stream limit updates in a windowed fashion, so that as a peer exhausts its streams we will grant it additional credit. This is implemented by having the stream manager check if an update is needed on removing streams, and the api layer potentially sending an update after it initiates the check for closed streams.

This also makes some driveby changes to use `std::lower_bound` instead of `std::find` for the sorted collections in the stream manager.

Reviewed By: yangchi

Differential Revision: D16808229

fbshipit-source-id: f6e3460d43e4d165e362164be00c0cec27cf1e79
2019-09-18 11:33:03 -07:00
Matt Joras
ece3cbe387 Draft-22 varint error codes
Summary: These were changed to varints. To support this we need to do some extra horrible version plumbing. I don't want to keep this long term but it works for now.

Reviewed By: yangchi

Differential Revision: D16293568

fbshipit-source-id: a9ea9083be160aa3e6b338a7d70d7f00e44ec5ab
2019-07-18 12:07:57 -07:00
Yang Chi
2a97d4533c Quic busy write loop detector
Summary:
This diff adds a DebugState in the QuicConnectionState to track the
reason we schedule transport WriteLooper to run, the reason we end up not
writing and the number of times such write happens consecutively. And when it
reaches a predefined limit, we trigger a callback on a loop detector interface.

Reviewed By: kvtsoy

Differential Revision: D15433881

fbshipit-source-id: d903342c00bc4dccf8d7320726368d23295bec66
2019-07-17 15:18:57 -07:00
Bonnie Xu
c8fc46a7ff Rename add to addPacket
Summary: Rename `add` to `addPacket`, since `add` is an ambiguous function name, especially as we include more events.

Reviewed By: sharma95

Differential Revision: D16102141

fbshipit-source-id: 73196a5f1bcc681e3bb0a26fd9edaf34f59bf710
2019-07-08 03:34:33 -07:00
Amaury Séchet
f4e90017a3 Add mvfst specific encryption level (#26)
Summary:
This ensure a lot of code do not depend on fizz anymore.
Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/26

Reviewed By: mjoras, JunqiWang

Differential Revision: D16030663

Pulled By: yangchi

fbshipit-source-id: a3cc34905a6afb657da194e2166434425e7e163c
2019-06-27 14:09:04 -07:00
Bonnie Xu
a6606f2a52 Setup logging in Quic based on QLogger
Summary: Setup logging in Quic based on QLogger.

Reviewed By: mjoras

Differential Revision: D15818340

fbshipit-source-id: 553aaedc6043a7f079c597ef0647c5b91f3033df
2019-06-24 09:45:45 -07:00
Yang Chi
a1b86e660d Rename Quic batching num to batch size
Summary: batchingNum -> batchSize

Reviewed By: mjoras

Differential Revision: D15740004

fbshipit-source-id: 2e3ba33792248ad67e3b06da0a95dc9ff8e76892
2019-06-11 07:28:34 -07:00
Amaury Séchet
f26cd1f62d Add a bridge to fizz::Aead (#12)
Summary:
This introduce quic::Aead as a simple typedef to fizz::Aead and update the codebase to use quic::Aead . This should not impact the functionality of the code in any way.

This is a first step toward introducing an interface that is specific for mvfst so that mvfst can swap fizz for something else.
Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/12

Reviewed By: JunqiWang

Differential Revision: D15335324

Pulled By: mjoras

fbshipit-source-id: fef166a9a5c2cbae08ad9511d0abd749f330c221
2019-05-29 11:54:08 -07:00
Yang Chi
1dbe39fd76 Separate app-limited and app-idle
Summary:
Current app-limited is defined as the connection doesn't have a no
non-control stream. I'm changing this to be app-idle. And app-limited will be
changed to a state in connection where app isn't sending bytes fast enough to
keep congestion controller probing higher bandwidth.

Reviewed By: mjoras

Differential Revision: D15456199

fbshipit-source-id: e084bc133284ae37ee6da8ebb3c12f505011521e
2019-05-24 12:16:09 -07:00
Yang Chi
0195295a5c Change the retransmission data handling precondition from DCHECK to CHECK
Summary: to get prod signals

Reviewed By: kvtsoy

Differential Revision: D15461186

fbshipit-source-id: 7e37fc2d1bc799851c438a6ae5cb417f215ce2f5
2019-05-23 12:22:02 -07:00
Yang Chi
482366c63a Fix ack writes scheduling
Summary:
There is a bug in how we decide if we should schedule a write loop due
to sending Acks. Currently if one PN space has needsToWriteAckImmediately to
true and another PN space has hasAcksToSchedule to true, but no PN space
actually has both to true, we will still schdeule a write loop. But that's
wrong. We won't be able to send anything in that case. This diff fixes that.

Reviewed By: JunqiWang

Differential Revision: D15446413

fbshipit-source-id: b7e49332dd7ac7f78fc3ea28f83dc49ccc758bb0
2019-05-22 19:06:33 -07:00
Yang Chi
ca31b43564 rename timeoutBasedRetxCount to timeoutBasedRtxCount
Summary: Just to make it consistent with other var names in quic

Reviewed By: siyengar

Differential Revision: D15415528

fbshipit-source-id: 917159d6ccf86cf34612386d128d6b6d5bf62de6
2019-05-20 11:22:24 -07:00
Subodh Iyengar
408a2b8a09 Gate QuicLogger to server only
Summary:
Using FOLLY_MOBILE macro to be able to exclude
quic trace generation on mobile

Reviewed By: mjoras

Differential Revision: D14609755

fbshipit-source-id: 2d5d624703a5b58c28cb533e3c2cc20d3a5c3d45
2019-05-10 15:59:11 -07:00
Yang Chi
c35e3d6e84 Rename RTO to PTO
Summary: To conform to the current specs.

Reviewed By: mjoras

Differential Revision: D15215018

fbshipit-source-id: 4dcc495aea1cd7cebf2bc84f7367cb2e4a55df19
2019-05-06 18:50:35 -07:00
Yang Chi
374c4e5b82 move cwnd blocked trace from Cubic to QuicTransportFunction
Summary:
So this trace is shared by all CongestionControllers. This also
changes what we log into the trace.

Reviewed By: siyengar

Differential Revision: D15184916

fbshipit-source-id: 6cbeb02ee2d24a6bf8d705ff883f5a57603988e7
2019-05-02 14:02:49 -07:00
Udip Pant
4a9537798e Add correct license headers on some missing files
Summary: ^

Reviewed By: sharma95

Differential Revision: D15172546

fbshipit-source-id: bacc832752a433b86962e77bb19aff4504640e60
2019-05-01 22:42:04 -07:00
Aman Sharma
c04e0e08a2 Implementing stateless retry on the client
Summary:
This diff implements the handling of retry packets. As per the spec:
1. A client MUST accept and process at most one Retry packet for each connection attempt.  After the client has received and processed an Initial or Retry packet from the server, it MUST discard any subsequent Retry packets that it receives.
2. Clients MUST discard Retry packets that contain an Original Destination Connection ID field that does not match the Destination Connection ID from its Initial packet. This prevents an off-path attacker from injecting a Retry packet.
3. The client responds to a Retry packet with an Initial packet that includes the provided Retry Token to continue connection establishment.
4. A client sets the Destination Connection ID field of this Initial packet to the value from the Source Connection ID in the Retry packet.  Changing Destination Connection ID also results in a change to the keys used to protect the Initial packet.  It also sets the Token field to the token provided in the Retry.

Reviewed By: mjoras

Differential Revision: D14464508

fbshipit-source-id: 212539a588378fb0d795caaec150959680172781
2019-05-01 16:49:05 -07:00
Junqi Wang
2c701de030 Continue on network unreachable with timeout
Summary:
Previously we tried continue on network down and it showed good
improvement. But there was a problem: it hurts UX for airplane mode users, it
didn't return error back to user immediately but after 30/60 seconds timeout.
This adds a timer for this feature and it only allows the transport to ignore
network unreachable error for 200ms. After 200ms, it throws and reports to user
if the error persists.

Reviewed By: siyengar

Differential Revision: D15089442

fbshipit-source-id: dd87f4f579187c4b45244a7ee0477d2a0cf1b5d7
2019-04-26 10:08:35 -07:00
udippant
79032c7b9b fbshipit-source-id: f498ac5e677b2931d937ba78edd4373ba04dca2a 2019-04-25 21:33:43 -07:00
udippant
50d4939e9e Initial commit of mvfst 2019-04-22 23:42:46 -07:00