|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // Copyright (C) 2008 Irene Ruengeler 00003 // Copyright (C) 2009 Thomas Dreibholz 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef __SCTPCLIENT_H_ 00020 #define __SCTPCLIENT_H_ 00021 00022 #include <omnetpp.h> 00023 #include "SCTPSocket.h" 00024 #include "SCTPAssociation.h" 00025 00032 class SCTPAssociation; 00033 00034 class INET_API SCTPClient : public cSimpleModule, public SCTPSocket::CallbackInterface 00035 { 00036 protected: 00037 SCTPSocket socket; 00038 SCTPAssociation* assoc; 00039 // statistics 00040 int32 numSessions; 00041 int32 numBroken; 00042 uint64 packetsSent; 00043 uint64 packetsRcvd; 00044 uint64 bytesSent; 00045 uint64 echoedBytesSent; 00046 uint64 bytesRcvd; 00047 uint64 numRequestsToSend; // requests to send in this session 00048 uint64 numPacketsToReceive; 00049 uint32 numBytes; 00050 int64 bufferSize; 00051 int32 echoFactor; 00052 int32 queueSize; 00053 uint32 inStreams; 00054 uint32 outStreams; 00055 bool ordered; 00056 bool sendAllowed; 00057 bool timer; 00058 bool finishEndsSimulation; 00059 cMessage* timeMsg; 00060 cMessage* stopTimer; 00061 cMessage* primaryChangeTimer; 00063 void sendRequest(bool last=true); 00064 public: 00065 00066 struct pathStatus { 00067 bool active; 00068 bool primaryPath; 00069 IPvXAddress pid; 00070 }; 00071 typedef std::map<IPvXAddress,pathStatus> SCTPPathStatus; 00072 SCTPPathStatus sctpPathStatus; 00076 void initialize(); 00077 00082 void handleMessage(cMessage *msg); 00083 00089 void finish(); 00093 void connect(); 00095 void close(); 00097 // virtual void sendPacket(int32 numBytes, bool serverClose=false); 00099 void setStatusString(const char *s); 00101 00102 void handleTimer(cMessage *msg); 00106 void socketEstablished(int32 connId, void *yourPtr, uint64 buffer); 00111 void socketDataArrived(int32 connId, void *yourPtr, cPacket *msg, bool urgent); 00112 void socketDataNotificationArrived(int32 connId, void *yourPtr, cPacket *msg); 00114 void socketPeerClosed(int32 connId, void *yourPtr); 00116 void socketClosed(int32 connId, void *yourPtr); 00118 void socketFailure(int32 connId, void *yourPtr, int32 code); 00120 void socketStatusArrived(int32 connId, void *yourPtr, SCTPStatusInfo *status); 00122 void setAssociation(SCTPAssociation *_assoc) {assoc = _assoc;}; 00123 void setPrimaryPath (const char* addr); 00124 void sendRequestArrived(); 00125 void sendQueueRequest(); 00126 void shutdownReceivedArrived(int32 connId); 00127 void sendqueueFullArrived(int32 connId); 00128 void sendqueueAbatedArrived(int32 connId, uint64 buffer); 00129 void addressAddedArrived(int32 assocId, IPvXAddress remoteAddr); 00130 }; 00131 00132 #endif 00133 00134