Skip to content

Commit

Permalink
Update TCP documentation (#654) (#667)
Browse files Browse the repository at this point in the history
* Update TCP documentation (#654)

* Refs #20314: Update TCP LAN example

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

* Refs #20314: Update TCP WAN example

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

* Refs #20314: Update TCP TLS example

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

* Refs #20314: Minor fixes

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

* Refs #20314: Extend WAN description, update image and modify examples

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

---------

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>
(cherry picked from commit 6c2c47a)

# Conflicts:
#	code/XMLTester.xml
#	docs/fastdds/transport/tcp/tcp.rst

* Refs #20314: Resolve conflicts

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

---------

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>
Co-authored-by: Jesús Pérez <78275223+jepemi@users.noreply.github.com>
Co-authored-by: Jesus Perez <jesusperez@eprosima.com>
  • Loading branch information
3 people authored Feb 15, 2024
1 parent 4152546 commit 79795ee
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 508 deletions.
75 changes: 69 additions & 6 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4586,18 +4586,19 @@ void dds_transport_examples ()
// Create a descriptor for the new transport.
auto tcp_transport = std::make_shared<eprosima::fastdds::rtps::TCPv4TransportDescriptor>();
tcp_transport->add_listener_port(5100);
tcp_transport->set_WAN_address("80.80.99.45");

// Link the Transport Layer to the Participant.
qos.transport().user_transports.push_back(tcp_transport);

// Avoid using the default transport
qos.transport().use_builtin_transports = false;

// [OPTIONAL] Set unicast locators
eprosima::fastrtps::rtps::Locator_t locator;
eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, "80.80.99.45");
eprosima::fastrtps::rtps::IPLocator::setWan(locator, "80.80.99.45");
locator.kind = LOCATOR_KIND_TCPv4;
eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, "192.168.1.10");
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, 5100);
// [OPTIONAL] Logical port default value is 0, automatically assigned.
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(locator, 5100);

qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(locator);
Expand All @@ -4620,14 +4621,77 @@ void dds_transport_examples ()
// Set initial peers.
eprosima::fastrtps::rtps::Locator_t initial_peer_locator;
initial_peer_locator.kind = LOCATOR_KIND_TCPv4;
eprosima::fastrtps::rtps::IPLocator::setIPv4(initial_peer_locator, "80.80.99.45");
eprosima::fastrtps::rtps::IPLocator::setIPv4(initial_peer_locator, "192.168.1.10");
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(initial_peer_locator, 5100);
// If the logical port is set in the server side, it must be also set here with the same value.
// If not set in the server side in a unicast locator, do not set it here.
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(initial_peer_locator, 5100);

qos.wire_protocol().builtin.initialPeersList.push_back(initial_peer_locator);
//!--
}

{
//CONF-TCP-TRANSPORT-SETTING-WAN-SERVER
eprosima::fastdds::dds::DomainParticipantQos qos;

// Create a descriptor for the new transport.
auto tcp_transport = std::make_shared<eprosima::fastdds::rtps::TCPv4TransportDescriptor>();
tcp_transport->add_listener_port(5100);
tcp_transport->set_WAN_address("80.80.99.45");

// Link the Transport Layer to the Participant.
qos.transport().user_transports.push_back(tcp_transport);

// Avoid using the default transport
qos.transport().use_builtin_transports = false;

// [OPTIONAL] Set unicast locators (do not use setWAN(), set_WAN_address() overwrites it)
eprosima::fastrtps::rtps::Locator_t locator;
locator.kind = LOCATOR_KIND_TCPv4;
// [RECOMMENDED] Use the LAN address of the server
eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, "192.168.1.10");
// [ALTERNATIVE] Use server's WAN address. In that case, initial peers must be configured
// only with server's WAN address.
// eprosima::fastrtps::rtps::IPLocator::setIPv4(locator, "80.80.99.45");
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(locator, 5100);
// [OPTIONAL] Logical port default value is 0, automatically assigned.
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(locator, 5100);

qos.wire_protocol().builtin.metatrafficUnicastLocatorList.push_back(locator);
qos.wire_protocol().default_unicast_locator_list.push_back(locator);
//!--
}

{
//CONF-TCP-TRANSPORT-SETTING-WAN-CLIENT
eprosima::fastdds::dds::DomainParticipantQos qos;

// Disable the built-in Transport Layer.
qos.transport().use_builtin_transports = false;

// Create a descriptor for the new transport.
// Do not configure any listener port
auto tcp_transport = std::make_shared<eprosima::fastdds::rtps::TCPv4TransportDescriptor>();
// [RECOMMENDED] Use client's WAN address if there are more clients in other local networks.
tcp_transport->set_WAN_address("80.80.99.47");
qos.transport().user_transports.push_back(tcp_transport);

// Set initial peers.
eprosima::fastrtps::rtps::Locator_t initial_peer_locator;
initial_peer_locator.kind = LOCATOR_KIND_TCPv4;
// [RECOMMENDED] Use both WAN and LAN server addresses
eprosima::fastrtps::rtps::IPLocator::setIPv4(initial_peer_locator, "192.168.1.10");
eprosima::fastrtps::rtps::IPLocator::setWan(initial_peer_locator, "80.80.99.45");
// [ALTERNATIVE] Use server's WAN address only. Valid if server specified its unicast locators
// with its LAN or WAN address.
// eprosima::fastrtps::rtps::IPLocator::setIPv4(initial_peer_locator, "80.80.99.45");
eprosima::fastrtps::rtps::IPLocator::setPhysicalPort(initial_peer_locator, 5100);
// If the logical port is set in the server side, it must be also set here with the same value.
// If not set in the server side in a unicast locator, do not set it here.
eprosima::fastrtps::rtps::IPLocator::setLogicalPort(initial_peer_locator, 5100);

qos.wire_protocol().builtin.initialPeersList.push_back(initial_peer_locator);
//!--
}

Expand All @@ -4652,7 +4716,6 @@ void dds_transport_examples ()
tls_transport->sendBufferSize = 9216;
tls_transport->receiveBufferSize = 9216;
tls_transport->add_listener_port(5100);
tls_transport->set_WAN_address("80.80.99.45");

// Create the TLS configuration
using TLSOptions = eprosima::fastdds::rtps::TCPTransportDescriptor::TLSConfig::TLSOptions;
Expand All @@ -4677,7 +4740,7 @@ void dds_transport_examples ()
// Set initial peers.
Locator_t initial_peer_locator;
initial_peer_locator.kind = LOCATOR_KIND_TCPv4;
IPLocator::setIPv4(initial_peer_locator, "80.80.99.45");
IPLocator::setIPv4(initial_peer_locator, "192.168.1.10");
initial_peer_locator.port = 5100;
qos.wire_protocol().builtin.initialPeersList.push_back(initial_peer_locator);

Expand Down
115 changes: 106 additions & 9 deletions code/XMLTester.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
<listening_ports>
<port>5100</port>
</listening_ports>
<wan_addr>80.80.99.45</wan_addr>
</transport_descriptor>
</transport_descriptors>

Expand All @@ -266,23 +265,25 @@
<transport_id>tcp_server_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
<!-- Optional unicast locator set -->
<defaultUnicastLocatorList>
<locator>
<tcpv4>
<wan_address>80.80.99.45</wan_address>
<address>80.80.99.45</address>
<address>192.168.1.10</address>
<physical_port>5100</physical_port>
<!-- Optional logical port set -->
<port>5100</port>
</tcpv4>
</locator>
</defaultUnicastLocatorList>
<!-- Optional metatraffic unicast locator set -->
<builtin>
<metatrafficUnicastLocatorList>
<locator>
<tcpv4>
<wan_address>80.80.99.45</wan_address>
<address>80.80.99.45</address>
<address>192.168.1.10</address>
<physical_port>5100</physical_port>
<!-- Optional logical port set -->
<port>5100</port>
</tcpv4>
</locator>
Expand All @@ -309,13 +310,110 @@
<userTransports>
<transport_id>tcp_client_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
<useBuiltinTransports>false</useBuiltinTransports>
<builtin>
<initialPeersList>
<locator>
<tcpv4>
<address>80.80.99.45</address>
<address>192.168.1.10</address>
<physical_port>5100</physical_port>
<!-- To be set if set in server -->
<port>5100</port>
</tcpv4>
</locator>
</initialPeersList>
</builtin>
</rtps>
</participant>
<!--><-->

<!-->CONF-TCP-TRANSPORT-SETTING-WAN-SERVER<-->
<!--
<?xml version="1.0" encoding="UTF-8" ?>
<dds>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
-->
<transport_descriptors>
<transport_descriptor>
<transport_id>tcp_server_wan_transport</transport_id>
<type>TCPv4</type>
<listening_ports>
<port>5100</port>
</listening_ports>
<wan_addr>80.80.99.45</wan_addr>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="tcp_server_wan_participant">
<rtps>
<userTransports>
<transport_id>tcp_server_wan_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
<!-- Optional unicast locator set -->
<defaultUnicastLocatorList>
<locator>
<tcpv4>
<address>192.168.1.10</address>
<!-- Alternatively use WAN address -->
<!-- <address>80.80.99.45</address> -->
<physical_port>5100</physical_port>
<!-- Optional logical port set -->
<port>5100</port>
</tcpv4>
</locator>
</defaultUnicastLocatorList>
<!-- Optional metatraffic unicast locator set -->
<builtin>
<metatrafficUnicastLocatorList>
<locator>
<tcpv4>
<address>192.168.1.10</address>
<!-- Alternatively use WAN address -->
<!-- <address>80.80.99.45</address> -->
<physical_port>5100</physical_port>
<!-- Optional logical port set -->
<port>5100</port>
</tcpv4>
</locator>
</metatrafficUnicastLocatorList>
</builtin>
</rtps>
</participant>
<!--><-->

<!-->CONF-TCP-TRANSPORT-SETTING-WAN-CLIENT<-->
<!--
<?xml version="1.0" encoding="UTF-8" ?>
<dds>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
-->
<transport_descriptors>
<transport_descriptor>
<transport_id>tcp_client_wan_transport</transport_id>
<type>TCPv4</type>
<!-- Recommended client's WAN set -->
<wan_addr>80.80.99.47</wan_addr>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="tcp_client_wan_participant">
<rtps>
<userTransports>
<transport_id>tcp_client_wan_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
<builtin>
<initialPeersList>
<locator>
<tcpv4>
<!-- Recommended use of both WAN and LAN server addresses -->
<wan_address>80.80.99.45</wan_address>
<address>192.168.1.10</address>
<!-- Alternatively use server's WAN addresses only -->
<!-- <address>80.80.99.45</address> -->
<physical_port>5100</physical_port>
<!-- To be set if set in server -->
<port>5100</port>
</tcpv4>
</locator>
Expand Down Expand Up @@ -373,7 +471,6 @@
<listening_ports>
<port>5100</port>
</listening_ports>
<wan_addr>80.80.99.45</wan_addr>
</transport_descriptor>
</transport_descriptors>

Expand Down Expand Up @@ -420,7 +517,7 @@
<initialPeersList>
<locator>
<tcpv4>
<address>80.80.99.45</address>
<address>192.168.1.10</address>
<physical_port>5100</physical_port>
</tcpv4>
</locator>
Expand Down
Binary file modified docs/01-figures/TCP_WAN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 79795ee

Please sign in to comment.