// // Copyright 2004 Andras Varga // // This library is free software, you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; // either version 2 of the License, or any later version. // The library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // #ifndef __INET_TCPSESSIONAPP_H #define __INET_TCPSESSIONAPP_H #include #include #include #include "TCPSocket.h" /** * Single-connection TCP application. */ class INET_API TCPSessionApp : public cSimpleModule { // private: // static std::vector idTable; protected: struct Command { simtime_t tSend; int numBytes; }; typedef std::vector CommandVector; CommandVector commands; TCPSocket socket; // statistics int packetsRcvd; long bytesRcvd; long bytesSent; int indicationsRcvd; public: TCPSessionApp() : cSimpleModule(65536) {} static std::vector idTable; const char * getNextId() { EV << "\n@@2@@@@@@@"; srand ( time(NULL) ); EV << "\n1@@@@@@@"; int nextelement = rand() * (idTable.size()); EV << "\n2@@@@@@"; std::string nextID = idTable[nextelement]; EV << "\n3@@@@@" << nextID; idTable.erase(idTable.begin()+nextelement); return nextID.c_str(); } protected: virtual void parseScript(const char *script); virtual void waitUntil(simtime_t t); virtual void count(cMessage *msg); virtual void activity(); virtual void finish(); }; #endif