|
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 "TCPVirtualDataSendQueue_old.h" 00020 00021 using namespace tcp_old; 00022 00023 Register_Class(TCPVirtualDataSendQueue); 00024 00025 TCPVirtualDataSendQueue::TCPVirtualDataSendQueue() : TCPSendQueue() 00026 { 00027 begin = end = 0; 00028 } 00029 00030 TCPVirtualDataSendQueue::~TCPVirtualDataSendQueue() 00031 { 00032 } 00033 00034 void TCPVirtualDataSendQueue::init(uint32 startSeq) 00035 { 00036 begin = startSeq; 00037 end = startSeq; 00038 } 00039 00040 std::string TCPVirtualDataSendQueue::info() const 00041 { 00042 std::stringstream out; 00043 out << "[" << begin << ".." << end << ")"; 00044 return out.str(); 00045 } 00046 00047 void TCPVirtualDataSendQueue::enqueueAppData(cPacket *msg) 00048 { 00049 //tcpEV << "sendQ: " << info() << " enqueueAppData(bytes=" << msg->getByteLength() << ")\n"; 00050 end += msg->getByteLength(); 00051 delete msg; 00052 } 00053 00054 uint32 TCPVirtualDataSendQueue::getBufferStartSeq() 00055 { 00056 return begin; 00057 } 00058 00059 uint32 TCPVirtualDataSendQueue::getBufferEndSeq() 00060 { 00061 return end; 00062 } 00063 00064 TCPSegment *TCPVirtualDataSendQueue::createSegmentWithBytes(uint32 fromSeq, ulong numBytes) 00065 { 00066 //tcpEV << "sendQ: " << info() << " createSeg(seq=" << fromSeq << " len=" << numBytes << ")\n"; 00067 ASSERT(seqLE(begin,fromSeq) && seqLE(fromSeq+numBytes,end)); 00068 00069 char msgname[32]; 00070 sprintf(msgname, "tcpseg(l=%lu)", numBytes); 00071 00072 TCPSegment *tcpseg = conn->createTCPSegment(msgname); 00073 tcpseg->setSequenceNo(fromSeq); 00074 tcpseg->setPayloadLength(numBytes); 00075 return tcpseg; 00076 } 00077 00078 void TCPVirtualDataSendQueue::discardUpTo(uint32 seqNum) 00079 { 00080 //tcpEV << "sendQ: " << info() << " discardUpTo(seq=" << seqNum << ")\n"; 00081 ASSERT(seqLE(begin,seqNum) && seqLE(seqNum,end)); 00082 begin = seqNum; 00083 } 00084