TCPBaseAlg.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2004 Andras Varga
00003 // Copyright (C) 2009-2010 Thomas Reschka
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef __INET_TCPBASEALG_H
00020 #define __INET_TCPBASEALG_H
00021 
00022 #include <omnetpp.h>
00023 #include "TCPAlgorithm.h"
00024 
00025 
00029 class INET_API TCPBaseAlgStateVariables : public TCPStateVariables
00030 {
00031   public:
00032     TCPBaseAlgStateVariables();
00033     virtual std::string info() const;
00034     virtual std::string detailedInfo() const;
00035 
00037 
00038     int rexmit_count;         
00039     simtime_t rexmit_timeout; 
00040 
00041 
00043 
00044     uint persist_factor;       
00045     simtime_t persist_timeout; 
00046 
00047 
00049 
00050     uint32 snd_cwnd;            
00051 
00052 
00054 
00055     uint32 rtseq;             
00056     simtime_t rtseq_sendtime; 
00057 
00058 
00060 
00061     simtime_t srtt;          
00062     simtime_t rttvar;        
00063 
00064 
00066 
00067     uint32 numRtos;          
00068 
00069 
00071 
00072     uint32 recover;            
00073     bool firstPartialACK;      
00074 
00075 };
00076 
00077 
00102 class INET_API TCPBaseAlg : public TCPAlgorithm
00103 {
00104   protected:
00105     TCPBaseAlgStateVariables *&state; // alias to TCPAlgorithm's 'state'
00106 
00107     cMessage *rexmitTimer;
00108     cMessage *persistTimer;
00109     cMessage *delayedAckTimer;
00110     cMessage *keepAliveTimer;
00111 
00112     cOutVector *cwndVector;  // will record changes to snd_cwnd
00113     cOutVector *ssthreshVector; // will record changes to ssthresh
00114     cOutVector *rttVector;   // will record measured RTT
00115     cOutVector *srttVector;  // will record smoothed RTT
00116     cOutVector *rttvarVector;// will record RTT variance (rttvar)
00117     cOutVector *rtoVector;   // will record retransmission timeout
00118     cOutVector *numRtosVector; // will record total number of RTOs
00119 
00120   protected:
00123     virtual void processRexmitTimer(TCPEventCode& event);
00124     virtual void processPersistTimer(TCPEventCode& event);
00125     virtual void processDelayedAckTimer(TCPEventCode& event);
00126     virtual void processKeepAliveTimer(TCPEventCode& event);
00128 
00132     virtual void startRexmitTimer();
00133 
00139     virtual void rttMeasurementComplete(simtime_t tSent, simtime_t tAcked);
00140 
00145     virtual void rttMeasurementCompleteUsingTS(uint32 echoedTS);
00146 
00150     virtual bool sendData();
00151 
00153     cMessage *cancelEvent(cMessage *msg) {return conn->getTcpMain()->cancelEvent(msg);}
00154 
00155   public:
00159     TCPBaseAlg();
00160 
00164     virtual ~TCPBaseAlg();
00165 
00169     virtual void initialize();
00170 
00171     virtual void established(bool active);
00172 
00173     virtual void connectionClosed();
00174 
00178     virtual void processTimer(cMessage *timer, TCPEventCode& event);
00179 
00180     virtual void sendCommandInvoked();
00181 
00182     virtual void receivedOutOfOrderSegment();
00183 
00184     virtual void receiveSeqChanged();
00185 
00186     virtual void receivedDataAck(uint32 firstSeqAcked);
00187 
00188     virtual void receivedDuplicateAck();
00189 
00190     virtual void receivedAckForDataNotYetSent(uint32 seq);
00191 
00192     virtual void ackSent();
00193 
00194     virtual void dataSent(uint32 fromseq);
00195 
00196     virtual void restartRexmitTimer();
00197 };
00198 
00199 #endif