Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __INET_TCPMAIN_OLD_H
00019 #define __INET_TCPMAIN_OLD_H
00020
00021 #include <map>
00022 #include <set>
00023 #include <omnetpp.h>
00024 #include "IPvXAddress.h"
00025
00026 class TCPSegment;
00027
00028 namespace tcp_old {
00029
00030 class TCPConnection;
00031
00032
00033 #define tcpEV (ev.disable_tracing||TCP::testing)?ev:ev
00034
00035
00036 #define tcpEV2 (ev.disable_tracing||TCP::testing||!TCP::logverbose)?ev:ev
00037
00038
00039 #define testingEV (ev.disable_tracing||!TCP::testing)?ev:ev
00040
00041
00042
00043
00044
00097 class INET_API TCP : public cSimpleModule
00098 {
00099 public:
00100 struct AppConnKey
00101 {
00102 int appGateIndex;
00103 int connId;
00104
00105 inline bool operator<(const AppConnKey& b) const
00106 {
00107 if (appGateIndex!=b.appGateIndex)
00108 return appGateIndex<b.appGateIndex;
00109 else
00110 return connId<b.connId;
00111 }
00112
00113 };
00114 struct SockPair
00115 {
00116 IPvXAddress localAddr;
00117 IPvXAddress remoteAddr;
00118 int localPort;
00119 int remotePort;
00120
00121 inline bool operator<(const SockPair& b) const
00122 {
00123 if (remoteAddr!=b.remoteAddr)
00124 return remoteAddr<b.remoteAddr;
00125 else if (localAddr!=b.localAddr)
00126 return localAddr<b.localAddr;
00127 else if (remotePort!=b.remotePort)
00128 return remotePort<b.remotePort;
00129 else
00130 return localPort<b.localPort;
00131 }
00132 };
00133
00134 protected:
00135 typedef std::map<AppConnKey,TCPConnection*> TcpAppConnMap;
00136 typedef std::map<SockPair,TCPConnection*> TcpConnMap;
00137
00138 TcpAppConnMap tcpAppConnMap;
00139 TcpConnMap tcpConnMap;
00140
00141 ushort lastEphemeralPort;
00142 std::multiset<ushort> usedEphemeralPorts;
00143
00144 protected:
00146 virtual TCPConnection *createConnection(int appGateIndex, int connId);
00147
00148
00149 virtual TCPConnection *findConnForSegment(TCPSegment *tcpseg, IPvXAddress srcAddr, IPvXAddress destAddr);
00150 virtual TCPConnection *findConnForApp(int appGateIndex, int connId);
00151 virtual void segmentArrivalWhileClosed(TCPSegment *tcpseg, IPvXAddress src, IPvXAddress dest);
00152 virtual void removeConnection(TCPConnection *conn);
00153 virtual void updateDisplayString();
00154
00155 public:
00156 static bool testing;
00157 static bool logverbose;
00158
00159 bool recordStatistics;
00160
00161 public:
00162 TCP() {}
00163 virtual ~TCP();
00164
00165 protected:
00166 virtual void initialize();
00167 virtual void handleMessage(cMessage *msg);
00168 virtual void finish();
00169
00170 public:
00175 virtual void addSockPair(TCPConnection *conn, IPvXAddress localAddr, IPvXAddress remoteAddr, int localPort, int remotePort);
00176
00181 virtual void updateSockPair(TCPConnection *conn, IPvXAddress localAddr, IPvXAddress remoteAddr, int localPort, int remotePort);
00182
00187 virtual void addForkedConnection(TCPConnection *conn, TCPConnection *newConn, IPvXAddress localAddr, IPvXAddress remoteAddr, int localPort, int remotePort);
00188
00192 virtual ushort getEphemeralPort();
00193 };
00194
00195 }
00196 #endif
00197
00198