Skip to content

Commit

Permalink
Feature/initial peers range (#282)
Browse files Browse the repository at this point in the history
* Refs #3614. Create a new configuration attribute for transports to set the maximum range for initial peers.

* Refs #3614 Initial Peers Range attribute fixed for tcp logical ports and new tests added.

* Refs #3614. Adding udp testing for max initial peer range.

* Refs #3614 Fixed udp test lease duration.

* Refs #3614. Removing lease duration and reording.

* Refs #3614. Fixed compilation error with security.
  • Loading branch information
LuisGP authored and richiware committed Oct 26, 2018
1 parent ea1eece commit 5f0df1a
Show file tree
Hide file tree
Showing 31 changed files with 522 additions and 241 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,5 @@ target/
.project

.pydevproject

compile_commands.json
5 changes: 3 additions & 2 deletions include/fastrtps/transport/SocketTransportDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ static const uint8_t s_defaultTTL = 1;
* */
struct SocketTransportDescriptor : public TransportDescriptorInterface
{
SocketTransportDescriptor(uint32_t maximumMessageSize) : TransportDescriptorInterface(maximumMessageSize)
SocketTransportDescriptor(uint32_t maximumMessageSize, uint32_t maximumInitialPeersRange)
: TransportDescriptorInterface(maximumMessageSize, maximumInitialPeersRange)
, sendBufferSize(0)
, receiveBufferSize(0)
, TTL(s_defaultTTL)
Expand All @@ -52,7 +53,7 @@ struct SocketTransportDescriptor : public TransportDescriptorInterface
virtual ~SocketTransportDescriptor(){}

virtual uint32_t min_send_buffer_size() const override { return sendBufferSize; }

//! Length of the send buffer.
uint32_t sendBufferSize;
//! Length of the receive buffer.
Expand Down
16 changes: 12 additions & 4 deletions include/fastrtps/transport/TransportDescriptorInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,21 @@ class TransportInterface;
* */
struct TransportDescriptorInterface
{
TransportDescriptorInterface(uint32_t maximumMessageSize) : maxMessageSize(maximumMessageSize)
TransportDescriptorInterface(uint32_t maximumMessageSize, uint32_t maximumInitialPeersRange)
: maxMessageSize(maximumMessageSize)
, maxInitialPeersRange(maximumInitialPeersRange)
{}

TransportDescriptorInterface(const TransportDescriptorInterface& t) : maxMessageSize(t.maxMessageSize)
TransportDescriptorInterface(const TransportDescriptorInterface& t)
: maxMessageSize(t.maxMessageSize)
, maxInitialPeersRange(t.maxInitialPeersRange)
{}

virtual ~TransportDescriptorInterface(){}

/**
* Factory method pattern. It will create and return a TransportInterface
* corresponding to this descriptor. This provides an interface to the NetworkFactory
* Factory method pattern. It will create and return a TransportInterface
* corresponding to this descriptor. This provides an interface to the NetworkFactory
* to create the transports without the need to know about their type
*/
virtual TransportInterface* create_transport() const = 0;
Expand All @@ -54,7 +58,11 @@ struct TransportDescriptorInterface
//! Returns the maximum size expected for received messages.
virtual uint32_t max_message_size() const { return maxMessageSize; }

virtual uint32_t max_initial_peers_range() const { return maxInitialPeersRange; }

uint32_t maxMessageSize;

uint32_t maxInitialPeersRange;
};

} // namespace rtps
Expand Down
7 changes: 4 additions & 3 deletions include/fastrtps/transport/TransportInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace fastrtps{
namespace rtps{

static const uint32_t s_maximumMessageSize = 65500;
static const uint32_t s_maximumInitialPeersRange = 4;
static const uint32_t s_minimumSocketBuffer = 65536;

class SenderResource;
Expand Down Expand Up @@ -132,14 +133,14 @@ class TransportInterface

virtual void AddDefaultOutputLocator(LocatorList_t &defaultList) = 0;

virtual bool getDefaultMetatrafficMulticastLocators(LocatorList_t &locators,
virtual bool getDefaultMetatrafficMulticastLocators(LocatorList_t &locators,
uint32_t metatraffic_multicast_port) const = 0;

virtual bool getDefaultMetatrafficUnicastLocators(LocatorList_t &locators,
virtual bool getDefaultMetatrafficUnicastLocators(LocatorList_t &locators,
uint32_t metatraffic_unicast_port) const = 0;

virtual bool getDefaultUnicastLocators(LocatorList_t &locators, uint32_t unicast_port) const = 0;

virtual bool fillMetatrafficMulticastLocator(Locator_t &locator, uint32_t metatraffic_multicast_port) const = 0;

virtual bool fillMetatrafficUnicastLocator(Locator_t &locator, uint32_t metatraffic_unicast_port) const = 0;
Expand Down
1 change: 1 addition & 0 deletions include/fastrtps/xmlparser/XMLParserCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extern const char* SEND_BUFFER_SIZE;
extern const char* TTL;
extern const char* WHITE_LIST;
extern const char* MAX_MESSAGE_SIZE;
extern const char* MAX_INITIAL_PEERS_RANGE;
extern const char* KEEP_ALIVE_FREQUENCY;
extern const char* KEEP_ALIVE_TIMEOUT;
extern const char* MAX_LOGICAL_PORT;
Expand Down
1 change: 1 addition & 0 deletions resources/xsd/fastRTPS_profiles.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@
<xs:element name="receiveBufferSize" type="int32Type"/>
<xs:element name="TTL" type="uint8Type"/>
<xs:element name="maxMessageSize" type="uint32Type"/>
<xs:element name="maxInitialPeersRange" type="uint32Type"/>
<xs:element name="interfaceWhiteList" type="stringListType"/>
<xs:sequence>
<xs:element name="id" type="stringType"/>
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/reader/StatefulReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ bool StatefulReader::matched_writer_add(RemoteWriterAttributes& wdata)
}
}

getRTPSParticipant()->createReceiverResources(wdata.endpoint.remoteLocatorList, false);
getRTPSParticipant()->createSenderResources(wdata.endpoint.remoteLocatorList, false);

WriterProxy* wp = new WriterProxy(wdata, this);

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/reader/StatelessReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool StatelessReader::matched_writer_add(RemoteWriterAttributes& wdata)
return false;
}

getRTPSParticipant()->createReceiverResources(wdata.endpoint.remoteLocatorList, false);
getRTPSParticipant()->createSenderResources(wdata.endpoint.remoteLocatorList, false);

logInfo(RTPS_READER,"Writer " << wdata.guid << " added to "<<m_guid.entityId);
m_matched_writers.push_back(wdata);
Expand Down
8 changes: 3 additions & 5 deletions src/cpp/transport/TCPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void TCPAcceptor::Accept(TCPTransportInterface* parent, asio::io_service& io_ser
}

TCPTransportDescriptor::TCPTransportDescriptor()
: SocketTransportDescriptor(s_maximumMessageSize)
: SocketTransportDescriptor(s_maximumMessageSize, s_maximumInitialPeersRange)
, keep_alive_frequency_ms(s_default_keep_alive_frequency)
, keep_alive_timeout_ms(s_default_keep_alive_timeout)
, max_logical_port(100)
Expand Down Expand Up @@ -1173,8 +1173,7 @@ bool TCPTransportInterface::configureInitialPeerLocator(Locator_t &locator, cons
{
if(IPLocator::getPhysicalPort(locator) == 0)
{
// TODO(Ricardo) Make configurable.
for(int32_t i = 0; i < 4; ++i)
for(uint32_t i = 0; i < GetConfiguration()->maxInitialPeersRange; ++i)
{
Locator_t auxloc(locator);
auxloc.port = static_cast<uint16_t>(port_params.getUnicastPort(domainId, i));
Expand All @@ -1191,8 +1190,7 @@ bool TCPTransportInterface::configureInitialPeerLocator(Locator_t &locator, cons
{
if (IPLocator::getLogicalPort(locator) == 0)
{
// TODO(Ricardo) Make configurable.
for(int32_t i = 0; i < 4; ++i)
for(uint32_t i = 0; i < GetConfiguration()->maxInitialPeersRange; ++i)
{
Locator_t auxloc(locator);
IPLocator::setLogicalPort(auxloc, static_cast<uint16_t>(port_params.getUnicastPort(domainId, i)));
Expand Down
5 changes: 2 additions & 3 deletions src/cpp/transport/UDPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct MultiUniLocatorsLinkage
};

UDPTransportDescriptor::UDPTransportDescriptor()
: SocketTransportDescriptor(s_maximumMessageSize)
: SocketTransportDescriptor(s_maximumMessageSize, s_maximumInitialPeersRange)
, m_output_udp_socket(0)
{
}
Expand Down Expand Up @@ -654,8 +654,7 @@ bool UDPTransportInterface::configureInitialPeerLocator(Locator_t &locator, cons
{
if(locator.port == 0)
{
// TODO(Ricardo) Make configurable.
for(int32_t i = 0; i < 4; ++i)
for(uint32_t i = 0; i < GetConfiguration()->maxInitialPeersRange; ++i)
{
Locator_t auxloc(locator);
auxloc.port = port_params.getUnicastPort(domainId, i);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/transport/test_UDPv4Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test_UDPv4Transport::test_UDPv4Transport(const test_UDPv4TransportDescriptor& de
}

test_UDPv4TransportDescriptor::test_UDPv4TransportDescriptor():
SocketTransportDescriptor(s_maximumMessageSize),
SocketTransportDescriptor(s_maximumMessageSize, s_maximumInitialPeersRange),
dropDataMessagesPercentage(0),
dropParticipantBuiltinTopicData(false),
dropPublicationBuiltinTopicData(false),
Expand Down
11 changes: 11 additions & 0 deletions src/cpp/xmlparser/XMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ XMLP_ret XMLParser::parseXMLTransportData(tinyxml2::XMLElement* p_root)
<xs:element name="receiveBufferSize" type="int32Type"/>
<xs:element name="TTL" type="int8Type"/>
<xs:element name="maxMessageSize" type="uint32Type"/>
<xs:element name="maxInitialPeersRange" type="uint32Type"/>
<xs:element name="interfaceWhiteList" type="stringListType"/>
<xs:sequence>
<xs:element name="id" type="stringType"/>
Expand Down Expand Up @@ -334,6 +335,7 @@ XMLP_ret XMLParser::parseXMLCommonTransportData(tinyxml2::XMLElement* p_root, sp
<xs:element name="receiveBufferSize" type="int32Type"/>
<xs:element name="TTL" type="int8Type"/>
<xs:element name="maxMessageSize" type="uint32Type"/>
<xs:element name="maxInitialPeersRange" type="uint32Type"/>
<xs:element name="interfaceWhiteList" type="stringListType"/>
<xs:sequence>
<xs:element name="id" type="stringType"/>
Expand Down Expand Up @@ -381,6 +383,15 @@ XMLP_ret XMLParser::parseXMLCommonTransportData(tinyxml2::XMLElement* p_root, sp
pDesc->maxMessageSize = uSize;
}

// maxInitialPeersRange - uint32Type
if (nullptr != (p_aux = p_root->FirstChildElement(MAX_INITIAL_PEERS_RANGE)))
{
uint32_t uRange = 0;
if (XMLP_ret::XML_OK != getXMLUint(p_aux, &uRange, 0))
return XMLP_ret::XML_ERROR;
pDesc->maxInitialPeersRange = uRange;
}

// InterfaceWhiteList stringListType
if (nullptr != (p_aux = p_root->FirstChildElement(WHITE_LIST)))
{
Expand Down
1 change: 1 addition & 0 deletions src/cpp/xmlparser/XMLParserCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const char* SEND_BUFFER_SIZE = "sendBufferSize";
const char* TTL = "TTL";
const char* WHITE_LIST = "interfaceWhiteList";
const char* MAX_MESSAGE_SIZE = "maxMessageSize";
const char* MAX_INITIAL_PEERS_RANGE = "maxInitialPeersRange";
const char* KEEP_ALIVE_FREQUENCY = "keep_alive_frequency_ms";
const char* KEEP_ALIVE_TIMEOUT = "keep_alive_timeout_ms";
const char* MAX_LOGICAL_PORT = "max_logical_port";
Expand Down
Loading

0 comments on commit 5f0df1a

Please sign in to comment.