|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // Copyright (C) 2004 Andras Varga 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public License 00015 // along with this program; if not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 00019 #include "TCPMsgBasedRcvQueue_old.h" 00020 00021 using namespace tcp_old; 00022 00023 Register_Class(TCPMsgBasedRcvQueue); 00024 00025 00026 TCPMsgBasedRcvQueue::TCPMsgBasedRcvQueue() : TCPVirtualDataRcvQueue() 00027 { 00028 } 00029 00030 TCPMsgBasedRcvQueue::~TCPMsgBasedRcvQueue() 00031 { 00032 } 00033 00034 void TCPMsgBasedRcvQueue::init(uint32 startSeq) 00035 { 00036 TCPVirtualDataRcvQueue::init(startSeq); 00037 } 00038 00039 std::string TCPMsgBasedRcvQueue::info() const 00040 { 00041 std::stringstream os; 00042 00043 os << "rcv_nxt=" << rcv_nxt; 00044 00045 for (RegionList::const_iterator i = regionList.begin(); i != regionList.end(); ++i) 00046 { 00047 os << " [" << i->begin << ".." << i->end << ")"; 00048 } 00049 00050 os << " " << payloadList.size() << " msgs"; 00051 00052 return os.str(); 00053 } 00054 00055 uint32 TCPMsgBasedRcvQueue::insertBytesFromSegment(TCPSegment *tcpseg) 00056 { 00057 TCPVirtualDataRcvQueue::insertBytesFromSegment(tcpseg); 00058 00059 cPacket *msg; 00060 uint32 endSeqNo; 00061 while ((msg=tcpseg->removeFirstPayloadMessage(endSeqNo))!=NULL) 00062 { 00063 // insert, avoiding duplicates 00064 PayloadList::iterator i = payloadList.find(endSeqNo); 00065 if (i!=payloadList.end()) {delete msg; continue;} 00066 payloadList[endSeqNo] = msg; 00067 } 00068 00069 return rcv_nxt; 00070 } 00071 00072 cPacket *TCPMsgBasedRcvQueue::extractBytesUpTo(uint32 seq) 00073 { 00074 extractTo(seq); 00075 00076 // pass up payload messages, in sequence number order 00077 if (payloadList.empty() || seqGreater(payloadList.begin()->first, seq)) 00078 return NULL; 00079 00080 cPacket *msg = payloadList.begin()->second; 00081 payloadList.erase(payloadList.begin()); 00082 return msg; 00083 } 00084