OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
OpenDDS::DCPS::TcpInst Class Reference

#include <TcpInst.h>

Inheritance diagram for OpenDDS::DCPS::TcpInst:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::TcpInst:
Collaboration graph
[legend]

Public Member Functions

virtual int load (ACE_Configuration_Heap &cf, ACE_Configuration_Section_Key &sect)
 
virtual OPENDDS_STRING dump_to_str () const
 Diagnostic aid. More...
 
bool is_reliable () const
 Does the transport as configured support RELIABLE_RELIABILITY_QOS? More...
 
const std::string & get_public_address () const
 
virtual size_t populate_locator (OpenDDS::DCPS::TransportLocator &trans_info, ConnectionInfoFlags flags) const
 Populate a transport locator sequence. Return the number of "locators.". More...
 
OPENDDS_STRING local_address_string () const
 
ACE_INET_Addr local_address () const
 
void local_address (const ACE_INET_Addr &addr)
 
void local_address (const char *str)
 
void local_address (u_short port_number, const char *host_name)
 
void local_address_set_port (u_short port_number)
 
- Public Member Functions inherited from OpenDDS::DCPS::TransportInst
const OPENDDS_STRINGname () const
 
void dump () const
 Diagnostic aid. More...
 
virtual bool requires_cdr_encapsulation () const
 Does the transport require a CDR-encapsulated data payload? More...
 
DCPS::WeakRcHandle< ICE::Endpointget_ice_endpoint ()
 
void rtps_relay_only_now (bool flag)
 
void use_rtps_relay_now (bool flag)
 
void use_ice_now (bool flag)
 
virtual void update_locators (const GUID_t &, const TransportLocatorSeq &)
 
virtual void get_last_recv_locator (const GUID_t &, TransportLocator &)
 
virtual void rtps_relay_address_change ()
 
ReactorTask_rch reactor_task ()
 
EventDispatcher_rch event_dispatcher ()
 
void count_messages (bool flag)
 
bool count_messages () const
 
virtual void append_transport_statistics (TransportStatisticsSequence &)
 
void drop_messages (bool flag)
 
void drop_messages_m (double m)
 
void drop_messages_b (double b)
 
bool should_drop (ssize_t length) const
 
bool should_drop (const iovec iov[], int n, ssize_t &length) const
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Public Attributes

std::string pub_address_str_
 
bool enable_nagle_algorithm_
 
int conn_retry_initial_delay_
 
double conn_retry_backoff_multiplier_
 
int conn_retry_attempts_
 
int max_output_pause_period_
 
int passive_reconnect_duration_
 
int active_conn_timeout_period_
 
- Public Attributes inherited from OpenDDS::DCPS::TransportInst
const OPENDDS_STRING transport_type_
 
size_t queue_messages_per_pool_
 
size_t queue_initial_pools_
 
ACE_UINT32 max_packet_size_
 Max size (in bytes) of a packet (packet header + sample(s)) More...
 
size_t max_samples_per_packet_
 Max number of samples that should ever be in a single packet. More...
 
ACE_UINT32 optimum_packet_size_
 Optimum size (in bytes) of a packet (packet header + sample(s)). More...
 
bool thread_per_connection_
 
long datalink_release_delay_
 
size_t datalink_control_chunks_
 
TimeDuration fragment_reassembly_timeout_
 
size_t receive_preallocated_message_blocks_
 
size_t receive_preallocated_data_blocks_
 

Static Public Attributes

static const int DEFAULT_PASSIVE_RECONNECT_DURATION = 2000
 
static const int DEFAULT_ACTIVE_CONN_TIMEOUT_PERIOD = 5000
 
- Static Public Attributes inherited from OpenDDS::DCPS::TransportInst
static const long DEFAULT_DATALINK_RELEASE_DELAY = 10000
 
static const size_t DEFAULT_DATALINK_CONTROL_CHUNKS = 32u
 

Private Member Functions

 TcpInst (const OPENDDS_STRING &name)
 
virtual ~TcpInst ()
 
TransportImpl_rch new_impl ()
 

Private Attributes

ACE_INET_Addr local_address_
 
std::string local_address_str_
 

Friends

class TcpType
 
class TcpTransport
 
class ::DDS_TEST
 
template<typename T , typename U >
RcHandle< T > OpenDDS::DCPS::make_rch (U const &)
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenDDS::DCPS::TransportInst
static OPENDDS_STRING formatNameForDump (const char *name)
 
- Protected Member Functions inherited from OpenDDS::DCPS::TransportInst
 TransportInst (const char *type, const OPENDDS_STRING &name)
 
virtual ~TransportInst ()
 
void set_port_in_addr_string (OPENDDS_STRING &addr_str, u_short port_number)
 
TransportImpl_rch get_or_create_impl ()
 
TransportImpl_rch get_impl ()
 
- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 
- Protected Attributes inherited from OpenDDS::DCPS::TransportInst
ACE_SYNCH_MUTEX lock_
 
bool shutting_down_
 

Detailed Description

Definition at line 32 of file TcpInst.h.

Constructor & Destructor Documentation

◆ TcpInst()

OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE OpenDDS::DCPS::TcpInst::TcpInst ( const OPENDDS_STRING name)
explicitprivate

Definition at line 13 of file TcpInst.inl.

References DBG_ENTRY_LVL, and OPENDDS_END_VERSIONED_NAMESPACE_DECL.

14  : TransportInst("tcp", name),
22 {
23  DBG_ENTRY_LVL("TcpInst", "TcpInst", 6);
24 }
const OPENDDS_STRING & name() const
Definition: TransportInst.h:70
int max_output_pause_period_
Definition: TcpInst.h:78
TransportInst(const char *type, const OPENDDS_STRING &name)
static const int DEFAULT_PASSIVE_RECONNECT_DURATION
Definition: TcpInst.h:36
double conn_retry_backoff_multiplier_
Definition: TcpInst.h:66
bool enable_nagle_algorithm_
Definition: TcpInst.h:50
int active_conn_timeout_period_
Definition: TcpInst.h:93
int passive_reconnect_duration_
Definition: TcpInst.h:86
int conn_retry_initial_delay_
Definition: TcpInst.h:56
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
static const int DEFAULT_ACTIVE_CONN_TIMEOUT_PERIOD
Definition: TcpInst.h:37

◆ ~TcpInst()

OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL OpenDDS::DCPS::TcpInst::~TcpInst ( )
privatevirtual

Definition at line 23 of file TcpInst.cpp.

References DBG_ENTRY_LVL.

24 {
25  DBG_ENTRY_LVL("TcpInst","~TcpInst",6);
26 }
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68

Member Function Documentation

◆ dump_to_str()

OPENDDS_STRING OpenDDS::DCPS::TcpInst::dump_to_str ( ) const
virtual

Diagnostic aid.

Reimplemented from OpenDDS::DCPS::TransportInst.

Definition at line 74 of file TcpInst.cpp.

References active_conn_timeout_period_, conn_retry_attempts_, conn_retry_backoff_multiplier_, conn_retry_initial_delay_, OpenDDS::DCPS::TransportInst::dump_to_str(), enable_nagle_algorithm_, OpenDDS::DCPS::TransportInst::formatNameForDump(), local_address_string(), max_output_pause_period_, OPENDDS_STRING, passive_reconnect_duration_, and pub_address_str_.

75 {
76  std::ostringstream os;
78 
79  os << formatNameForDump("local_address") << this->local_address_string() << std::endl;
80  os << formatNameForDump("pub_address") << this->pub_address_str_ << std::endl;
81  os << formatNameForDump("enable_nagle_algorithm") << (this->enable_nagle_algorithm_ ? "true" : "false") << std::endl;
82  os << formatNameForDump("conn_retry_initial_delay") << this->conn_retry_initial_delay_ << std::endl;
83  os << formatNameForDump("conn_retry_backoff_multiplier") << this->conn_retry_backoff_multiplier_ << std::endl;
84  os << formatNameForDump("conn_retry_attempts") << this->conn_retry_attempts_ << std::endl;
85  os << formatNameForDump("passive_reconnect_duration") << this->passive_reconnect_duration_ << std::endl;
86  os << formatNameForDump("max_output_pause_period") << this->max_output_pause_period_ << std::endl;
87  os << formatNameForDump("active_conn_timeout_period") << this->active_conn_timeout_period_ << std::endl;
88  return OPENDDS_STRING(os.str());
89 }
OPENDDS_STRING local_address_string() const
Definition: TcpInst.h:106
virtual OPENDDS_STRING dump_to_str() const
int max_output_pause_period_
Definition: TcpInst.h:78
#define OPENDDS_STRING
double conn_retry_backoff_multiplier_
Definition: TcpInst.h:66
bool enable_nagle_algorithm_
Definition: TcpInst.h:50
int active_conn_timeout_period_
Definition: TcpInst.h:93
int passive_reconnect_duration_
Definition: TcpInst.h:86
int conn_retry_initial_delay_
Definition: TcpInst.h:56
std::string pub_address_str_
Definition: TcpInst.h:48
static OPENDDS_STRING formatNameForDump(const char *name)

◆ get_public_address()

const std::string& OpenDDS::DCPS::TcpInst::get_public_address ( ) const
inline

The public address is our publicly advertised address. Usually this is the same as the local address, but if a public address is explicitly specified, use that.

Definition at line 100 of file TcpInst.h.

Referenced by populate_locator().

100  {
102  }
std::string pub_address_str_
Definition: TcpInst.h:48
std::string local_address_str_
Definition: TcpInst.h:148

◆ is_reliable()

bool OpenDDS::DCPS::TcpInst::is_reliable ( ) const
inlinevirtual

Does the transport as configured support RELIABLE_RELIABILITY_QOS?

Implements OpenDDS::DCPS::TransportInst.

Definition at line 95 of file TcpInst.h.

95 { return true; }

◆ load()

int OpenDDS::DCPS::TcpInst::load ( ACE_Configuration_Heap cf,
ACE_Configuration_Section_Key sect 
)
virtual

Overwrite the default configurations with the configuration from the given section in the ACE_Configuration_Heap object.

Reimplemented from OpenDDS::DCPS::TransportInst.

Definition at line 35 of file TcpInst.cpp.

References ACE_TEXT(), active_conn_timeout_period_, conn_retry_attempts_, conn_retry_backoff_multiplier_, conn_retry_initial_delay_, enable_nagle_algorithm_, GET_CONFIG_DOUBLE_VALUE, GET_CONFIG_STRING_VALUE, GET_CONFIG_VALUE, OpenDDS::DCPS::TransportInst::load(), local_address(), max_output_pause_period_, OPENDDS_STRING, passive_reconnect_duration_, and pub_address_str_.

37 {
38  TransportInst::load(cf, trans_sect);
39 
40  std::string local_address;
41  GET_CONFIG_STRING_VALUE(cf, trans_sect, ACE_TEXT("local_address"), local_address);
42 
43  if (!local_address.empty()) {
44  this->local_address(local_address.c_str());
45  }
46 
47  GET_CONFIG_STRING_VALUE(cf, trans_sect, ACE_TEXT("pub_address"), pub_address_str_);
48 
49  GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("enable_nagle_algorithm"),
50  this->enable_nagle_algorithm_, bool)
51 
52  GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_initial_delay"),
53  this->conn_retry_initial_delay_, int)
54 
55  GET_CONFIG_DOUBLE_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_backoff_multiplier"),
57 
58  GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_attempts"),
59  this->conn_retry_attempts_, int)
60 
61  GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("passive_reconnect_duration"),
62  this->passive_reconnect_duration_, int)
63 
64  GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("max_output_pause_period"),
65  this->max_output_pause_period_, int)
66 
67  GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("active_conn_timeout_period"),
68  this->active_conn_timeout_period_, int)
69 
70  return 0;
71 }
#define GET_CONFIG_STRING_VALUE(CF, SECT, KEY, VALUE)
Definition: TransportDefs.h:76
int max_output_pause_period_
Definition: TcpInst.h:78
ACE_INET_Addr local_address() const
Definition: TcpInst.h:107
double conn_retry_backoff_multiplier_
Definition: TcpInst.h:66
bool enable_nagle_algorithm_
Definition: TcpInst.h:50
#define GET_CONFIG_VALUE(CF, SECT, KEY, VALUE, TYPE)
Definition: TransportDefs.h:45
int active_conn_timeout_period_
Definition: TcpInst.h:93
int passive_reconnect_duration_
Definition: TcpInst.h:86
ACE_TEXT("TCP_Factory")
int conn_retry_initial_delay_
Definition: TcpInst.h:56
#define GET_CONFIG_DOUBLE_VALUE(CF, SECT, KEY, VALUE)
std::string pub_address_str_
Definition: TcpInst.h:48
virtual int load(ACE_Configuration_Heap &cf, ACE_Configuration_Section_Key &sect)

◆ local_address() [1/4]

ACE_INET_Addr OpenDDS::DCPS::TcpInst::local_address ( ) const
inline

Definition at line 107 of file TcpInst.h.

Referenced by load(), and populate_locator().

107 { return local_address_; }
ACE_INET_Addr local_address_
Definition: TcpInst.h:142

◆ local_address() [2/4]

void OpenDDS::DCPS::TcpInst::local_address ( const ACE_INET_Addr addr)
inline

Definition at line 108 of file TcpInst.h.

References OpenDDS::DCPS::LogAddr::str().

109  {
110  local_address_ = addr;
111  local_address_str_ = LogAddr(addr).str();
112  }
ACE_INET_Addr local_address_
Definition: TcpInst.h:142
std::string local_address_str_
Definition: TcpInst.h:148

◆ local_address() [3/4]

void OpenDDS::DCPS::TcpInst::local_address ( const char *  str)
inline

Definition at line 113 of file TcpInst.h.

References OpenDDS::DCPS::choose_single_coherent_address().

114  {
115  local_address_str_ = str;
117  }
ACE_INET_Addr local_address_
Definition: TcpInst.h:142
ACE_INET_Addr choose_single_coherent_address(const ACE_INET_Addr &address, bool prefer_loopback)
std::string local_address_str_
Definition: TcpInst.h:148

◆ local_address() [4/4]

void OpenDDS::DCPS::TcpInst::local_address ( u_short  port_number,
const char *  host_name 
)
inline

Definition at line 118 of file TcpInst.h.

References OpenDDS::DCPS::choose_single_coherent_address(), and OpenDDS::DCPS::to_dds_string().

119  {
120  local_address_str_ = host_name;
121  local_address_str_ += ":" + to_dds_string(port_number);
123  }
ACE_INET_Addr local_address_
Definition: TcpInst.h:142
ACE_INET_Addr choose_single_coherent_address(const ACE_INET_Addr &address, bool prefer_loopback)
std::string local_address_str_
Definition: TcpInst.h:148
String to_dds_string(unsigned short to_convert)

◆ local_address_set_port()

void OpenDDS::DCPS::TcpInst::local_address_set_port ( u_short  port_number)
inline

Definition at line 124 of file TcpInst.h.

124  {
125  local_address_.set_port_number(port_number);
127  }
ACE_INET_Addr local_address_
Definition: TcpInst.h:142
std::string local_address_str_
Definition: TcpInst.h:148
void set_port_number(u_short, int encode=1)
void set_port_in_addr_string(OPENDDS_STRING &addr_str, u_short port_number)

◆ local_address_string()

OPENDDS_STRING OpenDDS::DCPS::TcpInst::local_address_string ( ) const
inline

Definition at line 106 of file TcpInst.h.

Referenced by dump_to_str().

106 { return local_address_str_; }
std::string local_address_str_
Definition: TcpInst.h:148

◆ new_impl()

OpenDDS::DCPS::TransportImpl_rch OpenDDS::DCPS::TcpInst::new_impl ( )
privatevirtual

Implements OpenDDS::DCPS::TransportInst.

Definition at line 29 of file TcpInst.cpp.

References OpenDDS::DCPS::rchandle_from().

30 {
31  return make_rch<TcpTransport>(rchandle_from(this));
32 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ populate_locator()

size_t OpenDDS::DCPS::TcpInst::populate_locator ( OpenDDS::DCPS::TransportLocator trans_info,
ConnectionInfoFlags  flags 
) const
virtual

Populate a transport locator sequence. Return the number of "locators.".

Implements OpenDDS::DCPS::TransportInst.

Definition at line 92 of file TcpInst.cpp.

References ACE_OutputCDR::buffer(), OpenDDS::DCPS::TransportLocator::data, get_public_address(), local_address(), OPENDDS_END_VERSIONED_NAMESPACE_DECL, pub_address_str_, ACE_OutputCDR::total_length(), and OpenDDS::DCPS::TransportLocator::transport_type.

93 {
94  if (local_address() != ACE_INET_Addr() || !pub_address_str_.empty()) {
95  // Get the public address string from the inst (usually the local address)
96  NetworkResource network_resource(get_public_address());
97 
98  ACE_OutputCDR cdr;
99  cdr << network_resource;
100  const CORBA::ULong len = static_cast<CORBA::ULong>(cdr.total_length());
101  char* buffer = const_cast<char*>(cdr.buffer()); // safe
102 
103  local_info.transport_type = "tcp";
104  local_info.data = TransportBLOB(len, len,
105  reinterpret_cast<CORBA::Octet*>(buffer));
106  return 1;
107  } else {
108  return 0;
109  }
110 }
size_t total_length(void) const
ACE_INET_Addr local_address() const
Definition: TcpInst.h:107
const std::string & get_public_address() const
Definition: TcpInst.h:100
ACE_CDR::ULong ULong
const char * buffer(void) const
DDS::OctetSeq TransportBLOB
std::string pub_address_str_
Definition: TcpInst.h:48

Friends And Related Function Documentation

◆ ::DDS_TEST

friend class ::DDS_TEST
friend

Definition at line 132 of file TcpInst.h.

◆ OpenDDS::DCPS::make_rch

template<typename T , typename U >
RcHandle<T> OpenDDS::DCPS::make_rch ( U const &  )
friend

◆ TcpTransport

friend class TcpTransport
friend

Definition at line 131 of file TcpInst.h.

◆ TcpType

friend class TcpType
friend

Definition at line 130 of file TcpInst.h.

Member Data Documentation

◆ active_conn_timeout_period_

int OpenDDS::DCPS::TcpInst::active_conn_timeout_period_

The time period in milliseconds for the acceptor side of a connection to wait for the connection to be established. If not connected within this period then this link is removed from pending and any other links are attempted. The default is 5 seconds (5000 millseconds).

Definition at line 93 of file TcpInst.h.

Referenced by dump_to_str(), and load().

◆ conn_retry_attempts_

int OpenDDS::DCPS::TcpInst::conn_retry_attempts_

Number of attempts to reconnect before giving up and calling on_publication_lost() and on_subscription_lost() callbacks. The default is 3.

Definition at line 71 of file TcpInst.h.

Referenced by dump_to_str(), and load().

◆ conn_retry_backoff_multiplier_

double OpenDDS::DCPS::TcpInst::conn_retry_backoff_multiplier_

The backoff multiplier for reconnection strategy. The third and so on reconnect will be this value * the previous delay. Hence with conn_retry_initial_delay=500 and conn_retry_backoff_multiplier=1.5 the second reconnect attempt will be at 0.5 seconds after first retry connect fails; the third attempt will be 0.75 seconds after the second retry connect fails; the fourth attempt will be 1.125 seconds after the third retry connect fails. The default value is 2.0.

Definition at line 66 of file TcpInst.h.

Referenced by dump_to_str(), and load().

◆ conn_retry_initial_delay_

int OpenDDS::DCPS::TcpInst::conn_retry_initial_delay_

The initial retry delay in milliseconds. The first connection retry will be when the loss of connection is detected. The second try will be after this delay. The default is 500 miliseconds.

Definition at line 56 of file TcpInst.h.

Referenced by dump_to_str(), and load().

◆ DEFAULT_ACTIVE_CONN_TIMEOUT_PERIOD

const int OpenDDS::DCPS::TcpInst::DEFAULT_ACTIVE_CONN_TIMEOUT_PERIOD = 5000
static

Definition at line 37 of file TcpInst.h.

◆ DEFAULT_PASSIVE_RECONNECT_DURATION

const int OpenDDS::DCPS::TcpInst::DEFAULT_PASSIVE_RECONNECT_DURATION = 2000
static

Definition at line 36 of file TcpInst.h.

◆ enable_nagle_algorithm_

bool OpenDDS::DCPS::TcpInst::enable_nagle_algorithm_

Definition at line 50 of file TcpInst.h.

Referenced by dump_to_str(), and load().

◆ local_address_

ACE_INET_Addr OpenDDS::DCPS::TcpInst::local_address_
private

Describes the local endpoint to be used to accept passive connections.

Definition at line 142 of file TcpInst.h.

◆ local_address_str_

std::string OpenDDS::DCPS::TcpInst::local_address_str_
private

The address string used to configure the acceptor. This string is either from configuration file or default to hostname:port. The hostname is fully qualified hostname and the port is randomly picked by os.

Definition at line 148 of file TcpInst.h.

◆ max_output_pause_period_

int OpenDDS::DCPS::TcpInst::max_output_pause_period_

Maximum period (in milliseconds) of not being able to send queued messages. If there are samples queued and no output for longer than this period then the connection will be closed and on_*_lost() callbacks will be called. If the value is zero, the default, then this check will not be made.

Definition at line 78 of file TcpInst.h.

Referenced by dump_to_str(), and load().

◆ passive_reconnect_duration_

int OpenDDS::DCPS::TcpInst::passive_reconnect_duration_

The time period in milliseconds for the acceptor side of a connection to wait for the connection to be reconnected. If not reconnected within this period then on_publication_lost() and on_subscription_lost() callbacks will be called. The default is 2 seconds (2000 millseconds).

Definition at line 86 of file TcpInst.h.

Referenced by dump_to_str(), and load().

◆ pub_address_str_

std::string OpenDDS::DCPS::TcpInst::pub_address_str_

The address string provided to DCPSInfoRepo for connectors. This string is either from configuration file or defaults to the local address.

Definition at line 48 of file TcpInst.h.

Referenced by dump_to_str(), load(), and populate_locator().


The documentation for this class was generated from the following files: