18 #include "ns3/packet.h"
19 #include "ns3/simulator.h"
20 #include "ns3/tcp-tx-buffer.h"
42 void DoRun()
override;
43 void DoTeardown()
override;
50 void TestTransmittedBlock();
55 void TestMergeItemsWhenGetTransmittedSegment();
60 uint32_t GetRWnd()
const;
99 Simulator::Schedule(
Seconds(0.0),
104 Simulator::Destroy();
113 txBuf->SetHeadSequence(head);
116 txBuf->SetSegmentSize(1000);
117 txBuf->SetDupAckThresh(3);
119 txBuf->Add(Create<Packet>(10000));
121 for (uint8_t i = 0; i < 10; ++i)
126 for (uint8_t i = 0; i < 10; ++i)
130 "Lost is true, but it's not");
134 txBuf->Update(sack->GetSackList());
136 for (uint8_t i = 0; i < 10; ++i)
140 "Lost is true, but it's not");
144 txBuf->Update(sack->GetSackList());
146 for (uint8_t i = 0; i < 10; ++i)
150 "Lost is true, but it's not");
154 txBuf->Update(sack->GetSackList());
158 for (uint8_t i = 1; i < 10; ++i)
162 "Lost is true, but it's not");
182 txBuf->SetSegmentSize(150);
183 txBuf->SetDupAckThresh(3);
184 uint32_t dupThresh = 3;
191 "NextSeq should not be returned at the beginning");
193 txBuf->SetHeadSequence(head);
196 "NextSeq should not be returned with no data");
199 txBuf->Add(Create<Packet>(30000));
202 "No NextSeq with data at beginning");
205 "Different NextSeq than expected at the beginning");
208 for (uint32_t i = 0; i < 100; ++i)
212 "No NextSeq with data while \"transmitting\"");
215 "Different NextSeq than expected while \"transmitting\"");
222 for (uint32_t i = 1; i < dupThresh; ++i)
227 txBuf->Update(sack->GetSackList());
232 "No NextSeq with SACK block while \"transmitting\"");
235 "Different NextSeq than expected in limited transmit");
237 sack->ClearSackList();
245 txBuf->Update(sack->GetSackList());
248 "No NextSeq with SACK block for Fast Recovery");
251 sack->ClearSackList();
254 for (uint32_t i = 1; i <= 4; ++i)
259 txBuf->Update(sack->GetSackList());
262 "No NextSeq with SACK block after recv dupacks in FR");
265 "Different NextSeq than expected after recv dupacks in FR");
267 sack->ClearSackList();
283 txBuf->DiscardUpTo(head);
287 "No NextSeq with SACK block after receiving partial ACK");
290 "Different NextSeq than expected after receiving partial ACK ");
297 txBuf->Update(sack->GetSackList());
300 "No NextSeq with SACK block after recv dupacks after partial ack");
303 "Different NextSeq than expected after recv dupacks after partial ack");
305 sack->ClearSackList();
309 txBuf->DiscardUpTo(head);
312 for (uint32_t i = 0; i < 93; ++i)
316 "No NextSeq with data while \"transmitting\"");
319 "Different NextSeq than expected while \"transmitting\"");
334 txBuf->SetSegmentSize(100);
342 "TxBuf miscalculates size");
345 "TxBuf miscalculates size of in flight segments");
351 "TxBuf miscalculates size");
354 "TxBuf miscalculates size of in flight segments");
359 "TxBuf miscalculates size");
362 "TxBuf miscalculates size of in flight segments");
373 "TxBuf miscalculates size");
376 "TxBuf miscalculates size of in flight segments");
386 "TxBuf miscalculates size");
389 "TxBuf miscalculates size of in flight segments");
391 ret = txBuf->CopyFromSequence(3000,
SequenceNumber32(221))->GetPacketCopy();
395 "TxBuf miscalculates size");
398 "TxBuf miscalculates size of in flight segments");
413 txBuf.
Add(Create<Packet>(2000));
void TestTransmittedBlock()
Test the generation of a previously sent block.
void TestMergeItemsWhenGetTransmittedSegment()
Test the logic of merging items in GetTransmittedSegment() which is triggered by CopyFromSequence()
void DoRun() override
Implementation to actually run this TestCase.
void TestNewBlock()
Test the generation of an unsent block.
uint32_t GetRWnd() const
Callback to provide a value of receiver window.
void TestIsLost()
Test if a segment is really set as lost.
void TestNextSeg()
Test the generation of the "next" block.
TcpTxBufferTestCase()
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
the TestSuite for the TcpTxBuffer test case
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Smart pointer class similar to boost::intrusive_ptr.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
std::pair< SequenceNumber32, SequenceNumber32 > SackBlock
SACK block definition.
bool Add(Ptr< Packet > p)
Append a data packet to the end of the buffer.
void SetSegmentSize(uint32_t segmentSize)
Set the segment size.
TcpTxItem * CopyFromSequence(uint32_t numBytes, const SequenceNumber32 &seq)
Copy data from the range [seq, seq+numBytes) into a packet.
void MarkHeadAsLost()
Mark the head of the sent list as lost.
void SetHeadSequence(const SequenceNumber32 &seq)
Set the head sequence of the buffer.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static TcpTxBufferTestSuite g_tcpTxBufferTestSuite
Static variable for test initialization.