Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ack-frequency #319

Merged
merged 6 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/quicly.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ typedef struct st_quicly_transport_parameters_t {
* in milliseconds; quicly ignores the value set for quicly_context_t::transport_parameters
*/
uint16_t max_ack_delay;
/**
* quicly ignores the value set for quicly_context_t::transport_parameters. Set to UINT64_MAX when not specified by peer.
*/
uint64_t min_ack_delay_usec;
/**
*
*/
Expand Down
6 changes: 5 additions & 1 deletion include/quicly/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ extern "C" {
#include <stdint.h>
#include "picotls.h"

#define QUICLY_NUM_PACKETS_BEFORE_ACK 2
#define QUICLY_DELAYED_ACK_TIMEOUT 25 /* milliseconds */
#define QUICLY_DEFAULT_MAX_ACK_DELAY 25 /* milliseconds */
#define QUICLY_LOCAL_MAX_ACK_DELAY 25 /* milliseconds */
Expand All @@ -40,6 +39,11 @@ extern "C" {
#define QUICLY_DEFAULT_INITIAL_RTT 66 /* initial retransmission timeout is *3, i.e. 200ms */
#define QUICLY_LOSS_DEFAULT_PACKET_THRESHOLD 3

#define QUICLY_DEFAULT_PACKET_TOLERANCE 2
#define QUICLY_MAX_PACKET_TOLERANCE 100
#define QUICLY_FIRST_ACK_FREQUENCY_PACKET_NUMBER 1000
#define QUICLY_ACK_FREQUENCY_CWND_FRACTION 8

#define QUICLY_MAX_PACKET_SIZE 1280 /* must be >= 1200 bytes */
#define QUICLY_AEAD_TAG_SIZE 16

Expand Down
54 changes: 54 additions & 0 deletions include/quicly/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern "C" {
#define QUICLY_FRAME_TYPE_TRANSPORT_CLOSE 28
#define QUICLY_FRAME_TYPE_APPLICATION_CLOSE 29
#define QUICLY_FRAME_TYPE_HANDSHAKE_DONE 30
#define QUICLY_FRAME_TYPE_ACK_FREQUENCY 0xaf

#define QUICLY_FRAME_TYPE_STREAM_BITS 0x7
#define QUICLY_FRAME_TYPE_STREAM_BIT_OFF 0x4
Expand Down Expand Up @@ -233,6 +234,17 @@ typedef struct st_quicly_new_token_frame_t {

static int quicly_decode_new_token_frame(const uint8_t **src, const uint8_t *end, quicly_new_token_frame_t *frame);

typedef struct st_quicly_ack_frequency_frame_t {
uint64_t sequence;
uint64_t packet_tolerance;
uint64_t max_ack_delay;
uint8_t ignore_order;
} quicly_ack_frequency_frame_t;

static uint8_t *quicly_encode_ack_frequency_frame(uint8_t *dst, uint64_t sequence, uint64_t packet_tolerance,
uint64_t max_ack_delay, int ignore_order);
static int quicly_decode_ack_frequency_frame(const uint8_t **src, const uint8_t *end, quicly_ack_frequency_frame_t *frame);

/* inline definitions */

inline uint16_t quicly_decode16(const uint8_t **src)
Expand Down Expand Up @@ -644,6 +656,48 @@ inline int quicly_decode_new_token_frame(const uint8_t **src, const uint8_t *end
return QUICLY_TRANSPORT_ERROR_FRAME_ENCODING;
}

inline uint8_t *quicly_encode_ack_frequency_frame(uint8_t *dst, uint64_t sequence, uint64_t packet_tolerance,
uint64_t max_ack_delay, int ignore_order)
{
dst = quicly_encodev(dst, QUICLY_FRAME_TYPE_ACK_FREQUENCY);
dst = quicly_encodev(dst, sequence);
dst = quicly_encodev(dst, packet_tolerance);
dst = quicly_encodev(dst, max_ack_delay);
#if 0 // not in -00
*dst++ = !!ignore_order;
#endif
return dst;
}

inline int quicly_decode_ack_frequency_frame(const uint8_t **src, const uint8_t *end, quicly_ack_frequency_frame_t *frame)
{
if ((frame->sequence = quicly_decodev(src, end)) == UINT64_MAX)
goto Error;
if ((frame->packet_tolerance = quicly_decodev(src, end)) == UINT64_MAX || frame->packet_tolerance == 0)
goto Error;
if ((frame->max_ack_delay = quicly_decodev(src, end)) == UINT64_MAX)
goto Error;
if (*src == end)
goto Error;
#if 1 // not in -00
frame->ignore_order = 0;
#else
switch (*(*src)++) {
case 0:
frame->ignore_order = 0;
break;
case 1:
frame->ignore_order = 1;
break;
default:
goto Error;
}
#endif
return 0;
Error:
return QUICLY_TRANSPORT_ERROR_FRAME_ENCODING;
}

#ifdef __cplusplus
}
#endif
Expand Down
Loading