Skip to content

Commit 13e3713

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 9cb35ec commit 13e3713

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

include/haproxy/quic_cc-t.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ 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+
uint (*pacing_rate)(const struct quic_cc *cc);
126127
};
127128

128129
#endif /* USE_QUIC */

include/haproxy/quic_cc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ static inline size_t quic_cc_path_prep_data(struct quic_cc_path *path)
107107
return path->cwnd - path->prep_in_flight;
108108
}
109109

110+
static inline uint quic_cc_default_pacing_rate(const struct quic_cc *cc)
111+
{
112+
struct quic_cc_path *path = container_of(cc, struct quic_cc_path, cc);
113+
return path->loss.srtt * 1000000 / (path->cwnd / path->mtu + 1);
114+
}
110115

111116
#endif /* USE_QUIC */
112117
#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
@@ -7,6 +7,7 @@
77
struct quic_pacer {
88
struct list *frms;
99
const struct quic_cc *cc;
10+
ullong next;
1011
};
1112

1213
#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
@@ -12,6 +12,11 @@ static inline void quic_pacing_init(struct quic_pacer *pacer,
1212
{
1313
pacer->cc = cc;
1414
pacer->frms = frms;
15+
pacer->next = 0;
1516
}
1617

18+
int quic_pacing_expired(const struct quic_pacer *pacer);
19+
20+
void quic_pacing_sent_done(struct quic_pacer *pacer);
21+
1722
#endif /* _HAPROXY_QUIC_PACING_H */

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)