TCPVirtualDataRcvQueue.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2004 Andras Varga
00003 // Copyright (C) 2009 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_TCPVIRTUALDATARCVQUEUE_H
00020 #define __INET_TCPVIRTUALDATARCVQUEUE_H
00021 
00022 #include <list>
00023 #include <string>
00024 #include "TCPSegment.h"
00025 #include "TCPReceiveQueue.h"
00026 
00032 class INET_API TCPVirtualDataRcvQueue : public TCPReceiveQueue
00033 {
00034   protected:
00035     uint32 rcv_nxt;
00036 
00037     struct Region
00038     {
00039         uint32 begin;
00040         uint32 end;
00041     };
00042     typedef std::list<Region> RegionList;
00043     RegionList regionList;
00044 
00045     // merges segment byte range into regionList
00046     void merge(uint32 segmentBegin, uint32 segmentEnd);
00047 
00048     // returns number of bytes extracted
00049     ulong extractTo(uint32 toSeq);
00050 
00051   public:
00055     TCPVirtualDataRcvQueue();
00056 
00060     virtual ~TCPVirtualDataRcvQueue();
00061 
00065     virtual void init(uint32 startSeq);
00066 
00070     virtual std::string info() const;
00071 
00075     virtual uint32 insertBytesFromSegment(TCPSegment *tcpseg);
00076 
00080     virtual cPacket *extractBytesUpTo(uint32 seq);
00081 
00085     virtual uint32 getAmountOfBufferedBytes();
00086 
00090     virtual uint32 getAmountOfFreeBytes(uint32 maxRcvBuffer);
00091 
00095     virtual uint32 getQueueLength();
00096 
00100     virtual void getQueueStatus();
00101 
00105     virtual uint32 getLE(uint32 fromSeqNum);
00106 
00110     virtual uint32 getRE(uint32 toSeqNum);
00111 };
00112 
00113 #endif