Skip to content

Commit d7aab9e

Browse files
Add support for priority mappings in UDP (#6029)
* Refs #23434. Add UDP priority mappings to XSD. Signed-off-by: Miguel Company <[email protected]> * Refs #23434. Avoid failing with new specific xml element. Signed-off-by: Miguel Company <[email protected]> * Refs #23434. Add xml validation file. Signed-off-by: Miguel Company <[email protected]> * Refs #23434. Update `versions.md`. Signed-off-by: Miguel Company <[email protected]> * Refs #23434. Add friend to UDPTransportInterface. Signed-off-by: Miguel Company <[email protected]> * Refs #23434. Prepare for socket options extension. Signed-off-by: Miguel Company <[email protected]> --------- Signed-off-by: Miguel Company <[email protected]>
1 parent f539ff3 commit d7aab9e

File tree

8 files changed

+96
-6
lines changed

8 files changed

+96
-6
lines changed

resources/xsd/fastdds_profiles.xsd

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@
923923
├ TTL [uint8], (ONLY available for UDP type)
924924
├ non_blocking_send [boolean], (NOT available for SHM type)
925925
├ output_port [uint16], (ONLY available for UDP type)
926+
├ udp_priority_mappings [udpPriorityMappingsType], (ONLY available for UDP type)
926927
├ wan_addr [ipv4AddressFormat], (ONLY available for TCPv4 type)
927928
├ keep_alive_frequency_ms [uint32], (ONLY available for TCP type)
928929
├ keep_alive_timeout_ms [uint32], (ONLY available for TCP type)
@@ -996,6 +997,7 @@
996997
<xs:element name="TTL" type="uint8" minOccurs="0" maxOccurs="1"/>
997998
<xs:element name="non_blocking_send" type="boolean" minOccurs="0" maxOccurs="1"/>
998999
<xs:element name="output_port" type="uint16" minOccurs="0" maxOccurs="1"/>
1000+
<xs:element name="udp_priority_mappings" type="udpPriorityMappingsType" minOccurs="0" maxOccurs="1"/>
9991001
<xs:element name="wan_addr" type="ipv4AddressFormat" minOccurs="0" maxOccurs="1"/>
10001002
<xs:element name="keep_alive_frequency_ms" type="uint32" minOccurs="0" maxOccurs="1"/>
10011003
<xs:element name="keep_alive_timeout_ms" type="uint32" minOccurs="0" maxOccurs="1"/>
@@ -1159,6 +1161,26 @@
11591161
</xs:all>
11601162
</xs:complexType>
11611163

1164+
<!--udp_priority_mappings:
1165+
└ priority [0~*]
1166+
╠ att. value [int32] REQ
1167+
╠ att. dscp [uint8]
1168+
╠ att. source_port [uint16]
1169+
╚ att. interface [string]
1170+
-->
1171+
<xs:complexType name="udpPriorityMappingsType">
1172+
<xs:sequence minOccurs="0" maxOccurs="unbounded">
1173+
<xs:element name="priority" minOccurs="0" maxOccurs="unbounded">
1174+
<xs:complexType>
1175+
<xs:attribute name="value" type="int32" use="required"/>
1176+
<xs:attribute name="dscp" type="uint8" default="0"/>
1177+
<xs:attribute name="source_port" type="uint16" default="0"/>
1178+
<xs:attribute name="interface" type="string"/>
1179+
</xs:complexType>
1180+
</xs:element>
1181+
</xs:sequence>
1182+
</xs:complexType>
1183+
11621184
<!--eth_priority_mappings:
11631185
└ priority [0~*]
11641186
╠ att. value [int32] REQ

src/cpp/rtps/transport/UDPTransportInterface.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,9 @@ UDPChannelResource* UDPTransportInterface::CreateInputChannelResource(
245245
return p_channel_resource;
246246
}
247247

248-
eProsimaUDPSocket UDPTransportInterface::OpenAndBindUnicastOutputSocket(
249-
const ip::udp::endpoint& endpoint,
250-
uint16_t& port)
248+
void UDPTransportInterface::set_output_pre_bind_options(
249+
eProsimaUDPSocket& socket) const
251250
{
252-
eProsimaUDPSocket socket = createUDPSocket(io_context_);
253-
getSocketPtr(socket)->open(generate_protocol());
254251
if (mSendBufferSize != 0)
255252
{
256253
uint32_t configured_value = 0;
@@ -267,8 +264,23 @@ eProsimaUDPSocket UDPTransportInterface::OpenAndBindUnicastOutputSocket(
267264
}
268265
}
269266
getSocketPtr(socket)->set_option(ip::multicast::hops(configuration()->TTL));
270-
getSocketPtr(socket)->bind(endpoint);
267+
}
268+
269+
void UDPTransportInterface::set_output_post_bind_options(
270+
eProsimaUDPSocket& socket) const
271+
{
271272
getSocketPtr(socket)->non_blocking(configuration()->non_blocking_send);
273+
}
274+
275+
eProsimaUDPSocket UDPTransportInterface::OpenAndBindUnicastOutputSocket(
276+
const ip::udp::endpoint& endpoint,
277+
uint16_t& port)
278+
{
279+
eProsimaUDPSocket socket = createUDPSocket(io_context_);
280+
getSocketPtr(socket)->open(generate_protocol());
281+
set_output_pre_bind_options(socket);
282+
getSocketPtr(socket)->bind(endpoint);
283+
set_output_post_bind_options(socket);
272284

273285
if (port == 0)
274286
{

src/cpp/rtps/transport/UDPTransportInterface.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace rtps {
3939
class UDPTransportInterface : public TransportInterface
4040
{
4141
friend class UDPSenderResource;
42+
friend struct TSN_UDPSender;
4243

4344
using TransportInterface::transform_remote_locator;
4445

@@ -263,6 +264,22 @@ class UDPTransportInterface : public TransportInterface
263264
*/
264265
virtual std::vector<std::string> get_binding_interfaces_list() = 0;
265266

267+
/**
268+
* Set socket options before binding the output socket.
269+
*
270+
* @param socket Reference to the socket to set options on.
271+
*/
272+
virtual void set_output_pre_bind_options(
273+
eProsimaUDPSocket& socket) const;
274+
275+
/**
276+
* Set socket options after binding the output socket.
277+
*
278+
* @param socket Reference to the socket to set options on.
279+
*/
280+
virtual void set_output_post_bind_options(
281+
eProsimaUDPSocket& socket) const;
282+
266283
bool OpenAndBindInputSockets(
267284
const Locator& locator,
268285
TransportReceiverInterface* receiver,

src/cpp/xmlparser/XMLParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ XMLP_ret XMLParser::validateXMLTransportElements(
441441
strcmp(name, TTL) == 0 ||
442442
strcmp(name, NON_BLOCKING_SEND) == 0 ||
443443
strcmp(name, UDP_OUTPUT_PORT) == 0 ||
444+
strcmp(name, UDP_PRIORITY_MAPPINGS) == 0 ||
444445
strcmp(name, TCP_WAN_ADDR) == 0 ||
445446
strcmp(name, KEEP_ALIVE_FREQUENCY) == 0 ||
446447
strcmp(name, KEEP_ALIVE_TIMEOUT) == 0 ||

src/cpp/xmlparser/XMLParserCommon.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const char* REPLIER = "replier";
4242
const char* TRANSPORT_DESCRIPTOR = "transport_descriptor";
4343
const char* TRANSPORT_ID = "transport_id";
4444
const char* UDP_OUTPUT_PORT = "output_port";
45+
const char* UDP_PRIORITY_MAPPINGS = "udp_priority_mappings";
4546
const char* TCP_WAN_ADDR = "wan_addr";
4647
const char* RECEIVE_BUFFER_SIZE = "receiveBufferSize";
4748
const char* SEND_BUFFER_SIZE = "sendBufferSize";

src/cpp/xmlparser/XMLParserCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern const char* REPLIER;
5555
extern const char* TRANSPORT_DESCRIPTOR;
5656
extern const char* TRANSPORT_ID;
5757
extern const char* UDP_OUTPUT_PORT;
58+
extern const char* UDP_PRIORITY_MAPPINGS;
5859
extern const char* TCP_WAN_ADDR;
5960
extern const char* RECEIVE_BUFFER_SIZE;
6061
extern const char* SEND_BUFFER_SIZE;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<profiles xmlns="http://www.eprosima.com">
3+
<transport_descriptors>
4+
<transport_descriptor>
5+
<transport_id>udp4_priorities_transport</transport_id>
6+
<type>UDPv4</type>
7+
<udp_priority_mappings>
8+
<priority value="-1" source_port="5000"/>
9+
<priority value="1" source_port="5000" dscp="1"/>
10+
<priority value="2" source_port="5000" dscp="2" interface="eth0"/>
11+
<priority value="3" source_port="5000" dscp="3" interface="10.10.1.2"/>
12+
</udp_priority_mappings>
13+
</transport_descriptor>
14+
<transport_descriptor>
15+
<transport_id>udp6_priorities_transport</transport_id>
16+
<type>UDPv6</type>
17+
<udp_priority_mappings>
18+
<priority value="-1" source_port="5000"/>
19+
<priority value="1" source_port="5000" dscp="1"/>
20+
<priority value="2" source_port="5000" dscp="2" interface="eth0"/>
21+
<priority value="3" source_port="5000" dscp="3" interface="::1"/>
22+
</udp_priority_mappings>
23+
</transport_descriptor>
24+
</transport_descriptors>
25+
26+
<participant profile_name="UDP_priorities_participant" is_default_profile="true">
27+
<rtps>
28+
<useBuiltinTransports>false</useBuiltinTransports>
29+
<userTransports>
30+
<transport_id>udp4_priorities_transport</transport_id>
31+
<transport_id>udp6_priorities_transport</transport_id>
32+
</userTransports>
33+
</rtps>
34+
</participant>
35+
</profiles>

versions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Forthcoming
1111
* Add new `for_each_type_w_uri()` method in `DynamicTypeBuilderFactory`.
1212
* __Fast DDS Pro__ features:
1313
* Added Ethernet transport (Linux only).
14+
* Mapping transport priority to DSCP, interface and source port in UDP transport.
1415

1516
Version v3.3.0
1617
--------------

0 commit comments

Comments
 (0)