Helium
Macros | Functions
pmtud.h File Reference

Path MTU Discovery functions. More...

#include "he.h"
Include dependency graph for pmtud.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX_PROBES   3
 
#define MIN_PLPMTU   512
 The smallest PMTU the discovery process will attempt to use.
 
#define MAX_PLPMTU
 The largest PMTU the discovery process will attempt to use. More...
 
#define INITIAL_PLPMTU   1250
 The initial PMTU the discovery process will attempt to use first.
 
#define PMTUD_PROBE_TIMEOUT_MS   5000
 The default timeout for waiting for an acknowledgement to a probe packet, in milliseconds.
 
#define PMTUD_PROBE_BIG_STEP   32
 Number of bytes to increase for the next PROBED_SIZE.
 
#define PMTUD_PROBE_SMALL_STEP   8
 The minimal number of bytes to increase for the next PROBED_SIZE.
 
#define PMTUD_ERROR_RETRY_TIMEOUT_MS   (60 * 1000)
 The default timeout for retrying a failed PMTUD probe.
 
#define PMTUD_SUCCESSFUL_SEARCH_RETRY_TIMEOUT_MS   (10 * 60 * 1000)
 

Functions

he_return_code_t he_internal_pmtud_send_probe (he_conn_t *conn, uint16_t probe_mtu)
 Send PMTUD probe message with the given probe mtu size. More...
 
he_return_code_t he_internal_pmtud_handle_probe_ack (he_conn_t *conn, uint16_t probe_id)
 Called when the conn receives an acknowledgement of a probe message. More...
 
he_return_code_t he_internal_pmtud_handle_probe_timeout (he_conn_t *conn)
 Called when the timer of a probe expired. More...
 
he_return_code_t he_internal_pmtud_start_base_probing (he_conn_t *conn)
 Start PMTUD discovery and change state to BASE. More...
 
he_return_code_t he_internal_pmtud_base_confirmed (he_conn_t *conn)
 Called when the acknowledgement of current BASE_PLPMTU probing received. More...
 
he_return_code_t he_internal_pmtud_confirm_base_failed (he_conn_t *conn)
 Called when current state is BASE and PROBE_COUNT reaches MAX_PROBES. More...
 
he_return_code_t he_internal_pmtud_start_searching (he_conn_t *conn)
 Called when probing for the BASE_PLPMTU completes. More...
 
he_return_code_t he_internal_pmtud_search_completed (he_conn_t *conn)
 Called when the PROBE_COUNT reaches MAX_PROBES, a validated PTB is received that corresponds to the last successfully probed size (PL_PTB_SIZE = PLPMTU), or a probe of size MAX_PLPMTU is acknowledged (PLPMTU = MAX_PLPMTU) More...
 
he_return_code_t he_internal_pmtud_blackhole_detected (he_conn_t *conn)
 Called when a black hole situation is detected. More...
 
he_return_code_t he_internal_pmtud_retry_probe (he_conn_t *conn, int delay_ms)
 Called when we want to retry probing. More...
 

Detailed Description

Path MTU Discovery functions.

Lightway Core Copyright (C) 2023 Express VPN International Ltd.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Macro Definition Documentation

◆ MAX_PLPMTU

#define MAX_PLPMTU
Value:
(HE_MAX_WIRE_MTU - HE_IPV4_HEADER_SIZE - HE_UDP_HEADER_SIZE - sizeof(he_wire_hdr_t) - \
HE_WOLF_MAX_HEADER_SIZE - sizeof(he_msg_data_t))

The largest PMTU the discovery process will attempt to use.

◆ MAX_PROBES

#define MAX_PROBES   3

The maximum value of the PROBE_COUNT counter. MAX_PROBES represents the limit for the number of consecutive probe attempts of any size.

Function Documentation

◆ he_internal_pmtud_base_confirmed()

he_return_code_t he_internal_pmtud_base_confirmed ( he_conn_t conn)

Called when the acknowledgement of current BASE_PLPMTU probing received.

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the operation succeeds. HE_ERR_INVALID_STATE if current PMTUD state is not BASE.
Note
This function triggers a pmtud_state_change_cb callback to enter the Searching state.

◆ he_internal_pmtud_blackhole_detected()

he_return_code_t he_internal_pmtud_blackhole_detected ( he_conn_t conn)

Called when a black hole situation is detected.

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the operation succeeds. HE_ERR_INVALID_STATE if current PMTUD state is not SEARCHING.
Note
This function triggers a pmtud_state_change_cb callback to enter the BASE state.

◆ he_internal_pmtud_confirm_base_failed()

he_return_code_t he_internal_pmtud_confirm_base_failed ( he_conn_t conn)

Called when current state is BASE and PROBE_COUNT reaches MAX_PROBES.

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the operation succeeds. HE_ERR_INVALID_STATE if current PMTUD state is not BASE.
Note
This function changes conn->pmtu_state and triggers a pmtud_state_change_cb callback.

◆ he_internal_pmtud_handle_probe_ack()

he_return_code_t he_internal_pmtud_handle_probe_ack ( he_conn_t conn,
uint16_t  probe_id 
)

Called when the conn receives an acknowledgement of a probe message.

Parameters
connA pointer to a valid connection conn
probe_idId of the probe message
Returns
HE_SUCCESS if the probe ack message is handled
Note
This function may trigger pmtud_time_cb and/or pmtud_state_change callbacks depending on current state.

◆ he_internal_pmtud_handle_probe_timeout()

he_return_code_t he_internal_pmtud_handle_probe_timeout ( he_conn_t conn)

Called when the timer of a probe expired.

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the probe timeout is handled
Note
This function may trigger pmtud_time_cb and/or pmtud_state_change callbacks depending on current state.

◆ he_internal_pmtud_retry_probe()

he_return_code_t he_internal_pmtud_retry_probe ( he_conn_t conn,
int  delay_ms 
)

Called when we want to retry probing.

Parameters
connA pointer to a valid connection conn
delay_msDelay in milliseconds to retry probing
Returns
HE_SUCCESS if the operation succeeds. HE_ERR_PMTUD_CALLBACKS_NOT_SET if PMTUD callbacks are not set. Else it is the result of a pmtud_time_cb call.
Note
This function will also trigger a pmtud_time_cb callback to start the probe after the specified delay.

◆ he_internal_pmtud_search_completed()

he_return_code_t he_internal_pmtud_search_completed ( he_conn_t conn)

Called when the PROBE_COUNT reaches MAX_PROBES, a validated PTB is received that corresponds to the last successfully probed size (PL_PTB_SIZE = PLPMTU), or a probe of size MAX_PLPMTU is acknowledged (PLPMTU = MAX_PLPMTU)

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the operation succeeds. HE_ERR_INVALID_STATE if current PMTUD state is not SEARCHING.
Note
This function changes conn->pmtu_state and triggers a pmtud_state_change_cb callback. This function will also trigger a pmtud_time_cb callback to check the current PMTU periodically.

◆ he_internal_pmtud_send_probe()

he_return_code_t he_internal_pmtud_send_probe ( he_conn_t conn,
uint16_t  probe_mtu 
)

Send PMTUD probe message with the given probe mtu size.

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the probe message is sent successfully
Note
This function triggers a pmtud_time_cb callback.

◆ he_internal_pmtud_start_base_probing()

he_return_code_t he_internal_pmtud_start_base_probing ( he_conn_t conn)

Start PMTUD discovery and change state to BASE.

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the operation succeeds. HE_ERR_INVALID_STATE if current PMTUD state is not DISABLED or SEARCHING or SEARCH_COMPLETE.
Note
This function changes conn->pmtu_state and triggers a pmtud_state_change_cb callback.

◆ he_internal_pmtud_start_searching()

he_return_code_t he_internal_pmtud_start_searching ( he_conn_t conn)

Called when probing for the BASE_PLPMTU completes.

Parameters
connA pointer to a valid connection conn
Returns
HE_SUCCESS if the operation succeeds. HE_ERR_INVALID_STATE if current PMTUD state is not BASE or SEARCH_COMPLETE or ERROR.
Note
This function changes conn->pmtu_state and triggers a pmtud_state_change_cb callback. While PMTUD stays in the SEARCHING state, it will trigger the pmtud_time_cb callback for each probing attempt.
he_wire_hdr_t
struct he_wire_hdr he_wire_hdr_t
The wire header format It is strongly discouraged to interact with this header structure,...
he_msg_data
Definition: he_internal.h:398
HE_MAX_WIRE_MTU
#define HE_MAX_WIRE_MTU
Default MTU sizes.
Definition: he.h:41