VR-Link API Documentation for HLA 1.3
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
DtDisSocket Class Reference

The DtDisSocket class provides an address family independent datagram socket. More...

+ Inheritance diagram for DtDisSocket:
+ Collaboration diagram for DtDisSocket:

List of all members.

Classes

struct  DtDisSocketPduHeader

Public Member Functions

 DtDisSocket (const DtInetEndpoint &dest, DtU16 localPort=0, DtInetDevice *hostIf=NULL, DtU32 flags=DtDefaultSockOpts, bool immediateOpen=true, bool suppressSelfReflectEnabled=false)
 DIS Socket Constructor.
virtual ~DtDisSocket ()
 Destructor.
virtual bool openSocket ()
 Enable sending and receiving of packets.
virtual bool closeSocket ()
 Close a socket.
virtual DtInetSockRcvStatus recvFrom (caddr_t buff, size_t buffSize, DtInetEndpoint &src, DtU32 flags=0)
 Receive method override The DtInetUdpSocket base class revcFrom() method does not perform unbundling, PDU filtering, or self-reflect suppression.
virtual bool addDestination (const DtInetEndpoint &destination)
 Add an additional destination.
virtual void removeDestination (const DtInetEndpoint &destination)
 Remove a destination.
virtual DtPduFilterTestexerciseId ()
 DIS PDU filtering extension interface.
virtual DtPduFilterTestprotocolVersion ()
virtual DtPduFilterTestpduKind ()
virtual DtPduFilterTestipAddr ()
virtual DtInetEndpointlocalSenderEndpoint () const
 Return the endpoint of the sender.
virtual DtInetSockFlushStatus flush ()
 Flush bundles. This method is called to flush all queued bundles.
virtual int suppressSelfReflect (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status)
 Supress self-reflection method.
virtual int filterExercisePdus (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status)
 Filter out PDUs which match the parameters configured in the DtPduFilterTests.
Send methods.

The base class send methods are overridden to provide the optional capability to bundle/unbundle and to filter self-reflects by sending PDUs from a different socket on an ephemeral port

virtual int send (caddr_t packet, size_t size, DtU32 flags=0)
 Sends only to the given destination.
virtual int sendTo (caddr_t packet, size_t size, DtInetEndpoint &dest, DtU32 flags=0)
 Sends only to the given destination.
virtual int sendChain (DtInetBufferChain &packets, DtU32 flags=0)
 Sends only to the given destination.
virtual int sendChainTo (DtInetBufferChain &packets, DtInetEndpoint &dest, DtU32 flags=0)
 Sends only to the given destination.
Set / get socket options.

These methods provides an interface to all supported socket options.

These are only applied to the send socket when self-reflect suppression is enabled.

virtual bool setSendSockNonBlockingOption (bool onOrOff)
virtual bool setSendSockSendBuffSize (DtU32 size)
virtual bool setSendSockRcvBuffSize (DtU32 size)
virtual bool setSendSockBroadcastOption (bool onOrOff)
virtual bool setSendSockReuseAddrOption (bool onOrOff)
virtual bool setSendSockDoNotRouteOption (bool onOrOff)
virtual bool setSendSockSendLowWatermark (DtU32 size)
virtual bool setSendSockRcvLowWatermark (DtU32 size)
virtual bool setSendSockMcastDevice (DtInetAddr devAddr)
virtual bool setSendSockMcastDevice (DtInetDevice *hostIf)
virtual DtU32 getSendSockSendBuffSize ()
virtual DtU32 getSendSockRcvBuffSize ()
virtual DtU32 getSendSockBytesAvailable ()
virtual bool getSendSockBroadcastOption ()
virtual bool getSendSockReuseAddrOption ()
virtual bool getSendSockDoNotRouteOption ()
virtual DtU32 getSendSockSendLowWatermark ()
virtual DtU32 getSendSockRcvLowWatermark ()
Multicast specific methods.

Join / drop subscription to multicast group.

Socket will join group identified by the multicast address in grpAddr or grpEndpoint. If an object is passed in the port value of the endpoint will be ignored and the socket will join from the same port the socket's local endpoint uses. If no interface is specified in the join it will join on the host's default multicast interface.

virtual bool sendSockJoinMulticastGroup (DtInetAddr grpAddr, DtInetDevice *device=NULL)
 Change the default time-to-live on outbound multicast packets sent from this socket.
virtual bool sendSockJoinMulticastGroup (DtInetEndpoint grpEndpoint, DtInetDevice *device=NULL)
 Change the default time-to-live on outbound multicast packets sent from this socket.
virtual bool sendSockDropMulticastGroup (DtInetAddr grpAddr, DtInetDevice *device=NULL)
 Change the default time-to-live on outbound multicast packets sent from this socket.
virtual bool sendSockDropMulticastGroup (DtInetEndpoint grpEndpoint, DtInetDevice *device=NULL)
 Change the default time-to-live on outbound multicast packets sent from this socket.
virtual bool setSendSockMcastTtlOption (DtU32 ttl)
 Change the default time-to-live on outbound multicast packets sent from this socket.
DIS PDU bundling extension functions.
virtual void setBundling (int maxBundleSize, bool enableUnbundling, int minPacketSize, int sizeOffset, int sizeLength, bool testDisHeader)
 Bundling is only performed when using the sendChain(), sendChainTo(), recvToChain(), and recvToChainFrom() methods.
Set / get bundle maximum bundle size.

Setting maximum bundle size > 0 enables bundling.

Setting max bundle size to 0 disables bundling. For optimal network performance max bundle sizes should be slightly less than the MTU of the network.

virtual bool setMaxBundleSize (int size)
virtual int getMaxBundleSize ()
virtual bool isBundling ()
Set / get unbundling status.

Pass 0 to setUnbundling to disable unbundling, 1 to enable it.

Unbundling is enabled by default.

virtual void setUnbundling (int onOrOff)
virtual int isUnbundling ()
Set / get minimum valid packet size.

If not set manually, the min.

size is based on DtNetPduHeader for backwards compatibility. Currently used only when unbundling enabled

virtual void setMinPacketSize (int size)
virtual int minPacketSize ()
Bundling methods.

These methods are called from the bundling callback functions to perform the actual work.

virtual int addToBundle (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep)
virtual int unbundle (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status)
virtual int getNextBundle (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status)
virtual DtInetSockFlushStatus flushBundle (DtInetEndpoint &ep)

Protected Member Functions

virtual void * disSendSocket ()
 Return the underlying Boost class socket objects.
virtual DtInetDevicefindInterface (const DtInetAddr &dest)
 Find the correct interface from which to send to the specified destination.
virtual DtU16 getPduSize (DtDisSocketPduHeader *hdr, int hdrOffset, DtInetBufferChain::iterator current, DtInetBufferChain::iterator end, int *status)

Static Protected Member Functions

static int suppressSelfReflect (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr)
 Supress self-reflection callback.
static int filterExercisePdus (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr)
 PDU filtering callback.
Bundling callbacks.

All pre- and post- processing callbacks must return the total number of bytes in buffChain after processing or a negative value if an error occurs.

The static methods are registered as callbacks, but the actual work takes place in the bundling methods.

static int addToBundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr)
static int flushBundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr)
static int unbundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr)
static int getNextBundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr)

Protected Attributes

void * mySendSocketIoService
 Using Void pointer to abstract a boost type actual type: boost::asio::io_service*.
void * mySendSocket
 Using Void pointer to abstract a boost type actual type: boost::asio::ip::udp::socket*.
DtInetEndpoint mySendEndpoint
std::set< DtInetEndpointmyAdditionalDestinations
bool mySuppressSelfReflect
DtInetUtils::DtInetSockOutboundBundleMap myOutboundBundles
DtInetUtils::DtInetSockInboundBundleQueue myInboundBundles
int myMaxBundleSize
int myMinBundleSize
bool myUnbundlingEnabled
DtPduFilterTest myVersionFilter
DtPduFilterTest myExerciseFilter
DtPduFilterTest myKindFilter
DtPduFilterTest myAddrFilter

Private Member Functions

 DtDisSocket (const DtDisSocket &orig)
 Copy constructor not implemented.
DtDisSocketoperator= (const DtDisSocket &orig)
 Assignment not implemented.

Private Attributes

DtDisSockPimplmyAsyncSendSockPimpl

Friends

class DtDisSockPimpl
 For async operations.

Detailed Description

The DtDisSocket class provides an address family independent datagram socket.


Constructor & Destructor Documentation

DtDisSocket::DtDisSocket ( const DtInetEndpoint dest,
DtU16  localPort = 0,
DtInetDevice hostIf = NULL,
DtU32  flags = DtDefaultSockOpts,
bool  immediateOpen = true,
bool  suppressSelfReflectEnabled = false 
)

DIS Socket Constructor.

Takes a destination endpoint, a source port to use, a pointer to the local network interface device the socket will be bound to, socket option flags, an 'immediateOpen' indicator dictating how the socket should behave upon creation, and a flag to enable self- reflect suppression. If the destination endpoint port is 0 the default DIS port (3000) will be used. The address family (IPv4 or IPv6) is assumed from the destination endpoint object. If suppressSelfReflect is true all packets will be sent from the specified local port or an automatically chosen ephemeral if the localPort parameter is 0. If no host interface is specified the most appropriate interface will be chosen based on the destination. If the destination endpoint specifies a multicast address the multicast group is joined automatically when the socket is opened and the group membership is dropped when the socket is closed. If the 'immediateOpen' parameter is true the socket will immediately try to bind to an interface and allow datagrams to be sent and received. To use custom packet handlers for the send and receive functions the handlers must be set before any call to any of the send and receive methods. To ensure the handlers are configured it is recommended that 'immediateOpen' be set to false so the packet handler callbacks can be configured, then call openSocket(). This ctor will not throw exceptions on failure. Check the socket status by calling state() (or isOk()) to determine if the socket is ready.

virtual DtDisSocket::~DtDisSocket ( ) [virtual]

Destructor.

DtDisSocket::DtDisSocket ( const DtDisSocket orig) [private]

Copy constructor not implemented.


Member Function Documentation

virtual bool DtDisSocket::addDestination ( const DtInetEndpoint destination) [virtual]

Add an additional destination.

Packets will be sent to these destinations in addition to the sockets destination. Return indicates if destination was added successfully (true) or not (false).

virtual int DtDisSocket::addToBundle ( int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep 
) [virtual]
static int DtDisSocket::addToBundle ( DtInetSocket sock,
int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
void *  usr 
) [static, protected]
virtual bool DtDisSocket::closeSocket ( ) [virtual]

Close a socket.

Returns true on successful close or false on failure. Call getLastError() and getLastErrorString() to retrieve cause of failure. The base class method is overridden to provide the optional capability to filter self-reflects by sending PDUs from a different socket on an ephemeral port

Reimplemented from DtInetUdpSocket.

virtual void* DtDisSocket::disSendSocket ( ) [protected, virtual]

Return the underlying Boost class socket objects.

DtPduFilterTest * DtDisSocket::exerciseId ( ) [inline, virtual]

DIS PDU filtering extension interface.

virtual int DtDisSocket::filterExercisePdus ( int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
int *  status 
) [virtual]

Filter out PDUs which match the parameters configured in the DtPduFilterTests.

static int DtDisSocket::filterExercisePdus ( DtInetSocket sock,
int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
void *  usr 
) [static, protected]

PDU filtering callback.

This should always be added to the callbacks. The individual filtering tests can be enabled / disabled on the fly.

virtual DtInetDevice* DtDisSocket::findInterface ( const DtInetAddr dest) [protected, virtual]

Find the correct interface from which to send to the specified destination.

This is only used when no host interface is specified for the socket in order to determine which interface on a multi-homed host can send to the destination broadcast or multicast address.

Flush bundles. This method is called to flush all queued bundles.

static int DtDisSocket::flushBundle ( DtInetSocket sock,
int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
void *  usr 
) [static, protected]
virtual int DtDisSocket::getMaxBundleSize ( ) [virtual]
virtual int DtDisSocket::getNextBundle ( int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
int *  status 
) [virtual]
static int DtDisSocket::getNextBundle ( DtInetSocket sock,
int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
void *  usr 
) [static, protected]
virtual DtU16 DtDisSocket::getPduSize ( DtDisSocketPduHeader hdr,
int  hdrOffset,
DtInetBufferChain::iterator  current,
DtInetBufferChain::iterator  end,
int *  status 
) [protected, virtual]
virtual bool DtDisSocket::getSendSockBroadcastOption ( ) [virtual]
virtual bool DtDisSocket::getSendSockDoNotRouteOption ( ) [virtual]
virtual bool DtDisSocket::getSendSockReuseAddrOption ( ) [virtual]
DtPduFilterTest * DtDisSocket::ipAddr ( ) [inline, virtual]
virtual bool DtDisSocket::isBundling ( ) [virtual]
virtual int DtDisSocket::isUnbundling ( ) [virtual]
virtual DtInetEndpoint& DtDisSocket::localSenderEndpoint ( ) const [virtual]

Return the endpoint of the sender.

This will differ from the receiving endpoint when self-reflect suppression is enabled.

virtual int DtDisSocket::minPacketSize ( ) [virtual]
virtual bool DtDisSocket::openSocket ( ) [virtual]

Enable sending and receiving of packets.

Returns true on success or false on failure. Call getLastError() and getLastErrorString() to retrieve cause of failure. The base class method is overridden to provide the optional capability to filter self-reflects by sending PDUs from a different socket on an ephemeral port

Reimplemented from DtInetUdpSocket.

DtDisSocket& DtDisSocket::operator= ( const DtDisSocket orig) [private]

Assignment not implemented.

DtPduFilterTest * DtDisSocket::pduKind ( ) [inline, virtual]
virtual DtInetSockRcvStatus DtDisSocket::recvFrom ( caddr_t  buff,
size_t  buffSize,
DtInetEndpoint src,
DtU32  flags = 0 
) [virtual]

Receive method override The DtInetUdpSocket base class revcFrom() method does not perform unbundling, PDU filtering, or self-reflect suppression.

For backward compatibility those additional tasks are supported in all DIS socket receive methods.

Reimplemented from DtInetUdpSocket.

virtual void DtDisSocket::removeDestination ( const DtInetEndpoint destination) [virtual]

Remove a destination.

Address will be removed from the list of additional destinations for sending packets.

virtual int DtDisSocket::send ( caddr_t  packet,
size_t  size,
DtU32  flags = 0 
) [virtual]

Sends only to the given destination.

Reimplemented from DtInetUdpSocket.

virtual int DtDisSocket::sendChain ( DtInetBufferChain packets,
DtU32  flags = 0 
) [virtual]

Sends only to the given destination.

Reimplemented from DtInetUdpSocket.

virtual int DtDisSocket::sendChainTo ( DtInetBufferChain packets,
DtInetEndpoint dest,
DtU32  flags = 0 
) [virtual]

Sends only to the given destination.

Reimplemented from DtInetUdpSocket.

virtual bool DtDisSocket::sendSockDropMulticastGroup ( DtInetAddr  grpAddr,
DtInetDevice device = NULL 
) [virtual]

Change the default time-to-live on outbound multicast packets sent from this socket.

virtual bool DtDisSocket::sendSockDropMulticastGroup ( DtInetEndpoint  grpEndpoint,
DtInetDevice device = NULL 
) [virtual]

Change the default time-to-live on outbound multicast packets sent from this socket.

virtual bool DtDisSocket::sendSockJoinMulticastGroup ( DtInetAddr  grpAddr,
DtInetDevice device = NULL 
) [virtual]

Change the default time-to-live on outbound multicast packets sent from this socket.

virtual bool DtDisSocket::sendSockJoinMulticastGroup ( DtInetEndpoint  grpEndpoint,
DtInetDevice device = NULL 
) [virtual]

Change the default time-to-live on outbound multicast packets sent from this socket.

virtual int DtDisSocket::sendTo ( caddr_t  packet,
size_t  size,
DtInetEndpoint dest,
DtU32  flags = 0 
) [virtual]

Sends only to the given destination.

Reimplemented from DtInetUdpSocket.

virtual void DtDisSocket::setBundling ( int  maxBundleSize,
bool  enableUnbundling,
int  minPacketSize,
int  sizeOffset,
int  sizeLength,
bool  testDisHeader 
) [virtual]

Bundling is only performed when using the sendChain(), sendChainTo(), recvToChain(), and recvToChainFrom() methods.

If maxBundleSize == 0 bundling is disabled. Unbundling is enabled by default. Deprecated. Provided for backwards compatibility.

Set all bundling parameters at once. The sizeOffset, sizeLength, and testDisHeader arguments are ignored.

virtual bool DtDisSocket::setMaxBundleSize ( int  size) [virtual]
virtual void DtDisSocket::setMinPacketSize ( int  size) [virtual]
virtual bool DtDisSocket::setSendSockBroadcastOption ( bool  onOrOff) [virtual]
virtual bool DtDisSocket::setSendSockDoNotRouteOption ( bool  onOrOff) [virtual]
virtual bool DtDisSocket::setSendSockMcastDevice ( DtInetAddr  devAddr) [virtual]
virtual bool DtDisSocket::setSendSockMcastDevice ( DtInetDevice hostIf) [virtual]
virtual bool DtDisSocket::setSendSockMcastTtlOption ( DtU32  ttl) [virtual]

Change the default time-to-live on outbound multicast packets sent from this socket.

virtual bool DtDisSocket::setSendSockNonBlockingOption ( bool  onOrOff) [virtual]
virtual bool DtDisSocket::setSendSockRcvBuffSize ( DtU32  size) [virtual]
virtual bool DtDisSocket::setSendSockRcvLowWatermark ( DtU32  size) [virtual]
virtual bool DtDisSocket::setSendSockReuseAddrOption ( bool  onOrOff) [virtual]
virtual bool DtDisSocket::setSendSockSendBuffSize ( DtU32  size) [virtual]
virtual bool DtDisSocket::setSendSockSendLowWatermark ( DtU32  size) [virtual]
virtual void DtDisSocket::setUnbundling ( int  onOrOff) [virtual]
virtual int DtDisSocket::suppressSelfReflect ( int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
int *  status 
) [virtual]

Supress self-reflection method.

Filters out PDUs which originated from this socket's send port.

static int DtDisSocket::suppressSelfReflect ( DtInetSocket sock,
int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
void *  usr 
) [static, protected]

Supress self-reflection callback.

The real work is done by the public suppressSelfReflect method

virtual int DtDisSocket::unbundle ( int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
int *  status 
) [virtual]
static int DtDisSocket::unbundle ( DtInetSocket sock,
int  size,
DtInetBufferChain buffChain,
DtInetEndpoint ep,
void *  usr 
) [static, protected]

Friends And Related Function Documentation

friend class DtDisSockPimpl [friend]

For async operations.


Member Data Documentation

void* DtDisSocket::mySendSocket [protected]

Using Void pointer to abstract a boost type actual type: boost::asio::ip::udp::socket*.

Using Void pointer to abstract a boost type actual type: boost::asio::io_service*.


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

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)