nasa / HDTN

High-rate Delay Tolerant Network (HDTN) Software
https://www1.grc.nasa.gov/space/scan/acs/tech-studies/dtn/
Other
95 stars 24 forks source link

No way to bind UDPCL to a specific source port #56

Open BrianSipos opened 9 months ago

BrianSipos commented 9 months ago

The current outduct_element_config_t has a way to ensure a specific LTP local port with ltpSenderBoundPort but there is no way to do the equivalent thing with the outgoing UDP source port.

The current behavior uses a fixed bind port of "0" (meaning choose an ephemeral port) here https://github.com/nasa/HDTN/blob/73e30dbfc6962d647aeb4d5c1b5334d90b64d29f/common/udp/src/UdpBundleSource.cpp#L242 but this could be made a configuration from e.g. an option udpSenderBoundPort.

Additionally, the current open() and bind() within UdpBundleSource::OnResolve() doesn't actually need to wait for the peer address resolution. Both open and bind can happen (and catch errros) in that class constructor.

If source port selection is allowed, the following should be enabled just before the bind() call to enable multiple sockets to use the same sort port

m_udpSocket.set_option(boost::asio::socket_base::reuse_address(true));
rdudukov commented 8 months ago

Hi Brian, we will look into this and get back to you. Thanks!