SCTPPeer.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2008 Irene Ruengeler
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #ifndef __SCTPPEER_H_
00019 #define __SCTPPEER_H_
00020 
00021 #include <omnetpp.h>
00022 #include "SCTPAssociation.h"
00023 #include "SCTPSocket.h"
00024 
00025 
00026 class INET_API SCTPPeer : public cSimpleModule, public SCTPSocket::CallbackInterface
00027 {
00028     protected:
00029         int32 notifications;
00030         int32 serverAssocId;
00031         int32 clientAssocId;
00032         SCTPSocket clientSocket;
00033         double delay;
00034         double echoFactor;
00035         bool schedule;
00036         bool shutdownReceived;
00037         long bytesSent;
00038         int32 packetsSent;
00039         int32 packetsRcvd;
00040         int32 numSessions;
00041         int32 numRequestsToSend; // requests to send in this session
00042         bool ordered;
00043         int32 queueSize;
00044         cMessage *timeoutMsg;
00045         int32 outboundStreams;
00046         cMessage *timeMsg;
00047         cMessage *connectTimer;
00048         int32 bytesRcvd;
00049         int32 echoedBytesSent;
00050         int32 lastStream;
00051         bool sendAllowed;
00052         int32 numPacketsToReceive;
00053         typedef std::map<int32,long> RcvdPacketsPerAssoc;
00054         RcvdPacketsPerAssoc rcvdPacketsPerAssoc;
00055         typedef std::map<int32,long> SentPacketsPerAssoc;
00056         SentPacketsPerAssoc sentPacketsPerAssoc;
00057         typedef std::map<int32,long> RcvdBytesPerAssoc;
00058         RcvdBytesPerAssoc rcvdBytesPerAssoc;
00059         typedef std::map<int32,cOutVector*> BytesPerAssoc;
00060         BytesPerAssoc bytesPerAssoc;
00061         typedef std::map<int32,cDoubleHistogram*> HistEndToEndDelay;
00062         HistEndToEndDelay histEndToEndDelay;
00063         typedef std::map<int32,cOutVector*> EndToEndDelay;
00064         EndToEndDelay endToEndDelay;
00065         void sendOrSchedule(cPacket *msg);
00066         void sendRequest(bool last=true);
00067         int32 ssn;
00068     public:
00069         struct pathStatus {
00070             bool active;
00071             bool primaryPath;
00072             IPAddress  pid;
00073         };
00074         typedef std::map<IPvXAddress,pathStatus> SCTPPathStatus;
00075         SCTPPathStatus sctpPathStatus;
00076         void initialize();
00077         void handleMessage(cMessage *msg);
00078         void finish();
00079         void handleTimer(cMessage *msg);
00080         void generateAndSend(SCTPConnectInfo *connectInfo);
00081         void connect();
00082 
00084         void socketEstablished(int32 connId, void *yourPtr);
00085 
00090         void socketDataArrived(int32 connId, void *yourPtr, cPacket *msg, bool urgent);
00091 
00092         void socketDataNotificationArrived(int32 connId, void *yourPtr, cPacket *msg);
00094         void socketPeerClosed(int32 connId, void *yourPtr);
00095 
00097         void socketClosed(int32 connId, void *yourPtr);
00098 
00100         void socketFailure(int32 connId, void *yourPtr, int32 code);
00101 
00103         void socketStatusArrived(int32 connId, void *yourPtr, SCTPStatusInfo *status);
00105         void setPrimaryPath ();
00106         void sendRequestArrived();
00107         void sendQueueRequest();
00108         void shutdownReceivedArrived(int32 connId);
00109         void sendqueueFullArrived(int32 connId);
00110 
00111         void setStatusString(const char *s);
00112         void addressAddedArrived(int32 assocId, IPvXAddress remoteAddr);
00113 };
00114 
00115 #endif
00116 
00117