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 ();
54 uint32_t GetRWnd (
void)
const;
83 Simulator::Schedule (
Seconds (0.0),
85 Simulator::Schedule (
Seconds (0.0),
89 Simulator::Destroy ();
104 txBuf->
Add(Create<Packet> (10000));
106 for (uint8_t i = 0; i <10 ; ++i)
109 for (uint8_t i = 0; i < 10 ; ++i)
111 "Lost is true, but it's not");
116 for (uint8_t i = 0; i < 10 ; ++i)
118 "Lost is true, but it's not");
123 for (uint8_t i = 0; i < 10 ; ++i)
125 "Lost is true, but it's not");
131 "Lost is true, but it's not");
133 for (uint8_t i = 1; i < 10 ; ++i)
135 "Lost is true, but it's not");
157 uint32_t dupThresh = 3;
158 uint32_t segmentSize = 150;
163 "NextSeq should not be returned at the beginning");
167 "NextSeq should not be returned with no data");
170 txBuf->
Add (Create<Packet> (30000));
172 "No NextSeq with data at beginning");
174 "Different NextSeq than expected at the beginning");
177 for (uint32_t i=0; i<100; ++i)
180 "No NextSeq with data while \"transmitting\"");
182 "Different NextSeq than expected while \"transmitting\"");
189 for (uint32_t i=1; i<dupThresh; ++i)
198 "No NextSeq with SACK block while \"transmitting\"");
200 "Different NextSeq than expected in limited transmit");
209 head + (segmentSize * (dupThresh)) + segmentSize));
212 "No NextSeq with SACK block for Fast Recovery");
214 "Different NextSeq than expected for Fast Recovery");
219 for (uint32_t i=1; i<=4; ++i)
222 head + (segmentSize * (dupThresh+i)) + segmentSize));
225 "No NextSeq with SACK block after recv dupacks in FR");
227 "Different NextSeq than expected after recv dupacks in FR");
244 head = head + segmentSize;
248 "No NextSeq with SACK block after receiving partial ACK");
250 "Different NextSeq than expected after receiving partial ACK ");
255 head + (segmentSize * (dupThresh+6)) + segmentSize));
258 "No NextSeq with SACK block after recv dupacks after partial ack");
260 "Different NextSeq than expected after recv dupacks after partial ack");
263 head = lastRet = ret + segmentSize;
269 for (uint32_t i=0; i<93; ++i)
272 "No NextSeq with data while \"transmitting\"");
274 "Different NextSeq than expected while \"transmitting\"");
280 "Data inside the buffer");
297 "TxBuf miscalculates size");
299 "TxBuf miscalculates size of in flight segments");
303 "Returned packet has different size than requested");
305 "TxBuf miscalculates size");
307 "TxBuf miscalculates size of in flight segments");
311 "TxBuf miscalculates size");
313 "TxBuf miscalculates size of in flight segments");
322 "Returned packet has different size than requested");
324 "TxBuf miscalculates size");
326 "TxBuf miscalculates size of in flight segments");
334 "Returned packet has different size than requested");
336 "TxBuf miscalculates size");
338 "TxBuf miscalculates size of in flight segments");
342 "Returned packet has different size than requested");
344 "TxBuf miscalculates size");
346 "TxBuf miscalculates size of in flight segments");
351 "Size is different than expected");
Smart pointer class similar to boost::intrusive_ptr.
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.
uint32_t GetRWnd(void) const
Callback to provide a value of receiver window.
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 DiscardUpTo(const SequenceNumber32 &seq, const Callback< void, TcpTxItem *> &beforeDelCb=m_nullCb)
Discard data up to but not including this sequence number.
TcpTxItem * CopyFromSequence(uint32_t numBytes, const SequenceNumber32 &seq)
Copy data from the range [seq, seq+numBytes) into a packet.
void SetRWndCallback(Callback< uint32_t > rWndCallback)
Set callback to obtain receiver window value.
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.
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.
Ptr< Packet > GetPacketCopy(void) const
Get a copy of the Packet underlying this item.
bool IsLost(const SequenceNumber32 &seq) const
Check if a segment is lost.
uint32_t Update(const TcpOptionSack::SackList &list, const Callback< void, TcpTxItem *> &sackedCb=m_nullCb)
Update the scoreboard.
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.
bool NextSeg(SequenceNumber32 *seq, SequenceNumber32 *seqHigh, bool isRecovery) const
Get the next sequence number to transmit, according to RFC 6675.
This test suite implements a Unit Test.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
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...
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.