%description:
Test TCPMsgBasedSendQueue class
- segments with/without last byte of msg.
- enqueueing, create segment, discard up.

%includes:
#include "TCPQueueTesterFunctions.h"

%global:

using namespace ::inet::tcp;

%activity:
TCPMsgBasedSendQueue sendQueue;
TCPMsgBasedSendQueue *q = &sendQueue;

q->init(1000);
EV << q->info() <<"\n";

enqueue(q, "msg1", 100); // 1000..1100
enqueue(q, "msg2", 400); // 1100..1500
enqueue(q, "msg3", 600); // 1500..2100
enqueue(q, "msg4", 200); // 2100..2300

delete createSegmentWithBytes(q, 1000, 1099);
delete createSegmentWithBytes(q, 1000, 1100);
delete createSegmentWithBytes(q, 1000, 2099);
delete createSegmentWithBytes(q, 1000, 2100);
delete createSegmentWithBytes(q, 2000, 2099);
delete createSegmentWithBytes(q, 2000, 2100);

discardUpTo(q, 2099);
discardUpTo(q, 2100);

delete createSegmentWithBytes(q, 2100, 2100);

EV << ".\n";


%contains: stdout
[1000..1000), 0 packets
SQ:enqueue("msg1", 100): --> [1000..1100), 1 packets
SQ:enqueue("msg2", 400): --> [1000..1500), 2 packets
SQ:enqueue("msg3", 600): --> [1000..2100), 3 packets
SQ:enqueue("msg4", 200): --> [1000..2300), 4 packets
SQ:createSegmentWithBytes(1000, 1099):
SQ:createSegmentWithBytes(1000, 1100): msg1[1000..1100)
SQ:createSegmentWithBytes(1000, 2099): msg1[1000..1100), msg2[1100..1500)
SQ:createSegmentWithBytes(1000, 2100): msg1[1000..1100), msg2[1100..1500), msg3[1500..2100)
SQ:createSegmentWithBytes(2000, 2099):
SQ:createSegmentWithBytes(2000, 2100): msg3[1500..2100)
SQ:discardUpTo(2099): [2099..2300), 2 packets
SQ:discardUpTo(2100): [2100..2300), 1 packets
SQ:createSegmentWithBytes(2100, 2100):
.
