Fast DDS  Version 3.6.1.0
Fast DDS
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 
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 
41 {
43  typedef std::function<bool (eprosima::fastdds::rtps::CDRMessage_t& msg)> filter;
45  typedef std::function<bool (const Locator& destination, int32_t priority)> 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};
61  {
62  return false;
63  };
66  {
67  return false;
68  };
76  mutable std::atomic<uint8_t> dropDataFragMessagesPercentage{0};
79  {
80  return false;
81  };
83  mutable std::atomic<uint8_t> dropHeartbeatMessagesPercentage{0};
86  {
87  return false;
88  };
90  mutable std::atomic<uint8_t> dropAckNackMessagesPercentage{0};
93  {
94  return false;
95  };
97  mutable std::atomic<uint8_t> dropGapMessagesPercentage{0};
100  {
101  return false;
102  };
103  // General filtering function for all kind of sub-messages (indiscriminate)
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)
113  {
114  return false;
115  };
116 
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 
144  const test_UDPv4TransportDescriptor& t) = delete;
145 
147  FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor(
148  test_UDPv4TransportDescriptor&& t) = delete;
149 
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 
161 {
162  FASTDDS_EXPORTED_API 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};
170  std::atomic<bool> simulate_no_interfaces{false};
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
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition: Locator.hpp:74
Interface against which to implement a transport layer, decoupled from Fast DDS internals.
Definition: TransportInterface.hpp:64
Structure CDRMessage_t, contains a serialized message.
Definition: CDRMessage_t.hpp:51
Virtual base class for the data type used to define configuration of transports using sockets.
Definition: SocketTransportDescriptor.hpp:53
Definition: test_UDPv4TransportDescriptor.hpp:161
test_UDPv4TransportDescriptor::DestinationLocatorFilter locator_filter
Definition: test_UDPv4TransportDescriptor.hpp:171
std::atomic< bool > always_drop_participant_builtin_topic_data
Definition: test_UDPv4TransportDescriptor.hpp:169
std::atomic< bool > test_UDPv4Transport_ShutdownAllNetwork
Definition: test_UDPv4TransportDescriptor.hpp:165
std::atomic< uint32_t > test_UDPv4Transport_DropLogLength
Definition: test_UDPv4TransportDescriptor.hpp:168
std::atomic< bool > simulate_no_interfaces
Definition: test_UDPv4TransportDescriptor.hpp:170
std::vector< std::vector< fastdds::rtps::octet > > test_UDPv4Transport_DropLog
Definition: test_UDPv4TransportDescriptor.hpp:167
FASTDDS_EXPORTED_API TestUDPv4TransportOptions()=default
UDP v4 Test Transport configuration.
Definition: test_UDPv4TransportDescriptor.hpp:41
std::atomic< uint8_t > dropHeartbeatMessagesPercentage
Percentage of heartbeats being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:83
filter drop_data_frag_messages_filter_
Filtering function for dropping data fragments messages.
Definition: test_UDPv4TransportDescriptor.hpp:78
std::function< bool(eprosima::fastdds::rtps::CDRMessage_t &msg)> filter
Custom message filtering functions.
Definition: test_UDPv4TransportDescriptor.hpp:43
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor()
Constructor.
filter drop_ack_nack_messages_filter_
Filtering function for dropping AckNacks.
Definition: test_UDPv4TransportDescriptor.hpp:92
std::shared_ptr< TestUDPv4TransportOptions > test_transport_options
Test transport options.
Definition: test_UDPv4TransportDescriptor.hpp:48
std::atomic< uint8_t > dropParticipantBuiltinDataMessagesPercentage
Percentage of Data[P] messages being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:54
DestinationLocatorFilter locator_filter_
Filtering function for dropping messages to specific destinations.
Definition: test_UDPv4TransportDescriptor.hpp:118
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor & operator=(const test_UDPv4TransportDescriptor &t)=delete
Copy assignment.
std::vector< fastdds::rtps::SequenceNumber_t > sequenceNumberDataMessagesToDrop
Vector containing the message's sequence numbers being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:124
filter messages_filter_
Definition: test_UDPv4TransportDescriptor.hpp:112
std::atomic< uint8_t > dropDataMessagesPercentage
Test shim parameters Percentage of data messages being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:52
filter drop_builtin_data_messages_filter_
Filtering function for dropping builtin data messages.
Definition: test_UDPv4TransportDescriptor.hpp:65
bool dropSubscriptionBuiltinTopicData
Flag to enable dropping of discovery Reader DATA(R) messages.
Definition: test_UDPv4TransportDescriptor.hpp:74
FASTDDS_EXPORTED_API bool operator==(const test_UDPv4TransportDescriptor &t) const
Comparison operator.
std::atomic< uint8_t > dropDataFragMessagesPercentage
Percentage of data fragments being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:76
bool dropPublicationBuiltinTopicData
Flag to enable dropping of discovery Writer DATA(W) messages.
Definition: test_UDPv4TransportDescriptor.hpp:72
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor(test_UDPv4TransportDescriptor &&t)=delete
Move constructor.
filter drop_data_messages_filter_
Filtering function for dropping data messages.
Definition: test_UDPv4TransportDescriptor.hpp:60
filter sub_messages_filter_
Definition: test_UDPv4TransportDescriptor.hpp:104
virtual ~test_UDPv4TransportDescriptor()=default
Destructor.
std::atomic< uint8_t > dropPublicationBuiltinDataMessagesPercentage
Percentage of Data[W] messages being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:56
filter drop_heartbeat_messages_filter_
Filtering function for dropping heartbeat messages.
Definition: test_UDPv4TransportDescriptor.hpp:85
std::atomic< uint8_t > dropGapMessagesPercentage
Percentage of gap messages being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:97
std::function< bool(const Locator &destination, int32_t priority)> DestinationLocatorFilter
Locator filtering function.
Definition: test_UDPv4TransportDescriptor.hpp:45
virtual TransportInterface * create_transport() const override
Create transport using the parameters defined within the Descriptor.
bool dropParticipantBuiltinTopicData
Flag to enable dropping of discovery Participant DATA(P) messages.
Definition: test_UDPv4TransportDescriptor.hpp:70
std::atomic< uint8_t > dropSubscriptionBuiltinDataMessagesPercentage
Percentage of Data[R] messages being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:58
filter drop_gap_messages_filter_
Filtering function for dropping gap messages.
Definition: test_UDPv4TransportDescriptor.hpp:99
std::atomic< uint8_t > percentageOfMessagesToDrop
Definition: test_UDPv4TransportDescriptor.hpp:110
std::atomic< uint8_t > dropAckNackMessagesPercentage
Percentage of AckNacks being dropped.
Definition: test_UDPv4TransportDescriptor.hpp:90
uint32_t dropLogLength
Log dropped packets.
Definition: test_UDPv4TransportDescriptor.hpp:127
FASTDDS_EXPORTED_API test_UDPv4TransportDescriptor(const test_UDPv4TransportDescriptor &t)=delete
Copy constructor.