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
00019
00020
00021 #ifndef __TCP_NSC_H
00022 #define __TCP_NSC_H
00023
00024 #include <map>
00025 #include <list>
00026 #include <omnetpp.h>
00027
00028 #include "INETDefs.h"
00029 #include "IPvXAddress.h"
00030
00031 #include <sim_interface.h>
00032 #include "TCP_NSC_Connection.h"
00033
00034
00035 class TCPCommand;
00036 class TCPSegment;
00037
00041 class INET_API TCP_NSC : public cSimpleModule, ISendCallback, IInterruptCallback
00042 {
00043 protected:
00044 enum {MAX_SEND_BYTES = 500000};
00045
00046 public:
00047 TCP_NSC();
00048 virtual ~TCP_NSC();
00049
00050
00051
00052
00053 virtual void send_callback(const void *, int);
00054
00055
00056 virtual void wakeup();
00057 virtual void gettime(unsigned int *, unsigned int *);
00058
00059 protected:
00060
00061
00062 virtual void initialize();
00063 virtual void handleMessage(cMessage *msgP);
00064 virtual void finish();
00065
00066
00067
00068 void changeAddresses(TCP_NSC_Connection &connP,
00069 const TCP_NSC_Connection::SockPair &inetSockPairP,
00070 const TCP_NSC_Connection::SockPair &nscSockPairP);
00071
00072
00073 TCP_NSC_Connection *findAppConn(int connIdP);
00074
00075
00076 TCP_NSC_Connection *findConnByInetSockPair(TCP_NSC_Connection::SockPair const & sockPairP);
00077
00078
00079 TCP_NSC_Connection *findConnByNscSockPair(TCP_NSC_Connection::SockPair const & sockPairP);
00080
00081 virtual void updateDisplayString();
00082 void removeConnection(int connIdP);
00083 void printConnBrief(TCP_NSC_Connection& connP);
00084 void loadStack(const char* stacknameP, int bufferSizeP);
00085
00086 void handleAppMessage(cMessage *msgP);
00087 void handleIpInputMessage(TCPSegment* tcpsegP);
00088
00089
00090
00091 void sendToIP(const void *dataP, int lenP);
00092
00093
00094
00095 void processAppCommand(TCP_NSC_Connection& connP, cMessage *msgP);
00096
00097
00098
00099 void process_OPEN_ACTIVE(TCP_NSC_Connection& connP, TCPCommand *tcpCommandP, cMessage *msgP);
00100 void process_OPEN_PASSIVE(TCP_NSC_Connection& connP, TCPCommand *tcpCommandP, cMessage *msgP);
00101 void process_SEND(TCP_NSC_Connection& connP, TCPCommand *tcpCommandP, cPacket *msgP);
00102 void process_CLOSE(TCP_NSC_Connection& connP, TCPCommand *tcpCommandP, cMessage *msgP);
00103 void process_ABORT(TCP_NSC_Connection& connP, TCPCommand *tcpCommandP, cMessage *msgP);
00104 void process_STATUS(TCP_NSC_Connection& connP, TCPCommand *tcpCommandP, cMessage *msgP);
00105
00106 void do_SEND(TCP_NSC_Connection& connP);
00107 void do_SEND_all();
00108
00109
00110
00111 u_int32_t mapRemote2Nsc(IPvXAddress const& addrP);
00112
00113
00114
00115
00116 IPvXAddress const & mapNsc2Remote(u_int32_t nscAddrP);
00117
00118
00119
00120 void sendEstablishedMsg(TCP_NSC_Connection &connP);
00121
00122 protected:
00123 typedef std::map<int,TCP_NSC_Connection> TcpAppConnMap;
00124 typedef std::map<u_int32_t, IPvXAddress> Nsc2RemoteMap;
00125 typedef std::map<IPvXAddress, u_int32_t> Remote2NscMap;
00126 typedef std::map<TCP_NSC_Connection::SockPair, int> SockPair2ConnIdMap;
00127
00128
00129 TcpAppConnMap tcpAppConnMapM;
00130 SockPair2ConnIdMap inetSockPair2ConnIdMapM;
00131 SockPair2ConnIdMap nscSockPair2ConnIdMapM;
00132
00133 Nsc2RemoteMap nsc2RemoteMapM;
00134 Remote2NscMap remote2NscMapM;
00135
00136 INetStack *pStackM;
00137
00138 cMessage *pNsiTimerM;
00139
00140 void decode_tcpip(const void *, int);
00141 void decode_tcp(const void *, int);
00142
00143 public:
00144 static bool testingS;
00145 static bool logverboseS;
00146
00147 protected:
00148 bool isAliveM;
00149
00150 int curAddrCounterM;
00151 TCP_NSC_Connection *curConnM;
00152
00153 static const IPvXAddress localInnerIpS;
00154 static const IPvXAddress localInnerGwS;
00155 static const IPvXAddress localInnerMaskS;
00156 static const IPvXAddress remoteFirstInnerIpS;
00157
00158 static const char * stackNameParamNameS;
00159 static const char * bufferSizeParamNameS;
00160
00161
00162 cOutVector *sndWndVector;
00163 cOutVector *rcvWndVector;
00164 cOutVector *rcvAdvVector;
00165 cOutVector *sndNxtVector;
00166 cOutVector *sndAckVector;
00167 cOutVector *rcvSeqVector;
00168 cOutVector *rcvAckVector;
00169 cOutVector *unackedVector;
00170
00171 cOutVector *dupAcksVector;
00172 cOutVector *pipeVector;
00173 cOutVector *sndSacksVector;
00174 cOutVector *rcvSacksVector;
00175 cOutVector *rcvOooSegVector;
00176
00177 cOutVector *sackedBytesVector;
00178 cOutVector *tcpRcvQueueBytesVector;
00179 cOutVector *tcpRcvQueueDropsVector;
00180 };
00181
00182 #endif