Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_ECG_CDR_Message_Sender Class Reference

Sends CDR messages using UDP. NOT THREAD-SAFE. More...

#include <ECG_CDR_Message_Sender.h>

Collaboration diagram for TAO_ECG_CDR_Message_Sender:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { ECG_HEADER_SIZE = 32, ECG_MIN_MTU = 32 + 8, ECG_MAX_MTU = 65536, ECG_DEFAULT_MTU = 1024 }

Public Methods

void send_message (const TAO_OutputCDR &cdr, const ACE_INET_Addr &addr ACE_ENV_ARG_DECL) throw (CORBA::SystemException)
 The main method - send a CDR message.

 TAO_ECG_CDR_Message_Sender (CORBA::Boolean crc=0)
void init (TAO_ECG_Refcounted_Endpoint endpoint_rptr ACE_ENV_ARG_DECL) throw (CORBA::SystemException)
 Set the endpoint for sending messages.

void shutdown (ACE_ENV_SINGLE_ARG_DECL)
int get_local_addr (ACE_INET_Addr &addr)
 Get the local endpoint used to send the events.

int mtu (CORBA::ULong mtu)
CORBA::ULong mtu (void) const
 Get the local endpoint used to send the events.


Private Methods

ACE_SOCK_Dgramdgram (void)
 Return the datagram...

void send_fragment (const ACE_INET_Addr &addr, CORBA::ULong request_id, CORBA::ULong request_size, CORBA::ULong fragment_size, CORBA::ULong fragment_offset, CORBA::ULong fragment_id, CORBA::ULong fragment_count, iovec iov[], int iovcnt ACE_ENV_ARG_DECL)
CORBA::ULong compute_fragment_count (const ACE_Message_Block *begin, const ACE_Message_Block *end, int iov_size, CORBA::ULong max_fragment_payload, CORBA::ULong &total_length)

Private Attributes

TAO_ECG_Refcounted_Endpoint endpoint_rptr_
 The datagram used for sendto ().

CORBA::ULong mtu_
 The MTU for this sender...

CORBA::Boolean checksum_
 Should crc checksum be caluclated and sent?


Detailed Description

Sends CDR messages using UDP. NOT THREAD-SAFE.

This class breaks up a CDR message into fragments and sends each fragment with a header (described below) using UDP. The UDP address can be a normal IP address or it can be a multicast group. The UDP address is obtained from a RtecUDPAdmin::AddrServer class.

This class is used by various Gateway (Senders/Receivers) classes responsible for federating Event Channels with UDP/Mcast.

MESSAGE FORMAT

Message header are encapsulated using CDR, with the following format: struct Header { octet byte_order_flags; // bit 0 represents the byte order as in GIOP 1.1 // bit 1 is set if this is the last fragment unsigned long request_id; // The request ID, senders must not send two requests with // the same ID, senders can be distinguished using recvfrom.. unsigned long request_size; // The size of this request, this can be used to pre-allocate // the request buffer. unsgined long fragment_size; // The size of this fragment, excluding the header... unsigned long fragment_offset; // Where does this fragment fit in the complete message... unsigned long fragment_id; // The ID of this fragment... unsigned long fragment_count; // The total number of fragments to expect in this request

//

Todo:
This could be eliminated if efficient reassembly // could be implemented without it. octet padding[4];

// Ensures the header ends at an 8-byte boundary. }; // size (in CDR stream) = 32


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
ECG_HEADER_SIZE 
ECG_MIN_MTU 
ECG_MAX_MTU 
ECG_DEFAULT_MTU 


Constructor & Destructor Documentation

ACE_INLINE TAO_ECG_CDR_Message_Sender::TAO_ECG_CDR_Message_Sender CORBA::Boolean    crc = 0
 


Member Function Documentation

CORBA::ULong TAO_ECG_CDR_Message_Sender::compute_fragment_count const ACE_Message_Block   begin,
const ACE_Message_Block   end,
int    iov_size,
CORBA::ULong    max_fragment_payload,
CORBA::ULong   total_length
[private]
 

Count the number of fragments that will be required to send the message blocks in the range [begin,end) The maximum fragment payload (i.e. the size without the header is also required); <total_length> returns the total message size.

ACE_INLINE ACE_SOCK_Dgram & TAO_ECG_CDR_Message_Sender::dgram void    [private]
 

Return the datagram...

ACE_INLINE int TAO_ECG_CDR_Message_Sender::get_local_addr ACE_INET_Addr   addr
 

Get the local endpoint used to send the events.

void TAO_ECG_CDR_Message_Sender::init TAO_ECG_Refcounted_Endpoint endpoint_rptr    ACE_ENV_ARG_DECL throw (CORBA::SystemException)
 

Set the endpoint for sending messages.

If init () is successful, shutdown () must be called when the sender is no longer needed. If shutdown () is not called by the user, cleanup activities will be performed by the destructor.

ACE_INLINE CORBA::ULong TAO_ECG_CDR_Message_Sender::mtu void    const
 

Get the local endpoint used to send the events.

ACE_INLINE int TAO_ECG_CDR_Message_Sender::mtu CORBA::ULong    mtu
 

The sender may need to fragment the message, otherwise the network may drop the packets. Setting the MTU can fail if the value is too small (at least the header + 8 bytes must fit).

void TAO_ECG_CDR_Message_Sender::send_fragment const ACE_INET_Addr   addr,
CORBA::ULong    request_id,
CORBA::ULong    request_size,
CORBA::ULong    fragment_size,
CORBA::ULong    fragment_offset,
CORBA::ULong    fragment_id,
CORBA::ULong    fragment_count,
iovec    iov[],
int iovcnt    ACE_ENV_ARG_DECL
[private]
 

Send one fragment, the first entry in the iovec is used to send the header, the rest of the iovec array should contain pointers to the actual data.

void TAO_ECG_CDR_Message_Sender::send_message const TAO_OutputCDR   cdr,
const ACE_INET_Addr &addr    ACE_ENV_ARG_DECL
throw (CORBA::SystemException)
 

The main method - send a CDR message.

Todo:
Under some platforms, notably Linux, the fragmentation code in this method is woefully naive. The fragments are sent it a big burst, unfortunately, that can fill up the local kernel buffer before all the data is sent. In those circumstances some of the fragments are silently (gulp!) dropped by the kernel, check the documentation for sendto(2) specially the ENOBUFS error condition. There is no easy solution that I know off, except "pacing" the fragments, i.e. never sending more than a prescribed number of bytes per-second, sleeping before sending more or queueing them to send later via the reactor.

ACE_INLINE void TAO_ECG_CDR_Message_Sender::shutdown ACE_ENV_SINGLE_ARG_DECL   
 


Member Data Documentation

CORBA::Boolean TAO_ECG_CDR_Message_Sender::checksum_ [private]
 

Should crc checksum be caluclated and sent?

TAO_ECG_Refcounted_Endpoint TAO_ECG_CDR_Message_Sender::endpoint_rptr_ [private]
 

The datagram used for sendto ().

CORBA::ULong TAO_ECG_CDR_Message_Sender::mtu_ [private]
 

The MTU for this sender...


The documentation for this class was generated from the following files:
Generated on Fri Apr 2 18:32:11 2004 for TAO_RTEvent by doxygen1.2.18