Skip to content

Commit ab82fab

Browse files
committed
MINOR: quic/pacing: implement quic_pacer engine
Extend quic_pacer engine to support pacing emission. Several functions are defined. * quic_pacing_sent_done() to notify engine about an emission of one or several datagrams * quic_pacing_expired() to check if emission should be delayed or can be conducted immediately
1 parent 3e11492 commit ab82fab

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

include/haproxy/quic_cc-t.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ struct quic_cc_algo {
123123
void (*state_trace)(struct buffer *buf, const struct quic_cc *cc);
124124
void (*state_cli)(struct buffer *buf, const struct quic_cc_path *path);
125125
void (*hystart_start_round)(struct quic_cc *cc, uint64_t pn);
126+
127+
/* Defined only if pacing is used. */
128+
uint (*pacing_rate)(const struct quic_cc *cc);
126129
};
127130

128131
#endif /* USE_QUIC */

include/haproxy/quic_cc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ void quic_cc_init(struct quic_cc *cc, struct quic_cc_algo *algo, struct quic_con
3737
void quic_cc_event(struct quic_cc *cc, struct quic_cc_event *ev);
3838
void quic_cc_state_trace(struct buffer *buf, const struct quic_cc *cc);
3939

40+
/* Pacing callbacks */
41+
uint quic_cc_default_pacing_rate(const struct quic_cc *cc);
42+
4043
static inline const char *quic_cc_state_str(enum quic_cc_algo_state_type state)
4144
{
4245
switch (state) {
@@ -107,6 +110,5 @@ static inline size_t quic_cc_path_prep_data(struct quic_cc_path *path)
107110
return path->cwnd - path->prep_in_flight;
108111
}
109112

110-
111113
#endif /* USE_QUIC */
112114
#endif /* _PROTO_QUIC_CC_H */

include/haproxy/quic_pacing-t.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
struct quic_pacer {
88
const struct quic_cc *cc; /* Congestion controler algo used for this connection */
9+
ullong next; /* Nanosecond timestamp at which the next emission should be conducted */
910
};
1011

1112
#endif /* _HAPROXY_QUIC_PACING_T_H */

include/haproxy/quic_pacing.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ static inline void quic_pacing_init(struct quic_pacer *pacer,
1010
const struct quic_cc *cc)
1111
{
1212
pacer->cc = cc;
13+
pacer->next = 0;
1314
}
1415

16+
int quic_pacing_expired(const struct quic_pacer *pacer);
17+
18+
void quic_pacing_sent_done(struct quic_pacer *pacer);
19+
1520
#endif /* _HAPROXY_QUIC_PACING_H */

src/quic_cc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ void quic_cc_state_trace(struct buffer *buf, const struct quic_cc *cc)
4747
{
4848
cc->algo->state_trace(buf, cc);
4949
}
50+
51+
/* Return rate in nanoseconds between each datagram emission for a smooth pacing. */
52+
uint quic_cc_default_pacing_rate(const struct quic_cc *cc)
53+
{
54+
struct quic_cc_path *path = container_of(cc, struct quic_cc_path, cc);
55+
return path->loss.srtt * 1000000 / (path->cwnd / path->mtu + 1);
56+
}

src/quic_pacing.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
11
#include <haproxy/quic_pacing.h>
2+
3+
#include <haproxy/quic_tx.h>
4+
5+
/* Returns true if <pacer> timer is expired and emission can be retried. */
6+
int quic_pacing_expired(const struct quic_pacer *pacer)
7+
{
8+
return !pacer->next || pacer->next <= now_mono_time();
9+
}
10+
11+
/* Notify <pacer> about an emission of one datagram. */
12+
void quic_pacing_sent_done(struct quic_pacer *pacer)
13+
{
14+
pacer->next = now_mono_time() + pacer->cc->algo->pacing_rate(pacer->cc);
15+
}

0 commit comments

Comments
 (0)