tests: doxygen fixes

This commit is contained in:
Tommaso Pecorella
2022-01-13 17:07:08 -06:00
parent 0b3b639524
commit f33366d1e1
12 changed files with 893 additions and 225 deletions

View File

@@ -51,6 +51,11 @@
using namespace ns3;
/**
* \ingroup system-tests-csma
*
* \brief CSMA Bridge mode test.
*/
class CsmaBridgeTestCase : public TestCase
{
public:
@@ -59,8 +64,14 @@ public:
private:
virtual void DoRun (void);
/**
* Sink called when a packet is received.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
*/
void SinkRx (Ptr<const Packet> p, const Address &ad);
uint32_t m_count;
uint32_t m_count; //!< Counter of received packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -155,6 +166,11 @@ CsmaBridgeTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Bridge should have passed 10 packets");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA Broadcast mode test.
*/
class CsmaBroadcastTestCase : public TestCase
{
public:
@@ -163,12 +179,26 @@ public:
private:
virtual void DoRun (void);
/**
* Sink called when a packet is received by a node.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
* @{
*/
void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
/** @} */
/**
* Sink called when a packet is dropped.
* \param p Received packet (unused).
*/
void DropEvent (Ptr<const Packet> p);
uint32_t m_countNode1;
uint32_t m_countNode2;
uint32_t m_drops;
uint32_t m_countNode1; //!< Counter of received packets on node 1.
uint32_t m_countNode2; //!< Counter of received packets on node 2.
uint32_t m_drops; //!< Counter of dropped packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -275,6 +305,11 @@ CsmaBroadcastTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_countNode2, 10, "Node 2 should have received 10 packets");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA Multicast mode test.
*/
class CsmaMulticastTestCase : public TestCase
{
public:
@@ -283,10 +318,22 @@ public:
private:
virtual void DoRun (void);
/**
* Sink called when a packet is received by a node.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
*/
void SinkRx (Ptr<const Packet> p, const Address &ad);
/**
* Sink called when a packet is dropped.
* \param p Received packet (unused).
*/
void DropEvent (Ptr<const Packet> p);
uint32_t m_count;
uint32_t m_drops;
uint32_t m_count; //!< Counter of received packets.
uint32_t m_drops; //!< Counter of dropped packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -435,6 +482,11 @@ CsmaMulticastTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 4 should have received 10 packets");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA One Subnet mode test.
*/
class CsmaOneSubnetTestCase : public TestCase
{
public:
@@ -443,12 +495,25 @@ public:
private:
virtual void DoRun (void);
/**
* Sink called when a packet is received by a node.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
* @{
*/
void SinkRxNode0 (Ptr<const Packet> p, const Address &ad);
void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
/** @} */
/**
* Sink called when a packet is dropped.
* \param p Received packet (unused).
*/
void DropEvent (Ptr<const Packet> p);
uint32_t m_countNode0;
uint32_t m_countNode1;
uint32_t m_drops;
uint32_t m_countNode0; //!< Counter of received packets on node 0.
uint32_t m_countNode1; //!< Counter of received packets on node 1.
uint32_t m_drops; //!< Counter of dropped packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -563,6 +628,11 @@ CsmaOneSubnetTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_countNode1, 10, "Node 1 should have received 10 packets");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA PacketSocket test.
*/
class CsmaPacketSocketTestCase : public TestCase
{
public:
@@ -571,10 +641,22 @@ public:
private:
virtual void DoRun (void);
void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
/**
* Sink called when a packet is received by a node.
* \param path Sink path.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
*/
void SinkRx (std::string path, Ptr<const Packet> p, const Address &ad);
/**
* Sink called when a packet is dropped.
* \param p Received packet (unused).
*/
void DropEvent (Ptr<const Packet> p);
uint32_t m_count;
uint32_t m_drops;
uint32_t m_count; //!< Counter of received packets.
uint32_t m_drops; //!< Counter of dropped packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -669,6 +751,11 @@ CsmaPacketSocketTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 0 should have received 10 packets");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA PING test.
*/
class CsmaPingTestCase : public TestCase
{
public:
@@ -677,12 +764,29 @@ public:
private:
virtual void DoRun (void);
/**
* Sink called when a packet is received by a node.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
*/
void SinkRx (Ptr<const Packet> p, const Address &ad);
/**
* Sink called when a PING ois received.
* \param context Context path (unused).
* \param rtt Round Trip Time (unused).
*/
void PingRtt (std::string context, Time rtt);
/**
* Sink called when a packet is dropped.
* \param p Received packet (unused).
*/
void DropEvent (Ptr<const Packet> p);
uint32_t m_countSinkRx;
uint32_t m_countPingRtt;
uint32_t m_drops;
uint32_t m_countSinkRx; //!< Counter of received packets.
uint32_t m_countPingRtt; //!< Counter of PING received.
uint32_t m_drops; //!< Counter of dropped packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -790,6 +894,11 @@ CsmaPingTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_countPingRtt, 9, "Node 2 should have been pinged 9 times");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA Raw IP test.
*/
class CsmaRawIpSocketTestCase : public TestCase
{
public:
@@ -798,10 +907,22 @@ public:
private:
virtual void DoRun (void);
/**
* Sink called when a packet is received by a node.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
*/
void SinkRx (Ptr<const Packet> p, const Address &ad);
/**
* Sink called when a packet is dropped.
* \param p Received packet (unused).
*/
void DropEvent (Ptr<const Packet> p);
uint32_t m_count;
uint32_t m_drops;
uint32_t m_count; //!< Counter of received packets.
uint32_t m_drops; //!< Counter of dropped packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -888,6 +1009,11 @@ CsmaRawIpSocketTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 3 should have received 10 packets");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA star mode test.
*/
class CsmaStarTestCase : public TestCase
{
public:
@@ -896,10 +1022,22 @@ public:
private:
virtual void DoRun (void);
/**
* Sink called when a packet is received by a node.
* \param p Received packet (unused).
* \param ad Sender's address (uused).
*/
void SinkRx (Ptr<const Packet> p, const Address &ad);
/**
* Sink called when a packet is dropped.
* \param p Received packet (unused).
*/
void DropEvent (Ptr<const Packet> p);
uint32_t m_count;
uint32_t m_drops;
uint32_t m_count; //!< Counter of received packets.
uint32_t m_drops; //!< Counter of dropped packets.
};
// Add some help text to this case to describe what it is intended to test
@@ -1070,6 +1208,11 @@ CsmaStarTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (m_count, 10 * ( nSpokes * (nFill + 1)), "Hub node did not receive the proper number of packets");
}
/**
* \ingroup system-tests-csma
*
* \brief CSMA TestSuite.
*/
class CsmaSystemTestSuite : public TestSuite
{
public:
@@ -1089,5 +1232,5 @@ CsmaSystemTestSuite::CsmaSystemTestSuite ()
AddTestCase (new CsmaStarTestCase, TestCase::QUICK);
}
// Do not forget to allocate an instance of this TestSuite
/// Do not forget to allocate an instance of this TestSuite
static CsmaSystemTestSuite csmaSystemTestSuite;

84
src/test/doc/tests.h Normal file
View File

@@ -0,0 +1,84 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* \file
* \ingroup tests
* This file provides some doxygen documentation for the tests module.
*/
/**
* \ingroup tests
* \defgroup system-tests System Tests
*
* \brief The "tests" module contains the System Tests, i.e., tests that
* dependss on multiple modules. Due to their dependencies, the System Tests
* are in this module.
*
* Unit tests, on the contrary, are located in each module.
*/
/**
* \ingroup system-tests
* \ingroup traffic-control-test
* \defgroup system-tests-tc TrafficControl System Tests
*
* \brief TrafficControl System Tests
*/
/**
* \ingroup system-tests
* \ingroup internet-test
* \defgroup system-tests-tcp TCP System Tests
*
* \brief TCP System Tests
*/
/**
* \ingroup system-tests
* \ingroup wifi-test
* \defgroup system-tests-wifi WiFi System Tests
*
* \brief WiFi System Tests
*/
/**
* \ingroup system-tests
* \defgroup system-tests-perf Performance System Tests
*
* \brief Performance System Tests
*
* Note: these tests are (for real) scripts to be run.
* The ouput is the time (in nanoseconds) that the test
* required to perform the requested write operations.
*/
/**
* \ingroup system-tests
* \ingroup core-tests
* \defgroup system-tests-traced TracedCallback System Tests
*
* \brief TracedCallback System Tests
*/
/**
* \ingroup system-tests
* \ingroup csma
* \defgroup system-tests-csma CSMA System Tests
*
* \brief CSMA System Tests
*/

View File

@@ -39,12 +39,13 @@
using namespace ns3;
// Variable to assign m_hash to a new packet's flow
int32_t m_hash;
/// Variable to assign g_hash to a new packet's flow
static int32_t g_hash;
/**
* Simple test packet filter able to classify IPv4 packets
*
* \ingroup system-tests-tc
*
* Simple test packet filter able to classify IPv4 packets.
*/
class Ipv4FqCobaltTestPacketFilter : public Ipv4PacketFilter {
public:
@@ -58,7 +59,18 @@ public:
virtual ~Ipv4FqCobaltTestPacketFilter ();
private:
/**
* Classify a QueueDiscItem
* \param item The item to classify (unused).
* \return a pre-set hash value.
*/
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const;
/**
* Check the protocol.
* \param item The item to check (unused).
* \return true.
*/
virtual bool CheckProtocol (Ptr<QueueDiscItem> item) const;
};
@@ -84,7 +96,7 @@ Ipv4FqCobaltTestPacketFilter::~Ipv4FqCobaltTestPacketFilter ()
int32_t
Ipv4FqCobaltTestPacketFilter::DoClassify (Ptr<QueueDiscItem> item) const
{
return m_hash;
return g_hash;
}
bool
@@ -94,7 +106,9 @@ Ipv4FqCobaltTestPacketFilter::CheckProtocol (Ptr<QueueDiscItem> item) const
}
/**
* This class tests packets for which there is no suitable filter
* \ingroup system-tests-tc
*
* This class tests packets for which there is no suitable filter.
*/
class FqCobaltQueueDiscNoSuitableFilter : public TestCase
{
@@ -123,7 +137,7 @@ FqCobaltQueueDiscNoSuitableFilter::DoRun (void)
Ptr<Ipv4FqCobaltTestPacketFilter> filter = CreateObject<Ipv4FqCobaltTestPacketFilter> ();
queueDisc->AddPacketFilter (filter);
m_hash = -1;
g_hash = -1;
queueDisc->SetQuantum (1500);
queueDisc->Initialize ();
@@ -145,7 +159,9 @@ FqCobaltQueueDiscNoSuitableFilter::DoRun (void)
}
/**
* This class tests the IP flows separation and the packet limit
* \ingroup system-tests-tc
*
* This class tests the IP flows separation and the packet limit.
*/
class FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit : public TestCase
{
@@ -157,8 +173,8 @@ private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue the queue disc
* \param hdr the IPv4 header
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr);
};
@@ -219,7 +235,9 @@ FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::DoRun (void)
}
/**
* This class tests the deficit per flow
* \ingroup system-tests-tc
*
* This class tests the deficit per flow.
*/
class FqCobaltQueueDiscDeficit : public TestCase
{
@@ -231,8 +249,8 @@ private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue the queue disc
* \param hdr the IPv4 header
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr);
};
@@ -366,7 +384,9 @@ FqCobaltQueueDiscDeficit::DoRun (void)
}
/**
* This class tests the TCP flows separation
* \ingroup system-tests-tc
*
* This class tests the TCP flows separation.
*/
class FqCobaltQueueDiscTCPFlowsSeparation : public TestCase
{
@@ -378,9 +398,9 @@ private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue the queue disc
* \param ipHdr the IPv4 header
* \param tcpHdr the TCP header
* \param queue The queue disc.
* \param ipHdr The IPv4 header.
* \param tcpHdr The TCP header.
*/
void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header ipHdr, TcpHeader tcpHdr);
};
@@ -458,6 +478,8 @@ FqCobaltQueueDiscTCPFlowsSeparation::DoRun (void)
}
/**
* \ingroup system-tests-tc
*
* This class tests the UDP flows separation
*/
class FqCobaltQueueDiscUDPFlowsSeparation : public TestCase
@@ -550,7 +572,10 @@ FqCobaltQueueDiscUDPFlowsSeparation::DoRun (void)
}
/**
* This class tests ECN marking
* \ingroup system-tests-tc
*
* \brief This class tests ECN marking.
*
* The test is divided into 3 sub test cases.
* 1) CE threshold disabled
* This test enqueues 100 packets in the beginning of the test and dequeues 60 (some packets are dropped too) packets with the
@@ -575,30 +600,30 @@ private:
virtual void DoRun (void);
/**
* Enqueue the given number of packets.
* \param queue the queue disc
* \param hdr the IPv4 header
* \param nPkt the number of packets
* \param nPktEnqueued the expected number of enqueued packets
* \param nQueueFlows the expected number of flow queues
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param nPkt The number of packets.
* \param nPktEnqueued The expected number of enqueued packets.
* \param nQueueFlows The expected number of flow queues.
*/
void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows);
/**
* Dequeue the given number of packets
* \param queue the queue disc
* \param nPkt the number of packets
* Dequeue the given number of packets.
* \param queue The queue disc.
* \param nPkt The number of packets.
*/
void Dequeue (Ptr<FqCobaltQueueDisc> queue, uint32_t nPkt);
/**
* Dequeue the given number of packets at different times
* \param queue the queue disc
* \param delay the time between two consecutive dequeue operations
* \param nPkt the number of packets
* Dequeue the given number of packets at different times.
* \param queue The queue disc.
* \param delay The time between two consecutive dequeue operations.
* \param nPkt The number of packets.
*/
void DequeueWithDelay (Ptr<FqCobaltQueueDisc> queue, double delay, uint32_t nPkt);
/**
* Tracer for the DropNext attribute
* \param oldVal old value
* \param newVal new value
* \param oldVal Old value.
* \param newVal New value.
*/
void DropNextTracer (int64_t oldVal, int64_t newVal);
uint32_t m_dropNextCount; ///< count the number of times m_dropNext is recalculated
@@ -864,8 +889,11 @@ FqCobaltQueueDiscEcnMarking::DoRun (void)
}
/**
* This class tests linear probing, collision response, and set
* creation capability of set associative hashing in FqCodel.
* \ingroup system-tests-tc
*
* \brief This class tests linear probing, collision response, and set
* creation capability of set associative hashing in FqCobalt.
*
* We modified DoClassify () and CheckProtocol () so that we could control
* the hash returned for each packet. In the beginning, we use flow hashes
* ranging from 0 to 7. These must go into different queues in the same set.
@@ -893,8 +921,8 @@ private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue the queue disc
* \param hdr the IPv4 header
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr);
};
@@ -933,25 +961,25 @@ FqCobaltQueueDiscSetLinearProbing::DoRun (void)
hdr.SetDestination (Ipv4Address ("10.10.1.2"));
hdr.SetProtocol (7);
m_hash = 0;
g_hash = 0;
AddPacket (queueDisc, hdr);
m_hash = 1;
g_hash = 1;
AddPacket (queueDisc, hdr);
AddPacket (queueDisc, hdr);
m_hash = 2;
g_hash = 2;
AddPacket (queueDisc, hdr);
m_hash = 3;
g_hash = 3;
AddPacket (queueDisc, hdr);
m_hash = 4;
g_hash = 4;
AddPacket (queueDisc, hdr);
AddPacket (queueDisc, hdr);
m_hash = 5;
g_hash = 5;
AddPacket (queueDisc, hdr);
m_hash = 6;
g_hash = 6;
AddPacket (queueDisc, hdr);
m_hash = 7;
g_hash = 7;
AddPacket (queueDisc, hdr);
m_hash = 1024;
g_hash = 1024;
AddPacket (queueDisc, hdr);
NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 11,
@@ -972,11 +1000,11 @@ FqCobaltQueueDiscSetLinearProbing::DoRun (void)
"unexpected number of packets in the seventh flow queue of set one");
NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (7)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the eighth flow queue of set one");
m_hash = 1025;
g_hash = 1025;
AddPacket (queueDisc, hdr);
NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow of set one");
m_hash = 10;
g_hash = 10;
AddPacket (queueDisc, hdr);
NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (8)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow of set two");
@@ -985,8 +1013,13 @@ FqCobaltQueueDiscSetLinearProbing::DoRun (void)
/**
* This class tests L4S mode. This test is divided to sub test one without hash collisions and so ECT0 and ECT1 flows are
* \ingroup system-tests-tc
*
* \brief This class tests L4S mode.
*
* This test is divided to sub test one without hash collisions and so ECT0 and ECT1 flows are
* classified into different flows.
*
* Sub Test 1
* 70 packets are enqueued into both the flows with the delay of 0.5ms between two enqueues, and dequeued with the delay of
* 1ms between two dequeues.
@@ -1005,30 +1038,30 @@ private:
virtual void DoRun (void);
/**
* Enqueue the given number of packets.
* \param queue the queue disc
* \param hdr the IPv4 header
* \param nPkt the number of packets
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param nPkt The number of packets.
*/
void AddPacket (Ptr<FqCobaltQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt);
/**
* Enqueue the given number of packets at different times.
* \param queue the queue disc
* \param hdr the IPv4 header
* \param delay the time between two consecutive enqueue operations
* \param nPkt the number of packets
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param delay The time between two consecutive enqueue operations.
* \param nPkt The number of packets.
*/
void AddPacketWithDelay (Ptr<FqCobaltQueueDisc> queue,Ipv4Header hdr, double delay, uint32_t nPkt);
/**
* Dequeue the given number of packets
* \param queue the queue disc
* \param nPkt the number of packets
* Dequeue the given number of packets.
* \param queue The queue disc.
* \param nPkt The number of packets.
*/
void Dequeue (Ptr<FqCobaltQueueDisc> queue, uint32_t nPkt);
/**
* Dequeue the given number of packets at different times
* \param queue the queue disc
* \param delay the time between two consecutive dequeue operations
* \param nPkt the number of packets
* Dequeue the given number of packets at different times.
* \param queue The queue disc.
* \param delay The time between two consecutive dequeue operations.
* \param nPkt The number of packets.
*/
void DequeueWithDelay (Ptr<FqCobaltQueueDisc> queue, double delay, uint32_t nPkt);
};
@@ -1176,7 +1209,9 @@ FqCobaltQueueDiscL4sMode::DoRun (void)
}
/**
* FQ-COBALT queue disc test suite
* \ingroup system-tests-tc
*
* FQ-COBALT queue disc test suite.
*/
class FqCobaltQueueDiscTestSuite : public TestSuite
{
@@ -1197,4 +1232,5 @@ FqCobaltQueueDiscTestSuite::FqCobaltQueueDiscTestSuite ()
AddTestCase (new FqCobaltQueueDiscL4sMode, TestCase::QUICK);
}
static FqCobaltQueueDiscTestSuite fqCobaltQueueDiscTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static FqCobaltQueueDiscTestSuite g_fqCobaltQueueDiscTestSuite;

View File

@@ -37,12 +37,13 @@
using namespace ns3;
// Variable to assign hash to a new packet's flow
int32_t hash;
/// Variable to assign g_hash to a new packet's flow
static int32_t g_hash;
/**
* Simple test packet filter able to classify IPv4 packets
*
* \ingroup system-tests-tc
*
* Simple test packet filter able to classify IPv4 packets.
*/
class Ipv4TestPacketFilter : public Ipv4PacketFilter {
public:
@@ -56,7 +57,18 @@ public:
virtual ~Ipv4TestPacketFilter ();
private:
/**
* Classify a QueueDiscItem
* \param item The item to classify (unused).
* \return a pre-set hash value.
*/
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const;
/**
* Check the protocol.
* \param item The item to check (unused).
* \return true.
*/
virtual bool CheckProtocol (Ptr<QueueDiscItem> item) const;
};
@@ -82,7 +94,7 @@ Ipv4TestPacketFilter::~Ipv4TestPacketFilter ()
int32_t
Ipv4TestPacketFilter::DoClassify (Ptr<QueueDiscItem> item) const
{
return hash;
return g_hash;
}
bool
@@ -92,7 +104,9 @@ Ipv4TestPacketFilter::CheckProtocol (Ptr<QueueDiscItem> item) const
}
/**
* This class tests packets for which there is no suitable filter
* \ingroup system-tests-tc
*
* This class tests packets for which there is no suitable filter.
*/
class FqCoDelQueueDiscNoSuitableFilter : public TestCase
{
@@ -121,7 +135,7 @@ FqCoDelQueueDiscNoSuitableFilter::DoRun (void)
Ptr<Ipv4TestPacketFilter> filter = CreateObject<Ipv4TestPacketFilter> ();
queueDisc->AddPacketFilter (filter);
hash = -1;
g_hash = -1;
queueDisc->SetQuantum (1500);
queueDisc->Initialize ();
@@ -143,7 +157,9 @@ FqCoDelQueueDiscNoSuitableFilter::DoRun (void)
}
/**
* This class tests the IP flows separation and the packet limit
* \ingroup system-tests-tc
*
* This class tests the IP flows separation and the packet limit.
*/
class FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit : public TestCase
{
@@ -153,6 +169,11 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4Header hdr);
};
@@ -212,7 +233,9 @@ FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun (void)
}
/**
* This class tests the deficit per flow
* \ingroup system-tests-tc
*
* This class tests the deficit per flow.
*/
class FqCoDelQueueDiscDeficit : public TestCase
{
@@ -222,6 +245,11 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4Header hdr);
};
@@ -354,7 +382,9 @@ FqCoDelQueueDiscDeficit::DoRun (void)
}
/**
* This class tests the TCP flows separation
* \ingroup system-tests-tc
*
* This class tests the TCP flows separation.
*/
class FqCoDelQueueDiscTCPFlowsSeparation : public TestCase
{
@@ -364,6 +394,12 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param ipHdr The IPv4 header.
* \param tcpHdr The TCP header.
*/
void AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4Header ipHdr, TcpHeader tcpHdr);
};
@@ -440,6 +476,8 @@ FqCoDelQueueDiscTCPFlowsSeparation::DoRun (void)
}
/**
* \ingroup system-tests-tc
*
* This class tests the UDP flows separation
*/
class FqCoDelQueueDiscUDPFlowsSeparation : public TestCase
@@ -450,6 +488,12 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param ipHdr The IPv4 header.
* \param udpHdr The UDP header.
*/
void AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4Header ipHdr, UdpHeader udpHdr);
};
@@ -526,8 +570,12 @@ FqCoDelQueueDiscUDPFlowsSeparation::DoRun (void)
}
/**
* This class tests ECN marking
* Any future classifier options (e.g. SetAssociativeHash) should be disabled to prevent a hash collision on this test case.
* \ingroup system-tests-tc
*
* \brief This class tests ECN marking.
*
* Any future classifier options (e.g. SetAssociativeHash) should be
* disabled to prevent a hash collision on this test case.
*/
class FqCoDelQueueDiscECNMarking : public TestCase
{
@@ -537,8 +585,27 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue some packets.
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param nPkt The number of packets to enqueue.
* \param nPktEnqueued The expected number of queue disc classes.
* \param nQueueFlows The expected number of flows in the queue.
*/
void AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows);
/**
* Dequeue some packets.
* \param queue The queue disc.
* \param nPkt The number of packets to dequeue.
*/
void Dequeue (Ptr<FqCoDelQueueDisc> queue, uint32_t nPkt);
/**
* Dequeue some packets with delay.
* \param queue The queue disc.
* \param delay Delay [seconds].
* \param nPkt The number of packets to dequeue.
*/
void DequeueWithDelay (Ptr<FqCoDelQueueDisc> queue, double delay, uint32_t nPkt);
};
@@ -834,9 +901,12 @@ FqCoDelQueueDiscECNMarking::DoRun (void)
Simulator::Destroy ();
}
/*
* This class tests linear probing, collision response, and set
/**
* \ingroup system-tests-tc
*
* \brief This class tests linear probing, collision response, and set
* creation capability of set associative hashing in FqCodel.
*
* We modified DoClassify () and CheckProtocol () so that we could control
* the hash returned for each packet. In the beginning, we use flow hashes
* ranging from 0 to 7. These must go into different queues in the same set.
@@ -855,7 +925,6 @@ FqCoDelQueueDiscECNMarking::DoRun (void)
* is 16. Since m_flowIndices[16] wasnt previously allotted, a new flow
* is created, and the tag corresponding to this queue is set to 20.
*/
class FqCoDelQueueDiscSetLinearProbing : public TestCase
{
public:
@@ -863,6 +932,11 @@ public:
virtual ~FqCoDelQueueDiscSetLinearProbing ();
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4Header hdr);
};
@@ -900,25 +974,25 @@ FqCoDelQueueDiscSetLinearProbing::DoRun (void)
hdr.SetDestination (Ipv4Address ("10.10.1.2"));
hdr.SetProtocol (7);
hash = 0;
g_hash = 0;
AddPacket (queueDisc, hdr);
hash = 1;
g_hash = 1;
AddPacket (queueDisc, hdr);
AddPacket (queueDisc, hdr);
hash = 2;
g_hash = 2;
AddPacket (queueDisc, hdr);
hash = 3;
g_hash = 3;
AddPacket (queueDisc, hdr);
hash = 4;
g_hash = 4;
AddPacket (queueDisc, hdr);
AddPacket (queueDisc, hdr);
hash = 5;
g_hash = 5;
AddPacket (queueDisc, hdr);
hash = 6;
g_hash = 6;
AddPacket (queueDisc, hdr);
hash = 7;
g_hash = 7;
AddPacket (queueDisc, hdr);
hash = 1024;
g_hash = 1024;
AddPacket (queueDisc, hdr);
NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 11,
@@ -939,11 +1013,11 @@ FqCoDelQueueDiscSetLinearProbing::DoRun (void)
"unexpected number of packets in the seventh flow queue of set one");
NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (7)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the eighth flow queue of set one");
hash = 1025;
g_hash = 1025;
AddPacket (queueDisc, hdr);
NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow of set one");
hash = 10;
g_hash = 10;
AddPacket (queueDisc, hdr);
NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (8)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow of set two");
@@ -952,8 +1026,11 @@ FqCoDelQueueDiscSetLinearProbing::DoRun (void)
/**
* This class tests L4S mode
* Any future classifier options (e.g. SetAssociativeHash) should be disabled to prevent a hash collision on this test case.
* \ingroup system-tests-tc
*
* \brief This class tests L4S mode.
* Any future classifier options (e.g. SetAssociativeHash) should be
* disabled to prevent a hash collision on this test case.
*/
class FqCoDelQueueDiscL4sMode : public TestCase
{
@@ -963,9 +1040,36 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue some packets.
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param nPkt The number of packets to enqueue.
*/
void AddPacket (Ptr<FqCoDelQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt);
/**
* Enqueue some packets with delay.
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param delay Delay [seconds].
* \param nPkt The number of packets to enqueue.
*/
void AddPacketWithDelay (Ptr<FqCoDelQueueDisc> queue,Ipv4Header hdr, double delay, uint32_t nPkt);
/**
* Dequeue some packets.
* \param queue The queue disc.
* \param nPkt The number of packets to dequeue.
*/
void Dequeue (Ptr<FqCoDelQueueDisc> queue, uint32_t nPkt);
/**
* Dequeue some packets with delay.
* \param queue The queue disc.
* \param delay Delay [seconds].
* \param nPkt The number of packets to dequeue.
*/
void DequeueWithDelay (Ptr<FqCoDelQueueDisc> queue, double delay, uint32_t nPkt);
};
@@ -1106,6 +1210,13 @@ FqCoDelQueueDiscL4sMode::DoRun (void)
Simulator::Destroy ();
}
/**
* \ingroup system-tests-tc
*
* FQ-CoDel queue disc test suite.
*/
class FqCoDelQueueDiscTestSuite : public TestSuite
{
public:
@@ -1125,4 +1236,5 @@ FqCoDelQueueDiscTestSuite::FqCoDelQueueDiscTestSuite ()
AddTestCase (new FqCoDelQueueDiscL4sMode, TestCase::QUICK);
}
static FqCoDelQueueDiscTestSuite fqCoDelQueueDiscTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static FqCoDelQueueDiscTestSuite g_fqCoDelQueueDiscTestSuite;

View File

@@ -24,7 +24,7 @@
* Vivek Jain <jain.vivek.anand@gmail.com>
* Ankit Deepak <adadeepak8@gmail.com>
*
*/
*/
#include "ns3/test.h"
#include "ns3/simulator.h"
@@ -44,12 +44,13 @@
using namespace ns3;
// Variable to assign g_hash to a new packet's flow
int32_t g_hash;
/// Variable to assign g_hash to a new packet's flow
static int32_t g_hash;
/**
* Simple test packet filter able to classify IPv4 packets
*
* \ingroup system-tests-tc
*
* Simple test packet filter able to classify IPv4 packets.
*/
class Ipv4FqPieTestPacketFilter : public Ipv4PacketFilter
{
@@ -64,7 +65,18 @@ public:
virtual ~Ipv4FqPieTestPacketFilter ();
private:
/**
* Classify a QueueDiscItem
* \param item The item to classify (unused).
* \return a pre-set hash value.
*/
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const;
/**
* Check the protocol.
* \param item The item to check (unused).
* \return true.
*/
virtual bool CheckProtocol (Ptr<QueueDiscItem> item) const;
};
@@ -98,7 +110,9 @@ Ipv4FqPieTestPacketFilter::CheckProtocol (Ptr<QueueDiscItem> item) const
}
/**
* This class tests packets for which there is no suitable filter
* \ingroup system-tests-tc
*
* This class tests packets for which there is no suitable filter.
*/
class FqPieQueueDiscNoSuitableFilter : public TestCase
{
@@ -147,7 +161,9 @@ FqPieQueueDiscNoSuitableFilter::DoRun (void)
}
/**
* This class tests the IP flows separation and the packet limit
* \ingroup system-tests-tc
*
* This class tests the IP flows separation and the packet limit.
*/
class FqPieQueueDiscIPFlowsSeparationAndPacketLimit : public TestCase
{
@@ -157,6 +173,11 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue the queue disc
* \param hdr the IPv4 header
*/
void AddPacket (Ptr<FqPieQueueDisc> queue, Ipv4Header hdr);
};
@@ -214,7 +235,9 @@ FqPieQueueDiscIPFlowsSeparationAndPacketLimit::DoRun (void)
}
/**
* This class tests the deficit per flow
* \ingroup system-tests-tc
*
* This class tests the deficit per flow.
*/
class FqPieQueueDiscDeficit : public TestCase
{
@@ -224,6 +247,11 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqPieQueueDisc> queue, Ipv4Header hdr);
};
@@ -354,7 +382,9 @@ FqPieQueueDiscDeficit::DoRun (void)
}
/**
* This class tests the TCP flows separation
* \ingroup system-tests-tc
*
* This class tests the TCP flows separation.
*/
class FqPieQueueDiscTCPFlowsSeparation : public TestCase
{
@@ -364,6 +394,12 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param ipHdr The IPv4 header.
* \param tcpHdr The TCP header.
*/
void AddPacket (Ptr<FqPieQueueDisc> queue, Ipv4Header ipHdr, TcpHeader tcpHdr);
};
@@ -438,6 +474,8 @@ FqPieQueueDiscTCPFlowsSeparation::DoRun (void)
}
/**
* \ingroup system-tests-tc
*
* This class tests the UDP flows separation
*/
class FqPieQueueDiscUDPFlowsSeparation : public TestCase
@@ -448,6 +486,12 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param ipHdr The IPv4 header.
* \param udpHdr The UDP header.
*/
void AddPacket (Ptr<FqPieQueueDisc> queue, Ipv4Header ipHdr, UdpHeader udpHdr);
};
@@ -522,7 +566,12 @@ FqPieQueueDiscUDPFlowsSeparation::DoRun (void)
}
/*
/**
* \ingroup system-tests-tc
*
* \brief This class tests linear probing, collision response, and set
* creation capability of set associative hashing in FqPIE.
*
* This class tests linear probing, collision response, and set
* creation capability of set associative hashing in FqPIE.
* We modified DoClassify () and CheckProtocol () so that we could control
@@ -543,7 +592,6 @@ FqPieQueueDiscUDPFlowsSeparation::DoRun (void)
* is 16. Since m_flowIndices[16] wasn't previously allotted, a new flow
* is created, and the tag corresponding to this queue is set to 20.
*/
class FqPieQueueDiscSetLinearProbing : public TestCase
{
public:
@@ -552,7 +600,12 @@ public:
private:
virtual void DoRun (void);
void AddPacket (Ptr<FqPieQueueDisc> queue, Ipv4Header hdr);
/**
* Enqueue a packet.
* \param queue The queue disc.
* \param hdr The IPv4 header.
*/
void AddPacket (Ptr<FqPieQueueDisc> queue, Ipv4Header hdr);
};
FqPieQueueDiscSetLinearProbing::FqPieQueueDiscSetLinearProbing ()
@@ -639,7 +692,11 @@ FqPieQueueDiscSetLinearProbing::DoRun (void)
/**
* This class tests L4S mode. This test is divided to sub test one without hash collisions and so ECT0 and ECT1 flows are
* \ingroup system-tests-tc
*
* \brief This class tests L4S mode.
*
* This test is divided to sub test one without hash collisions and so ECT0 and ECT1 flows are
* classified into different flows.
* Sub Test 1
* 70 packets are enqueued into both the flows with the delay of 0.5ms between two enqueues, and dequeued with the delay of
@@ -657,9 +714,33 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue the given number of packets.
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param nPkt The number of packets.
*/
void AddPacket (Ptr<FqPieQueueDisc> queue, Ipv4Header hdr, u_int32_t nPkt);
/**
* Enqueue the given number of packets at different times.
* \param queue The queue disc.
* \param hdr The IPv4 header.
* \param delay The time between two consecutive enqueue operations.
* \param nPkt The number of packets.
*/
void AddPacketWithDelay (Ptr<FqPieQueueDisc> queue,Ipv4Header hdr, double delay, uint32_t nPkt);
/**
* Dequeue the given number of packets.
* \param queue The queue disc.
* \param nPkt The number of packets.
*/
void Dequeue (Ptr<FqPieQueueDisc> queue, uint32_t nPkt);
/**
* Dequeue the given number of packets at different times.
* \param queue The queue disc.
* \param delay The time between two consecutive dequeue operations.
* \param nPkt The number of packets.
*/
void DequeueWithDelay (Ptr<FqPieQueueDisc> queue, double delay, uint32_t nPkt);
};
@@ -802,6 +883,12 @@ FqPieQueueDiscL4sMode::DoRun (void)
Simulator::Destroy ();
}
/**
* \ingroup system-tests-tc
*
* FQ-PIE queue disc test suite.
*/
class FqPieQueueDiscTestSuite : public TestSuite
{
public:
@@ -820,4 +907,5 @@ FqPieQueueDiscTestSuite::FqPieQueueDiscTestSuite ()
AddTestCase (new FqPieQueueDiscL4sMode, TestCase::QUICK);
}
static FqPieQueueDiscTestSuite FqPieQueueDiscTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static FqPieQueueDiscTestSuite g_fqPieQueueDiscTestSuite;

View File

@@ -32,6 +32,8 @@
using namespace ns3;
/**
* \ingroup system-tests-tc
*
* This class tests that each possible TOS is enqueued in the right band
*/
class PfifoFastQueueDiscTosPrioritization : public TestCase
@@ -42,6 +44,13 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet and checks that it's added to the proper band.
*
* \param queue The queue disc.
* \param tos The TOS of the packet.
* \param band Expected band.
*/
void TestTosValue (Ptr<PfifoFastQueueDisc> queue, uint8_t tos, uint32_t band);
};
@@ -109,7 +118,9 @@ PfifoFastQueueDiscTosPrioritization::DoRun (void)
}
/**
* This class tests that each possible DSCP is enqueued in the right band
* \ingroup system-tests-tc
*
* This class tests that each possible DSCP is enqueued in the right band.
*/
class PfifoFastQueueDiscDscpPrioritization : public TestCase
{
@@ -119,6 +130,13 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet and checks that it's added to the proper band.
*
* \param queue The queue disc.
* \param dscp The DSCP of the packet.
* \param band Expected band.
*/
void TestDscpValue (Ptr<PfifoFastQueueDisc> queue, Ipv4Header::DscpType dscp, uint32_t band);
};
@@ -191,7 +209,9 @@ PfifoFastQueueDiscDscpPrioritization::DoRun (void)
}
/**
* This class tests that each band is txqueuelen deep
* \ingroup system-tests-tc
*
* This class tests that each band is txqueuelen deep.
*/
class PfifoFastQueueDiscOverflow : public TestCase
{
@@ -201,6 +221,12 @@ public:
private:
virtual void DoRun (void);
/**
* Enqueue a packet.
*
* \param queue The queue disc.
* \param dscp The DSCP of the packet.
*/
void AddPacket (Ptr<PfifoFastQueueDisc> queue, Ipv4Header::DscpType dscp);
};
@@ -264,8 +290,10 @@ PfifoFastQueueDiscOverflow::DoRun (void)
}
/**
* \ingroup system-tests-tc
*
* This class tests that packets without a priority tag are handled by placing
* them into band 1
* them into band 1.
*/
class PfifoFastQueueDiscNoPriority : public TestCase
{
@@ -326,6 +354,11 @@ PfifoFastQueueDiscNoPriority::DoRun (void)
Simulator::Destroy ();
}
/**
* \ingroup system-tests-tc
*
* PfifoFast queue disc test suite.
*/
class PfifoFastQueueDiscTestSuite : public TestSuite
{
public:
@@ -341,4 +374,5 @@ PfifoFastQueueDiscTestSuite::PfifoFastQueueDiscTestSuite ()
AddTestCase (new PfifoFastQueueDiscNoPriority, TestCase::QUICK);
}
static PfifoFastQueueDiscTestSuite pfifoFastQueueTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static PfifoFastQueueDiscTestSuite g_pfifoFastQueueTestSuite;

View File

@@ -54,21 +54,28 @@ NS_LOG_COMPONENT_DEFINE ("Ns3TcpLossTest");
// revised vectors are the correct ones. In other words, don't simply
// enable this to true to clear a failing test without looking at the
// results closely.
const bool WRITE_VECTORS = false; // set to true to write response vectors
const bool WRITE_PCAP = false; // set to true to write out pcap
const bool WRITE_LOGGING = false; // set to true to write logging
const uint32_t PCAP_LINK_TYPE = 1187373557; // Some large random number -- we use to verify data was written by this program
const uint32_t PCAP_SNAPLEN = 64; // Don't bother to save much data
// ===========================================================================
// Tests of TCP implementation loss behavior
// ===========================================================================
//
const bool WRITE_VECTORS = false; //!< Set to true to write response vectors.
const bool WRITE_PCAP = false; //!< Set to true to write out pcap.
const bool WRITE_LOGGING = false; //!< Set to true to write logging.
const uint32_t PCAP_LINK_TYPE = 1187373557; //!< Some large random number -- we use to verify data was written by this program.
const uint32_t PCAP_SNAPLEN = 64; //!< Don't bother to save much data.
/**
* \ingroup system-tests-tcp
*
* \brief Tests of TCP implementation loss behavior.
*/
class Ns3TcpLossTestCase : public TestCase
{
public:
Ns3TcpLossTestCase ();
/**
* Constructor.
*
* \param tcpModel The TCP model name.
* \param testCase Testcase number.
*/
Ns3TcpLossTestCase (std::string tcpModel, uint32_t testCase);
virtual ~Ns3TcpLossTestCase ()
{
@@ -79,24 +86,50 @@ private:
virtual void DoRun (void);
virtual void DoTeardown (void);
Ptr<OutputStreamWrapper> m_osw;
std::string m_pcapFilename;
PcapFile m_pcapFile;
uint32_t m_testCase;
uint32_t m_totalTxBytes;
uint32_t m_currentTxBytes;
bool m_writeVectors;
bool m_writeResults;
bool m_writeLogging;
bool m_needToClose;
std::string m_tcpModel;
Ptr<OutputStreamWrapper> m_osw; //!< The output stream.
std::string m_pcapFilename; //!< The PCAP filename.
PcapFile m_pcapFile; //!< The PCAP ffile.
uint32_t m_testCase; //!< Testcase number.
uint32_t m_totalTxBytes; //!< Total number of bytes to send.
uint32_t m_currentTxBytes; //!< Current number of bytes sent.
bool m_writeVectors; //!< True if response vectors have to be written (and not read).
bool m_writeResults; //!< True if write PCAP files.
bool m_writeLogging; //!< True if write logging.
bool m_needToClose; //!< Check if the sending socket need to be closed.
std::string m_tcpModel; //!< The TCP model name.
/**
* Check that the transmitted packets are consitent with the trace.
* This callback is hooked to ns3::Ipv4L3Protocol/Tx.
*
* \param context The callback context (unused).
* \param packet The transmitted packet.
* \param ipv4 The IPv4 object that did send the packet (unused).
* \param interface The IPv4 interface that did send the packet (unused).
*/
void Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
/**
* CWND trace.
*
* \param oldval The old value.
* \param newval The new value.
*/
void CwndTracer (uint32_t oldval, uint32_t newval);
/**
* Write to the socket until the buffer is full.
*
* \param localSocket The output socket.
* \param txSpace The space left on the socket (unused).
*/
void WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSpace);
void StartFlow (Ptr<Socket> localSocket,
Ipv4Address servAddress,
uint16_t servPort);
/**
* Start transmitting a TCP flow.
*
* \param localSocket The sending socket.
* \param servAddress The IPv4 address of the server (i.e., the destination address).
* \param servPort The TCP port of the server (i.e., the destination port).
*/
void StartFlow (Ptr<Socket> localSocket, Ipv4Address servAddress, uint16_t servPort);
};
@@ -165,7 +198,7 @@ Ns3TcpLossTestCase::DoTeardown (void)
}
void
Ns3TcpLossTestCase::Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface)
Ns3TcpLossTestCase::Ipv4L3Tx (std::string, Ptr<const Packet> packet, Ptr<Ipv4>, uint32_t)
{
//
// We're not testing IP so remove and toss the header. In order to do this,
@@ -244,7 +277,7 @@ Ns3TcpLossTestCase::CwndTracer (uint32_t oldval, uint32_t newval)
////////////////////////////////////////////////////////////////////
// Implementing an "application" to send bytes over a TCP connection
void
Ns3TcpLossTestCase::WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSpace)
Ns3TcpLossTestCase::WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t)
{
while (m_currentTxBytes < m_totalTxBytes)
{
@@ -473,6 +506,11 @@ Ns3TcpLossTestCase::DoRun (void)
Simulator::Destroy ();
}
/**
* \ingroup system-tests-tcp
*
* TCP implementation loss behavior TestSuite.
*/
class Ns3TcpLossTestSuite : public TestSuite
{
public:
@@ -506,5 +544,6 @@ Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
}
static Ns3TcpLossTestSuite ns3TcpLossTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static Ns3TcpLossTestSuite g_ns3TcpLossTestSuite;

View File

@@ -39,26 +39,37 @@ using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("Ns3TcpNoDelayTest");
// ===========================================================================
// Tests of Nagle's algorithm and the TCP no delay option
// ===========================================================================
//
//
/**
* \ingroup system-tests-tcp
*
* \brief Tests of Nagle's algorithm and the TCP no delay option.
*/
class Ns3TcpNoDelayTestCase : public TestCase
{
public:
/**
* Constructor.
*
* \param noDelay Enable or disable TCP no delay option.
*/
Ns3TcpNoDelayTestCase (bool noDelay);
virtual ~Ns3TcpNoDelayTestCase () {}
private:
virtual void DoRun (void);
bool m_noDelay;
bool m_writeResults;
bool m_noDelay; //!< Enable or disable TCP no delay option.
bool m_writeResults; //!< True if write PCAP files.
/**
* Receive a TCP packet.
* \param path The callback context (unused).
* \param p The received packet.
* \param address The sender's address (unused).
*/
void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
TestVectors<uint32_t> m_inputs;
TestVectors<uint32_t> m_responses;
TestVectors<uint32_t> m_inputs; //!< Sent packets test vector.
TestVectors<uint32_t> m_responses; //!< Received packets test vector.
};
Ns3TcpNoDelayTestCase::Ns3TcpNoDelayTestCase (bool noDelay)
@@ -69,7 +80,7 @@ Ns3TcpNoDelayTestCase::Ns3TcpNoDelayTestCase (bool noDelay)
}
void
Ns3TcpNoDelayTestCase::SinkRx (std::string path, Ptr<const Packet> p, const Address &address)
Ns3TcpNoDelayTestCase::SinkRx (std::string, Ptr<const Packet> p, const Address &)
{
m_responses.Add (p->GetSize ());
}
@@ -192,6 +203,11 @@ Ns3TcpNoDelayTestCase::DoRun (void)
}
}
/**
* \ingroup system-tests-tcp
*
* TCP Nagle's algorithm and the TCP no delay option TestSuite.
*/
class Ns3TcpNoDelayTestSuite : public TestSuite
{
public:
@@ -205,4 +221,5 @@ Ns3TcpNoDelayTestSuite::Ns3TcpNoDelayTestSuite ()
AddTestCase (new Ns3TcpNoDelayTestCase (false), TestCase::QUICK);
}
static Ns3TcpNoDelayTestSuite ns3TcpNoDelayTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static Ns3TcpNoDelayTestSuite g_ns3TcpNoDelayTestSuite;

View File

@@ -40,41 +40,48 @@ using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("Ns3SocketTest");
// ===========================================================================
// Tests of TCP implementations from the application/socket perspective
// ===========================================================================
//
//
class Ns3TcpSocketTestCase1 : public TestCase
/**
* \ingroup system-tests-tcp
*
* \brief Tests of TCP implementations from the application/socket perspective
* using point-to-point links.
*/
class Ns3TcpSocketTestCaseP2P : public TestCase
{
public:
Ns3TcpSocketTestCase1 ();
virtual ~Ns3TcpSocketTestCase1 () {}
Ns3TcpSocketTestCaseP2P ();
virtual ~Ns3TcpSocketTestCaseP2P () {}
private:
virtual void DoRun (void);
bool m_writeResults;
bool m_writeResults; //!< True if write PCAP files.
/**
* Receive a TCP packet.
* \param path The callback context (unused).
* \param p The received packet.
* \param address The sender's address (unused).
*/
void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
TestVectors<uint32_t> m_inputs;
TestVectors<uint32_t> m_responses;
TestVectors<uint32_t> m_inputs; //!< Sent packets test vector.
TestVectors<uint32_t> m_responses; //!< Received packets test vector.
};
Ns3TcpSocketTestCase1::Ns3TcpSocketTestCase1 ()
Ns3TcpSocketTestCaseP2P::Ns3TcpSocketTestCaseP2P ()
: TestCase ("Check that ns-3 TCP successfully transfers an application data write of various sizes (point-to-point)"),
m_writeResults (false)
{
}
void
Ns3TcpSocketTestCase1::SinkRx (std::string path, Ptr<const Packet> p, const Address &address)
Ns3TcpSocketTestCaseP2P::SinkRx (std::string path, Ptr<const Packet> p, const Address &address)
{
m_responses.Add (p->GetSize ());
}
void
Ns3TcpSocketTestCase1::DoRun (void)
Ns3TcpSocketTestCaseP2P::DoRun (void)
{
uint16_t sinkPort = 50000;
double sinkStopTime = 40; // sec; will trigger Socket::Close
@@ -116,7 +123,7 @@ Ns3TcpSocketTestCase1::DoRun (void)
apps.Stop (sinkStopTimeObj);
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",
MakeCallback (&Ns3TcpSocketTestCase1::SinkRx, this));
MakeCallback (&Ns3TcpSocketTestCaseP2P::SinkRx, this));
Simulator::Schedule (Seconds (2), &SocketWriter::Connect, socketWriter);
// Send 1, 10, 100, 1000 bytes
@@ -150,36 +157,48 @@ Ns3TcpSocketTestCase1::DoRun (void)
}
}
class Ns3TcpSocketTestCase2 : public TestCase
/**
* \ingroup system-tests-tcp
*
* \brief Tests of TCP implementations from the application/socket perspective
* using CSMA links.
*/
class Ns3TcpSocketTestCaseCsma : public TestCase
{
public:
Ns3TcpSocketTestCase2 ();
virtual ~Ns3TcpSocketTestCase2 () {}
Ns3TcpSocketTestCaseCsma ();
virtual ~Ns3TcpSocketTestCaseCsma () {}
private:
virtual void DoRun (void);
bool m_writeResults;
bool m_writeResults; //!< True if write PCAP files.
/**
* Receive a TCP packet.
* \param path The callback context (unused).
* \param p The received packet.
* \param address The sender's address (unused).
*/
void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
TestVectors<uint32_t> m_inputs;
TestVectors<uint32_t> m_responses;
TestVectors<uint32_t> m_inputs; //!< Sent packets test vector.
TestVectors<uint32_t> m_responses; //!< Received packets test vector.
};
Ns3TcpSocketTestCase2::Ns3TcpSocketTestCase2 ()
Ns3TcpSocketTestCaseCsma::Ns3TcpSocketTestCaseCsma ()
: TestCase ("Check to see that ns-3 TCP successfully transfers an application data write of various sizes (CSMA)"),
m_writeResults (false)
{
}
void
Ns3TcpSocketTestCase2::SinkRx (std::string path, Ptr<const Packet> p, const Address &address)
Ns3TcpSocketTestCaseCsma::SinkRx (std::string path, Ptr<const Packet> p, const Address &address)
{
m_responses.Add (p->GetSize ());
}
void
Ns3TcpSocketTestCase2::DoRun (void)
Ns3TcpSocketTestCaseCsma::DoRun (void)
{
uint16_t sinkPort = 50000;
double sinkStopTime = 40; // sec; will trigger Socket::Close
@@ -225,7 +244,7 @@ Ns3TcpSocketTestCase2::DoRun (void)
apps.Stop (sinkStopTimeObj);
Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx",
MakeCallback (&Ns3TcpSocketTestCase2::SinkRx, this));
MakeCallback (&Ns3TcpSocketTestCaseCsma::SinkRx, this));
Simulator::Schedule (Seconds (2), &SocketWriter::Connect, socketWriter);
// Send 1, 10, 100, 1000 bytes
@@ -262,6 +281,11 @@ Ns3TcpSocketTestCase2::DoRun (void)
}
}
/**
* \ingroup system-tests-tcp
*
* TCP implementations from the application/socket perspective TestSuite.
*/
class Ns3TcpSocketTestSuite : public TestSuite
{
public:
@@ -271,8 +295,9 @@ public:
Ns3TcpSocketTestSuite::Ns3TcpSocketTestSuite ()
: TestSuite ("ns3-tcp-socket", SYSTEM)
{
AddTestCase (new Ns3TcpSocketTestCase1, TestCase::QUICK);
AddTestCase (new Ns3TcpSocketTestCase2, TestCase::QUICK);
AddTestCase (new Ns3TcpSocketTestCaseP2P, TestCase::QUICK);
AddTestCase (new Ns3TcpSocketTestCaseCsma, TestCase::QUICK);
}
static Ns3TcpSocketTestSuite ns3TcpSocketTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static Ns3TcpSocketTestSuite g_ns3TcpSocketTestSuite;

View File

@@ -24,7 +24,12 @@
namespace ns3
{
// Simple class to write data to sockets
/**
* \ingroup system-tests-tcp
*
* \brief Simple class to write data to sockets.
*/
class SocketWriter : public Application
{
public:
@@ -36,18 +41,33 @@ public:
*/
static TypeId GetTypeId (void);
/**
* Setup the socket.
* \param node The node owning the socket.
* \param peer The destinaiton address.
*/
void Setup (Ptr<Node> node, Address peer);
/**
* Connect the socket.
*/
void Connect ();
/**
* Write to the socket.
* \param numBytes The number of bytes to write.
*/
void Write (uint32_t numBytes);
/**
* Close the socket.
*/
void Close ();
private:
virtual void StartApplication (void);
virtual void StopApplication (void);
Address m_peer;
Ptr<Node> m_node;
Ptr<Socket> m_socket;
bool m_isSetup;
bool m_isConnected;
Address m_peer; //!< Peer's address.
Ptr<Node> m_node; //!< Node pointer
Ptr<Socket> m_socket; //!< Socket.
bool m_isSetup; //!< True if the socket is connected.
bool m_isConnected; //!< True if the socket setup has been done.
};
}

View File

@@ -56,21 +56,26 @@ NS_LOG_COMPONENT_DEFINE ("Ns3TcpStateTest");
// revised vectors are the correct ones. In other words, don't simply
// enable this to true to clear a failing test without looking at the
// results closely.
const bool WRITE_VECTORS = false; // set to true to write response vectors
const bool WRITE_PCAP = false; // set to true to write out pcap
const bool WRITE_LOGGING = false; // set to true to write logging
const uint32_t PCAP_LINK_TYPE = 1187373554; // Some large random number -- we use to verify data was written by this program
const uint32_t PCAP_SNAPLEN = 64; // Don't bother to save much data
const bool WRITE_VECTORS = false; //!< Set to true to write response vectors.
const bool WRITE_PCAP = false; //!< Set to true to write out pcap.
const bool WRITE_LOGGING = false; //!< Set to true to write logging.
const uint32_t PCAP_LINK_TYPE = 1187373554; //!< Some large random number -- we use to verify data was written by this program.
const uint32_t PCAP_SNAPLEN = 64; //!< Don't bother to save much data.
// ===========================================================================
// Tests of TCP implementation state machine behavior
// ===========================================================================
//
/**
* \ingroup system-tests-tcp
*
* \brief Tests of TCP implementation state machine behavior
*/
class Ns3TcpStateTestCase : public TestCase
{
public:
Ns3TcpStateTestCase ();
/**
* Constructor.
* \param testCase Testcase number.
*/
Ns3TcpStateTestCase (uint32_t testCase);
virtual ~Ns3TcpStateTestCase ()
{
@@ -81,19 +86,50 @@ private:
virtual void DoRun (void);
virtual void DoTeardown (void);
std::string m_pcapFilename;
PcapFile m_pcapFile;
uint32_t m_testCase;
uint32_t m_totalTxBytes;
uint32_t m_currentTxBytes;
bool m_writeVectors;
bool m_writeResults;
bool m_writeLogging;
bool m_needToClose;
std::string m_pcapFilename; //!< The PCAP filename.
PcapFile m_pcapFile; //!< The PCAP ffile.
uint32_t m_testCase; //!< Testcase number.
uint32_t m_totalTxBytes; //!< Total number of bytes to send.
uint32_t m_currentTxBytes; //!< Current number of bytes sent.
bool m_writeVectors; //!< True if response vectors have to be written (and not read).
bool m_writeResults; //!< True if write PCAP files.
bool m_writeLogging; //!< True if write logging.
bool m_needToClose; //!< Check if the sending socket need to be closed.
/**
* Check that the transmitted packets are consitent with the trace.
* This callback is hooked to ns3::Ipv4L3Protocol/Tx.
*
* \param context The callback context (unused).
* \param packet The transmitted packet.
* \param ipv4 The IPv4 object that did send the packet (unused).
* \param interface The IPv4 interface that did send the packet (unused).
*/
void Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
/**
* Check that the received packets are consitent with the trace.
* This callback is hooked to ns3::Ipv4L3Protocol/Tx.
*
* \param context The callback context (unused).
* \param packet The transmitted packet.
* \param ipv4 The IPv4 object that did send the packet (unused).
* \param interface The IPv4 interface that did send the packet (unused).
*/
void Ipv4L3Rx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
/**
* Write to the socket until the buffer is full.
*
* \param localSocket The output socket.
* \param txSpace The space left on the socket (unused).
*/
void WriteUntilBufferFull (Ptr<Socket> localSocket, uint32_t txSpace);
/**
* Start transmitting a TCP flow.
*
* \param localSocket The sending socket.
* \param servAddress The IPv4 address of the server (i.e., the destination address).
* \param servPort The TCP port of the server (i.e., the destination port).
*/
void StartFlow (Ptr<Socket> localSocket,
Ipv4Address servAddress,
uint16_t servPort);
@@ -157,7 +193,7 @@ Ns3TcpStateTestCase::DoTeardown (void)
}
void
Ns3TcpStateTestCase::Ipv4L3Rx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface)
Ns3TcpStateTestCase::Ipv4L3Rx (std::string, Ptr<const Packet> packet, Ptr<Ipv4>, uint32_t)
{
Ptr<Packet> received = packet->Copy ();
Ipv4Header ipHeader;
@@ -169,7 +205,7 @@ Ns3TcpStateTestCase::Ipv4L3Rx (std::string context, Ptr<const Packet> packet, Pt
}
void
Ns3TcpStateTestCase::Ipv4L3Tx (std::string context, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface)
Ns3TcpStateTestCase::Ipv4L3Tx (std::string, Ptr<const Packet> packet, Ptr<Ipv4>, uint32_t)
{
//
// We're not testing IP so remove and toss the header. In order to do this,
@@ -480,6 +516,11 @@ Ns3TcpStateTestCase::DoRun (void)
Simulator::Destroy ();
}
/**
* \ingroup system-tests-tcp
*
* TCP implementation state machine behavior TestSuite.
*/
class Ns3TcpStateTestSuite : public TestSuite
{
public:
@@ -504,4 +545,5 @@ Ns3TcpStateTestSuite::Ns3TcpStateTestSuite ()
AddTestCase (new Ns3TcpStateTestCase (8), TestCase::QUICK);
}
static Ns3TcpStateTestSuite ns3TcpLossTestSuite;
/// Do not forget to allocate an instance of this TestSuite.
static Ns3TcpStateTestSuite g_ns3TcpLossTestSuite;

View File

@@ -28,10 +28,18 @@
using namespace ns3;
/// Microseconds to nanoseconds conversion factor.
static const uint64_t US_PER_NS = (uint64_t)1000;
static const uint64_t US_PER_SEC = (uint64_t)1000000;
/// Nanoseconds to seconds conversion factor.
static const uint64_t NS_PER_SEC = (uint64_t)1000000000;
/**
* \ingroup system-tests-perf
*
* Get the system clock time in nanoseconds.
*
* \return the system clock time in nanoseconds.
*/
uint64_t
GetRealtimeInNs (void)
{
@@ -42,6 +50,16 @@ GetRealtimeInNs (void)
return nsResult;
}
/**
* \ingroup system-tests-perf
*
* Check the performance of writing to file.
*
* \param file The file to write to.
* \param n The number of writes to perform.
* \param buffer The buffer to write.
* \param size The buffer size.
*/
void
PerfFile (FILE *file, uint32_t n, const char *buffer, uint32_t size)
{
@@ -54,6 +72,16 @@ PerfFile (FILE *file, uint32_t n, const char *buffer, uint32_t size)
}
}
/**
* \ingroup system-tests-perf
*
* Check the performance of writing to an output stream.
*
* \param stream The output stream to write to.
* \param n The number of writes to perform.
* \param buffer The buffer to write.
* \param size The buffer size.
*/
void
PerfStream (ostream &stream, uint32_t n, const char *buffer, uint32_t size)
{