| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
test_UDPv4TransportDescriptor.hpp
1// Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
19
20#ifndef FASTDDS_RTPS_TRANSPORT__TEST_UDPV4TRANSPORTDESCRIPTOR_HPP
21#define FASTDDS_RTPS_TRANSPORT__TEST_UDPV4TRANSPORTDESCRIPTOR_HPP
22
23#include <functional>
24#include <atomic>
25
26#include <fastdds/rtps/transport/SocketTransportDescriptor.hpp>
27#include <fastdds/rtps/common/SequenceNumber.hpp>
28
29 namespace eprosima {
30 namespace fastdds {
31 namespace rtps {
32
33 struct CDRMessage_t;
34 struct TestUDPv4TransportOptions;
35
40 struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor
41{
43 typedef std::function<bool (eprosima::fastdds::rtps::CDRMessage_t& msg)> filter;
45 typedef std::function<bool (const Locator& destination)> DestinationLocatorFilter;
46
48 std::shared_ptr<TestUDPv4TransportOptions> test_transport_options = std::make_shared<TestUDPv4TransportOptions>();
49
52 mutable std::atomic<uint8_t> dropDataMessagesPercentage{0};
54 mutable std::atomic<uint8_t> dropParticipantBuiltinDataMessagesPercentage{0};
56 mutable std::atomic<uint8_t> dropPublicationBuiltinDataMessagesPercentage{0};
58 mutable std::atomic<uint8_t> dropSubscriptionBuiltinDataMessagesPercentage{0};
60 filter drop_data_messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
61 {
62 return false;
63 };
64
65 filter drop_builtin_data_messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
66 {
67 return false;
68 };
69
70 bool dropParticipantBuiltinTopicData = false;
72 bool dropPublicationBuiltinTopicData = false;
74 bool dropSubscriptionBuiltinTopicData = false;
76 mutable std::atomic<uint8_t> dropDataFragMessagesPercentage{0};
78 filter drop_data_frag_messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
79 {
80 return false;
81 };
82
83 mutable std::atomic<uint8_t> dropHeartbeatMessagesPercentage{0};
85 filter drop_heartbeat_messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
86 {
87 return false;
88 };
89
90 mutable std::atomic<uint8_t> dropAckNackMessagesPercentage{0};
92 filter drop_ack_nack_messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
93 {
94 return false;
95 };
96
97 mutable std::atomic<uint8_t> dropGapMessagesPercentage{0};
99 filter drop_gap_messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
100 {
101 return false;
102 };
103 // General filtering function for all kind of sub-messages (indiscriminate)
104 filter sub_messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
105 {
106 return false;
107 };
108
109 // General drop percentage (indiscriminate)
110 mutable std::atomic<uint8_t> percentageOfMessagesToDrop{0};
111 // General filtering function for all kind of messages (indiscriminate)
112 filter messages_filter_ = [](fastdds::rtps::CDRMessage_t&)
113 {
114 return false;
115 };
116
118 DestinationLocatorFilter locator_filter_ = [](const Locator&)
119 {
120 return false;
121 };
122
124 std::vector<fastdds::rtps::SequenceNumber_t> sequenceNumberDataMessagesToDrop{};
125
127 uint32_t dropLogLength = 0;
128
130 FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor();
131
133 virtual ~test_UDPv4TransportDescriptor() = default;
134
136 virtual TransportInterface* create_transport() const override;
137
139 FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor(
140 const test_UDPv4TransportDescriptor& t) = delete;
141
143 FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor& operator =(
144 const test_UDPv4TransportDescriptor& t) = delete;
145
147 FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor(
148 test_UDPv4TransportDescriptor&& t) = delete;
149
151 FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor& operator =(
152 test_UDPv4TransportDescriptor&& t) = delete;
153
155 // Filters are not included
156 FASTDDS_EXPORTED_API bool operator ==(
157 const test_UDPv4TransportDescriptor& t) const;
158};
159
160 struct TestUDPv4TransportOptions
161{
162 FASTDDS_EXPORTED_API TestUDPv4TransportOptions() = default;
163 ~TestUDPv4TransportOptions() = default;
164
165 std::atomic<bool> test_UDPv4Transport_ShutdownAllNetwork{false};
166 // Handle to a persistent log of dropped packets. Defaults to length 0 (no logging) to prevent wasted resources.
167 std::vector<std::vector<fastdds::rtps::octet>> test_UDPv4Transport_DropLog{};
168 std::atomic<uint32_t> test_UDPv4Transport_DropLogLength{0};
169 std::atomic<bool> always_drop_participant_builtin_topic_data{false};
170 std::atomic<bool> simulate_no_interfaces{false};
171 test_UDPv4TransportDescriptor::DestinationLocatorFilter locator_filter = [](const Locator&)
172 {
173 return false;
174 };
175};
176
177} // namespace rtps
178} // namespace fastdds
179} // namespace eprosima
180
181#endif // FASTDDS_RTPS_TRANSPORT__TEST_UDPV4TRANSPORTDESCRIPTOR_HPP
eprosima::fastdds::rtps::TransportInterface
Interface against which to implement a transport layer, decoupled from Fast DDS internals.
Definition TransportInterface.hpp:64
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::Locator
eprosima::fastdds::rtps::Locator_t Locator
Definition Locator.hpp:523
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::CDRMessage_t
Structure CDRMessage_t, contains a serialized message.
Definition CDRMessage_t.hpp:51
eprosima::fastdds::rtps::SocketTransportDescriptor::SocketTransportDescriptor
FASTDDS_EXPORTED_API SocketTransportDescriptor(uint32_t maximumMessageSize, uint32_t maximumInitialPeersRange)
Constructor.
Definition SocketTransportDescriptor.hpp:55
eprosima::fastdds::rtps::TestUDPv4TransportOptions
Definition test_UDPv4TransportDescriptor.hpp:161
eprosima::fastdds::rtps::TestUDPv4TransportOptions::locator_filter
test_UDPv4TransportDescriptor::DestinationLocatorFilter locator_filter
Definition test_UDPv4TransportDescriptor.hpp:171
eprosima::fastdds::rtps::TestUDPv4TransportOptions::always_drop_participant_builtin_topic_data
std::atomic< bool > always_drop_participant_builtin_topic_data
Definition test_UDPv4TransportDescriptor.hpp:169
eprosima::fastdds::rtps::TestUDPv4TransportOptions::test_UDPv4Transport_ShutdownAllNetwork
std::atomic< bool > test_UDPv4Transport_ShutdownAllNetwork
Definition test_UDPv4TransportDescriptor.hpp:165
eprosima::fastdds::rtps::TestUDPv4TransportOptions::test_UDPv4Transport_DropLogLength
std::atomic< uint32_t > test_UDPv4Transport_DropLogLength
Definition test_UDPv4TransportDescriptor.hpp:168
eprosima::fastdds::rtps::TestUDPv4TransportOptions::simulate_no_interfaces
std::atomic< bool > simulate_no_interfaces
Definition test_UDPv4TransportDescriptor.hpp:170
eprosima::fastdds::rtps::TestUDPv4TransportOptions::test_UDPv4Transport_DropLog
std::vector< std::vector< fastdds::rtps::octet > > test_UDPv4Transport_DropLog
Definition test_UDPv4TransportDescriptor.hpp:167
eprosima::fastdds::rtps::TestUDPv4TransportOptions::~TestUDPv4TransportOptions
~TestUDPv4TransportOptions()=default
eprosima::fastdds::rtps::TestUDPv4TransportOptions::TestUDPv4TransportOptions
FASTDDS_EXPORTED_API TestUDPv4TransportOptions()=default
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropHeartbeatMessagesPercentage
std::atomic< uint8_t > dropHeartbeatMessagesPercentage
Percentage of heartbeats being dropped.
Definition test_UDPv4TransportDescriptor.hpp:83
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::drop_data_frag_messages_filter_
filter drop_data_frag_messages_filter_
Filtering function for dropping data fragments messages.
Definition test_UDPv4TransportDescriptor.hpp:78
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::filter
std::function< bool(eprosima::fastdds::rtps::CDRMessage_t &msg)> filter
Custom message filtering functions.
Definition test_UDPv4TransportDescriptor.hpp:43
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::test_UDPv4TransportDescriptor
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor()
Constructor.
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::drop_ack_nack_messages_filter_
filter drop_ack_nack_messages_filter_
Filtering function for dropping AckNacks.
Definition test_UDPv4TransportDescriptor.hpp:92
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::test_transport_options
std::shared_ptr< TestUDPv4TransportOptions > test_transport_options
Test transport options.
Definition test_UDPv4TransportDescriptor.hpp:48
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::DestinationLocatorFilter
std::function< bool(const Locator &destination)> DestinationLocatorFilter
Locator filtering function.
Definition test_UDPv4TransportDescriptor.hpp:45
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropParticipantBuiltinDataMessagesPercentage
std::atomic< uint8_t > dropParticipantBuiltinDataMessagesPercentage
Percentage of Data[P] messages being dropped.
Definition test_UDPv4TransportDescriptor.hpp:54
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::locator_filter_
DestinationLocatorFilter locator_filter_
Filtering function for dropping messages to specific destinations.
Definition test_UDPv4TransportDescriptor.hpp:118
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::sequenceNumberDataMessagesToDrop
std::vector< fastdds::rtps::SequenceNumber_t > sequenceNumberDataMessagesToDrop
Vector containing the message's sequence numbers being dropped.
Definition test_UDPv4TransportDescriptor.hpp:124
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::messages_filter_
filter messages_filter_
Definition test_UDPv4TransportDescriptor.hpp:112
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropDataMessagesPercentage
std::atomic< uint8_t > dropDataMessagesPercentage
Test shim parameters Percentage of data messages being dropped.
Definition test_UDPv4TransportDescriptor.hpp:52
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::drop_builtin_data_messages_filter_
filter drop_builtin_data_messages_filter_
Filtering function for dropping builtin data messages.
Definition test_UDPv4TransportDescriptor.hpp:65
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::operator=
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor & operator=(const test_UDPv4TransportDescriptor &t)=delete
Copy assignment.
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::create_transport
virtual TransportInterface * create_transport() const override
Create transport using the parameters defined within the Descriptor.
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropSubscriptionBuiltinTopicData
bool dropSubscriptionBuiltinTopicData
Flag to enable dropping of discovery Reader DATA(R) messages.
Definition test_UDPv4TransportDescriptor.hpp:74
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::operator==
FASTDDS_EXPORTED_API bool operator==(const test_UDPv4TransportDescriptor &t) const
Comparison operator.
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropDataFragMessagesPercentage
std::atomic< uint8_t > dropDataFragMessagesPercentage
Percentage of data fragments being dropped.
Definition test_UDPv4TransportDescriptor.hpp:76
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropPublicationBuiltinTopicData
bool dropPublicationBuiltinTopicData
Flag to enable dropping of discovery Writer DATA(W) messages.
Definition test_UDPv4TransportDescriptor.hpp:72
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::test_UDPv4TransportDescriptor
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor(test_UDPv4TransportDescriptor &&t)=delete
Move constructor.
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::drop_data_messages_filter_
filter drop_data_messages_filter_
Filtering function for dropping data messages.
Definition test_UDPv4TransportDescriptor.hpp:60
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::sub_messages_filter_
filter sub_messages_filter_
Definition test_UDPv4TransportDescriptor.hpp:104
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::~test_UDPv4TransportDescriptor
virtual ~test_UDPv4TransportDescriptor()=default
Destructor.
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropPublicationBuiltinDataMessagesPercentage
std::atomic< uint8_t > dropPublicationBuiltinDataMessagesPercentage
Percentage of Data[W] messages being dropped.
Definition test_UDPv4TransportDescriptor.hpp:56
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::drop_heartbeat_messages_filter_
filter drop_heartbeat_messages_filter_
Filtering function for dropping heartbeat messages.
Definition test_UDPv4TransportDescriptor.hpp:85
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropGapMessagesPercentage
std::atomic< uint8_t > dropGapMessagesPercentage
Percentage of gap messages being dropped.
Definition test_UDPv4TransportDescriptor.hpp:97
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropParticipantBuiltinTopicData
bool dropParticipantBuiltinTopicData
Flag to enable dropping of discovery Participant DATA(P) messages.
Definition test_UDPv4TransportDescriptor.hpp:70
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropSubscriptionBuiltinDataMessagesPercentage
std::atomic< uint8_t > dropSubscriptionBuiltinDataMessagesPercentage
Percentage of Data[R] messages being dropped.
Definition test_UDPv4TransportDescriptor.hpp:58
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::drop_gap_messages_filter_
filter drop_gap_messages_filter_
Filtering function for dropping gap messages.
Definition test_UDPv4TransportDescriptor.hpp:99
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::percentageOfMessagesToDrop
std::atomic< uint8_t > percentageOfMessagesToDrop
Definition test_UDPv4TransportDescriptor.hpp:110
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropAckNackMessagesPercentage
std::atomic< uint8_t > dropAckNackMessagesPercentage
Percentage of AckNacks being dropped.
Definition test_UDPv4TransportDescriptor.hpp:90
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::dropLogLength
uint32_t dropLogLength
Log dropped packets.
Definition test_UDPv4TransportDescriptor.hpp:127
eprosima::fastdds::rtps::test_UDPv4TransportDescriptor::test_UDPv4TransportDescriptor
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor(const test_UDPv4TransportDescriptor &t)=delete
Copy constructor.