MAK RTIspy API Documentation for HLA 1516
 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 

Document ID: Generated on Fri Sep 27 00:57:56 EDT 2019 from SVN revision 201708
Copyright © 2005-2018 VT MÄK Inc. All Rights Reserved (www.mak.com)