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 ();
57 uint32_t GetRWnd (
void)
const;
86 Simulator::Schedule (
Seconds (0.0),
88 Simulator::Schedule (
Seconds (0.0),
98 Simulator::Schedule (
Seconds (0.0),
102 Simulator::Destroy ();
117 txBuf->
Add(Create<Packet> (10000));
119 for (uint8_t i = 0; i <10 ; ++i)
122 for (uint8_t i = 0; i < 10 ; ++i)
124 "Lost is true, but it's not");
129 for (uint8_t i = 0; i < 10 ; ++i)
131 "Lost is true, but it's not");
136 for (uint8_t i = 0; i < 10 ; ++i)
138 "Lost is true, but it's not");
144 "Lost is true, but it's not");
146 for (uint8_t i = 1; i < 10 ; ++i)
148 "Lost is true, but it's not");
170 uint32_t dupThresh = 3;
176 "NextSeq should not be returned at the beginning");
180 "NextSeq should not be returned with no data");
183 txBuf->
Add (Create<Packet> (30000));
185 "No NextSeq with data at beginning");
187 "Different NextSeq than expected at the beginning");
190 for (uint32_t i=0; i<100; ++i)
193 "No NextSeq with data while \"transmitting\"");
195 "Different NextSeq than expected while \"transmitting\"");
202 for (uint32_t i=1; i<dupThresh; ++i)
211 "No NextSeq with SACK block while \"transmitting\"");
213 "Different NextSeq than expected in limited transmit");
225 "No NextSeq with SACK block for Fast Recovery");
227 "Different NextSeq than expected for Fast Recovery");
232 for (uint32_t i=1; i<=4; ++i)
238 "No NextSeq with SACK block after recv dupacks in FR");
240 "Different NextSeq than expected after recv dupacks in FR");
261 "No NextSeq with SACK block after receiving partial ACK");
263 "Different NextSeq than expected after receiving partial ACK ");
271 "No NextSeq with SACK block after recv dupacks after partial ack");
273 "Different NextSeq than expected after recv dupacks after partial ack");
282 for (uint32_t i=0; i<93; ++i)
285 "No NextSeq with data while \"transmitting\"");
287 "Different NextSeq than expected while \"transmitting\"");
293 "Data inside the buffer");
310 "TxBuf miscalculates size");
312 "TxBuf miscalculates size of in flight segments");
316 "Returned packet has different size than requested");
318 "TxBuf miscalculates size");
320 "TxBuf miscalculates size of in flight segments");
324 "TxBuf miscalculates size");
326 "TxBuf miscalculates size of in flight segments");
335 "Returned packet has different size than requested");
337 "TxBuf miscalculates size");
339 "TxBuf miscalculates size of in flight segments");
347 "Returned packet has different size than requested");
349 "TxBuf miscalculates size");
351 "TxBuf miscalculates size of in flight segments");
355 "Returned packet has different size than requested");
357 "TxBuf miscalculates size");
359 "TxBuf miscalculates size of in flight segments");
364 "Size is different than expected");
375 txBuf.
Add(Create<Packet> (2000));
Smart pointer class similar to boost::intrusive_ptr.
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit 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.
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 TestMergeItemsWhenGetTransmittedSegment()
Test the logic of merging items in GetTransmittedSegment() which is triggered by CopyFromSequence() ...
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.
void MarkHeadAsLost()
Mark the head of the sent list as lost.
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.