Skip to content

Commit

Permalink
Methods to configure transport scenarios (#4098) (#4174)
Browse files Browse the repository at this point in the history
* Methods to configure transport scenarios (#4098)

* Refs #20020. Added enumeration for possible builtin transports configuration.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Add method to parse environment variable.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Cleanup RTPSParticipantAttributes.h.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Moved default transports configuration into RTPSParticipantAttributes::setup_transports.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. RTPSParticipantImpl constructor uses private copy of attributes.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Added support for DEFAULTv6.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. SHM transport added before UDP.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Added support for SHM.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Added support for UDPv4.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Added support for UDPv6.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Factor out duplicated code.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Added support for LARGE_DATA.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Added support for LARGE_DATAv6.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020. Added DomainParticipantQos::setup_transports.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs #20020: Add constants for builtin transports

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Add XML parser functions for builtin_transports

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: add builtinTransports to .xsd

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: add mock tests needed

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Add builtin transports XML file

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Add new API to tests classes

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Add Blackbox tests

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs 20020: Rename XML file and EOF

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Add unittest test

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>

* Refs #20020: Update versions.md

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Make enum uint16_t

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Add Parsing test

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Apply minor changes

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Remove - in CMakeLists

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Uncrustify

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Fix .xsd and remove unnecesary mock test

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Add implementation for mock test

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Fix windows build

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20020: Uncrustify

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Disable v6 tests for Mac

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

---------

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
Co-authored-by: cferreiragonz <carlosferreira@eprosima.com>
Co-authored-by: elianalf <62831776+elianalf@users.noreply.github.com>
(cherry picked from commit 8cbd461)

# Conflicts:
#	include/fastdds/dds/domain/qos/DomainParticipantQos.hpp
#	include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
#	include/fastrtps/xmlparser/XMLParser.h
#	resources/xsd/fastRTPS_profiles.xsd
#	src/cpp/rtps/participant/RTPSParticipantImpl.cpp
#	src/cpp/rtps/xmlparser/XMLElementParser.cpp
#	test/blackbox/CMakeLists.txt
#	test/unittest/dds/participant/CMakeLists.txt
#	test/unittest/dds/participant/ParticipantTests.cpp
#	test/unittest/dynamic_types/CMakeLists.txt
#	test/unittest/statistics/dds/CMakeLists.txt
#	test/unittest/xmlparser/CMakeLists.txt
#	versions.md

* Fix Conflicts: others

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Fix conflicts

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Cherry pick 1e498af

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

* Refs #20055: Separate builtin transports tests into individual cases

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

* Refs #20055: Mark large_data tests as flaky due to TCP

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>

---------

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
Signed-off-by: EduPonz <eduardoponz@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: cferreiragonz <carlosferreira@eprosima.com>
Co-authored-by: EduPonz <eduardoponz@eprosima.com>
  • Loading branch information
4 people authored Dec 23, 2023
1 parent bdc508e commit 77e4a4c
Show file tree
Hide file tree
Showing 34 changed files with 2,397 additions and 92 deletions.
9 changes: 9 additions & 0 deletions include/fastdds/dds/domain/qos/DomainParticipantQos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <string>

#include <fastdds/rtps/attributes/BuiltinTransports.hpp>
#include <fastrtps/fastrtps_dll.h>
#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp>
Expand Down Expand Up @@ -321,6 +322,14 @@ class DomainParticipantQos
return flow_controllers_;
}

/**
* Provides a way of easily configuring transport related configuration on certain pre-defined scenarios.
*
* @param transports Defines the transport configuration scenario to setup.
*/
RTPS_DllAPI void setup_transports(
rtps::BuiltinTransports transports);

private:

//!UserData Qos, implemented in the library.
Expand Down
85 changes: 85 additions & 0 deletions include/fastdds/rtps/attributes/BuiltinTransports.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file BuiltinTransports.hpp
*/

#ifndef _FASTDDS_RTPS_ATTRIBUTES__BUILTINTRANSPORTS_HPP_
#define _FASTDDS_RTPS_ATTRIBUTES__BUILTINTRANSPORTS_HPP_

#include <ostream>
#include <cstdint>

namespace eprosima {
namespace fastdds {
namespace rtps {

/**
* Defines the kind of transports automatically instantiated upon the creation of a participant
*/
enum class BuiltinTransports : uint16_t
{
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
};

inline std::ostream& operator <<(
std::ostream& output,
BuiltinTransports transports)
{
switch (transports)
{
case BuiltinTransports::NONE:
output << "NONE";
break;
case BuiltinTransports::DEFAULT:
output << "DEFAULT";
break;
case BuiltinTransports::DEFAULTv6:
output << "DEFAULTv6";
break;
case BuiltinTransports::SHM:
output << "SHM";
break;
case BuiltinTransports::UDPv4:
output << "UDPv4";
break;
case BuiltinTransports::UDPv6:
output << "UDPv6";
break;
case BuiltinTransports::LARGE_DATA:
output << "LARGE_DATA";
break;
case BuiltinTransports::LARGE_DATAv6:
output << "LARGE_DATAv6";
break;
default:
output << "UNKNOWN";
break;
}
return output;
}

} // namespace rtps
} // namespace fastdds
} // namespace eprosima

#endif // _FASTDDS_RTPS_ATTRIBUTES__BUILTINTRANSPORTS_HPP_
64 changes: 31 additions & 33 deletions include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define _FASTDDS_RTPSPARTICIPANTPARAMETERS_H_

#include <fastdds/rtps/common/Time_t.h>
#include <fastdds/rtps/attributes/BuiltinTransports.hpp>
#include <fastdds/rtps/common/Locator.h>
#include <fastdds/rtps/common/PortParameters.h>
#include <fastdds/rtps/attributes/PropertyPolicy.h>
Expand All @@ -35,14 +36,12 @@
#include <sstream>

namespace eprosima {

namespace fastdds {

namespace rtps {

/**
* Struct to define participant types to set participant type parameter property
*@ingroup DISCOVERY_MODULE
* @ingroup DISCOVERY_MODULE
*/
struct ParticipantType
{
Expand All @@ -56,14 +55,13 @@ struct ParticipantType
static constexpr const char* UNKNOWN = "UNKNOWN";
};

} /* namespace rtps */
} /* namespace fastdds */
} // namespace rtps
} // namespace fastdds

namespace fastrtps {
namespace rtps {


//!PDP subclass choice
//! PDP subclass choice
typedef enum DiscoveryProtocol
{
NONE,
Expand Down Expand Up @@ -126,7 +124,7 @@ inline std::ostream& operator <<(
return output;
}

//!Filtering flags when discovering participants
//! Filtering flags when discovering participants
typedef enum ParticipantFilteringFlags : uint32_t
{
NO_FILTER = 0,
Expand Down Expand Up @@ -435,26 +433,17 @@ class BuiltinAttributes

/**
* Class RTPSParticipantAttributes used to define different aspects of a RTPSParticipant.
*@ingroup RTPS_ATTRIBUTES_MODULE
* @ingroup RTPS_ATTRIBUTES_MODULE
*/
class RTPSParticipantAttributes
{
using FlowControllerDescriptorList = std::vector<std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>>;

public:

RTPSParticipantAttributes()
{
setName("RTPSParticipant");
sendSocketBufferSize = 0;
listenSocketBufferSize = 0;
participantID = -1;
useBuiltinTransports = true;
}
RTPSParticipantAttributes() = default;

virtual ~RTPSParticipantAttributes()
{
}
virtual ~RTPSParticipantAttributes() = default;

bool operator ==(
const RTPSParticipantAttributes& b) const
Expand All @@ -475,6 +464,14 @@ class RTPSParticipantAttributes
(this->flow_controllers == b.flow_controllers);
}

/**
* Provides a way of easily configuring transport related configuration on certain pre-defined scenarios.
*
* @param transports Defines the transport configuration scenario to setup.
*/
RTPS_DllAPI void setup_transports(
fastdds::rtps::BuiltinTransports transports);

/**
* Default list of Unicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case
* that it was defined with NO UnicastLocators. At least ONE locator should be included in this list.
Expand All @@ -491,12 +488,12 @@ class RTPSParticipantAttributes
* @brief Send socket buffer size for the send resource. Zero value indicates to use default system buffer size.
* Default value: 0.
*/
uint32_t sendSocketBufferSize;
uint32_t sendSocketBufferSize = 0;

/*! Listen socket buffer for all listen resources. Zero value indicates to use default system buffer size.
* Default value: 0.
*/
uint32_t listenSocketBufferSize;
uint32_t listenSocketBufferSize = 0;

//! Optionally allows user to define the GuidPrefix_t
GuidPrefix_t prefix;
Expand All @@ -516,8 +513,8 @@ class RTPSParticipantAttributes
//!User Data of the participant
std::vector<octet> userData;

//!Participant ID
int32_t participantID;
//! Participant ID
int32_t participantID = -1;

/**
* @brief Throughput controller parameters. Leave default for uncontrolled flow.
Expand All @@ -529,9 +526,10 @@ class RTPSParticipantAttributes
//!User defined transports to use alongside or in place of builtins.
std::vector<std::shared_ptr<fastdds::rtps::TransportDescriptorInterface>> userTransports;

//!Set as false to disable the default UDPv4 implementation.
bool useBuiltinTransports;
//!Holds allocation limits affecting collections managed by a participant.
//! Set as false to disable the creation of the default transports.
bool useBuiltinTransports = true;

//! Holds allocation limits affecting collections managed by a participant.
RTPSParticipantAllocationAttributes allocation;

//! Property policies
Expand All @@ -555,12 +553,12 @@ class RTPSParticipantAttributes

private:

//!Name of the participant.
string_255 name;
//! Name of the participant.
string_255 name{"RTPSParticipant"};
};

} /* namespace rtps */
} /* namespace fastrtps */
} /* namespace eprosima */
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima

#endif /* _FASTDDS_RTPSPARTICIPANTPARAMETERS_H_ */
#endif // _FASTDDS_RTPSPARTICIPANTPARAMETERS_H_
5 changes: 5 additions & 0 deletions include/fastrtps/xmlparser/XMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@ class XMLParser
tinyxml2::XMLElement* elem,
SubscriberAttributes& subscriber,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLBuiltinTransports(
tinyxml2::XMLElement* elem,
eprosima::fastdds::rtps::BuiltinTransports* bt,
uint8_t ident);
};

} // namespace xmlparser
Expand Down
5 changes: 5 additions & 0 deletions include/fastrtps/xmlparser/XMLParserCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ extern const char* IP6_TO_SEND;
extern const char* THROUGHPUT_CONT;
extern const char* USER_TRANS;
extern const char* USE_BUILTIN_TRANS;
extern const char* BUILTIN_TRANS;
extern const char* PROPERTIES_POLICY;
extern const char* NAME;
extern const char* REMOTE_LOCATORS;
Expand Down Expand Up @@ -171,6 +172,10 @@ extern const char* UDPv6;
extern const char* TCPv4;
extern const char* TCPv6;
extern const char* SHM;
extern const char* DEFAULT_C;
extern const char* DEFAULTv6;
extern const char* LARGE_DATA;
extern const char* LARGE_DATAv6;
extern const char* INIT_ACKNACK_DELAY;
extern const char* HEARTB_RESP_DELAY;
extern const char* INIT_HEARTB_DELAY;
Expand Down
14 changes: 14 additions & 0 deletions resources/xsd/fastRTPS_profiles.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,20 @@
<xs:element name="throughputController" type="throughputControllerType" minOccurs="0"/>
<xs:element name="userTransports" type="stringListType" minOccurs="0"/>
<xs:element name="useBuiltinTransports" type="boolType" minOccurs="0"/>
<xs:element name="builtinTransports" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="NONE"/>
<xs:enumeration value="DEFAULT"/>
<xs:enumeration value="DEFAULTv6"/>
<xs:enumeration value="SHM"/>
<xs:enumeration value="UDPv4"/>
<xs:enumeration value="UDPv6"/>
<xs:enumeration value="LARGE_DATA"/>
<xs:enumeration value="LARGE_DATAv6"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="propertiesPolicy" type="propertyPolicyType" minOccurs="0"/>
<xs:element name="name" type="stringType" minOccurs="0"/>
</xs:all>
Expand Down
6 changes: 4 additions & 2 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ set(${PROJECT_NAME}_source_files
rtps/messages/submessages/HeartbeatMsg.hpp
rtps/network/NetworkFactory.cpp
rtps/network/ReceiverResource.cpp
rtps/attributes/RTPSParticipantAttributes.cpp
rtps/participant/RTPSParticipant.cpp
rtps/participant/RTPSParticipantImpl.cpp
rtps/RTPSDomain.cpp
Expand Down Expand Up @@ -174,6 +175,7 @@ set(${PROJECT_NAME}_source_files
fastdds/core/policy/QosPolicyUtils.cpp
fastdds/publisher/qos/WriterQos.cpp
fastdds/subscriber/qos/ReaderQos.cpp
fastdds/utils/QosConverters.cpp
rtps/builtin/BuiltinProtocols.cpp
rtps/builtin/discovery/participant/DirectMessageSender.cpp
rtps/builtin/discovery/participant/PDP.cpp
Expand Down Expand Up @@ -383,7 +385,7 @@ find_package(Atomic MODULE)
# prioritizes writes

# try_run cannot manage targets yet
get_target_property(CMAKE_ATOMIC_LIB eProsima_atomic INTERFACE_LINK_LIBRARIES)
get_target_property(CMAKE_ATOMIC_LIB eProsima_atomic INTERFACE_LINK_LIBRARIES)
if(NOT CMAKE_ATOMIC_LIB)
set(CMAKE_ATOMIC_LIB)
endif()
Expand Down Expand Up @@ -501,7 +503,7 @@ if(MSVC OR MSVC_IDE)
endif()

# Get OpenSSL version suitable manifest format
execute_process( COMMAND PowerShell -NoLogo -Command "&{ param([string]$original)
execute_process( COMMAND PowerShell -NoLogo -Command "&{ param([string]$original)
if ($original -notmatch '\\d+$')
{ $res = $original.Substring(0,$original.length-1) + '.' +
([int]$original[$original.length-1]-[int][char]'a'+1); }
Expand Down
15 changes: 15 additions & 0 deletions src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,27 @@

#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>

#include <fastdds/rtps/attributes/BuiltinTransports.hpp>
#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
#include <fastdds/utils/QosConverters.hpp>

namespace eprosima {
namespace fastdds {
namespace dds {

const DomainParticipantQos PARTICIPANT_QOS_DEFAULT;

void DomainParticipantQos::setup_transports(
rtps::BuiltinTransports transports)
{
fastrtps::rtps::RTPSParticipantAttributes attr;
utils::set_attributes_from_qos(attr, *this);

attr.setup_transports(transports);

utils::set_qos_from_attributes(*this, attr);
}

} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
Loading

0 comments on commit 77e4a4c

Please sign in to comment.