MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
inOutForwarderPort.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: inOutForwarderPort.h,v $ $Revision: 1.18 $ $State: Exp $
7 *******************************************************************************/
10 
11 #ifndef DtInOutForwarderPort_H_
12 #define DtInOutForwarderPort_H_
13 
14 #include "forwarderPort.h"
15 #include "routeMap.h"
16 #include "rtiMsConfig.h"
17 #include "peerToPeerSockMgr.h"
18 #include <vlutil/vlTime.h>
19 #include <udpMsgSocket.h>
20 #include <map>
21 
22 class DtRIDParameters;
23 class DtRouteMap;
24 class DtTcpSocketMgr__vl__;
26 class DtMacAddrMsg;
27 struct DtForwarderNodeInfo;
28 
34 {
35 
36 protected:
37 
40  DtBoost::shared_ptr<DtRouteMap> routes,
41  const MAKRti::DtInetAddr& host,
42  int forwarderPort,
43  const MAKRti::DtInetEndpoint& forwarderAddrToConnectTo );
44 
45 public:
46 
47  virtual ~DtInOutForwarderPort();
48 
50  virtual bool isReady() const;
51 
53  virtual DtAddressMsgPair getNextMsg();
54 
56  virtual bool getInitializationMsgs( DtForwarderPort::DtSocketSet& socks,
57  std::list<DtAddressMsgPair>& msgs, bool printBeDestMetadata);
58 
60  virtual bool getInitializationMsg( DtMsgSocket* sock,
61  DtAddressMsgPair& msg, bool printBeDestMetadata);
62 
64  virtual void sendByTransport( const DtForwarderMsg& msg ) const;
65 
67  virtual void sendToAllReliable( const DtForwarderMsg& msg ) const;
68 
71  virtual void sendToListReliable( const DtForwarderMsg& msg,
72  const DtAddressPortList& destinations ) const;
73 
75  virtual void selectParams( MAKRti::DtSelectParamWithWrite& selectParams );
76 
78  virtual void updateRoutes();
79 
80  // Retrieve and process initialization messages if necessary.
81  virtual void processInitializationMessages();
82 
83  // Process message acting on connection messages if necessary.
84  virtual void processConnectionMessages(const DtAddressMsgPair& msgPair);
85 
88  virtual int checkConnectionStatus( const DtInetAddrAndPort* target = 0 );
89 
90  // Attempts to fix the TCP connection. Returns true if it was not fixed, 0 if it was successful.
91  virtual bool fixConnection(DtTcpMsgSocket* sock);
92 
94  virtual void clearNeededConnections();
95 
97  virtual unsigned int abortPendingConnections();
98 
100  virtual unsigned int pendingConnectionsAborted();
101 
103  virtual DtAddressPortList connections() const;
104 
106 
107  virtual void listenToMulticastGroup( const MAKRti::DtInetAddr& mcastAddr ){};
108  virtual void dropMulticastGroup( const MAKRti::DtInetAddr& mcastAddr ){};
110 
112  virtual bool updateFederateConnectionId( unsigned long orig, unsigned long final );
113 
115  virtual bool flush();
116 
118  virtual bool flushOnly();
119 
121  virtual DtString connectionListToString( const char* separator = " : " ) const;
122 
123  virtual bool populateConnectionInformation(
124  unsigned int& numForwarderToForwarderConns,
125  std::vector<DtString>& forwarderIdentifiers,
126  std::vector<DtString>& forwarderConnectionHostNames,
127  std::vector<DtInetAddrAndPort>& forwarderConnectionAddrs) const;
128 
130  virtual bool addPeerConnection(const DtString& host,
131  const MAKRti::DtInetAddr& ipAddress, int port, bool distributeConnection);
132 
134  virtual void processMacAddrMsg(const DtForwarderPort::DtAddressMsgPair& msg);
135 
138  virtual void processPortMsg(const DtForwarderPort::DtAddressMsgPair& msgPair);
139 
141  virtual void processForwarderNodeInfoMsg(const DtForwarderPort::DtAddressMsgPair& msg);
142 
144  virtual void processConnectToForwarderMsg(const DtForwarderPort::DtAddressMsgPair& msg);
145 
146 public:
147 
149  static DtForwarderPort* create( const DtRIDParameters* params,
150  const DtBoost::shared_ptr<DtRouteMap> routes,
151  const MAKRti::DtInetAddr& host, int forwarderPort,
152  const MAKRti::DtInetEndpoint& additionalForwarderToConnectTo );
153 
157  static void setCreatorFunction( DtForwarderPortCreatorFcn creator );
158 
159 protected:
160 
162 
163  static void socketAdditionCb( DtTcpMsgSocket* sock, void* usr );
164  virtual void socketAdditionCb( DtTcpMsgSocket* sock );
166 
168 
169  static void socketEstablishedCb( DtTcpMsgSocket* sock, void* usr );
170  virtual void socketEstablishedCb( DtTcpMsgSocket* sock );
172 
174 
175  static void socketRemovalCb( DtTcpMsgSocket* sock, void* usr );
176  virtual void socketRemovalCb( DtTcpMsgSocket* sock );
178 
180  virtual void initializeConnections();
181 
183  virtual void sendMacAddrMsg( DtTcpMsgSocket* sock );
184 
186  virtual void sendPortMsg( DtTcpMsgSocket* sock );
187 
189  virtual void sendForwarderNodeInfoMsgToConnections();
190 
193  virtual void sendForwarderNodeInfoMsg( DtTcpMsgSocket* sock, unsigned long nodeIdToUse=0);
194 
196  virtual void sendConnectToForwarderMsg(const DtInetAddrAndPort& fwDestination,
197  const DtString& fwName, const DtString& fwHostName );
198 
199 // //! Returns whether sock was ok()
200 // virtual bool reconnectToPeer( const DtInetAddrAndPort& addrToConnectTo, bool wasClient);
201 
203  virtual bool connectToPeer( const DtInetAddrAndPort& addrToConnectTo );
204 
206  virtual int processLostConnection( DtTcpMsgSocket* sock );
207 
210  virtual void connectionCompleted( const DtInetAddrAndPort& addrAndPort, DtTcpMsgSocket* sock );
211 
214  virtual void connectionCompleted(const DtString& nodeName,const DtString& hostName, unsigned long nodeId,
215  const DtInetAddrAndPort& addrAndPort, DtTcpMsgSocket* sock);
216 
218  virtual void addSocketUsingRoutesFile(DtTcpMsgSocket* sock,
219  const DtInetAddrAndPort& addrAndPort);
220 
222  virtual void addInitiatedSocketDynamically(DtTcpMsgSocket* sock, const DtInetAddrAndPort& addrAndPort);
223 
225  virtual void addReceivedSocketDynamically(DtTcpMsgSocket* sock, const DtInetAddrAndPort& addrAndPort);
226 
227  //Store / remove connection and update dependencies.
229  virtual void addConnection( const DtInetAddrAndPort& newConn, DtTcpMsgSocket* sock );
230  virtual void removeConnection( DtAddrToConnMap::iterator pos );
232 
233  // Return the socket with this listening destination
234  virtual DtTcpMsgSocket* socketFromListeningAddr(const DtInetAddrAndPort& addrAndPort);
235 
237  virtual bool removeFromPendingList( DtTcpMsgSocket* addr );
238 
240  virtual void becomeRootForwarderNode();
241 
243  virtual void distributeConnections(const DtInetAddrAndPort& fwAddrAndPort,
244  const DtString& fwName, const DtString& fwHostName, const std::set<DtForwarderNodeInfo>& fwConnPeers);
245 
246 protected:
247 
251  DtInOutForwarderPort& operator=( const DtInOutForwarderPort& orig );
252 
253 protected:
254 
255 
256  bool myIsReady;
259  DtForwarderPort::DtAddrToConnMap::const_iterator myNextConnection;
260  DtForwarderPort::DtAddrToConnMap::const_iterator myLastConnection;
263 
265  DtAddrToConnMap mySocketToBeRemoved;
266 
267  std::map<DtInetAddrAndPort, DtTcpMsgSocket*> myAddrToSockMap;
268 
269  std::map<DtTcpMsgSocket*, unsigned long> mySockToIdMap;
270 
278 
280  std::map<DtInetAddrAndPort, DtString> myNeededConnections;
281 
283  std::map<DtInetAddrAndPort, DtString> myStillNeededConnections;
284 
287  std::map<DtInetAddrAndPort, DtInetAddrAndPort> myUsedToListeningMap;
288  std::map<DtInetAddrAndPort, DtInetAddrAndPort> myListeningToUsedMap;
289 
290 
294 
296  std::map<DtInetAddrAndPort, unsigned long long> myMacAddrsOfConnectedForwardersMap;
298 
299  MAKRti::DtClock myClock;
300  mutable std::map< DtTcpMsgSocket*, MAKRti::DtTime > mySktSendTimeMap;
301 
302  std::map< DtTcpMsgSocket *, unsigned int> myTestCountFailureMap;
304  MAKRti::DtInetDevice myHostIf;
305 
307 
308  MAKRti::DtString myHostname;
309 
310  unsigned long myMsgCount;
311 
312 protected:
313 
314  static DtForwarderPortCreatorFcn theCreator;
315 
316 };
317 
318 inline bool DtInOutForwarderPort::updateFederateConnectionId( unsigned long orig,
319  unsigned long final )
320 {
322  return false;
323 }
324 
325 #endif
326 
std::set< DtTcpMsgSocket * > DtSocketSet
Definition: forwarderPort.h:55
The DtForwarderPort is an Abstract Base Class which provides the interface to a collection of connect...
Definition: inOutForwarderPort.h:33
DtForwarderPort::DtSocketSet myPostPendingConnections
Definition: inOutForwarderPort.h:274
std::pair< MAKRti::DtInetAddr, int > DtInetAddrAndPort
Definition: rtiUtil.h:147
The DtMacAddrMsg defines a msg used by forwarders to connect.
Definition: macAddrMsg.h:32
virtual DtAddressPortList connections() const =0
Get the list of all current connections to this port.
DtForwarderPort::DtSocketSet myDynamicallyReceivedConnections
Definition: inOutForwarderPort.h:277
bool myIsRootForwarderNode
Definition: inOutForwarderPort.h:297
std::map< DtInetAddrAndPort, DtString > myNeededConnections
Connections needed before the forwarding network is complete.
Definition: inOutForwarderPort.h:280
The DtForwarderPort is an Abstract Base Class which provides the interface to a collection of connect...
Definition: forwarderPort.h:35
This class manages the RTI&#39;s start-up configuration using both MTL variables and functions.
Definition: RIDparams.h:87
std::map< DtInetAddrAndPort, DtInetAddrAndPort > myListeningToUsedMap
Definition: inOutForwarderPort.h:288
DtForwarderPort::DtSocketSet myExpiredConnections
Definition: inOutForwarderPort.h:292
DtInetAddrAndPort myPendingPeerAddition
Definition: inOutForwarderPort.h:262
The DtPeerToPeerTcpSockMgr adds the ability to act as a client as well as a server to the DtTcpMsgSoc...
Definition: peerToPeerSockMgr.h:45
virtual void listenToMulticastGroup(const MAKRti::DtInetAddr &mcastAddr)
Listen / drop multicast groups (not implemented in this class)
Definition: inOutForwarderPort.h:107
DtUdpMsgSocket * myLegacyUdpConnection
Definition: inOutForwarderPort.h:295
DtForwarderPort::DtSocketList myInitiatedConnections
Definition: inOutForwarderPort.h:291
virtual void updateRoutes()=0
Handle changes to the Routing map.
std::map< DtTcpMsgSocket *, unsigned long > mySockToIdMap
Definition: inOutForwarderPort.h:269
This file contains the declaration of the DtUdpMsgSocket base class.
MAKRti::DtInetDevice myHostIf
The interface used for connections with other forwarders.
Definition: inOutForwarderPort.h:304
int myCompressionLevel
Definition: inOutForwarderPort.h:306
static DtForwarderPortCreatorFcn theCreator
Definition: inOutForwarderPort.h:314
Definition: forwarderPort.h:44
std::map< DtInetAddrAndPort, unsigned long long > myMacAddrsOfConnectedForwardersMap
Definition: inOutForwarderPort.h:296
MAKRti::DtClock myClock
Definition: inOutForwarderPort.h:299
virtual void clearNeededConnections()=0
Clear the list of connections that this forwarder needs to establish.
MAKRti::DtString myHostname
Definition: inOutForwarderPort.h:308
std::map< DtInetAddrAndPort, DtInetAddrAndPort > myUsedToListeningMap
Map of actual address/port pairs to listening address/port pairs, which are also used for identificat...
Definition: inOutForwarderPort.h:287
This file contains the declaration of the DtPeerToPeerTcpSockMgr class.
std::pair< DtInetAddrAndPort, DtForwarderMsg > DtAddressMsgPair
Definition: forwarderPort.h:56
DtForwarderPort::DtAddrToConnMap::const_iterator myNextConnection
Definition: inOutForwarderPort.h:259
std::map< DtInetAddrAndPort, DtTcpMsgSocket * > myAddrToSockMap
Definition: inOutForwarderPort.h:267
DtForwarderPort::DtSocketSet myPendingConnections
Connections which are in process.
Definition: inOutForwarderPort.h:272
DtRouteMap::DtAddressPortList DtAddressPortList
Definition: forwarderPort.h:51
virtual void sendToAllReliable(const DtForwarderMsg &msg) const =0
Send a message to all available destinations.
bool myIsReady
Definition: inOutForwarderPort.h:256
DtAddrToConnMap mySocketToBeRemoved
Duplicate connections to be deleted on processPortMsg.
Definition: inOutForwarderPort.h:265
Definition: forwarderNodeInfoMsg.h:28
virtual bool isReady() const =0
Is the Port fully usable and available?
DtForwarderPort::DtAddrToConnMap::const_iterator myLastConnection
Definition: inOutForwarderPort.h:260
Definition: routeMap.h:41
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages...
Definition: tcpMsgSocket.h:42
virtual int checkConnectionStatus(const DtInetAddrAndPort *target=0)=0
Test for lost connections - returns true if targeted connection is active or, if no target specified...
DtForwarderPort::DtSocketSet myDiscardedRemoteSockets
Definition: inOutForwarderPort.h:293
std::vector< DtTcpMsgSocket * > DtSocketList
Definition: forwarderPort.h:54
DtForwarderPort::DtSocketSet myUnknownPortConnections
Definition: inOutForwarderPort.h:275
virtual unsigned int pendingConnectionsAborted()=0
Return count of aborted connections.
std::map< DtTcpMsgSocket *, unsigned int > myTestCountFailureMap
Definition: inOutForwarderPort.h:302
virtual bool updateFederateConnectionId(unsigned long orig, unsigned long final)
Update locally connected federate connection ID (LAN-port-only)
Definition: inOutForwarderPort.h:318
virtual void sendToListReliable(const DtForwarderMsg &msg, const DtRouteMap::DtAddressPortList &destinations) const =0
Send a message to the specified list of destinations excluding the list of filtered destinations...
The DtMsgSocket provides a wrapper around the DtInetSocket class to operate on messages rather than j...
Definition: msgSocket.h:29
virtual void selectParams(MAKRti::DtSelectParamWithWrite &selectParams)=0
Add this port&#39;s current select() notification set to the passed set.
DtForwarderPort::DtAddrToConnMap myConnections
Definition: inOutForwarderPort.h:258
unsigned long myMsgCount
Definition: inOutForwarderPort.h:310
DtForwarderPort::DtSocketSet myPrePendingConnections
Definition: inOutForwarderPort.h:273
virtual void sendByTransport(const DtForwarderMsg &msg) const =0
Check transport metadata and send message to appropriate socket(s)
The DtForwarderNodeInfoMsg defines a msg for a client to report the results of a latency test...
Definition: forwarderNodeInfoMsg.h:88
DtPeerToPeerTcpSockMgr * myConnectionMgr
Definition: inOutForwarderPort.h:257
std::map< DtInetAddrAndPort, DtTcpMsgSocket * > DtAddrToConnMap
Definition: forwarderPort.h:58
std::map< DtTcpMsgSocket *, MAKRti::DtTime > mySktSendTimeMap
Definition: inOutForwarderPort.h:300
virtual void dropMulticastGroup(const MAKRti::DtInetAddr &mcastAddr)
Listen / drop multicast groups (not implemented in this class)
Definition: inOutForwarderPort.h:108
#define DT_DLL_FORWARDER
Definition: rtiMsConfig.h:124
virtual bool updateFederateConnectionId(unsigned long orig, unsigned long final)=0
Update locally connected federate connection ID (LAN-port-only)
DtForwarderPort::DtSocketSet myDynamicallyInitiatedConnections
Definition: inOutForwarderPort.h:276
std::map< DtInetAddrAndPort, DtString > myStillNeededConnections
Connections still needed before the forwarding network is complete.
Definition: inOutForwarderPort.h:283
The DtUdpMsgSocket class provides an address family independent UDP socket that handles RTI messages...
Definition: udpMsgSocket.h:28
virtual bool flush()
Flush any unsent/buffered packets; return true if flush sent data.
Definition: forwarderPort.h:351
DtInetAddrAndPort myLocalDestination
Definition: inOutForwarderPort.h:261
virtual DtAddressMsgPair getNextMsg()=0
Get the next message to forward and the source connection.
virtual unsigned int abortPendingConnections()=0
Abort any embryonic connections.

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)