8#include "ns3/simulator.h"
9#include "ns3/tcp-tx-buffer.h"
31 void DoRun()
override;
102 txBuf->SetHeadSequence(head);
105 txBuf->SetSegmentSize(1000);
106 txBuf->SetDupAckThresh(3);
110 for (uint8_t i = 0; i < 10; ++i)
115 for (uint8_t i = 0; i < 10; ++i)
119 "Lost is true, but it's not");
123 txBuf->Update(sack->GetSackList());
125 for (uint8_t i = 0; i < 10; ++i)
129 "Lost is true, but it's not");
133 txBuf->Update(sack->GetSackList());
135 for (uint8_t i = 0; i < 10; ++i)
139 "Lost is true, but it's not");
143 txBuf->Update(sack->GetSackList());
147 for (uint8_t i = 1; i < 10; ++i)
151 "Lost is true, but it's not");
159 return std::numeric_limits<uint32_t>::max();
171 txBuf->SetSegmentSize(150);
172 txBuf->SetDupAckThresh(3);
180 "NextSeq should not be returned at the beginning");
182 txBuf->SetHeadSequence(head);
185 "NextSeq should not be returned with no data");
191 "No NextSeq with data at beginning");
194 "Different NextSeq than expected at the beginning");
201 "No NextSeq with data while \"transmitting\"");
204 "Different NextSeq than expected while \"transmitting\"");
211 for (
uint32_t i = 1; i < dupThresh; ++i)
216 txBuf->Update(sack->GetSackList());
221 "No NextSeq with SACK block while \"transmitting\"");
224 "Different NextSeq than expected in limited transmit");
226 sack->ClearSackList();
234 txBuf->Update(sack->GetSackList());
237 "No NextSeq with SACK block for Fast Recovery");
240 sack->ClearSackList();
248 txBuf->Update(sack->GetSackList());
251 "No NextSeq with SACK block after recv dupacks in FR");
254 "Different NextSeq than expected after recv dupacks in FR");
256 sack->ClearSackList();
272 txBuf->DiscardUpTo(head);
276 "No NextSeq with SACK block after receiving partial ACK");
279 "Different NextSeq than expected after receiving partial ACK ");
286 txBuf->Update(sack->GetSackList());
289 "No NextSeq with SACK block after recv dupacks after partial ack");
292 "Different NextSeq than expected after recv dupacks after partial ack");
294 sack->ClearSackList();
298 txBuf->DiscardUpTo(head);
305 "No NextSeq with data while \"transmitting\"");
308 "Different NextSeq than expected while \"transmitting\"");
323 txBuf->SetSegmentSize(100);
331 "TxBuf miscalculates size");
334 "TxBuf miscalculates size of in flight segments");
340 "TxBuf miscalculates size");
343 "TxBuf miscalculates size of in flight segments");
348 "TxBuf miscalculates size");
351 "TxBuf miscalculates size of in flight segments");
362 "TxBuf miscalculates size");
365 "TxBuf miscalculates size of in flight segments");
375 "TxBuf miscalculates size");
378 "TxBuf miscalculates size of in flight segments");
380 ret = txBuf->CopyFromSequence(3000,
SequenceNumber32(221))->GetPacketCopy();
384 "TxBuf miscalculates size");
387 "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.
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.
static constexpr auto UNIT
#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, 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.