|
INET Framework for OMNeT++/OMNEST
|
#include <TCPSegment.h>
Public Member Functions | |
| TCPSegment (const char *name=NULL, int kind=0) | |
| TCPSegment (const TCPSegment &other) | |
| virtual | ~TCPSegment () |
| TCPSegment & | operator= (const TCPSegment &other) |
| virtual TCPSegment * | dup () const |
| virtual void | parsimPack (cCommBuffer *b) |
| virtual void | parsimUnpack (cCommBuffer *b) |
| virtual void | setPayloadArraySize (unsigned int size) |
| virtual void | setPayload (unsigned int k, const TCPPayloadMessage &payload_var) |
| virtual unsigned int | getPayloadArraySize () const |
| virtual TCPPayloadMessage & | getPayload (unsigned int k) |
| virtual void | addPayloadMessage (cPacket *msg, uint32 endSequenceNo) |
| virtual cPacket * | removeFirstPayloadMessage (uint32 &outEndSequenceNo) |
| virtual void | truncateSegment (uint32 firstSeqNo, uint32 endSeqNo) |
Protected Attributes | |
| std::list< TCPPayloadMessage > | payloadList |
Represents a TCP segment. More info in the TCPSegment.msg file (and the documentation generated from it).
| TCPSegment::TCPSegment | ( | const char * | name = NULL, |
| int | kind = 0 |
||
| ) | [inline] |
: TCPSegment_Base(name,kind) {}
| TCPSegment::TCPSegment | ( | const TCPSegment & | other | ) | [inline] |
: TCPSegment_Base(other.getName()) {operator=(other);}
| TCPSegment::~TCPSegment | ( | ) | [virtual] |
{
while (!payloadList.empty())
{
cPacket *msg = payloadList.front().msg;
payloadList.pop_front();
dropAndDelete(msg);
}
}
| void TCPSegment::addPayloadMessage | ( | cPacket * | msg, |
| uint32 | endSequenceNo | ||
| ) | [virtual] |
Adds a message object to the TCP segment. The sequence number+1 of the last byte of the message should be passed as 2nd argument
Referenced by tcp_old::TCPMsgBasedSendQueue::createSegmentWithBytes(), TCPMsgBasedSendQueue::createSegmentWithBytes(), and operator=().
{
take(msg);
TCPPayloadMessage payload;
payload.endSequenceNo = endSequenceNo;
payload.msg = msg;
payloadList.push_back(payload);
}
| virtual TCPSegment* TCPSegment::dup | ( | ) | const [inline, virtual] |
{return new TCPSegment(*this);}
| TCPPayloadMessage & TCPSegment::getPayload | ( | unsigned int | k | ) | [virtual] |
Returns the kth payload message in this TCP segment
{
std::list<TCPPayloadMessage>::iterator i = payloadList.begin();
while (k>0 && i!=payloadList.end())
(++i, --k);
return *i;
}
| unsigned int TCPSegment::getPayloadArraySize | ( | ) | const [virtual] |
Returns the number of payload messages in this TCP segment
Referenced by tcp_old::TCPMsgBasedSendQueue::createSegmentWithBytes(), and TCPMsgBasedSendQueue::createSegmentWithBytes().
{
return payloadList.size();
}
| TCPSegment & TCPSegment::operator= | ( | const TCPSegment & | other | ) |
{
TCPSegment_Base::operator=(other);
for (std::list<TCPPayloadMessage>::const_iterator i=other.payloadList.begin(); i!=other.payloadList.end(); ++i)
addPayloadMessage(i->msg->dup(), i->endSequenceNo);
return *this;
}
| void TCPSegment::parsimPack | ( | cCommBuffer * | b | ) | [virtual] |
{
TCPSegment_Base::parsimPack(b);
doPacking(b, payloadList);
}
| void TCPSegment::parsimUnpack | ( | cCommBuffer * | b | ) | [virtual] |
{
TCPSegment_Base::parsimUnpack(b);
doUnpacking(b, payloadList);
}
| cPacket * TCPSegment::removeFirstPayloadMessage | ( | uint32 & | outEndSequenceNo | ) | [virtual] |
Removes and returns the first message object in this TCP segment. It also returns the sequence number+1 of its last octet in outEndSequenceNo.
Referenced by tcp_old::TCPMsgBasedRcvQueue::insertBytesFromSegment(), and TCPMsgBasedRcvQueue::insertBytesFromSegment().
{
if (payloadList.empty())
return NULL;
cPacket *msg = payloadList.front().msg;
endSequenceNo = payloadList.front().endSequenceNo;
payloadList.pop_front();
drop(msg);
return msg;
}
| void TCPSegment::setPayload | ( | unsigned int | k, |
| const TCPPayloadMessage & | payload_var | ||
| ) | [virtual] |
Generated but unused method, should not be called.
{
throw cRuntimeError(this, "setPayload() not supported, use addPayloadMessage()");
}
| void TCPSegment::setPayloadArraySize | ( | unsigned int | size | ) | [virtual] |
Generated but unused method, should not be called.
{
throw cRuntimeError(this, "setPayloadArraySize() not supported, use addPayloadMessage()");
}
| void TCPSegment::truncateSegment | ( | uint32 | firstSeqNo, |
| uint32 | endSeqNo | ||
| ) | [virtual] |
Truncate segment.
| firstSeqNo,: | sequence no of new first byte |
| endSeqNo,: | sequence no of new last byte+1 |
Referenced by TCPConnection::processSegment1stThru8th().
{
if(seqLess(sequenceNo_var, firstSeqNo))
{
unsigned int truncleft = firstSeqNo - sequenceNo_var;
while (!payloadList.empty())
{
if (seqGE(payloadList.front().endSequenceNo, firstSeqNo))
break;
cPacket *msg = payloadList.front().msg;
payloadList.pop_front();
dropAndDelete(msg);
}
payloadLength_var -= truncleft;
sequenceNo_var = firstSeqNo;
//TODO truncate data correctly if need
}
if(seqGreater(sequenceNo_var+payloadLength_var, endSeqNo))
{
unsigned int truncright = sequenceNo_var + payloadLength_var - endSeqNo;
while (!payloadList.empty())
{
if (seqLE(payloadList.back().endSequenceNo, endSeqNo))
break;
cPacket *msg = payloadList.back().msg;
payloadList.pop_back();
dropAndDelete(msg);
}
payloadLength_var -= truncright;
//TODO truncate data correctly if need
}
}
std::list<TCPPayloadMessage> TCPSegment::payloadList [protected] |