MAK RTIspy API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
DtRtiMsgForwarder Class Reference

DtRtiMsgForwarder manages connections and message distribution to local federates and remote Forwarders (if any). More...

+ Inheritance diagram for DtRtiMsgForwarder:
+ Collaboration diagram for DtRtiMsgForwarder:

Classes

struct  ConnectionInfo
 

Public Types

typedef DtBoost::shared_ptr
< ConnectionInfo
ConnectionInfoSP
 
typedef DtBoost::weak_ptr
< ConnectionInfo
ConnectionInfoWP
 
typedef std::map< const
DtTcpMsgSocket
*, ConnectionInfoSP
SocketToConnInfoMap
 

Public Member Functions

virtual ~DtRtiMsgForwarder ()
 Destructor. More...
 
virtual void init ()
 Initialize the forwarder (called by creator) More...
 
virtual bool hasExec () const
 Query the rtiExec Handshake monitor for whether it has an exec. More...
 
virtual void run ()
 Main execution routine. More...
 
virtual void setEnableBundling (unsigned int maxBundleSize)
 Get the rtiexec's socket if known. More...
 
virtual void setUseSmartForwarding (bool yesNo)
 Enable Smart DM Subscription Filtering. More...
 
virtual void setUseInternalSmartForwarding (bool yesNo)
 Enable Smart DM Subscription Filtering for internal messages. More...
 
virtual void setRouteFedexMessages (bool yesNo)
 Enable Smart Fedex Message Filtering. More...
 
virtual void addPacketFilter (DtMessageFilter *filter)
 [Un]Register a forwarding filter on incoming packets More...
 
virtual void removePacketFilter (DtMessageFilter *filter)
 
virtual unsigned long forwarderId () const
 Return the forwarder ID (defines the address space for connIds for this forwarder) More...
 
virtual void setForwarderId (unsigned long newId)
 set the forwarder ID. More...
 
void updateTcpForwarderQueuedSockets ()
 update the tcp forwarders queued sockets More...
 
virtual const
DtRtiMsgForwarder::SocketToConnInfoMap
getConnToConnInfoMap () const
 WARNING: These methods are not thread-safe and may only be called by the back-end forwarder thread! More...
 
virtual ConnectionInfoSP getConnectionInfoByConnId (unsigned long connId) const
 Get a shared pointer to the connection info for a connection by Conn ID. More...
 
virtual ConnectionInfoSP getConnectionInfoByHandle (unsigned long federateHandle) const
 Get a shared pointer to the connection info for a connection by Federate Handle. More...
 
virtual ConnectionInfoSP getConnectionInfoBySocket (const DtTcpMsgSocket *sock) const
 Get a shared pointer to the connection info for a connection by Socket. More...
 
virtual std::pair< bool,
unsigned long > 
rtiExecConnected () const
 Is the rtiexec connected and if so what is its connId? More...
 
virtual void sendMessage (const DtRtiMsg &msg, const DtTcpMsgSocket *src=0)
 Send a message to all local sockets (filters will be applied) More...
 
virtual void requestCloseAllConnections ()
 Disconnect all open connections after this pass through run-loop completes. More...
 
virtual void requestKillSingleConnection (const DtTcpMsgSocket *sock)
 Disconnect the requestedTcpSocket. More...
 
virtual void markConnectionAsAboutToBeDeleted (DtTcpMsgSocket const *socket, unsigned int connectionId)
 Mark the given socket as one that is to be deleted silently. More...
 
virtual bool isConnectionMarkedForDeletion (unsigned int connectionId) const
 Return boolean: given connection has been marked for deletion? More...
 
virtual void removeOldConnection (unsigned int connectionId)
 Remove the socket specified by the given connection. More...
 
virtual void shutdownRequestedByExec ()
 Shutdown the forwarder application. More...
 
virtual bool updateFederateConnectionId (unsigned long orig, unsigned long final)
 Set a locally connected federate's connId in the associated connection info struct. More...
 
virtual void updateConnectionProcessParameters (unsigned long connId, unsigned long processId, MAKRti::DtString processName, MAKRti::DtString commandArgs)
 Set a connections process information. More...
 
virtual bool shouldStop ()
 should this forwarder stop. More...
 

Static Public Member Functions

static DtRtiMsgForwardercreate (unsigned long id, const DtRIDParameters &params)
 Create an instance of a DtRtiMsgForwarder. More...
 
static void setCreatorFunction (DtRtiMsgFwderCreator fn)
 Call this function to set an alternate creator function With this function, users can replace this DtRtiMsgForwarder with their own derived class. More...
 
static void tcpSocketAdditionCb (DtTcpMsgSocket *sock, void *usr)
 Callbacks on addition/removal of TCP sockets. More...
 
static void tcpSocketRemovalCb (DtTcpMsgSocket *sock, void *usr)
 

Protected Member Functions

 DtRtiMsgForwarder (unsigned long id, const DtRIDParameters &params)
 Default Constructor. More...
 
virtual void performMcastDiscovery ()
 
virtual void applyRegisteredFilters ()
 Enable / Disable all filters registered with forwarder. More...
 
virtual void disableRegisteredFilters ()
 
virtual void waitForIo ()
 Wait on sockets for next IO event (allows RTIspy users to control the wait mechanism and period) More...
 
virtual void tcpSocketAdditionCb (DtTcpMsgSocket *sock)
 
virtual void tcpSocketRemovalCb (DtTcpMsgSocket *sock)
 
virtual unsigned long consumeConnId ()
 Get and consume Connection ID. More...
 
virtual void preRunLoopEvent ()
 Plug-in defined Run Loop operations Gives users the ability to add functionality to the Run() loop without over-riding it completely. More...
 
virtual void runLoopEvent ()
 
virtual void postRunLoopEvent ()
 
virtual bool populateConnectionInformation (unsigned int &numForwarderToForwarderConns, std::vector< MAKRti::DtString > &forwarderIdentifiers, std::vector< MAKRti::DtString > &forwarderConnectionHostNames, std::vector< MAKRti::DtInetAddr > &forwarderConnectionAddrs, unsigned int &numForwarderClientConns, std::vector< MAKRti::DtString > &clientConnectionHostNames, std::vector< MAKRti::DtInetAddr > &clientConnectionAddrs) const
 
virtual void closeAllConnectionsIfRequested ()
 Disconnect all open connections. More...
 
 DtRtiMsgForwarder (const DtRtiMsgForwarder &orig)
 Copy Ctor and Assignment Operator unimplemented. More...
 
DtRtiMsgForwarderoperator= (const DtRtiMsgForwarder &orig)
 

Protected Attributes

unsigned long myForwarderId
 Data Members. More...
 
MAKRti::DtInetAddr myForwarderAddr
 Local host IP address (used by rtiExec monitor filter, among other uses) More...
 
bool myCloseAllConnectionsRequested
 Connection shutdown requested? More...
 
DtFilteredTcpForwardermyTcpForwarder
 Tcp Forwarder with Filtering Capabilities. More...
 
DtTcpMsgSocketMgrmySocketMgr
 Tcp Socket Manager (handles passive connections to Federates) More...
 
int myPort
 Port for local federate connections. More...
 
int myTcpNoDelay
 
unsigned long myNextConnectionIdOffset
 The ID to be assigned to the next Federate or Forwarder connection The IDs are offset from the forwarderId. More...
 
unsigned int myPacketBundleSize
 Packet Bundle size (if bundle size = 0, bundling is disabled) More...
 
DtRtiExecTrackingFiltermyRtiExecMonitor
 If registered, Monitors rtiexec connection life-cycle. More...
 
DtRoutePrinterFiltermyRoutePrinter
 Smart DM Forwarding Filters. More...
 
DtInternalRoutePrinterFiltermyInternalRoutePrinter
 
DtUpdateInterRoutingFiltermyDmMsgRouter
 
DtInternalRoutingFiltermyIntMsgRouter
 
DtFedexMsgFiltermyFedexMsgRouter
 Fedex Routing Filter. More...
 
DtConnectConfirmFiltermyConnectConfirmFilter
 Extracts info from connect confirm messages. More...
 
DtDeleteSocketFiltermySocketMonitor
 Marks sockets that are being disconnected normally so that no complaint is given when they disconnect versus abnormal disconnect. More...
 
const DtRIDParametersmyParams
 Local access to the RID Parameters. More...
 
DtMulitcastDiscoveryMgr myMcastDiscoveryMgr
 
DtThreadSafe< std::deque
< DtMsgFwdrFunctor * > > 
myPendingProxyCommands
 
std::vector< DtMessageFilter * > myRegisteredFilters
 Registered Message Filters. More...
 
SocketToConnInfoMap myConnToConnInfoMap
 Map from socket (conn) to ConnectionInfo object for that connection notes: More...
 
std::set< DtTcpMsgSocket const * > myConnectionsAboutToBeDeleted
 Set of connections that when deleted there should be no complaint. More...
 
MAKRti::DtSelectParamWithWrite mySelectParams
 
bool myShouldStop
 should this forwarder stop. More...
 
MAKRti::DtString myHostname
 

Static Protected Attributes

static DtRtiMsgFwderCreator theCreator
 

Detailed Description

DtRtiMsgForwarder manages connections and message distribution to local federates and remote Forwarders (if any).

It is designed to run as a thread, asynchronous to the main execution.

Member Typedef Documentation

Constructor & Destructor Documentation

DtRtiMsgForwarder::DtRtiMsgForwarder ( unsigned long  id,
const DtRIDParameters params 
)
protected

Default Constructor.

virtual DtRtiMsgForwarder::~DtRtiMsgForwarder ( )
virtual

Destructor.

DtRtiMsgForwarder::DtRtiMsgForwarder ( const DtRtiMsgForwarder orig)
protected

Copy Ctor and Assignment Operator unimplemented.

Member Function Documentation

virtual void DtRtiMsgForwarder::addPacketFilter ( DtMessageFilter filter)
virtual

[Un]Register a forwarding filter on incoming packets

  • Filters directly modify the current Destination list
virtual void DtRtiMsgForwarder::applyRegisteredFilters ( )
protectedvirtual

Enable / Disable all filters registered with forwarder.

  • called only once at start and stop of run
virtual void DtRtiMsgForwarder::closeAllConnectionsIfRequested ( )
protectedvirtual

Disconnect all open connections.

virtual unsigned long DtRtiMsgForwarder::consumeConnId ( )
protectedvirtual

Get and consume Connection ID.

static DtRtiMsgForwarder* DtRtiMsgForwarder::create ( unsigned long  id,
const DtRIDParameters params 
)
static

Create an instance of a DtRtiMsgForwarder.

virtual void DtRtiMsgForwarder::disableRegisteredFilters ( )
protectedvirtual
unsigned long DtRtiMsgForwarder::forwarderId ( ) const
inlinevirtual

Return the forwarder ID (defines the address space for connIds for this forwarder)

References myForwarderId.

virtual ConnectionInfoSP DtRtiMsgForwarder::getConnectionInfoByConnId ( unsigned long  connId) const
virtual

Get a shared pointer to the connection info for a connection by Conn ID.

virtual ConnectionInfoSP DtRtiMsgForwarder::getConnectionInfoByHandle ( unsigned long  federateHandle) const
virtual

Get a shared pointer to the connection info for a connection by Federate Handle.

virtual ConnectionInfoSP DtRtiMsgForwarder::getConnectionInfoBySocket ( const DtTcpMsgSocket sock) const
virtual

Get a shared pointer to the connection info for a connection by Socket.

const DtRtiMsgForwarder::SocketToConnInfoMap & DtRtiMsgForwarder::getConnToConnInfoMap ( ) const
inlinevirtual

WARNING: These methods are not thread-safe and may only be called by the back-end forwarder thread!

Get a handle to the connection to connId map

References myConnToConnInfoMap.

virtual bool DtRtiMsgForwarder::hasExec ( ) const
virtual

Query the rtiExec Handshake monitor for whether it has an exec.

virtual void DtRtiMsgForwarder::init ( )
virtual

Initialize the forwarder (called by creator)

Reimplemented in DtExtendedRtiMsgForwarder.

virtual bool DtRtiMsgForwarder::isConnectionMarkedForDeletion ( unsigned int  connectionId) const
virtual

Return boolean: given connection has been marked for deletion?

virtual void DtRtiMsgForwarder::markConnectionAsAboutToBeDeleted ( DtTcpMsgSocket const *  socket,
unsigned int  connectionId 
)
virtual

Mark the given socket as one that is to be deleted silently.

The forwarder won't complain when the given socket disconnects. If known, the socket connection ID should be provided A confirmation message is returned through the socket.

DtRtiMsgForwarder& DtRtiMsgForwarder::operator= ( const DtRtiMsgForwarder orig)
protected
virtual void DtRtiMsgForwarder::performMcastDiscovery ( )
protectedvirtual
virtual bool DtRtiMsgForwarder::populateConnectionInformation ( unsigned int &  numForwarderToForwarderConns,
std::vector< MAKRti::DtString > &  forwarderIdentifiers,
std::vector< MAKRti::DtString > &  forwarderConnectionHostNames,
std::vector< MAKRti::DtInetAddr > &  forwarderConnectionAddrs,
unsigned int &  numForwarderClientConns,
std::vector< MAKRti::DtString > &  clientConnectionHostNames,
std::vector< MAKRti::DtInetAddr > &  clientConnectionAddrs 
) const
protectedvirtual
virtual void DtRtiMsgForwarder::postRunLoopEvent ( )
inlineprotectedvirtual
virtual void DtRtiMsgForwarder::preRunLoopEvent ( )
inlineprotectedvirtual

Plug-in defined Run Loop operations Gives users the ability to add functionality to the Run() loop without over-riding it completely.

virtual void DtRtiMsgForwarder::removeOldConnection ( unsigned int  connectionId)
virtual

Remove the socket specified by the given connection.

Used by reconnect to clean up orphaned sockets where client detected break but server has not.

virtual void DtRtiMsgForwarder::removePacketFilter ( DtMessageFilter filter)
virtual
virtual void DtRtiMsgForwarder::requestCloseAllConnections ( )
virtual

Disconnect all open connections after this pass through run-loop completes.

  • cannot immediately disconnect since this may be called from a RTI Forwarder callback
virtual void DtRtiMsgForwarder::requestKillSingleConnection ( const DtTcpMsgSocket sock)
virtual

Disconnect the requestedTcpSocket.

Introduced so that the rtiExecTrackingFilter can have connections deleted. The alternative is that the myTcpForwarder be made publicly accessible. Filter will call this on sockets from which it receives rtiExecReconnectMsgs when it is still connected to the rtiExec, and connect and disconnect messages from the exec when we are still connected and are not connected to the rtiExec respectively.

virtual std::pair< bool, unsigned long > DtRtiMsgForwarder::rtiExecConnected ( ) const
virtual

Is the rtiexec connected and if so what is its connId?

virtual void DtRtiMsgForwarder::run ( )
virtual

Main execution routine.

  • Called by start() when run as a thread
  • Can be called directly to run sequentially
virtual void DtRtiMsgForwarder::runLoopEvent ( )
inlineprotectedvirtual
virtual void DtRtiMsgForwarder::sendMessage ( const DtRtiMsg msg,
const DtTcpMsgSocket src = 0 
)
virtual

Send a message to all local sockets (filters will be applied)

static void DtRtiMsgForwarder::setCreatorFunction ( DtRtiMsgFwderCreator  fn)
static

Call this function to set an alternate creator function With this function, users can replace this DtRtiMsgForwarder with their own derived class.

virtual void DtRtiMsgForwarder::setEnableBundling ( unsigned int  maxBundleSize)
virtual

Get the rtiexec's socket if known.

Enable Message Bundling optimization

virtual void DtRtiMsgForwarder::setForwarderId ( unsigned long  newId)
virtual

set the forwarder ID.

virtual void DtRtiMsgForwarder::setRouteFedexMessages ( bool  yesNo)
virtual

Enable Smart Fedex Message Filtering.

virtual void DtRtiMsgForwarder::setUseInternalSmartForwarding ( bool  yesNo)
virtual

Enable Smart DM Subscription Filtering for internal messages.

virtual void DtRtiMsgForwarder::setUseSmartForwarding ( bool  yesNo)
virtual

Enable Smart DM Subscription Filtering.

virtual bool DtRtiMsgForwarder::shouldStop ( )
virtual

should this forwarder stop.

virtual void DtRtiMsgForwarder::shutdownRequestedByExec ( )
virtual

Shutdown the forwarder application.

Triggered by the rtiExec sending a forwarderShutdown message to the RTI Forwarder.

static void DtRtiMsgForwarder::tcpSocketAdditionCb ( DtTcpMsgSocket sock,
void *  usr 
)
static

Callbacks on addition/removal of TCP sockets.

virtual void DtRtiMsgForwarder::tcpSocketAdditionCb ( DtTcpMsgSocket sock)
protectedvirtual

Reimplemented in DtExtendedRtiMsgForwarder.

static void DtRtiMsgForwarder::tcpSocketRemovalCb ( DtTcpMsgSocket sock,
void *  usr 
)
static
virtual void DtRtiMsgForwarder::tcpSocketRemovalCb ( DtTcpMsgSocket sock)
protectedvirtual

Reimplemented in DtExtendedRtiMsgForwarder.

virtual void DtRtiMsgForwarder::updateConnectionProcessParameters ( unsigned long  connId,
unsigned long  processId,
MAKRti::DtString  processName,
MAKRti::DtString  commandArgs 
)
virtual

Set a connections process information.

virtual bool DtRtiMsgForwarder::updateFederateConnectionId ( unsigned long  orig,
unsigned long  final 
)
virtual

Set a locally connected federate's connId in the associated connection info struct.

This should only need to be invoked when the forwarder is part of the federate's Forwarder Group, but not its primary forwarder.

void DtRtiMsgForwarder::updateTcpForwarderQueuedSockets ( )

update the tcp forwarders queued sockets

virtual void DtRtiMsgForwarder::waitForIo ( )
protectedvirtual

Wait on sockets for next IO event (allows RTIspy users to control the wait mechanism and period)

Member Data Documentation

bool DtRtiMsgForwarder::myCloseAllConnectionsRequested
protected

Connection shutdown requested?

DtConnectConfirmFilter* DtRtiMsgForwarder::myConnectConfirmFilter
protected

Extracts info from connect confirm messages.

std::set<DtTcpMsgSocket const*> DtRtiMsgForwarder::myConnectionsAboutToBeDeleted
protected

Set of connections that when deleted there should be no complaint.

SocketToConnInfoMap DtRtiMsgForwarder::myConnToConnInfoMap
protected

Map from socket (conn) to ConnectionInfo object for that connection notes:

  • infos may be shared by some registered filters (which is why the are SPs)
  • lrcs which have not joined (or have resigned) will have empty fields)

Referenced by getConnToConnInfoMap().

DtUpdateInterRoutingFilter* DtRtiMsgForwarder::myDmMsgRouter
protected
DtFedexMsgFilter* DtRtiMsgForwarder::myFedexMsgRouter
protected

Fedex Routing Filter.

MAKRti::DtInetAddr DtRtiMsgForwarder::myForwarderAddr
protected

Local host IP address (used by rtiExec monitor filter, among other uses)

unsigned long DtRtiMsgForwarder::myForwarderId
protected

Data Members.

Address space for connection IDs for this LAN (required to differentiate when there are multiple forwarders)

Referenced by forwarderId().

MAKRti::DtString DtRtiMsgForwarder::myHostname
protected
DtInternalRoutePrinterFilter* DtRtiMsgForwarder::myInternalRoutePrinter
protected
DtInternalRoutingFilter* DtRtiMsgForwarder::myIntMsgRouter
protected
DtMulitcastDiscoveryMgr DtRtiMsgForwarder::myMcastDiscoveryMgr
protected
unsigned long DtRtiMsgForwarder::myNextConnectionIdOffset
protected

The ID to be assigned to the next Federate or Forwarder connection The IDs are offset from the forwarderId.

unsigned int DtRtiMsgForwarder::myPacketBundleSize
protected

Packet Bundle size (if bundle size = 0, bundling is disabled)

const DtRIDParameters& DtRtiMsgForwarder::myParams
protected

Local access to the RID Parameters.

DtThreadSafe< std::deque<DtMsgFwdrFunctor*> > DtRtiMsgForwarder::myPendingProxyCommands
protected
int DtRtiMsgForwarder::myPort
protected

Port for local federate connections.

std::vector< DtMessageFilter* > DtRtiMsgForwarder::myRegisteredFilters
protected

Registered Message Filters.

DtRoutePrinterFilter* DtRtiMsgForwarder::myRoutePrinter
protected

Smart DM Forwarding Filters.

DtRtiExecTrackingFilter* DtRtiMsgForwarder::myRtiExecMonitor
protected

If registered, Monitors rtiexec connection life-cycle.

MAKRti::DtSelectParamWithWrite DtRtiMsgForwarder::mySelectParams
protected
bool DtRtiMsgForwarder::myShouldStop
protected

should this forwarder stop.

DtTcpMsgSocketMgr* DtRtiMsgForwarder::mySocketMgr
protected

Tcp Socket Manager (handles passive connections to Federates)

DtDeleteSocketFilter* DtRtiMsgForwarder::mySocketMonitor
protected

Marks sockets that are being disconnected normally so that no complaint is given when they disconnect versus abnormal disconnect.

DtFilteredTcpForwarder* DtRtiMsgForwarder::myTcpForwarder
protected

Tcp Forwarder with Filtering Capabilities.

int DtRtiMsgForwarder::myTcpNoDelay
protected
DtRtiMsgFwderCreator DtRtiMsgForwarder::theCreator
staticprotected

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

Document ID: Generated on Mon Sep 7 15:40:32 EDT 2020 from SVN revision 217499
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)