1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-04-18 17:24:03 +03:00
mvfst/quic/logging/QLoggerConstants.cpp
Joseph Beshay b45c82b884 ACK_EXTENDED frame support
Summary:
This introduces a new frame type for acks (ACK_EXTENDED) that can carry optional fields depending on the features supported by the peer. The currently supported features set will include ECN count fields, and Receive Timstamp fields. This enables a quic connection to report both ECN counts and receive timestamps, which is not possible otherwise because they use different frame types.

Support for the extended ack as well as the set of features that can be included in it is negotiated through a new transport parameter (extended_ack_supported = 0xff0a004). Its value indicates which features are supported by the local transport. The value is an integer which is evaluated against the following bitmasks:
```
  ECN_COUNTS = 0x01,
  RECEIVE_TIMESTAMPS = 0x02,
```

This diff introduces the transport parameter and negotiates the supported features between the peers of the connection. The parameter is cached in the psk cache so the client can remember the server config. It is also encoded inside the 0-rtt ticket so the server can reject it if its local config has changed.

The following diffs add reading and writing the frame itself.

The ACK_EXTENDED frame itself will have the following format
```
ACK_EXTENDED Frame {
  Type (i) = 0xB1
  // Fields of the existing ACK (type=0x02) frame:
  Largest Acknowledged (i),
  ACK Delay (i),
  ACK Range Count (i),
  First ACK Range (i),
  ACK Range (..) ...,
  Extended Ack Features (i),
  // Optional ECN counts (if bit 0 is set in Features)
  [ECN Counts (..)],
  // Optional Receive Timestamps (if bit 1 is set in Features)
  [Receive Timestamps (..)]
}

// Fields from the existing ACK_ECN frame
ECN Counts {
  ECT0 Count (i),
  ECT1 Count (i),
  ECN-CE Count (i),
}

// Fields from the existing ACK_RECEIVE_TIMESTAMPS frame
Receive Timestamps {
  Timestamp Range Count (i),
  Timestamp Ranges (..) ...,
}

Timestamp Range {
  Gap (i),
  Timestamp Delta Count (i),
  Timestamp Delta (i) ...,
}
```

Reviewed By: sharmafb

Differential Revision: D68931151

fbshipit-source-id: 44c8c83d2f434abca97c4e85f0fa7502736cddc1
2025-02-24 12:32:50 -08:00

118 lines
3.4 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <quic/logging/QLoggerConstants.h>
namespace quic {
folly::StringPiece vantagePointString(VantagePoint vantagePoint) noexcept {
switch (vantagePoint) {
case VantagePoint::Client:
return kQLogClientVantagePoint;
case VantagePoint::Server:
return kQLogServerVantagePoint;
}
folly::assume_unreachable();
}
folly::StringPiece toQlogString(FrameType frame) {
switch (frame) {
case FrameType::PADDING:
return "padding";
case FrameType::PING:
return "ping";
case FrameType::ACK:
return "ack";
case FrameType::ACK_ECN:
return "ack_ecn";
case FrameType::RST_STREAM:
return "rst_stream";
case FrameType::RST_STREAM_AT:
return "rst_stream_at";
case FrameType::STOP_SENDING:
return "stop_sending";
case FrameType::CRYPTO_FRAME:
return "crypto_frame";
case FrameType::NEW_TOKEN:
return "new_token";
case FrameType::STREAM:
case FrameType::STREAM_FIN:
case FrameType::STREAM_LEN:
case FrameType::STREAM_LEN_FIN:
case FrameType::STREAM_OFF:
case FrameType::STREAM_OFF_FIN:
case FrameType::STREAM_OFF_LEN:
case FrameType::STREAM_OFF_LEN_FIN:
return "stream";
case FrameType::MAX_DATA:
return "max_data";
case FrameType::MAX_STREAM_DATA:
return "max_stream_data";
case FrameType::MAX_STREAMS_BIDI:
case FrameType::MAX_STREAMS_UNI:
return "max_streams";
case FrameType::DATA_BLOCKED:
return "data_blocked";
case FrameType::STREAM_DATA_BLOCKED:
return "stream_data_blocked";
case FrameType::STREAMS_BLOCKED_BIDI:
case FrameType::STREAMS_BLOCKED_UNI:
return "streams_blocked";
case FrameType::NEW_CONNECTION_ID:
return "new_connection_id";
case FrameType::RETIRE_CONNECTION_ID:
return "retire_connection_id";
case FrameType::PATH_CHALLENGE:
return "path_challenge";
case FrameType::PATH_RESPONSE:
return "path_response";
case FrameType::CONNECTION_CLOSE:
case FrameType::CONNECTION_CLOSE_APP_ERR:
return "connection_close";
case FrameType::HANDSHAKE_DONE:
return "handshake_done";
case FrameType::DATAGRAM:
case FrameType::DATAGRAM_LEN:
return "datagram";
case FrameType::KNOB:
return "knob";
case FrameType::ACK_FREQUENCY:
return "ack_frequency";
case FrameType::IMMEDIATE_ACK:
return "immediate_ack";
case FrameType::GROUP_STREAM:
case FrameType::GROUP_STREAM_FIN:
case FrameType::GROUP_STREAM_LEN:
case FrameType::GROUP_STREAM_LEN_FIN:
case FrameType::GROUP_STREAM_OFF:
case FrameType::GROUP_STREAM_OFF_FIN:
case FrameType::GROUP_STREAM_OFF_LEN:
case FrameType::GROUP_STREAM_OFF_LEN_FIN:
return "group_stream";
case FrameType::ACK_RECEIVE_TIMESTAMPS:
return "ack_receive_timestamps";
case FrameType::ACK_EXTENDED:
return "ack_extended";
}
folly::assume_unreachable();
}
folly::StringPiece toQlogString(LongHeader::Types type) {
switch (type) {
case LongHeader::Types::Initial:
return "initial";
case LongHeader::Types::Retry:
return "RETRY";
case LongHeader::Types::Handshake:
return "handshake";
case LongHeader::Types::ZeroRtt:
return "0RTT";
}
folly::assume_unreachable();
}
} // namespace quic