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);
49 void TestTransmittedBlock ();
80 Simulator::Schedule (
Seconds (0.0),
82 Simulator::Schedule (
Seconds (0.0),
86 Simulator::Destroy ();
100 txBuf.
Add(Create<Packet> (10000));
102 for (uint8_t i = 0; i <10 ; ++i)
105 for (uint8_t i = 0; i < 10 ; ++i)
107 "Lost is true, but it's not");
112 for (uint8_t i = 0; i < 10 ; ++i)
114 "Lost is true, but it's not");
119 for (uint8_t i = 0; i < 10 ; ++i)
121 "Lost is true, but it's not");
127 "Lost is true, but it's not");
129 for (uint8_t i = 1; i < 10 ; ++i)
131 "Lost is true, but it's not");
144 uint32_t dupThresh = 3;
145 uint32_t segmentSize = 150;
150 "NextSeq should not be returned at the beginning");
154 "NextSeq should not be returned with no data");
157 txBuf.
Add (Create<Packet> (30000));
159 "No NextSeq with data at beginning");
161 "Different NextSeq than expected at the beginning");
164 for (uint32_t i=0; i<100; ++i)
167 "No NextSeq with data while \"transmitting\"");
169 "Different NextSeq than expected while \"transmitting\"");
176 for (uint32_t i=1; i<dupThresh; ++i)
185 "No NextSeq with SACK block while \"transmitting\"");
187 "Different NextSeq than expected in limited transmit");
196 head + (segmentSize * (dupThresh)) + segmentSize));
199 "No NextSeq with SACK block for Fast Recovery");
201 "Different NextSeq than expected for Fast Recovery");
206 for (uint32_t i=1; i<=4; ++i)
209 head + (segmentSize * (dupThresh+i)) + segmentSize));
212 "No NextSeq with SACK block after recv dupacks in FR");
214 "Different NextSeq than expected after recv dupacks in FR");
231 head = head + segmentSize;
235 "No NextSeq with SACK block after receiving partial ACK");
237 "Different NextSeq than expected after receiving partial ACK ");
242 head + (segmentSize * (dupThresh+6)) + segmentSize));
245 "No NextSeq with SACK block after recv dupacks after partial ack");
247 "Different NextSeq than expected after recv dupacks after partial ack");
250 head = lastRet = ret + segmentSize;
256 for (uint32_t i=0; i<93; ++i)
259 "No NextSeq with data while \"transmitting\"");
261 "Different NextSeq than expected while \"transmitting\"");
267 "Data inside the buffer");
283 "TxBuf miscalculates size");
285 "TxBuf miscalculates size of in flight segments");
289 "Returned packet has different size than requested");
291 "TxBuf miscalculates size");
293 "TxBuf miscalculates size of in flight segments");
297 "TxBuf miscalculates size");
299 "TxBuf miscalculates size of in flight segments");
308 "Returned packet has different size than requested");
310 "TxBuf miscalculates size");
312 "TxBuf miscalculates size of in flight segments");
320 "Returned packet has different size than requested");
322 "TxBuf miscalculates size");
324 "TxBuf miscalculates size of in flight segments");
328 "Returned packet has different size than requested");
330 "TxBuf miscalculates size");
332 "TxBuf miscalculates size of in flight segments");
337 "Size is different than expected");
Smart pointer class similar to boost::intrusive_ptr.
void DiscardUpTo(const SequenceNumber32 &seq)
Discard data up to but not including this sequence number.
TcpTxBufferTestCase()
Constructor.
void TestNextSeg()
Test the generation of the "next" block.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void AddSackBlock(SackBlock s)
Add a SACK block.
void TestIsLost()
Test if a segment is really set as lost.
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.
bool NextSeg(SequenceNumber32 *seq, bool isRecovery) const
Get the next sequence number to transmit, according to RFC 6675.
uint32_t SizeFromSequence(const SequenceNumber32 &seq) const
Returns the number of bytes from the buffer in the range [seq, tailSequence)
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 Add(Ptr< Packet > p)
Append a data packet to the end of the buffer.
void TestNewBlock()
Test the generation of an unsent block.
void SetDupAckThresh(uint32_t dupAckThresh)
Set the DupAckThresh.
std::pair< SequenceNumber32, SequenceNumber32 > SackBlock
SACK block definition.
bool Update(const TcpOptionSack::SackList &list)
Update the scoreboard.
void SetSegmentSize(uint32_t segmentSize)
Set the segment size.
static TcpTxBufferTestSuite g_tcpTxBufferTestSuite
Static variable for test initialization.
uint32_t Size(void) const
Returns total number of bytes in this buffer.
bool IsLost(const SequenceNumber32 &seq) const
Check if a segment is lost.
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.
This test suite implements a Unit Test.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
uint32_t BytesInFlight() const
Return total bytes in flight.
SackList GetSackList(void) const
Get the SACK list.
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.