Packages
hackney
3.0.2
4.7.2
4.7.1
4.7.0
4.6.1
4.6.0
4.5.2
4.5.1
4.5.0
4.4.5
4.4.3
4.4.2
4.4.1
4.4.0
4.3.0
4.2.3
4.2.2
4.2.1
4.2.0
4.1.0
4.0.3
4.0.2
4.0.1
4.0.0
3.2.1
3.2.0
3.1.2
3.1.1
3.1.0
3.0.3
3.0.2
3.0.1
3.0.0
retired
2.0.1
2.0.0
2.0.0-beta.1
1.25.0
1.24.1
1.24.0
1.23.0
1.22.0
1.21.0
1.20.1
1.20.0
1.19.1
1.19.0
1.18.2
1.18.1
1.18.0
1.17.4
1.17.3
1.17.2
1.17.1
1.17.0
1.16.0
1.15.2
1.15.1
1.15.0
1.14.3
1.14.2
1.14.0
1.13.0
1.12.1
1.12.0
1.11.0
1.10.1
1.10.0
1.9.0
1.8.6
1.8.5
1.8.4
1.8.3
1.8.2
1.8.0
1.7.1
1.7.0
1.6.6
retired
1.6.5
1.6.4
retired
1.6.3
1.6.2
1.6.1
1.6.0
1.5.7
1.5.6
1.5.5
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.10
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.2
1.3.1
1.3.0
1.2.0
1.1.0
1.0.6
1.0.5
1.0.2
1.0.1
0.15.2
0.15.0
0.14.3
0.14.2
0.14.1
0.14.0
0.13.1
Simple HTTP client with HTTP/1.1, HTTP/2, and HTTP/3 support
Security advisory:
This version has known vulnerabilities.
View advisories
Current section
Files
Jump to
Current section
Files
c_src/lsquic/src/liblsquic/lsquic_bw_sampler.h
/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc. See LICENSE. */
#ifndef LSQUIC_BW_SAMPLER_H
#define LSQUIC_BW_SAMPLER_H 1
/* Translated from Chromium. */
// Copyright 2016 The Chromium Authors. All rights reserved.
struct lsquic_packet_out;
/* This struct provides a type for bits per second units. It's made into
* a struct so that it is a little harder to make a mistake. The Chromium
* equivalent of this is QuicBandwidth. Use macros to operate.
*/
struct bandwidth
{
uint64_t value; /* Bits per second */
};
#define BW_INFINITE() ((struct bandwidth) { .value = UINT64_MAX, })
#define BW_ZERO() ((struct bandwidth) { .value = 0, })
#define BW_FROM_BYTES_AND_DELTA(bytes_, usecs_) \
((struct bandwidth) { .value = (bytes_) * 8 * 1000000 / (usecs_), })
#define BW_IS_ZERO(bw_) ((bw_)->value == 0)
#define BW_TO_BYTES_PER_SEC(bw_) ((bw_)->value / 8)
#define BW_VALUE(bw_) (+(bw_)->value)
#define BW_TIMES(bw_, factor_) \
((struct bandwidth) { .value = BW_VALUE(bw_) * (factor_), })
#define BW(initial_value_) ((struct bandwidth) { .value = (initial_value_) })
struct bw_sampler
{
struct lsquic_conn *bws_conn;
uint64_t bws_total_sent,
bws_total_acked,
bws_total_lost;
/* Value of bws_total_sent at the time last ACKed packet was sent. Only
* valid if bws_last_acked_sent_time is valid.
*/
uint64_t bws_last_acked_total_sent;
/* Time when last acked packet was sent. Zero if no valid timestamp is
* available.
*/
lsquic_time_t bws_last_acked_sent_time;
lsquic_time_t bws_last_acked_packet_time;
lsquic_packno_t bws_last_sent_packno;
lsquic_packno_t bws_end_of_app_limited_phase;
struct malo *bws_malo; /* For struct osp_state objects */
enum quic_ft_bit bws_retx_frames;
enum {
BWS_CONN_ABORTED = 1 << 0,
BWS_WARNED = 1 << 1,
BWS_APP_LIMITED = 1 << 2,
} bws_flags;
};
struct bw_sample
{
TAILQ_ENTRY(bw_sample) next;
struct bandwidth bandwidth;
lsquic_time_t rtt;
int is_app_limited;
};
int
lsquic_bw_sampler_init (struct bw_sampler *, struct lsquic_conn *,
enum quic_ft_bit);
void
lsquic_bw_sampler_packet_sent (struct bw_sampler *, struct lsquic_packet_out *,
uint64_t in_flight);
/* Free returned sample via lsquic_malo_put() after you're done */
struct bw_sample *
lsquic_bw_sampler_packet_acked (struct bw_sampler *, struct lsquic_packet_out *,
lsquic_time_t ack_time);
void
lsquic_bw_sampler_packet_lost (struct bw_sampler *, struct lsquic_packet_out *);
void
lsquic_bw_sampler_app_limited (struct bw_sampler *);
void
lsquic_bw_sampler_cleanup (struct bw_sampler *);
unsigned
lsquic_bw_sampler_entry_count (const struct bw_sampler *);
#define lsquic_bw_sampler_total_acked(sampler_) (+(sampler_)->bws_total_acked)
/* The following types are exposed in the header file because of unit tests.
* Do not use outside of lsquic_bw_sampler.c.
*/
struct bwps_send_state
{
uint64_t total_bytes_sent,
total_bytes_acked,
total_bytes_lost;
int is_app_limited;
};
struct bwp_state /* BWP State stands for Bandwidth Packet State */
{
struct bwps_send_state bwps_send_state;
uint64_t bwps_sent_at_last_ack;
lsquic_time_t bwps_last_ack_sent_time;
lsquic_time_t bwps_last_ack_ack_time;
unsigned short bwps_packet_size;
};
#endif