Skip to content

Commit

Permalink
Methods to configure transport scenarios (#4098) (#4173)
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/unittest/dynamic_types/CMakeLists.txt
#	test/unittest/statistics/dds/CMakeLists.txt
#	test/unittest/xmlparser/CMakeLists.txt
#	versions.md

* Fix Conflicts: dpqos

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

* Fix Conflicts: XMLParser

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

* Fix Conflicts: RTPSParticipant

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

* Fix Conflicts: others

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

* Fix Conflicts: Tests

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

* Cherry-pick c46518643

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

* Fix dns filter

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

---------

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: cferreiragonz <carlosferreira@eprosima.com>
  • Loading branch information
3 people authored Jan 9, 2024
1 parent 73f517b commit 18fb9c4
Show file tree
Hide file tree
Showing 31 changed files with 1,922 additions and 87 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 @@ -24,6 +24,7 @@

#include <fastrtps/fastrtps_dll.h>
#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/rtps/attributes/BuiltinTransports.hpp>
#include <fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp>

namespace eprosima {
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_
57 changes: 27 additions & 30 deletions include/fastdds/rtps/attributes/RTPSParticipantAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef _FASTDDS_RTPSPARTICIPANTPARAMETERS_H_
#define _FASTDDS_RTPSPARTICIPANTPARAMETERS_H_

#include <fastdds/rtps/attributes/BuiltinTransports.hpp>
#include <fastdds/rtps/attributes/ExternalLocators.hpp>
#include <fastdds/rtps/attributes/PropertyPolicy.h>
#include <fastdds/rtps/attributes/RTPSParticipantAllocationAttributes.hpp>
Expand All @@ -36,14 +37,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 @@ -57,14 +56,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 @@ -127,7 +125,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 @@ -440,26 +438,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 @@ -482,6 +471,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 @@ -508,12 +505,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 @@ -534,7 +531,7 @@ class RTPSParticipantAttributes
std::vector<octet> userData;

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

/**
* @brief Throughput controller parameters. Leave default for uncontrolled flow.
Expand All @@ -546,8 +543,8 @@ 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;
//! 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;
Expand All @@ -574,11 +571,11 @@ class RTPSParticipantAttributes
private:

//! Name of the participant.
string_255 name;
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 @@ -603,6 +603,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 @@ -117,6 +117,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 @@ -175,6 +176,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
18 changes: 15 additions & 3 deletions resources/xsd/fastRTPS_profiles.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
├ userTransports [0~1],
| └ transport_id [1~*] [string],
├ useBuiltinTransports [bool],
├ builtinTransports [0~1][string],
├ propertiesPolicy [0~1],
├ allocation [0~1],
├ userData [0~1],
Expand Down Expand Up @@ -141,6 +142,20 @@
</xs:complexType>
</xs:element>
<xs:element name="useBuiltinTransports" type="boolean" minOccurs="0" maxOccurs="1"/>
<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" maxOccurs="1"/>
<xs:element name="allocation" type="rtpsParticipantAllocationAttributesType" minOccurs="0" maxOccurs="1"/>
<xs:element name="userData" type="octectVectorQosPolicyType" minOccurs="0" maxOccurs="1"/>
Expand Down Expand Up @@ -504,9 +519,6 @@
<xs:attribute name="mapMaxLength" type="int32" use="optional"/>
</xs:complexType>




<!--| LOG ELEMENTS |-->
<!--Log consumer:
├ class [string] ("StdoutConsumer" OR "StdoutErrConsumer" OR "FileConsumer"),
Expand Down
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ set(${PROJECT_NAME}_source_files
rtps/network/ExternalLocatorsProcessor.cpp
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
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 18fb9c4

Please sign in to comment.