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

#include <MulticastSendStrategy.h>

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

Public Member Functions

 MulticastSendStrategy (MulticastDataLink *link)
 
virtual void stop_i ()
 Let the subclass stop. More...
 
- Public Member Functions inherited from OpenDDS::DCPS::TransportSendStrategy
virtual ~TransportSendStrategy ()
 
void send_buffer (TransportSendBuffer *send_buffer)
 Assigns an optional send buffer. More...
 
int start ()
 
void stop ()
 
void send_start ()
 
void send (TransportQueueElement *element, bool relink=true)
 
void send_stop (GUID_t repoId)
 
RemoveResult remove_sample (const DataSampleElement *sample)
 
void remove_all_msgs (const GUID_t &pub_id)
 
virtual WorkOutcome perform_work ()
 
virtual void relink (bool do_suspend=true)
 
void suspend_send ()
 
void resume_send ()
 
void terminate_send (bool graceful_disconnecting=false)
 Remove all samples in the backpressure queue and packet queue. More...
 
virtual void terminate_send_if_suspended ()
 
virtual bool start_i ()
 Let the subclass start. More...
 
void link_released (bool flag)
 
bool isDirectMode ()
 
virtual ACE_HANDLE get_handle ()
 
void deliver_ack_request (TransportQueueElement *element)
 
bool fragmentation_helper (TransportQueueElement *original_element, TqeVector &elements_to_send)
 
void clear (SendMode new_mode, SendMode old_mode=MODE_NOT_SET)
 
SendMode mode () const
 Access the current sending mode. More...
 
- Public Member Functions inherited from OpenDDS::DCPS::ThreadSynchWorker
virtual ~ThreadSynchWorker ()
 
virtual void schedule_output ()
 Indicate that queued data is available to be sent. More...
 
std::size_t id () const
 DataLink reference value for diagnostics. More...
 
- 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
 

Protected Member Functions

virtual void prepare_header_i ()
 Specific implementation processing of prepared packet header. More...
 
virtual ssize_t send_bytes_i (const iovec iov[], int n)
 
ssize_t sync_send (const iovec iov[], int n)
 
ssize_t async_send (const iovec iov[], int n, const ACE_INET_Addr &addr)
 
virtual size_t max_message_size () const
 
- Protected Member Functions inherited from OpenDDS::DCPS::TransportSendStrategy
 TransportSendStrategy (std::size_t id, const TransportImpl_rch &transport, ThreadSynchResource *synch_resource, Priority priority, const ThreadSynchStrategy_rch &thread_sync_strategy)
 
virtual ssize_t send_bytes (const iovec iov[], int n, int &bp)
 
virtual ssize_t non_blocking_send (const iovec iov[], int n, int &bp)
 
virtual void prepare_packet_i ()
 Specific implementation processing of prepared packet. More...
 
TransportQueueElementcurrent_packet_first_element () const
 
void set_graceful_disconnecting (bool flag)
 Set graceful disconnecting flag. More...
 
virtual void add_delayed_notification (TransportQueueElement *element)
 
bool send_delayed_notifications (const TransportQueueElement::MatchCriteria *match=0)
 
virtual Security::SecurityConfig_rch security_config () const
 
virtual RemoveResult do_remove_sample (const GUID_t &pub_id, const TransportQueueElement::MatchCriteria &criteria, bool remove_all=false)
 Implement framework chain visitations to remove a sample. More...
 
ThreadSynchsynch () const
 
void set_header_source (ACE_INT64 source)
 
- Protected Member Functions inherited from OpenDDS::DCPS::ThreadSynchWorker
 ThreadSynchWorker (std::size_t id=0)
 
- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Private Attributes

MulticastDataLinklink_
 

Additional Inherited Members

- Public Types inherited from OpenDDS::DCPS::TransportSendStrategy
enum  SendMode {
  MODE_NOT_SET, MODE_DIRECT, MODE_QUEUE, MODE_SUSPEND,
  MODE_TERMINATED
}
 
typedef BasicQueue< TransportQueueElementQueueType
 
- Public Types inherited from OpenDDS::DCPS::ThreadSynchWorker
enum  WorkOutcome { WORK_OUTCOME_MORE_TO_DO, WORK_OUTCOME_NO_MORE_TO_DO, WORK_OUTCOME_CLOGGED_RESOURCE, WORK_OUTCOME_BROKEN_RESOURCE }
 
- Static Public Member Functions inherited from OpenDDS::DCPS::TransportSendStrategy
static int mb_to_iov (const ACE_Message_Block &msg, iovec *iov)
 
- Static Public Attributes inherited from OpenDDS::DCPS::TransportSendStrategy
static const size_t UDP_MAX_MESSAGE_SIZE = 65466
 

Detailed Description

Definition at line 23 of file MulticastSendStrategy.h.

Constructor & Destructor Documentation

◆ MulticastSendStrategy()

OpenDDS::DCPS::MulticastSendStrategy::MulticastSendStrategy ( MulticastDataLink link)

Definition at line 18 of file MulticastSendStrategy.cpp.

References if(), and OpenDDS::DCPS::TransportSendStrategy::link_released().

19  : TransportSendStrategy(0, link->impl(),
20  0, // synch_resource
21  link->transport_priority(),
22  make_rch<NullSynchStrategy>()),
23  link_(link)
24 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
25  , async_init_(false)
26 #endif
27 {
28  // Multicast will send a SYN (TRANSPORT_CONTROL) before any reservations
29  // are made on the DataLink, if the link is "release" it will be dropped.
30  this->link_released(false);
31 }
TransportSendStrategy(std::size_t id, const TransportImpl_rch &transport, ThreadSynchResource *synch_resource, Priority priority, const ThreadSynchStrategy_rch &thread_sync_strategy)

Member Function Documentation

◆ async_send()

ssize_t OpenDDS::DCPS::MulticastSendStrategy::async_send ( const iovec  iov[],
int  n,
const ACE_INET_Addr addr 
)
protected

Definition at line 67 of file MulticastSendStrategy.cpp.

References ACE_Message_Block::cont(), ACE_IPC_SAP::get_handle(), OpenDDS::DCPS::MulticastDataLink::get_proactor(), link_, ACE_Message_Block::release(), OpenDDS::DCPS::MulticastDataLink::socket(), and ACE_Message_Block::wr_ptr().

Referenced by send_bytes_i().

68 {
69 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
70  if (!async_init_) {
71  if (-1 == async_writer_.open(*this, link_->socket().get_handle(), 0 /*completion_key*/,
72  link_->get_proactor())) {
73  return -1;
74  }
75  async_init_ = true;
76  }
77 
78  ACE_Message_Block* mb = 0;
79  size_t total_length = 0;
80 
81  for (int i = n - 1; i >= 0; --i) {
82  ACE_Message_Block* next =
83  new ACE_Message_Block(static_cast<const char*>(iov[i].iov_base),
84  iov[i].iov_len);
85  next->wr_ptr(iov[i].iov_len);
86  total_length += iov[i].iov_len;
87  next->cont(mb);
88  mb = next;
89  }
90 
91  size_t bytes_sent = 0;
92  ssize_t result = async_writer_.send(mb, bytes_sent, 0 /*flags*/, group_address);
93 
94  if (result < 0) {
95  if (mb) mb->release();
96  return result;
97  }
98 
99  // framework needs to think we sent the entire datagram
100  return total_length;
101 #else
102  ACE_UNUSED_ARG(iov);
103  ACE_UNUSED_ARG(n);
104  return -1;
105 #endif
106 }
int ssize_t
virtual ACE_Message_Block * release(void)
ACE_Message_Block * cont(void) const
ACE_SOCK_Dgram_Mcast & socket()
char * wr_ptr(void) const
ACE_HANDLE get_handle(void) const

◆ max_message_size()

virtual size_t OpenDDS::DCPS::MulticastSendStrategy::max_message_size ( void  ) const
inlineprotectedvirtual

The maximum size of a message allowed by the this TransportImpl, or 0 if there is no such limit. This is expected to be a constant, for example UDP/IPv4 can send messages of up to 65466 bytes. The transport framework will use the returned value (if > 0) to fragment larger messages. This fragmentation and reassembly will be transparent to the user.

Reimplemented from OpenDDS::DCPS::TransportSendStrategy.

Definition at line 42 of file MulticastSendStrategy.h.

43  {
44  return UDP_MAX_MESSAGE_SIZE;
45  }

◆ prepare_header_i()

void OpenDDS::DCPS::MulticastSendStrategy::prepare_header_i ( )
protectedvirtual

Specific implementation processing of prepared packet header.

Reimplemented from OpenDDS::DCPS::TransportSendStrategy.

Definition at line 34 of file MulticastSendStrategy.cpp.

References link_, OpenDDS::DCPS::MulticastDataLink::local_peer(), and OpenDDS::DCPS::TransportSendStrategy::set_header_source().

35 {
36  // Tag outgoing packets with our peer ID:
38 }

◆ send_bytes_i()

ssize_t OpenDDS::DCPS::MulticastSendStrategy::send_bytes_i ( const iovec  iov[],
int  n 
)
protectedvirtual

Implements OpenDDS::DCPS::TransportSendStrategy.

Definition at line 41 of file MulticastSendStrategy.cpp.

References async_send(), OpenDDS::DCPS::MulticastDataLink::config(), link_, and sync_send().

42 {
44  return (cfg && cfg->async_send()) ? async_send(iov, n, cfg->group_address_) : sync_send(iov, n);
45 }
ssize_t async_send(const iovec iov[], int n, const ACE_INET_Addr &addr)
ssize_t sync_send(const iovec iov[], int n)
RcHandle< MulticastInst > MulticastInst_rch

◆ stop_i()

void OpenDDS::DCPS::MulticastSendStrategy::stop_i ( )
virtual

Let the subclass stop.

Implements OpenDDS::DCPS::TransportSendStrategy.

Definition at line 109 of file MulticastSendStrategy.cpp.

References ACE_ERROR, ACE_Asynch_Result::error(), LM_ERROR, ACE_Asynch_Write_Dgram::Result::message_block(), OPENDDS_END_VERSIONED_NAMESPACE_DECL, ACE_Message_Block::release(), and ACE_Asynch_Result::success().

110 {
111 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
112  if (async_init_) {
113  async_writer_.cancel();
114  }
115 #endif
116 }

◆ sync_send()

ssize_t OpenDDS::DCPS::MulticastSendStrategy::sync_send ( const iovec  iov[],
int  n 
)
protected

Definition at line 48 of file MulticastSendStrategy.cpp.

References ENOBUFS, link_, ACE_SOCK_Dgram_Mcast::send(), socket(), and OpenDDS::DCPS::MulticastDataLink::socket().

Referenced by send_bytes_i().

49 {
51 
52  const ssize_t result = socket.send(iov, n);
53 
54  if (result == -1 && errno == ENOBUFS) {
55  // Make the framework think this was a successful send to avoid
56  // putting the send strategy in suspended mode. If reliability
57  // is enabled, the data may be resent later in response to a NAK.
58  ssize_t b = 0;
59  for (int i = 0; i < n; ++i) b += iov[i].iov_len;
60  return b;
61  }
62 
63  return result;
64 }
ssize_t send(const void *buf, size_t n, int flags=0) const
int ssize_t
ACE_HANDLE socket(int protocol_family, int type, int proto)
ACE_SOCK_Dgram_Mcast & socket()

Member Data Documentation

◆ link_

MulticastDataLink* OpenDDS::DCPS::MulticastSendStrategy::link_
private

Definition at line 53 of file MulticastSendStrategy.h.

Referenced by async_send(), prepare_header_i(), send_bytes_i(), and sync_send().


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