Skip to content

Commit

Permalink
Merge pull request #586 from h2o/kazuho/stats-send-receive-per-epoch
Browse files Browse the repository at this point in the history
record number of packets sent / received per each QUIC packet type
  • Loading branch information
kazuho authored Jul 17, 2024
2 parents 83286c3 + eb42571 commit 0d5188b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 18 deletions.
24 changes: 22 additions & 2 deletions include/quicly.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,29 @@ struct st_quicly_conn_streamgroup_state_t {
*/ \
uint64_t late_acked; \
/** \
* Total number of Initial and Handshake packets sent. \
* Total number of Initial packets received. \
*/ \
uint64_t initial_handshake_sent; \
uint64_t initial_received; \
/** \
* Total number of 0-RTT packets received. \
*/ \
uint64_t zero_rtt_received; \
/** \
* Total number of Handshake packets received. \
*/ \
uint64_t handshake_received; \
/** \
* Total number of Initial packets sent. \
*/ \
uint64_t initial_sent; \
/** \
* Total number of 0-RTT packets sent. \
*/ \
uint64_t zero_rtt_sent; \
/** \
* Total number of Handshake packets sent. \
*/ \
uint64_t handshake_sent; \
/** \
* Total number of packets received out of order. \
*/ \
Expand Down
31 changes: 25 additions & 6 deletions lib/quicly.c
Original file line number Diff line number Diff line change
Expand Up @@ -3642,8 +3642,13 @@ static int commit_send_packet(quicly_conn_t *conn, quicly_send_context_t *s, int
quicly_encode16(s->dst_payload_from - QUICLY_SEND_PN_SIZE - 2, length);
switch (*s->target.first_byte_at & QUICLY_PACKET_TYPE_BITMASK) {
case QUICLY_PACKET_TYPE_INITIAL:
conn->super.stats.num_packets.initial_sent++;
break;
case QUICLY_PACKET_TYPE_0RTT:
conn->super.stats.num_packets.zero_rtt_sent++;
break;
case QUICLY_PACKET_TYPE_HANDSHAKE:
conn->super.stats.num_packets.initial_handshake_sent++;
conn->super.stats.num_packets.handshake_sent++;
break;
}
} else {
Expand Down Expand Up @@ -5208,10 +5213,10 @@ static int do_send(quicly_conn_t *conn, quicly_send_context_t *s)
conn->super.stats.num_handshake_timeouts++;
goto CloseNow;
}
if (conn->super.stats.num_packets.initial_handshake_sent > conn->super.ctx->max_initial_handshake_packets) {
QUICLY_PROBE(INITIAL_HANDSHAKE_PACKET_EXCEED, conn, conn->stash.now, conn->super.stats.num_packets.initial_handshake_sent);
QUICLY_LOG_CONN(initial_handshake_packet_exceed, conn,
{ PTLS_LOG_ELEMENT_UNSIGNED(num_packets, conn->super.stats.num_packets.initial_handshake_sent); });
uint64_t initial_handshake_sent = conn->super.stats.num_packets.initial_sent + conn->super.stats.num_packets.handshake_sent;
if (initial_handshake_sent > conn->super.ctx->max_initial_handshake_packets) {
QUICLY_PROBE(INITIAL_HANDSHAKE_PACKET_EXCEED, conn, conn->stash.now, initial_handshake_sent);
QUICLY_LOG_CONN(initial_handshake_packet_exceed, conn, { PTLS_LOG_ELEMENT_UNSIGNED(num_packets, initial_handshake_sent); });
conn->super.stats.num_initial_handshake_exceeded++;
goto CloseNow;
}
Expand Down Expand Up @@ -6911,6 +6916,7 @@ int quicly_accept(quicly_conn_t **conn, quicly_context_t *ctx, struct sockaddr *

/* handle the input; we ignore is_ack_only, we consult if there's any output from TLS in response to CH anyways */
(*conn)->super.stats.num_packets.received += 1;
(*conn)->super.stats.num_packets.initial_received += 1;
if (packet->ecn != 0)
(*conn)->super.stats.num_packets.received_ecn_counts[get_ecn_index_from_bits(packet->ecn)] += 1;
(*conn)->super.stats.num_bytes.received += packet->datagram_size;
Expand Down Expand Up @@ -7157,7 +7163,20 @@ int quicly_receive(quicly_conn_t *conn, struct sockaddr *dest_addr, struct socka
conn->super.stats.num_packets.received += 1;
conn->paths[path_index]->packet_last_received = conn->super.stats.num_packets.received;
conn->paths[path_index]->num_packets.received += 1;
if (packet->ecn != 0)
if (QUICLY_PACKET_IS_LONG_HEADER(packet->octets.base[0])) {
switch (packet->octets.base[0] & QUICLY_PACKET_TYPE_BITMASK) {
case QUICLY_PACKET_TYPE_INITIAL:
conn->super.stats.num_packets.initial_received += 1;
break;
case QUICLY_PACKET_TYPE_0RTT:
conn->super.stats.num_packets.zero_rtt_received += 1;
break;
case QUICLY_PACKET_TYPE_HANDSHAKE:
conn->super.stats.num_packets.handshake_received += 1;
break;
}
}
if (packet->ecn != 0)
conn->super.stats.num_packets.received_ecn_counts[get_ecn_index_from_bits(packet->ecn)] += 1;

/* state updates, that are triggered by the receipt of a packet */
Expand Down
24 changes: 14 additions & 10 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,28 @@ static void dump_stats(FILE *fp, quicly_conn_t *conn)

quicly_get_stats(conn, &stats);
fprintf(fp,
"packets-received: %" PRIu64 ", received-ecn-ect0: %" PRIu64 ", received-ecn-ect1: %" PRIu64
"packets-received: %" PRIu64 ", initial-packets-received: %" PRIu64 ", 0rtt-packets-received: %" PRIu64
", handshake-packets-received: %" PRIu64 ", received-ecn-ect0: %" PRIu64 ", received-ecn-ect1: %" PRIu64
", received-ecn-ce: %" PRIu64 ", packets-decryption-failed: %" PRIu64 ", packets-sent: %" PRIu64
", initial-packets-sent: %" PRIu64 ", 0rtt-packets-sent: %" PRIu64 ", handshake-packets-sent: %" PRIu64
", packets-lost: %" PRIu64 ", ack-received: %" PRIu64 ", ack-ecn-ect0: %" PRIu64 ", ack-ecn-ect1: %" PRIu64
", ack-ecn-ce: %" PRIu64 ", late-acked: %" PRIu64 ", bytes-received: %" PRIu64 ", bytes-sent: %" PRIu64
", paths-created %" PRIu64 ", paths-validated %" PRIu64 ", paths-promoted: %" PRIu64 ", srtt: %" PRIu32
", num-loss-episodes: %" PRIu32 ", num-ecn-loss-episodes: %" PRIu32 ", delivery-rate: %" PRIu64 ", cwnd: %" PRIu32
", cwnd-exiting-slow-start: %" PRIu32 ", slow-start-exit-at: %" PRId64 ", jumpstart-cwnd: %" PRIu32
", jumpstart-exit: %" PRIu32 ", jumpstart-prev-rate: %" PRIu64 ", jumpstart-prev-rtt: %" PRIu32
", token-sent-rate: %" PRIu64 ", token-sent-rtt: %" PRIu32 "\n",
stats.num_packets.received, stats.num_packets.received_ecn_counts[0], stats.num_packets.received_ecn_counts[1],
stats.num_packets.received_ecn_counts[2], stats.num_packets.decryption_failed, stats.num_packets.sent,
stats.num_packets.lost, stats.num_packets.ack_received, stats.num_packets.acked_ecn_counts[0],
stats.num_packets.acked_ecn_counts[1], stats.num_packets.acked_ecn_counts[2], stats.num_packets.late_acked,
stats.num_bytes.received, stats.num_bytes.sent, stats.num_paths.created, stats.num_paths.validated,
stats.num_paths.promoted, stats.rtt.smoothed, stats.cc.num_loss_episodes, stats.cc.num_ecn_loss_episodes,
stats.delivery_rate.smoothed, stats.cc.cwnd, stats.cc.cwnd_exiting_slow_start, stats.cc.exit_slow_start_at,
stats.jumpstart.cwnd, stats.cc.cwnd_exiting_jumpstart, stats.jumpstart.prev_rate, stats.jumpstart.prev_rtt,
stats.token_sent.rate, stats.token_sent.rtt);
stats.num_packets.received, stats.num_packets.initial_received, stats.num_packets.zero_rtt_received,
stats.num_packets.handshake_received, stats.num_packets.received_ecn_counts[0],
stats.num_packets.received_ecn_counts[1], stats.num_packets.received_ecn_counts[2], stats.num_packets.decryption_failed,
stats.num_packets.sent, stats.num_packets.initial_sent, stats.num_packets.zero_rtt_sent,
stats.num_packets.handshake_sent, stats.num_packets.lost, stats.num_packets.ack_received,
stats.num_packets.acked_ecn_counts[0], stats.num_packets.acked_ecn_counts[1], stats.num_packets.acked_ecn_counts[2],
stats.num_packets.late_acked, stats.num_bytes.received, stats.num_bytes.sent, stats.num_paths.created,
stats.num_paths.validated, stats.num_paths.promoted, stats.rtt.smoothed, stats.cc.num_loss_episodes,
stats.cc.num_ecn_loss_episodes, stats.delivery_rate.smoothed, stats.cc.cwnd, stats.cc.cwnd_exiting_slow_start,
stats.cc.exit_slow_start_at, stats.jumpstart.cwnd, stats.cc.cwnd_exiting_jumpstart, stats.jumpstart.prev_rate,
stats.jumpstart.prev_rtt, stats.token_sent.rate, stats.token_sent.rtt);
}

static int validate_path(const char *path)
Expand Down

0 comments on commit 0d5188b

Please sign in to comment.