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

TCP multiple descriptors #2920

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions examples/cpp/dds/HelloWorldExampleTCP/HelloWorldPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ bool HelloWorldPublisher::init(

pqos.transport().use_builtin_transports = false;

/////////////

std::shared_ptr<TCPv4TransportDescriptor> descriptor = std::make_shared<TCPv4TransportDescriptor>();

for (std::string ip : whitelist)
Expand Down Expand Up @@ -85,7 +87,33 @@ bool HelloWorldPublisher::init(
std::cout << wan_ip << ":" << port << std::endl;
}
descriptor->add_listener_port(port);

// pqos.transport().user_transports.push_back(descriptor);

/////////////

static_cast<void>(wan_ip);
static_cast<void>(use_tls);
static_cast<void>(whitelist);

std::shared_ptr<TCPv4TransportDescriptor> descriptor_local = std::make_shared<TCPv4TransportDescriptor>();
descriptor_local->sendBufferSize = 0;
descriptor_local->receiveBufferSize = 0;
std::string local_ip = "127.0.0.1";
port += 10;
descriptor_local->set_WAN_address(local_ip);
std::cout << local_ip << ":" << port << std::endl;

descriptor_local->add_listener_port(port);
// pqos.transport().user_transports.push_back(descriptor_local);


///////////////////

pqos.transport().user_transports.push_back(descriptor);
pqos.transport().user_transports.push_back(descriptor_local);

///////////////////

participant_ = DomainParticipantFactory::get_instance()->create_participant(0, pqos);

Expand Down
5 changes: 4 additions & 1 deletion include/fastdds/rtps/common/Locator.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ inline std::ostream& operator <<(
}

// Stream port
output << "]:" << loc.port;
auto p_port = IPLocator::getPhysicalPort(loc);
auto l_port = IPLocator::getLogicalPort(loc);

output << "]:" << p_port << ":" << l_port;

return output;
}
Expand Down
86 changes: 86 additions & 0 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,50 @@ RTPSParticipantImpl::RTPSParticipantImpl(
, is_intraprocess_only_(should_be_intraprocess_only(PParam))
, has_shm_transport_(false)
{

std::cout << std::endl;
std::cout << "RTPSParticipant Params to construct participnt" << std::endl;
for (const auto& x : PParam.builtin.metatrafficMulticastLocatorList)
{
std::cout << "Metatraffic Multicast Locator: " << x << std::endl;
}
for (const auto& x : PParam.builtin.metatrafficUnicastLocatorList)
{
std::cout << "Metatraffic Unicast Locator: " << x << std::endl;
}
for (const auto& x : PParam.builtin.initialPeersList)
{
std::cout << "Initial Peers Locator: " << x << std::endl;
}
for (const auto& x : PParam.defaultMulticastLocatorList)
{
std::cout << "Default Multicast Locator: " << x << std::endl;
}
for (const auto& x : PParam.defaultUnicastLocatorList)
{
std::cout << "Default Unicast Locator: " << x << std::endl;
}
for (const auto& x : PParam.userTransports)
{
std::cout << "User Transports: " << x << std::endl;
auto y = std::dynamic_pointer_cast<eprosima::fastdds::rtps::TCPv4TransportDescriptor>(x);
if (y)
{
for (const auto& p : y->listening_ports)
{
std::cout << "Listening Port: " << p << std::endl;
}
std::cout << "TCPv4TransportDescriptor " <<
static_cast<int>(y->wan_addr[0]) << "." <<
static_cast<int>(y->wan_addr[1]) << "." <<
static_cast<int>(y->wan_addr[2]) << "." <<
static_cast<int>(y->wan_addr[3]) << "." <<
std::endl;
}
}
std::cout << "End Locators in PParams" << std::endl;
std::cout << std::endl;

if (c_GuidPrefix_Unknown != persistence_guid)
{
m_persistence_guid = GUID_t(persistence_guid, c_EntityId_RTPSParticipant);
Expand Down Expand Up @@ -422,6 +466,48 @@ RTPSParticipantImpl::RTPSParticipantImpl(
"RTPSParticipant \"" << m_att.getName() << "\" with guidPrefix: " << m_guid.guidPrefix);
}

std::cout << "RTPSParticipant with guidPrefix: " << m_guid.guidPrefix << std::endl;
for (const auto& x : m_att.builtin.metatrafficMulticastLocatorList)
{
std::cout << "Metatraffic Multicast Locator: " << x << std::endl;
}
for (const auto& x : m_att.builtin.metatrafficUnicastLocatorList)
{
std::cout << "Metatraffic Unicast Locator: " << x << std::endl;
}
for (const auto& x : m_att.builtin.initialPeersList)
{
std::cout << "Initial Peers Locator: " << x << std::endl;
}
for (const auto& x : m_att.defaultMulticastLocatorList)
{
std::cout << "Default Multicast Locator: " << x << std::endl;
}
for (const auto& x : m_att.defaultUnicastLocatorList)
{
std::cout << "Default Unicast Locator: " << x << std::endl;
}
for (const auto& x : m_att.userTransports)
{
std::cout << "User Transports: " << x << std::endl;
auto y = std::dynamic_pointer_cast<eprosima::fastdds::rtps::TCPv4TransportDescriptor>(x);
if (y)
{
for (const auto& p : y->listening_ports)
{
std::cout << "Listening Port: " << p << std::endl;
}
std::cout << "TCPv4TransportDescriptor " <<
static_cast<int>(y->wan_addr[0]) << "." <<
static_cast<int>(y->wan_addr[1]) << "." <<
static_cast<int>(y->wan_addr[2]) << "." <<
static_cast<int>(y->wan_addr[3]) << "." <<
std::endl;
}
}
std::cout << "End Locators " << m_guid.guidPrefix << std::endl;
std::cout << std::endl;

initialized_ = true;
}

Expand Down
3 changes: 3 additions & 0 deletions test/dds/communication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ list(APPEND TEST_DEFINITIONS
zero_copy_sub_communication
mix_zero_copy_communication
close_TCP_client
TCP_multiple_descriptors
)


Expand All @@ -121,7 +122,9 @@ list(APPEND XML_CONFIGURATION_FILES
simple_besteffort_zerocopy.xml
TCP_server.xml
TCP_client.xml
TCP_server_multiple_descriptors.xml
)

# Python file
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_build.py
${CMAKE_CURRENT_BINARY_DIR}/test_build.py COPYONLY)
Expand Down
15 changes: 15 additions & 0 deletions test/dds/communication/TCP_multiple_descriptors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"description" : "[13540] Test that TCP client does not get stuck when being deleted in the following case: client launched before server and deleted also before server",
"participants" : [
{
"kind" : "subscriber",
"samples" : "5",
"xmlfile" : "TCP_client.xml"
},
{
"kind" : "publisher",
"sleep_before_exec" : "1",
"xmlfile" : "TCP_server_multiple_descriptors.xml"
}
]
}
34 changes: 34 additions & 0 deletions test/dds/communication/TCP_server_multiple_descriptors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<dds xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<profiles>
<transport_descriptors>
<transport_descriptor>
<transport_id>tcp_transport_server_1</transport_id>
<type>TCPv4</type>
<listening_ports>
<port>5100</port>
</listening_ports>
<wan_addr>127.0.0.1</wan_addr>
</transport_descriptor>
<transport_descriptor>
<transport_id>tcp_transport_server_2</transport_id>
<type>TCPv4</type>
<listening_ports>
<port>5200</port>
</listening_ports>
<wan_addr>127.0.0.1</wan_addr>
</transport_descriptor>
</transport_descriptors>

<participant profile_name="TCPServer" is_default_profile="true">
<rtps>
<userTransports>
<!-- Changing the order so 1 is first it works. This way it does not. -->
<transport_id>tcp_transport_server_2</transport_id>
<transport_id>tcp_transport_server_1</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
</dds>