20 #include "ns3/tcp-tx-buffer.h"
21 #include "ns3/packet.h"
22 #include "ns3/simulator.h"
42 virtual void DoRun (
void);
43 virtual void DoTeardown (
void);
50 void TestTransmittedBlock ();
55 void TestMergeItemsWhenGetTransmittedSegment ();
60 uint32_t GetRWnd (
void)
const;
89 Simulator::Schedule (
Seconds (0.0),
91 Simulator::Schedule (
Seconds (0.0),
101 Simulator::Schedule (
Seconds (0.0),
105 Simulator::Destroy ();
114 txBuf->SetHeadSequence (head);
117 txBuf->SetSegmentSize (1000);
118 txBuf->SetDupAckThresh (3);
120 txBuf->Add(Create<Packet> (10000));
122 for (uint8_t i = 0; i <10 ; ++i)
125 for (uint8_t i = 0; i < 10 ; ++i)
127 "Lost is true, but it's not");
130 txBuf->Update(sack->GetSackList());
132 for (uint8_t i = 0; i < 10 ; ++i)
134 "Lost is true, but it's not");
137 txBuf->Update(sack->GetSackList());
139 for (uint8_t i = 0; i < 10 ; ++i)
141 "Lost is true, but it's not");
144 txBuf->Update(sack->GetSackList());
147 "Lost is true, but it's not");
149 for (uint8_t i = 1; i < 10 ; ++i)
151 "Lost is true, but it's not");
171 txBuf->SetSegmentSize (150);
172 txBuf->SetDupAckThresh (3);
173 uint32_t dupThresh = 3;
179 "NextSeq should not be returned at the beginning");
181 txBuf->SetHeadSequence (head);
183 "NextSeq should not be returned with no data");
186 txBuf->Add (Create<Packet> (30000));
188 "No NextSeq with data at beginning");
190 "Different NextSeq than expected at the beginning");
193 for (uint32_t i=0; i<100; ++i)
196 "No NextSeq with data while \"transmitting\"");
198 "Different NextSeq than expected while \"transmitting\"");
205 for (uint32_t i=1; i<dupThresh; ++i)
210 txBuf->Update (sack->GetSackList ());
214 "No NextSeq with SACK block while \"transmitting\"");
216 "Different NextSeq than expected in limited transmit");
218 sack->ClearSackList ();
226 txBuf->Update (sack->GetSackList ());
228 "No NextSeq with SACK block for Fast Recovery");
230 "Different NextSeq than expected for Fast Recovery");
232 sack->ClearSackList ();
235 for (uint32_t i=1; i<=4; ++i)
239 txBuf->Update (sack->GetSackList ());
241 "No NextSeq with SACK block after recv dupacks in FR");
243 "Different NextSeq than expected after recv dupacks in FR");
245 sack->ClearSackList ();
261 txBuf->DiscardUpTo (head);
264 "No NextSeq with SACK block after receiving partial ACK");
266 "Different NextSeq than expected after receiving partial ACK ");
272 txBuf->Update (sack->GetSackList ());
274 "No NextSeq with SACK block after recv dupacks after partial ack");
276 "Different NextSeq than expected after recv dupacks after partial ack");
278 sack->ClearSackList ();
282 txBuf->DiscardUpTo (head);
285 for (uint32_t i=0; i<93; ++i)
288 "No NextSeq with data while \"transmitting\"");
290 "Different NextSeq than expected while \"transmitting\"");
296 "Data inside the buffer");
306 txBuf->SetSegmentSize (100);
313 "TxBuf miscalculates size");
315 "TxBuf miscalculates size of in flight segments");
319 "Returned packet has different size than requested");
321 "TxBuf miscalculates size");
323 "TxBuf miscalculates size of in flight segments");
327 "TxBuf miscalculates size");
329 "TxBuf miscalculates size of in flight segments");
336 ret = txBuf->CopyFromSequence (50,
SequenceNumber32 (101))->GetPacketCopy ();
338 "Returned packet has different size than requested");
340 "TxBuf miscalculates size");
342 "TxBuf miscalculates size of in flight segments");
348 ret = txBuf->CopyFromSequence (70,
SequenceNumber32 (151))->GetPacketCopy ();
350 "Returned packet has different size than requested");
352 "TxBuf miscalculates size");
354 "TxBuf miscalculates size of in flight segments");
356 ret = txBuf->CopyFromSequence (3000,
SequenceNumber32 (221))->GetPacketCopy ();
358 "Returned packet has different size than requested");
360 "TxBuf miscalculates size");
362 "TxBuf miscalculates size of in flight segments");
367 "Size is different than expected");
378 txBuf.
Add(Create<Packet> (2000));
virtual void DoRun(void)
Implementation to actually run this TestCase.
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 TestNewBlock()
Test the generation of an unsent block.
uint32_t GetRWnd(void) const
Callback to provide a value of receiver window.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
void TestIsLost()
Test if a segment is really set as lost.
void TestNextSeg()
Test the generation of the "next" block.
TcpTxBufferTestCase()
Constructor.
the TestSuite for the TcpTxBuffer test case
uint32_t GetSize(void) 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, Ts... > MakeCallback(R(T::*memPtr)(Ts...), 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.