Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21793] Easy Mode Implementation #5548

Merged
merged 49 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
25e5e49
Refs #22013: Add new port offset
cferreiragonz Nov 5, 2024
4e20f08
Refs #22013: Add CLI keywords architecture
cferreiragonz Nov 6, 2024
eceb77d
Refs #22106: Python -h/-e args
cferreiragonz Nov 11, 2024
bc7941a
Refs #22106: 'getDiscoveryServerPort'
cferreiragonz Nov 11, 2024
13eb90a
Refs #22106: Parse options in main
cferreiragonz Nov 11, 2024
52397a0
Refs #22106: Domain (-d) arg
cferreiragonz Nov 11, 2024
aad467c
Refs #22106: Justify Help message
cferreiragonz Nov 11, 2024
d1ff7ae
Refs #22106: Create CliDiscoveryManager & remove server.cpp
cferreiragonz Nov 14, 2024
a920d0a
Refs #22106: LIST keyword
cferreiragonz Nov 14, 2024
be75033
Refs #22106: AUTO keyword
cferreiragonz Nov 14, 2024
bf3c48d
Refs #22106: STOP keyword
cferreiragonz Nov 14, 2024
a8d6001
Refs #22106: Update server tests
cferreiragonz Nov 18, 2024
d48b1e7
Refs #22106: Refactor SERVER behavior
cferreiragonz Nov 18, 2024
8783949
Refs #22106: ADD keyword
cferreiragonz Nov 19, 2024
aba80ab
Refs #22106: Parse ROS_STATIC_PEERS
cferreiragonz Nov 19, 2024
3cd8566
Refs #22106: SET keyword & minor fixes
cferreiragonz Nov 20, 2024
2db0981
Refs #22106: Uncrustify
cferreiragonz Nov 20, 2024
52e0e68
Refs #22106: Remove debug log
cferreiragonz Nov 20, 2024
8f031e9
Refs #22106: START keyword & doxygen
cferreiragonz Nov 21, 2024
d1906ed
Refs #22106: print Domain ID
cferreiragonz Nov 21, 2024
c34e7f2
Refs #22106: Unittests
cferreiragonz Nov 22, 2024
0a60b97
Refs #22106: Add SHM transport
cferreiragonz Nov 25, 2024
d7646b2
Refs #22106: Make arguments const
cferreiragonz Nov 25, 2024
8360897
Refs #22106: Use data_sharing directory
cferreiragonz Nov 25, 2024
f7cbca6
Refs #22106: Use Logs in CLI
cferreiragonz Nov 25, 2024
762d78c
Refs #22106: Support Windows & Mac commands
cferreiragonz Nov 27, 2024
0be47ca
Refs #22106: Uncrustify
cferreiragonz Nov 26, 2024
e46eea7
Refs #22106: Protect std::stoi & Add server name
cferreiragonz Nov 28, 2024
48f7739
Refs #22106: Fix MacOS build
Mario-DL Dec 2, 2024
00115a6
Refs #22106: Fix Windows build
cferreiragonz Dec 2, 2024
ac728fd
Refs #22106: Add help/examples tests
cferreiragonz Dec 4, 2024
123199e
Refs #22106: Rearrange methods to simplify windows def
cferreiragonz Dec 5, 2024
efa9adc
Refs #22106: Workaround to solve Mac Tests
cferreiragonz Dec 11, 2024
4c88e91
Refs #22106: Minor fixes
cferreiragonz Dec 18, 2024
6bce330
Refs #22518: Add Fast DDS XML-RPC Daemon
cferreiragonz Dec 20, 2024
68823ef
Refs #22518: Test enum
cferreiragonz Dec 20, 2024
a4b62cf
Refs #22518: Cancel fork in cpp tool
cferreiragonz Dec 20, 2024
d2a83a5
Refs #22518: Add parser tests
cferreiragonz Jan 8, 2025
c2e40a4
Refs #22518: Apply Revision
cferreiragonz Jan 10, 2025
e3feef8
Refs #22518: Review - Use stop to shutdown server
cferreiragonz Jan 10, 2025
eba9be9
Refs #22518: Apply Revision 2
cferreiragonz Jan 10, 2025
70285bf
Refs #22623: Allow TCP reconnections
cferreiragonz Jan 15, 2025
06a5941
Refs #22518: Fix build in Ubuntu24
cferreiragonz Jan 15, 2025
321e284
Refs #22627: Add EASY_MODE to parser
cferreiragonz Jan 16, 2025
06e6282
Refs #22518: Improve unittest robustness
cferreiragonz Jan 17, 2025
e4307ab
Fast DDS EASY_MODE - Feature - XMLRPC Server (#5551)
cferreiragonz Jan 22, 2025
e64989e
Refs #22627: logs, comments, versions, displays
cferreiragonz Jan 22, 2025
034e7d5
Refs #22627: Review - Logs
cferreiragonz Jan 22, 2025
04b363a
Refs #22627: ROS2_EASY_MODE
cferreiragonz Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/reusable-ubuntu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ jobs:
- name: Install Python dependencies
uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0
with:
packages: vcstool xmlschema
packages: vcstool xmlschema psutil

- name: Setup CCache
uses: eProsima/eProsima-CI/external/setup-ccache-action@v0
Expand Down Expand Up @@ -650,7 +650,7 @@ jobs:
- name: Install Python dependencies
uses: eProsima/eProsima-CI/ubuntu/install_python_packages@v0
with:
packages: vcstool xmlschema xmltodict==0.13.0 jsondiff==2.0.0 pandas==1.5.2
packages: vcstool xmlschema xmltodict==0.13.0 jsondiff==2.0.0 pandas==1.5.2 psutil

- name: Setup CCache
uses: eProsima/eProsima-CI/external/setup-ccache-action@v0
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ option(INSTALL_TOOLS "Install tools" OFF)

if(INSTALL_TOOLS)
# Install tools
install(DIRECTORY ${PROJECT_SOURCE_DIR}/tools
install(DIRECTORY ${PROJECT_SOURCE_DIR}/tools/
DESTINATION tools
COMPONENT tools
PATTERN "tools/CMakeLists.txt" EXCLUDE
Expand Down
10 changes: 7 additions & 3 deletions include/fastdds/rtps/attributes/BuiltinTransports.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ inline bool operator ==(
*/
enum class BuiltinTransports : uint16_t
{
NONE = 0, //< No transport will be instantiated
DEFAULT = 1, //< Default value that will instantiate UDPv4 and SHM transports
NONE = 0, //< No transport will be instantiated
DEFAULT = 1, //< Default value that will instantiate UDPv4 and SHM transports
DEFAULTv6 = 2, //< Instantiate UDPv6 and SHM transports
SHM = 3, //< Instantiate SHM transport only
UDPv4 = 4, //< Instantiate UDPv4 transport only
UDPv6 = 5, //< Instantiate UDPv6 transport only
LARGE_DATA = 6, //< Instantiate SHM, UDPv4 and TCPv4 transports, but UDPv4 is only used for bootstrapping discovery
LARGE_DATAv6 = 7 //< Instantiate SHM, UDPv6 and TCPv6 transports, but UDPv6 is only used for bootstrapping discovery
LARGE_DATAv6 = 7, //< Instantiate SHM, UDPv6 and TCPv6 transports, but UDPv6 is only used for bootstrapping discovery
P2P = 8 //< Instantiate SHM, UDPv4 (unicast) and TCPv4 transports, shall only be used along with ROS2_EASY_MODE=<ip>
};

inline std::ostream& operator <<(
Expand Down Expand Up @@ -144,6 +145,9 @@ inline std::ostream& operator <<(
case BuiltinTransports::LARGE_DATAv6:
output << "LARGE_DATAv6";
break;
case BuiltinTransports::P2P:
output << "P2P";
break;
default:
output << "UNKNOWN";
break;
Expand Down
30 changes: 29 additions & 1 deletion include/fastdds/rtps/common/PortParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class PortParameters
, offsetd1(10)
, offsetd2(1)
, offsetd3(11)
, offsetd4(2)
{
}

Expand All @@ -58,7 +59,8 @@ class PortParameters
(this->offsetd0 == b.offsetd0) &&
(this->offsetd1 == b.offsetd1) &&
(this->offsetd2 == b.offsetd2) &&
(this->offsetd3 == b.offsetd3);
(this->offsetd3 == b.offsetd3) &&
(this->offsetd4 == b.offsetd4);
}

/**
Expand Down Expand Up @@ -111,6 +113,30 @@ class PortParameters
return port;
}

/**
* Get a discovery server port based on the domain ID.
*
* @param domainId Domain ID.
* @return Discovery server port
*/
inline uint16_t get_discovery_server_port(
uint32_t domainId) const
{
uint32_t port = portBase + domainIDGain * domainId + offsetd4;

if (port > 65535)
{
EPROSIMA_LOG_ERROR(RTPS, "Calculated port number is too high. Probably the domainId is over 232 "
<< "or portBase is too high.");
std::cout << "Calculated port number is too high. Probably the domainId is over 232 "
<< "or portBase is too high." << std::endl;
std::cout.flush();
exit(EXIT_FAILURE);
}

return static_cast<uint16_t>(port);
}

public:

//!PortBase, default value 7400.
Expand All @@ -127,6 +153,8 @@ class PortParameters
uint16_t offsetd2;
//!Offset d3, default value 11.
uint16_t offsetd3;
//!Offset d4, default value 2.
uint16_t offsetd4;
};

} // namespace rtps
Expand Down
Binary file modified resources/images/fastdds_github_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion resources/xsd/fastdds_profiles.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@
├ offsetd0 [uint16],
├ offsetd1 [uint16],
├ offsetd2 [uint16],
└ offsetd3 [uint16] -->
├ offsetd3 [uint16],
└ offsetd4 [uint16] -->
<xs:complexType name="portType">
<xs:all>
<xs:element name="portBase" type="uint16" minOccurs="0" maxOccurs="1"/>
Expand All @@ -826,6 +827,7 @@
<xs:element name="offsetd1" type="uint16" minOccurs="0" maxOccurs="1"/>
<xs:element name="offsetd2" type="uint16" minOccurs="0" maxOccurs="1"/>
<xs:element name="offsetd3" type="uint16" minOccurs="0" maxOccurs="1"/>
<xs:element name="offsetd4" type="uint16" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>

Expand Down Expand Up @@ -1961,6 +1963,7 @@
<xs:enumeration value="UDPv6" />
<xs:enumeration value="LARGE_DATA" />
<xs:enumeration value="LARGE_DATAv6" />
<xs:enumeration value="P2P" />
</xs:restriction>
</xs:simpleType>

Expand Down
162 changes: 116 additions & 46 deletions src/cpp/rtps/RTPSDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <rtps/transport/UDPv6Transport.h>
#include <rtps/writer/BaseWriter.hpp>
#include <utils/Host.hpp>
#include <utils/SystemCommandBuilder.hpp>
#include <utils/SystemInfo.hpp>
#include <xmlparser/XMLProfileManager.h>

Expand Down Expand Up @@ -518,59 +519,128 @@ RTPSParticipant* RTPSDomainImpl::clientServerEnvironmentCreationOverride(
// Is up to the caller guarantee the att argument is not modified during the call
RTPSParticipantAttributes client_att(att);

// Retrieve the info from the environment variable
LocatorList_t& server_list = client_att.builtin.discovery_config.m_DiscoveryServers;
if (load_environment_server_info(server_list) && server_list.empty())
{
// It's not an error, the environment variable may not be set. Any issue with environment
// variable syntax is EPROSIMA_LOG_ERROR already
return nullptr;
}
// Check whether we need to initialize in easy mode
const std::string& easy_mode_env_value = easy_mode_env();
Mario-DL marked this conversation as resolved.
Show resolved Hide resolved

// Check if some address requires the UDPv6, TCPv4 or TCPv6 transport
if (server_list.has_kind<LOCATOR_KIND_UDPv6>() &&
!has_user_transport<fastdds::rtps::UDPv6TransportDescriptor>(client_att))
if (easy_mode_env_value.empty())
{
// Extend builtin transports with the UDPv6 transport
auto descriptor = std::make_shared<fastdds::rtps::UDPv6TransportDescriptor>();
descriptor->sendBufferSize = client_att.sendSocketBufferSize;
descriptor->receiveBufferSize = client_att.listenSocketBufferSize;
client_att.userTransports.push_back(std::move(descriptor));
}
if (server_list.has_kind<LOCATOR_KIND_TCPv4>() &&
!has_user_transport<fastdds::rtps::TCPv4TransportDescriptor>(client_att))
{
// Extend builtin transports with the TCPv4 transport
auto descriptor = std::make_shared<fastdds::rtps::TCPv4TransportDescriptor>();
// Add automatic port
descriptor->add_listener_port(0);
descriptor->sendBufferSize = client_att.sendSocketBufferSize;
descriptor->receiveBufferSize = client_att.listenSocketBufferSize;
client_att.userTransports.push_back(std::move(descriptor));
}
if (server_list.has_kind<LOCATOR_KIND_TCPv6>() &&
!has_user_transport<fastdds::rtps::TCPv6TransportDescriptor>(client_att))
{
// Extend builtin transports with the TCPv6 transport
auto descriptor = std::make_shared<fastdds::rtps::TCPv6TransportDescriptor>();
// Add automatic port
descriptor->add_listener_port(0);
descriptor->sendBufferSize = client_att.sendSocketBufferSize;
descriptor->receiveBufferSize = client_att.listenSocketBufferSize;
client_att.userTransports.push_back(std::move(descriptor));
}
// Retrieve the info from the environment variable
LocatorList_t& server_list = client_att.builtin.discovery_config.m_DiscoveryServers;
if (load_environment_server_info(server_list) && server_list.empty())
{
// It's not an error, the environment variable may not be set. Any issue with environment
// variable syntax is EPROSIMA_LOG_ERROR already
return nullptr;
}

EPROSIMA_LOG_INFO(DOMAIN, "Detected auto client-server environment variable."
<< "Trying to create client with the default server setup: "
<< client_att.builtin.discovery_config.m_DiscoveryServers);
// Check if some address requires the UDPv6, TCPv4 or TCPv6 transport
if (server_list.has_kind<LOCATOR_KIND_UDPv6>() &&
!has_user_transport<fastdds::rtps::UDPv6TransportDescriptor>(client_att))
{
// Extend builtin transports with the UDPv6 transport
auto descriptor = std::make_shared<fastdds::rtps::UDPv6TransportDescriptor>();
descriptor->sendBufferSize = client_att.sendSocketBufferSize;
descriptor->receiveBufferSize = client_att.listenSocketBufferSize;
client_att.userTransports.push_back(std::move(descriptor));
}
if (server_list.has_kind<LOCATOR_KIND_TCPv4>() &&
!has_user_transport<fastdds::rtps::TCPv4TransportDescriptor>(client_att))
{
// Extend builtin transports with the TCPv4 transport
auto descriptor = std::make_shared<fastdds::rtps::TCPv4TransportDescriptor>();
// Add automatic port
descriptor->add_listener_port(0);
descriptor->sendBufferSize = client_att.sendSocketBufferSize;
descriptor->receiveBufferSize = client_att.listenSocketBufferSize;
client_att.userTransports.push_back(std::move(descriptor));
}
if (server_list.has_kind<LOCATOR_KIND_TCPv6>() &&
!has_user_transport<fastdds::rtps::TCPv6TransportDescriptor>(client_att))
{
// Extend builtin transports with the TCPv6 transport
auto descriptor = std::make_shared<fastdds::rtps::TCPv6TransportDescriptor>();
// Add automatic port
descriptor->add_listener_port(0);
descriptor->sendBufferSize = client_att.sendSocketBufferSize;
descriptor->receiveBufferSize = client_att.listenSocketBufferSize;
client_att.userTransports.push_back(std::move(descriptor));
}

EPROSIMA_LOG_INFO(DOMAIN, "Detected auto client-server environment variable."
<< "Trying to create client with the default server setup: "
<< client_att.builtin.discovery_config.m_DiscoveryServers);

client_att.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;
// RemoteServerAttributes already fill in above
client_att.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::CLIENT;
// RemoteServerAttributes already fill in above

// Check if the client must become a super client
if (ros_super_client_env())
// Check if the client must become a super client
if (ros_super_client_env())
{
client_att.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SUPER_CLIENT;
}
}
else
{
// SUPER_CLIENT
client_att.builtin.discovery_config.discoveryProtocol = DiscoveryProtocol::SUPER_CLIENT;

// P2P transport. Similar to LARGE_DATA, but with UDPv4 unicast
client_att.useBuiltinTransports = false;
client_att.setup_transports(BuiltinTransports::P2P);

// Ignore initialpeers
client_att.builtin.initialPeersList = LocatorList();

eprosima::fastdds::rtps::PortParameters port_params;

auto domain_port = port_params.get_discovery_server_port(domain_id);

// Add user traffic TCP
eprosima::fastdds::rtps::Locator_t locator_tcp;
locator_tcp.kind = LOCATOR_KIND_TCPv4;

IPLocator::setPhysicalPort(locator_tcp, 0);
IPLocator::setLogicalPort(locator_tcp, 0);
// Initialize to the wan interface
IPLocator::setIPv4(locator_tcp, "0.0.0.0");

client_att.defaultUnicastLocatorList.push_back(locator_tcp);

// Add remote DS based on port
eprosima::fastdds::rtps::Locator_t locator_udp;
locator_udp.kind = LOCATOR_KIND_UDPv4;

locator_udp.port = domain_port;
IPLocator::setIPv4(locator_udp, 127, 0, 0, 1);

// Point to the well known DS port in the corresponding domain
client_att.builtin.discovery_config.m_DiscoveryServers.push_back(locator_udp);

SystemCommandBuilder sys_command;
int res = sys_command.executable(FAST_DDS_DEFAULT_CLI_SCRIPT_NAME)
.verb(FAST_DDS_DEFAULT_CLI_DISCOVERY_VERB)
.verb(FAST_DDS_DEFAULT_CLI_AUTO_VERB)
.arg("-d")
.value(std::to_string(domain_id))
.value(easy_mode_env_value + ":" + std::to_string(domain_id))
.build_and_call();
#ifndef _WIN32
// Adecuate Python subprocess return
res = WEXITSTATUS(res);
#endif // _WIN32

if (res != SystemCommandBuilder::SystemCommandResult::SUCCESS)
{
if (res == SystemCommandBuilder::SystemCommandResult::BAD_PARAM)
{
EPROSIMA_LOG_ERROR("DOMAIN", "ROS2_EASY_MODE IP connection conflicts with a previous one.");
}
else
{
EPROSIMA_LOG_ERROR(DOMAIN, "Auto discovery server client setup. Unable to spawn daemon.");
}
return nullptr;
}
}

RTPSParticipant* part = createParticipant(domain_id, enabled, client_att, listen);
Expand Down
45 changes: 42 additions & 3 deletions src/cpp/rtps/attributes/RTPSParticipantAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,38 @@ static void setup_transports_large_datav6(
}
}

static void setup_transports_p2p(
RTPSParticipantAttributes& att,
bool intraprocess_only,
const fastdds::rtps::BuiltinTransportsOptions& options)
{
if (!intraprocess_only)
{
setup_large_data_shm_transport(att, options);

auto tcp_transport = create_tcpv4_transport(att, options);
att.userTransports.push_back(tcp_transport);

Locator_t tcp_loc;
tcp_loc.kind = LOCATOR_KIND_TCPv4;
IPLocator::setIPv4(tcp_loc, "0.0.0.0");
IPLocator::setPhysicalPort(tcp_loc, 0);
IPLocator::setLogicalPort(tcp_loc, 0);
att.defaultUnicastLocatorList.push_back(tcp_loc);
}

auto udp_descriptor = create_udpv4_transport(att, intraprocess_only, options);
att.userTransports.push_back(udp_descriptor);

if (!intraprocess_only)
{
Locator_t udp_locator;
udp_locator.kind = LOCATOR_KIND_UDPv4;
IPLocator::setIPv4(udp_locator, "127.0.0.1");
att.builtin.metatrafficUnicastLocatorList.push_back(udp_locator);
}
}

void RTPSParticipantAttributes::setup_transports(
fastdds::rtps::BuiltinTransports transports,
const fastdds::rtps::BuiltinTransportsOptions& options)
Expand All @@ -309,7 +341,8 @@ void RTPSParticipantAttributes::setup_transports(
(transports != fastdds::rtps::BuiltinTransports::NONE &&
transports != fastdds::rtps::BuiltinTransports::SHM &&
transports != fastdds::rtps::BuiltinTransports::LARGE_DATA &&
transports != fastdds::rtps::BuiltinTransports::LARGE_DATAv6))
transports != fastdds::rtps::BuiltinTransports::LARGE_DATAv6 &&
transports != fastdds::rtps::BuiltinTransports::P2P))
{
EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT,
"Max message size of UDP cannot be greater than " << std::to_string(
Expand Down Expand Up @@ -347,17 +380,23 @@ void RTPSParticipantAttributes::setup_transports(
break;

case fastdds::rtps::BuiltinTransports::LARGE_DATA:
// This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB (s_maximumMessageSize)
// This parameter will allow the initialization of UDP transports with maxMessageSize > 65500 KB (s_maximumMessageSize)
max_msg_size_no_frag = options.maxMessageSize;
setup_transports_large_data(*this, intraprocess_only, options);
break;

case fastdds::rtps::BuiltinTransports::LARGE_DATAv6:
// This parameter will allow allow the initialization of UDP transports with maxMessageSize > 65500 KB (s_maximumMessageSize)
// This parameter will allow the initialization of UDP transports with maxMessageSize > 65500 KB (s_maximumMessageSize)
max_msg_size_no_frag = options.maxMessageSize;
setup_transports_large_datav6(*this, intraprocess_only, options);
break;

case fastdds::rtps::BuiltinTransports::P2P:
// This parameter will allow the initialization of UDP transports with maxMessageSize > 65500 KB (s_maximumMessageSize)
max_msg_size_no_frag = options.maxMessageSize;
setup_transports_p2p(*this, intraprocess_only, options);
break;

default:
EPROSIMA_LOG_ERROR(RTPS_PARTICIPANT,
"Setup for '" << transports << "' transport configuration not yet supported.");
Expand Down
Loading
Loading