#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).
Definition at line 40 of file TCPSegment.h.
TCPSegment::TCPSegment | ( | const char * | name = NULL , |
|
int | kind = 0 | |||
) | [inline] |
Definition at line 46 of file TCPSegment.h.
: TCPSegment_Base(name,kind) {}
TCPSegment::TCPSegment | ( | const TCPSegment & | other | ) | [inline] |
Definition at line 47 of file TCPSegment.h.
: TCPSegment_Base(other.getName()) {operator=(other);}
TCPSegment::~TCPSegment | ( | ) | [virtual] |
Definition at line 34 of file TCPSegment.cc.
{ 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
Definition at line 118 of file TCPSegment.cc.
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] |
Definition at line 50 of file TCPSegment.h.
{return new TCPSegment(*this);}
TCPPayloadMessage & TCPSegment::getPayload | ( | unsigned int | k | ) | [virtual] |
Returns the kth payload message in this TCP segment
Definition at line 105 of file TCPSegment.cc.
{ 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
Definition at line 100 of file TCPSegment.cc.
Referenced by tcp_old::TCPMsgBasedSendQueue::createSegmentWithBytes(), and TCPMsgBasedSendQueue::createSegmentWithBytes().
{ return payloadList.size(); }
TCPSegment & TCPSegment::operator= | ( | const TCPSegment & | other | ) |
Definition at line 24 of file TCPSegment.cc.
{ 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] |
Definition at line 83 of file TCPSegment.cc.
{ TCPSegment_Base::parsimPack(b); doPacking(b, payloadList); }
void TCPSegment::parsimUnpack | ( | cCommBuffer * | b | ) | [virtual] |
Definition at line 89 of file TCPSegment.cc.
{ 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.
Definition at line 128 of file TCPSegment.cc.
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.
Definition at line 113 of file TCPSegment.cc.
{ throw cRuntimeError(this, "setPayload() not supported, use addPayloadMessage()"); }
void TCPSegment::setPayloadArraySize | ( | unsigned int | size | ) | [virtual] |
Generated but unused method, should not be called.
Definition at line 95 of file TCPSegment.cc.
{ 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 |
Definition at line 44 of file TCPSegment.cc.
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] |
Definition at line 43 of file TCPSegment.h.
Referenced by addPayloadMessage(), getPayload(), getPayloadArraySize(), operator=(), parsimPack(), parsimUnpack(), removeFirstPayloadMessage(), truncateSegment(), and ~TCPSegment().