22
22
*/
23
23
#define QUIC_VERSION_V1 1
24
24
25
+ /**
26
+ * The Connection ID MUST NOT exceed 20 bytes in QUIC version 1.
27
+ * See RFC 9000 Section 17.2
28
+ */
29
+ #define MAX_CID_LEN 20
30
+
25
31
/**
26
32
* Available congestion control algorithms.
27
33
*/
@@ -224,6 +230,34 @@ typedef struct quic_packet_send_methods_t {
224
230
225
231
typedef void * quic_packet_send_context_t ;
226
232
233
+ /**
234
+ * Connection Id is an identifier used to identify a QUIC connection
235
+ * at an endpoint.
236
+ */
237
+ typedef struct ConnectionId {
238
+ /**
239
+ * length of cid
240
+ */
241
+ uint8_t len ;
242
+ /**
243
+ * octets of cid
244
+ */
245
+ uint8_t data [MAX_CID_LEN ];
246
+ } ConnectionId ;
247
+
248
+ typedef struct ConnectionIdGeneratorMethods {
249
+ /**
250
+ * Generate a new CID
251
+ */
252
+ struct ConnectionId (* generate )(void * gctx );
253
+ /**
254
+ * Return the length of a CID
255
+ */
256
+ uint8_t (* cid_len )(void * gctx );
257
+ } ConnectionIdGeneratorMethods ;
258
+
259
+ typedef void * ConnectionIdGeneratorContext ;
260
+
227
261
/**
228
262
* Meta information of an incoming packet.
229
263
*/
@@ -241,6 +275,100 @@ typedef struct quic_path_address_t {
241
275
socklen_t remote_addr_len ;
242
276
} quic_path_address_t ;
243
277
278
+ /**
279
+ * Statistics about path
280
+ */
281
+ typedef struct PathStats {
282
+ /**
283
+ * The number of QUIC packets received.
284
+ */
285
+ uint64_t recv_count ;
286
+ /**
287
+ * The number of received bytes.
288
+ */
289
+ uint64_t recv_bytes ;
290
+ /**
291
+ * The number of QUIC packets sent.
292
+ */
293
+ uint64_t sent_count ;
294
+ /**
295
+ * The number of sent bytes.
296
+ */
297
+ uint64_t sent_bytes ;
298
+ /**
299
+ * The number of QUIC packets lost.
300
+ */
301
+ uint64_t lost_count ;
302
+ /**
303
+ * The number of lost bytes.
304
+ */
305
+ uint64_t lost_bytes ;
306
+ /**
307
+ * Total number of bytes acked.
308
+ */
309
+ uint64_t acked_bytes ;
310
+ /**
311
+ * Total number of packets acked.
312
+ */
313
+ uint64_t acked_count ;
314
+ /**
315
+ * Initial congestion window in bytes.
316
+ */
317
+ uint64_t init_cwnd ;
318
+ /**
319
+ * Final congestion window in bytes.
320
+ */
321
+ uint64_t final_cwnd ;
322
+ /**
323
+ * Maximum congestion window in bytes.
324
+ */
325
+ uint64_t max_cwnd ;
326
+ /**
327
+ * Minimum congestion window in bytes.
328
+ */
329
+ uint64_t min_cwnd ;
330
+ /**
331
+ * Maximum inflight data in bytes.
332
+ */
333
+ uint64_t max_inflight ;
334
+ /**
335
+ * Total loss events.
336
+ */
337
+ uint64_t loss_event_count ;
338
+ /**
339
+ * Total congestion window limited events.
340
+ */
341
+ uint64_t cwnd_limited_count ;
342
+ /**
343
+ * Total duration of congestion windowlimited events in microseconds.
344
+ */
345
+ uint64_t cwnd_limited_duration ;
346
+ /**
347
+ * Minimum roundtrip time in microseconds.
348
+ */
349
+ uint64_t min_rtt ;
350
+ /**
351
+ * Maximum roundtrip time in microseconds.
352
+ */
353
+ uint64_t max_rtt ;
354
+ /**
355
+ * Smoothed roundtrip time in microseconds.
356
+ */
357
+ uint64_t srtt ;
358
+ /**
359
+ * Roundtrip time variation in microseconds.
360
+ */
361
+ uint64_t rttvar ;
362
+ /**
363
+ * Whether the congestion controller is in slow start status.
364
+ */
365
+ bool in_slow_start ;
366
+ /**
367
+ * Pacing rate estimated by congestion control algorithm.
368
+ */
369
+ uint64_t pacing_rate ;
370
+ } PathStats ;
371
+
244
372
/**
245
373
* Statistics about a QUIC connection.
246
374
*/
@@ -478,6 +606,18 @@ void quic_config_set_bbr_probe_bw_cwnd_gain(struct quic_config_t *config, double
478
606
*/
479
607
void quic_config_set_initial_rtt (struct quic_config_t * config , uint64_t v );
480
608
609
+ /**
610
+ * Enable pacing to smooth the flow of packets sent onto the network.
611
+ * The default value is true.
612
+ */
613
+ void quic_config_enable_pacing (struct quic_config_t * config , bool v );
614
+
615
+ /**
616
+ * Set clock granularity used by the pacer.
617
+ * The default value is 10 milliseconds.
618
+ */
619
+ void quic_config_set_pacing_granularity (struct quic_config_t * config , uint64_t v );
620
+
481
621
/**
482
622
* Set the linear factor for calculating the probe timeout.
483
623
* The endpoint do not backoff the first `v` consecutive probe timeouts.
@@ -581,6 +721,7 @@ void quic_config_set_send_batch_size(struct quic_config_t *config, uint16_t v);
581
721
582
722
/**
583
723
* Set the buffer size for disordered zerortt packets on the server.
724
+ * The default value is `1000`. A value of 0 will be treated as default value.
584
725
* Applicable to Server only.
585
726
*/
586
727
void quic_config_set_zerortt_buffer_size (struct quic_config_t * config , uint16_t v );
@@ -707,6 +848,14 @@ struct quic_endpoint_t *quic_endpoint_new(struct quic_config_t *config,
707
848
*/
708
849
void quic_endpoint_free (struct quic_endpoint_t * endpoint );
709
850
851
+ /**
852
+ * Set the connection id generator for the endpoint.
853
+ * By default, the random connection id generator is used.
854
+ */
855
+ void quic_endpoint_set_cid_generator (struct quic_endpoint_t * endpoint ,
856
+ const struct ConnectionIdGeneratorMethods * cid_gen_methods ,
857
+ ConnectionIdGeneratorContext cid_gen_ctx );
858
+
710
859
/**
711
860
* Create a client connection.
712
861
* If success, the output parameter `index` carrys the index of the connection.
@@ -868,6 +1017,15 @@ bool quic_conn_path_iter_next(struct quic_path_address_iter_t *iter, struct quic
868
1017
*/
869
1018
bool quic_conn_active_path (const struct quic_conn_t * conn , struct quic_path_address_t * a );
870
1019
1020
+ /**
1021
+ * Return the latest statistics about the specified path.
1022
+ */
1023
+ const struct PathStats * quic_conn_path_stats (struct quic_conn_t * conn ,
1024
+ const struct sockaddr * local ,
1025
+ socklen_t local_len ,
1026
+ const struct sockaddr * remote ,
1027
+ socklen_t remote_len );
1028
+
871
1029
/**
872
1030
* Return statistics about the connection.
873
1031
*/
@@ -1069,6 +1227,17 @@ int quic_stream_set_context(struct quic_conn_t *conn, uint64_t stream_id, void *
1069
1227
*/
1070
1228
void * quic_stream_context (struct quic_conn_t * conn , uint64_t stream_id );
1071
1229
1230
+ /**
1231
+ * Extract the header form, version and destination connection id from the
1232
+ * QUIC packet.
1233
+ */
1234
+ int quic_packet_header_info (uint8_t * buf ,
1235
+ size_t buf_len ,
1236
+ uint8_t dcid_len ,
1237
+ bool * long_header ,
1238
+ uint32_t * version ,
1239
+ struct ConnectionId * dcid );
1240
+
1072
1241
/**
1073
1242
* Create default config for HTTP3.
1074
1243
*/
0 commit comments