|
INET Framework for OMNeT++/OMNEST
|
#include <TCPMsgBasedSendQueue_old.h>
Classes | |
| struct | Payload |
Public Member Functions | |
| TCPMsgBasedSendQueue () | |
| virtual | ~TCPMsgBasedSendQueue () |
| virtual void | init (uint32 startSeq) |
| virtual std::string | info () const |
| virtual void | enqueueAppData (cPacket *msg) |
| virtual uint32 | getBufferStartSeq () |
| virtual uint32 | getBufferEndSeq () |
| virtual TCPSegment * | createSegmentWithBytes (uint32 fromSeq, ulong numBytes) |
| virtual void | discardUpTo (uint32 seqNum) |
Protected Types | |
| typedef std::list< Payload > | PayloadQueue |
Protected Attributes | |
| PayloadQueue | payloadQueue |
| uint32 | begin |
| uint32 | end |
Send queue that manages messages.
Definition at line 31 of file TCPMsgBasedSendQueue_old.h.
typedef std::list<Payload> tcp_old::TCPMsgBasedSendQueue::PayloadQueue [protected] |
Definition at line 39 of file TCPMsgBasedSendQueue_old.h.
Ctor
Definition at line 25 of file old/queues/TCPMsgBasedSendQueue.cc.
: TCPSendQueue() { begin = end = 0; }
| TCPMsgBasedSendQueue::~TCPMsgBasedSendQueue | ( | ) | [virtual] |
Virtual dtor.
Definition at line 30 of file old/queues/TCPMsgBasedSendQueue.cc.
{
for (PayloadQueue::iterator it=payloadQueue.begin(); it!=payloadQueue.end(); ++it)
delete it->msg;
}
| TCPSegment * TCPMsgBasedSendQueue::createSegmentWithBytes | ( | uint32 | fromSeq, |
| ulong | maxNumBytes | ||
| ) | [virtual] |
Called when the TCP wants to send or retransmit data, it constructs a TCP segment which contains the data from the requested sequence number range. The actually returned segment may contain less than maxNumBytes bytes if the subclass wants to reproduce the original segment boundaries when retransmitting.
Implements tcp_old::TCPSendQueue.
Definition at line 70 of file old/queues/TCPMsgBasedSendQueue.cc.
{
//tcpEV << "sendQ: " << info() << " createSeg(seq=" << fromSeq << " len=" << numBytes << ")\n";
ASSERT(seqLE(begin,fromSeq) && seqLE(fromSeq+numBytes,end));
TCPSegment *tcpseg = conn->createTCPSegment(NULL);
tcpseg->setSequenceNo(fromSeq);
tcpseg->setPayloadLength(numBytes);
// add payload messages whose endSequenceNo is between fromSeq and fromSeq+numBytes
PayloadQueue::iterator i = payloadQueue.begin();
while (i!=payloadQueue.end() && seqLE(i->endSequenceNo, fromSeq))
++i;
uint32 toSeq = fromSeq+numBytes;
const char *payloadName = NULL;
while (i!=payloadQueue.end() && seqLE(i->endSequenceNo, toSeq))
{
if (!payloadName) payloadName = i->msg->getName();
tcpseg->addPayloadMessage(i->msg->dup(), i->endSequenceNo);
++i;
}
// give segment a name
char msgname[80];
if (!payloadName)
sprintf(msgname, "tcpseg(l=%lu,%dmsg)", numBytes, tcpseg->getPayloadArraySize());
else
sprintf(msgname, "%.10s(l=%lu,%dmsg)", payloadName, numBytes, tcpseg->getPayloadArraySize());
tcpseg->setName(msgname);
return tcpseg;
}
| void TCPMsgBasedSendQueue::discardUpTo | ( | uint32 | seqNum | ) | [virtual] |
Tells the queue that bytes up to (but NOT including) seqNum have been transmitted and ACKed, so they can be removed from the queue.
Implements tcp_old::TCPSendQueue.
Definition at line 103 of file old/queues/TCPMsgBasedSendQueue.cc.
{
//tcpEV << "sendQ: " << info() << " discardUpTo(seq=" << seqNum << ")\n";
ASSERT(seqLE(begin,seqNum) && seqLE(seqNum,end));
begin = seqNum;
// remove payload messages whose endSequenceNo is below seqNum
while (!payloadQueue.empty() && seqLE(payloadQueue.front().endSequenceNo, seqNum))
{
delete payloadQueue.front().msg;
payloadQueue.pop_front();
}
}
| void TCPMsgBasedSendQueue::enqueueAppData | ( | cPacket * | msg | ) | [virtual] |
Called on SEND app command, it inserts in the queue the data the user wants to send. Implementations of this abstract class will decide what this means: copying actual bytes, just increasing the "last byte queued" variable, or storing cMessage object(s). The msg object should not be referenced after this point (sendQueue may delete it.)
Implements tcp_old::TCPSendQueue.
Definition at line 49 of file old/queues/TCPMsgBasedSendQueue.cc.
{
//tcpEV << "sendQ: " << info() << " enqueueAppData(bytes=" << msg->getByteLength() << ")\n";
end += msg->getByteLength();
Payload payload;
payload.endSequenceNo = end;
payload.msg = msg;
payloadQueue.push_back(payload);
}
| uint32 TCPMsgBasedSendQueue::getBufferEndSeq | ( | ) | [virtual] |
Returns the sequence number of the last byte stored in the buffer plus one. (The first byte of the next send operation would get this sequence number.)
Implements tcp_old::TCPSendQueue.
Definition at line 65 of file old/queues/TCPMsgBasedSendQueue.cc.
{
return end;
}
| uint32 TCPMsgBasedSendQueue::getBufferStartSeq | ( | ) | [virtual] |
Definition at line 60 of file old/queues/TCPMsgBasedSendQueue.cc.
{
return begin;
}
| std::string TCPMsgBasedSendQueue::info | ( | ) | const [virtual] |
Returns a string with the region stored.
Definition at line 42 of file old/queues/TCPMsgBasedSendQueue.cc.
{
std::stringstream out;
out << "[" << begin << ".." << end << "), " << payloadQueue.size() << " packets";
return out.str();
}
| void TCPMsgBasedSendQueue::init | ( | uint32 | startSeq | ) | [virtual] |
Initialize the object. The startSeq parameter tells what sequence number the first byte of app data should get. This is usually ISS+1 because SYN consumes one byte in the sequence number space.
init() may be called more than once; every call flushes the existing contents of the queue.
Implements tcp_old::TCPSendQueue.
Definition at line 36 of file old/queues/TCPMsgBasedSendQueue.cc.
uint32 tcp_old::TCPMsgBasedSendQueue::begin [protected] |
Definition at line 42 of file TCPMsgBasedSendQueue_old.h.
Referenced by createSegmentWithBytes(), discardUpTo(), getBufferStartSeq(), info(), init(), and TCPMsgBasedSendQueue().
uint32 tcp_old::TCPMsgBasedSendQueue::end [protected] |
Definition at line 43 of file TCPMsgBasedSendQueue_old.h.
Referenced by createSegmentWithBytes(), discardUpTo(), enqueueAppData(), getBufferEndSeq(), info(), init(), and TCPMsgBasedSendQueue().
Definition at line 40 of file TCPMsgBasedSendQueue_old.h.
Referenced by createSegmentWithBytes(), discardUpTo(), enqueueAppData(), info(), and ~TCPMsgBasedSendQueue().