1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
* ngtcp2
*
* Copyright (c) 2022 ngtcp2 contributors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NGTCP2_PMTUD_H
#define NGTCP2_PMTUD_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <ngtcp2/ngtcp2.h>
typedef struct ngtcp2_pmtud {
const ngtcp2_mem *mem;
/* mtu_idx is the index of UDP payload size candidates to try
out. */
size_t mtu_idx;
/* num_pkts_sent is the number of mtu_idx sized UDP datagram payload
sent */
size_t num_pkts_sent;
/* expiry is the expired, if it is reached, send out the next UDP
datagram. UINT64_MAX means no expiry, or expiration is canceled.
In either case, new probe packet should be sent unless we have
done all attempts. */
ngtcp2_tstamp expiry;
/* tx_pkt_num is the smallest outgoing packet number where the
current discovery is performed. In other words, acknowledging
packet whose packet number lower than that does not indicate the
success of Path MTU Discovery. */
int64_t tx_pkt_num;
/* max_udp_payload_size is the maximum UDP payload size which is
known to work. */
size_t max_udp_payload_size;
/* hard_max_udp_payload_size is the maximum UDP payload size that is
going to be probed. */
size_t hard_max_udp_payload_size;
/* min_fail_udp_payload_size is the minimum UDP payload size that is
known to fail. */
size_t min_fail_udp_payload_size;
} ngtcp2_pmtud;
/*
* ngtcp2_pmtud_new creates new ngtcp2_pmtud object, and assigns its
* pointer to |*ppmtud|. |max_udp_payload_size| is the maximum UDP
* payload size that is known to work for the current path.
* |tx_pkt_num| should be the next packet number to send, which is
* used to differentiate the PMTUD probe packet sent by the previous
* PMTUD. PMTUD might finish immediately if |max_udp_payload_size| is
* larger than or equal to all UDP payload probe candidates.
* Therefore, call ngtcp2_pmtud_finished to check this situation.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGTCP2_ERR_NOMEM
* Out of memory.
*/
int ngtcp2_pmtud_new(ngtcp2_pmtud **ppmtud, size_t max_udp_payload_size,
size_t hard_max_udp_payload_size, int64_t tx_pkt_num,
const ngtcp2_mem *mem);
/*
* ngtcp2_pmtud_del deletes |pmtud|.
*/
void ngtcp2_pmtud_del(ngtcp2_pmtud *pmtud);
/*
* ngtcp2_pmtud_probelen returns the length of UDP payload size for a
* PMTUD probe packet.
*/
size_t ngtcp2_pmtud_probelen(ngtcp2_pmtud *pmtud);
/*
* ngtcp2_pmtud_probe_sent should be invoked when a PMTUD probe packet is
* sent.
*/
void ngtcp2_pmtud_probe_sent(ngtcp2_pmtud *pmtud, ngtcp2_duration pto,
ngtcp2_tstamp ts);
/*
* ngtcp2_pmtud_require_probe returns nonzero if a PMTUD probe packet
* should be sent.
*/
int ngtcp2_pmtud_require_probe(ngtcp2_pmtud *pmtud);
/*
* ngtcp2_pmtud_probe_success should be invoked when a PMTUD probe
* UDP datagram sized |payloadlen| is acknowledged.
*/
void ngtcp2_pmtud_probe_success(ngtcp2_pmtud *pmtud, size_t payloadlen);
/*
* ngtcp2_pmtud_handle_expiry handles expiry.
*/
void ngtcp2_pmtud_handle_expiry(ngtcp2_pmtud *pmtud, ngtcp2_tstamp ts);
/*
* ngtcp2_pmtud_finished returns nonzero if PMTUD has finished.
*/
int ngtcp2_pmtud_finished(ngtcp2_pmtud *pmtud);
#endif /* NGTCP2_PMTUD_H */
|