19 #include "ns3/tcp-tx-buffer.h"
20 #include "ns3/packet.h"
21 #include "ns3/simulator.h"
41 virtual void DoRun (
void);
42 virtual void DoTeardown (
void);
47 void TestTransmittedBlock ();
51 void TestUpdateScoreboardWithCraftedSACK ();
79 Simulator::Schedule (
Seconds (0.0),
81 Simulator::Schedule (
Seconds (0.0),
83 Simulator::Schedule (
Seconds (0.0),
87 Simulator::Destroy ();
96 uint32_t dupThresh = 3;
97 uint32_t segmentSize = 150;
102 "NextSeq should not be returned at the beginning");
106 "NextSeq should not be returned with no data");
109 txBuf.
Add (Create<Packet> (30000));
111 "No NextSeq with data at beginning");
113 "Different NextSeq than expected at the beginning");
116 for (uint32_t i=0; i<100; ++i)
119 "No NextSeq with data while \"transmitting\"");
121 "Different NextSeq than expected while \"transmitting\"");
128 for (uint32_t i=1; i<dupThresh; ++i)
137 "No NextSeq with SACK block while \"transmitting\"");
139 "Different NextSeq than expected in limited transmit");
148 head + (segmentSize * (dupThresh)) + segmentSize));
151 "No NextSeq with SACK block for Fast Recovery");
153 "Different NextSeq than expected for Fast Recovery");
158 for (uint32_t i=1; i<=4; ++i)
161 head + (segmentSize * (dupThresh+i)) + segmentSize));
164 "No NextSeq with SACK block after recv dupacks in FR");
166 "Different NextSeq than expected after recv dupacks in FR");
183 head = head + segmentSize;
186 "No NextSeq with SACK block after receiving partial ACK");
188 "Different NextSeq than expected after receiving partial ACK");
193 head + (segmentSize * (dupThresh+6)) + segmentSize));
196 "No NextSeq with SACK block after recv dupacks after partial ack");
198 "Different NextSeq than expected after recv dupacks after partial ack");
201 head = lastRet = ret + segmentSize;
207 for (uint32_t i=0; i<93; ++i)
210 "No NextSeq with data while \"transmitting\"");
212 "Different NextSeq than expected while \"transmitting\"");
218 "Data inside the buffer");
233 "TxBuf miscalculates size");
239 "Returned packet has different size than requested");
241 "TxBuf miscalculates size");
247 "TxBuf miscalculates size");
258 "Returned packet has different size than requested");
260 "TxBuf miscalculates size");
270 "Returned packet has different size than requested");
272 "TxBuf miscalculates size");
278 "Returned packet has different size than requested");
280 "TxBuf miscalculates size");
287 "Size is different than expected");
298 txBuf.
Add (Create<Packet> (30000));
301 for (uint32_t i=0; i<100; ++i)
309 for (uint32_t i=0; i<99; ++i)
318 "Different block number than expected");
323 "Different block number than expected");
328 "More blocks than expected");
333 sackList.pop_front ();
339 "First sack block is wrong (on the left)");
341 "First sack block is wrong (on the right)");
344 for (TcpOptionSack::SackList::iterator it = sackList.begin (); it != sackList.end (); ++it)
351 "First sack block is wrong (on the left)");
353 "First sack block is wrong (on the right)");
362 "SequenceNumber 1 isLost, but for RFC 6675 is not");
367 "SequenceNumber 1 isLost, but for RFC 6675 is not");
370 "SequenceNumber " << lost <<
371 "isLost, but for RFC 6675 is because is SACKed");
376 "SequenceNumber 1 ! isLost, but for RFC 6675 is");
379 "SequenceNumber " << lost <<
380 "isLost, but for RFC 6675 is because is SACKed");
384 for (uint32_t i=0; i<100; ++i)
390 "Data inside the buffer");
Smart pointer class similar to boost::intrusive_ptr.
uint32_t Size(void) const
Returns total number of bytes in this buffer.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
void DiscardUpTo(const SequenceNumber32 &seq)
Discard data up to but not including this sequence number.
uint32_t SizeFromSequence(const SequenceNumber32 &seq) const
Returns the number of bytes from the buffer in the range [seq, tailSequence)
bool IsLost(const SequenceNumber32 &seq, uint32_t dupThresh, uint32_t segmentSize) const
Check if a segment is lost per RFC 6675.
TcpTxBufferTestCase()
Constructor.
std::list< SackBlock > SackList
SACK list definition.
void TestNextSeg()
Test the generation of the "next" block.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void TestUpdateScoreboardWithCraftedSACK()
Test the scoreboard with emulated SACK.
This test suite implements a Unit Test.
void AddSackBlock(SackBlock s)
Add a SACK block.
SackList GetSackList(void) const
Get the SACK list.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
the TestSuite for the TcpTxBuffer test case
#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.
void TestTransmittedBlock()
Test the generation of a previously sent block.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
bool NextSeg(SequenceNumber32 *seq, uint32_t dupThresh, uint32_t segmentSize, bool isRecovery) const
Get the next sequence number to transmit, according to RFC 6675.
bool Add(Ptr< Packet > p)
Append a data packet to the end of the buffer.
void TestNewBlock()
Test the generation of an unsent block.
uint32_t GetNumSackBlocks(void) const
Count the total number of SACK blocks.
std::pair< SequenceNumber32, SequenceNumber32 > SackBlock
SACK block definition.
bool Update(const TcpOptionSack::SackList &list)
Update the scoreboard.
static TcpTxBufferTestSuite g_tcpTxBufferTestSuite
Static variable for test initialization.
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void ClearSackList(void)
Clear the SACK list.
Ptr< const TcpOptionSack > CraftSackOption(const SequenceNumber32 &seq, uint8_t available) const
Craft a SACK block.
void SetHeadSequence(const SequenceNumber32 &seq)
Set the head sequence of the buffer.
Ptr< Packet > CopyFromSequence(uint32_t numBytes, const SequenceNumber32 &seq)
Copy data from the range [seq, seq+numBytes) into a packet.