8#include "ns3/simulator.h"
9#include "ns3/tcp-tx-buffer.h"
31 void DoRun()
override;
102 txBuf->SetHeadSequence(head);
104 txBuf->SetSegmentSize(1000);
105 txBuf->SetDupAckThresh(3);
109 for (uint8_t i = 0; i < 10; ++i)
114 for (uint8_t i = 0; i < 10; ++i)
118 "Lost is true, but it's not");
122 txBuf->Update(sack->GetSackList());
124 for (uint8_t i = 0; i < 10; ++i)
128 "Lost is true, but it's not");
132 txBuf->Update(sack->GetSackList());
134 for (uint8_t i = 0; i < 10; ++i)
138 "Lost is true, but it's not");
142 txBuf->Update(sack->GetSackList());
146 for (uint8_t i = 1; i < 10; ++i)
150 "Lost is true, but it's not");
158 return std::numeric_limits<uint32_t>::max();
170 txBuf->SetSegmentSize(150);
171 txBuf->SetDupAckThresh(3);
179 "NextSeq should not be returned at the beginning");
181 txBuf->SetHeadSequence(head);
184 "NextSeq should not be returned with no data");
190 "No NextSeq with data at beginning");
193 "Different NextSeq than expected at the beginning");
200 "No NextSeq with data while \"transmitting\"");
203 "Different NextSeq than expected while \"transmitting\"");
210 for (
uint32_t i = 1; i < dupThresh; ++i)
215 txBuf->Update(sack->GetSackList());
220 "No NextSeq with SACK block while \"transmitting\"");
223 "Different NextSeq than expected in limited transmit");
225 sack->ClearSackList();
233 txBuf->Update(sack->GetSackList());
236 "No NextSeq with SACK block for Fast Recovery");
239 sack->ClearSackList();
247 txBuf->Update(sack->GetSackList());
250 "No NextSeq with SACK block after recv dupacks in FR");
253 "Different NextSeq than expected after recv dupacks in FR");
255 sack->ClearSackList();
271 txBuf->DiscardUpTo(head);
275 "No NextSeq with SACK block after receiving partial ACK");
278 "Different NextSeq than expected after receiving partial ACK ");
285 txBuf->Update(sack->GetSackList());
288 "No NextSeq with SACK block after recv dupacks after partial ack");
291 "Different NextSeq than expected after recv dupacks after partial ack");
293 sack->ClearSackList();
297 txBuf->DiscardUpTo(head);
304 "No NextSeq with data while \"transmitting\"");
307 "Different NextSeq than expected while \"transmitting\"");
322 txBuf->SetSegmentSize(100);
330 "TxBuf miscalculates size");
333 "TxBuf miscalculates size of in flight segments");
339 "TxBuf miscalculates size");
342 "TxBuf miscalculates size of in flight segments");
347 "TxBuf miscalculates size");
350 "TxBuf miscalculates size of in flight segments");
361 "TxBuf miscalculates size");
364 "TxBuf miscalculates size of in flight segments");
374 "TxBuf miscalculates size");
377 "TxBuf miscalculates size of in flight segments");
379 ret = txBuf->CopyFromSequence(3000,
SequenceNumber32(221))->GetPacketCopy();
383 "TxBuf miscalculates size");
386 "TxBuf miscalculates size of in flight segments");
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
Smart pointer class similar to boost::intrusive_ptr.
constexpr NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
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, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
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...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
SequenceNumber< uint32_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.
static TcpTxBufferTestSuite g_tcpTxBufferTestSuite
Static variable for test initialization.