IPv4 Deduplication Test. More...
Public Member Functions | |
Ipv4DeduplicationTest (bool enable, Time expire=Seconds(1)) | |
Constructor. More... | |
void | DoRun () override |
Implementation to actually run this TestCase. More... | |
void | DropPkt (const Ipv4Header &ipHeader, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface) |
Register dropped packet. More... | |
void | ReceivePkt (Ptr< Socket > socket) |
Receive data. More... | |
Public Member Functions inherited from ns3::TestCase | |
TestCase (const TestCase &)=delete | |
virtual | ~TestCase () |
Destructor. More... | |
std::string | GetName () const |
TestCase & | operator= (const TestCase &)=delete |
Private Types | |
enum | MODE { ENABLED = 0 , DISABLED , DEGENERATE } |
Enum of test types. More... | |
Private Member Functions | |
void | CheckDrops (const std::string &name) |
Check packet drops. More... | |
void | CheckPackets (const std::string &name) |
Check packet receptions. More... | |
void | DoSendData (Ptr< Socket > socket, std::string to) |
Send data. More... | |
void | DoSendPacket (Ptr< Socket > socket, Ptr< Packet > packet, std::string to) |
Send data. More... | |
void | SendData (Ptr< Socket > socket, std::string to) |
Send data. More... | |
void | SendPacket (Ptr< Socket > socket, Ptr< Packet > packet, std::string to) |
Send data. More... | |
Static Private Member Functions | |
static std::string | MakeName (bool enable, Time expire) |
Creates the test name according to the parameters. More... | |
Private Attributes | |
std::map< std::string, uint32_t > | m_dropCountMap |
map of received packets (node name, counter) More... | |
Time | m_expire |
Expiration delay for duplicate cache entries. More... | |
MODE | m_mode |
Test type. More... | |
std::map< std::string, uint32_t > | m_packetCountMap |
map of received packets (node name, counter) More... | |
Static Private Attributes | |
static const Time | DELAY = MilliSeconds(1) |
Channel delay. More... | |
Additional Inherited Members | |
Public Types inherited from ns3::TestCase | |
enum | TestDuration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 } |
How long the test takes to execute. More... | |
Protected Member Functions inherited from ns3::TestCase | |
TestCase (std::string name) | |
Constructor. More... | |
void | AddTestCase (TestCase *testCase, TestDuration duration=QUICK) |
Add an individual child TestCase to this test suite. More... | |
TestCase * | GetParent () const |
Get the parent of this TestCase. More... | |
bool | IsStatusFailure () const |
Check if any tests failed. More... | |
bool | IsStatusSuccess () const |
Check if all tests passed. More... | |
void | SetDataDir (std::string directory) |
Set the data directory where reference trace files can be found. More... | |
void | ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line) |
Log the failure of this TestCase. More... | |
bool | MustAssertOnFailure () const |
Check if this run should assert on failure. More... | |
bool | MustContinueOnFailure () const |
Check if this run should continue on failure. More... | |
std::string | CreateDataDirFilename (std::string filename) |
Construct the full path to a file in the data directory. More... | |
std::string | CreateTempDirFilename (std::string filename) |
Construct the full path to a file in a temporary directory. More... | |
IPv4 Deduplication Test.
Tests topology:
/---- B ----\
A -— | -— D -— E ---- C -—/
This test case counts the number of packets received and dropped at each node across the topology. Every node is configured to forward the multicast packet which originates at node A.
With RFC 6621 de-duplication enabled, one 1 packet is received while some number of duplicate relayed packets are dropped by RFC 6621 at each node.
When RFC6621 is disabled, the original packet has TTL = 4. Multiple packets are received at each node and several packets are dropped due to TTL expiry at each node.
Definition at line 82 of file ipv4-deduplication-test.cc.
|
private |
Enum of test types.
Enumerator | |
---|---|
ENABLED | |
DISABLED | |
DEGENERATE |
Definition at line 137 of file ipv4-deduplication-test.cc.
Ipv4DeduplicationTest::Ipv4DeduplicationTest | ( | bool | enable, |
Time | expire = Seconds(1) |
||
) |
Constructor.
enable | deduplication enabled |
expire | expiration delay for duplicate cache entries |
Definition at line 184 of file ipv4-deduplication-test.cc.
References DEGENERATE, DELAY, DISABLED, m_expire, and m_mode.
|
private |
Check packet drops.
name | Node name |
Definition at line 499 of file ipv4-deduplication-test.cc.
References DEGENERATE, DISABLED, ENABLED, m_dropCountMap, m_mode, NS_TEST_ASSERT_MSG_NE, and NS_TEST_EXPECT_MSG_EQ.
Referenced by DoRun().
|
private |
Check packet receptions.
name | Node name |
Definition at line 446 of file ipv4-deduplication-test.cc.
References DEGENERATE, DISABLED, ENABLED, m_mode, m_packetCountMap, NS_TEST_ASSERT_MSG_EQ, and NS_TEST_EXPECT_MSG_EQ.
Referenced by DoRun().
|
overridevirtual |
Implementation to actually run this TestCase.
Subclasses should override this method to conduct their tests.
Implements ns3::TestCase.
Definition at line 294 of file ipv4-deduplication-test.cc.
References ns3::Ipv4ListRoutingHelper::Add(), ns3::Ipv4StaticRoutingHelper::AddMulticastRoute(), ns3::Ipv4AddressHelper::Assign(), ns3::NodeContainer::Begin(), third::channel, CheckDrops(), CheckPackets(), ns3::Config::ConnectWithoutContext(), ns3::NodeContainer::Create(), ns3::SocketFactory::CreateSocket(), DELAY, first::devices, DISABLED, DropPkt(), ns3::NodeContainer::End(), ns3::NodeContainer::Get(), ns3::Object::GetObject(), ns3::Ipv4StaticRoutingHelper::GetStaticRouting(), ns3::SimpleNetDeviceHelper::Install(), nsclick-simple-lan::internet, nsclick-simple-lan::ipv4, m_expire, m_mode, m_packetCountMap, ns3::MakeCallback(), ns3::UdpSocket::MulticastJoinGroup(), nodes, NS_TEST_ASSERT_MSG_EQ, NS_TEST_EXPECT_MSG_EQ, ReceivePkt(), SendData(), ns3::ObjectBase::SetAttribute(), ns3::Ipv4AddressHelper::SetBase(), and ns3::Config::SetDefault().
Send data.
socket | The sending socket. |
to | Destination address. |
Definition at line 241 of file ipv4-deduplication-test.cc.
References SendPacket().
Referenced by SendData().
|
private |
Send data.
socket | The sending socket. |
packet | The packet to send. |
to | Destination address. |
Definition at line 247 of file ipv4-deduplication-test.cc.
References NS_TEST_EXPECT_MSG_EQ, and ns3::Socket::SendTo().
Referenced by SendPacket().
void Ipv4DeduplicationTest::DropPkt | ( | const Ipv4Header & | ipHeader, |
Ptr< const Packet > | packet, | ||
Ipv4L3Protocol::DropReason | reason, | ||
Ptr< Ipv4 > | ipv4, | ||
uint32_t | interface | ||
) |
Register dropped packet.
[in] | ipHeader | IP header |
[in] | packet | Packet that was dropped |
[in] | reason | Reason for dropping packet |
[in] | ipv4 | Ipv4 instance |
[in] | interface | Interface number |
Definition at line 216 of file ipv4-deduplication-test.cc.
References DEGENERATE, DISABLED, ENABLED, nsclick-simple-lan::ipv4, m_dropCountMap, m_mode, and NS_TEST_EXPECT_MSG_EQ.
Referenced by DoRun().
|
staticprivate |
Creates the test name according to the parameters.
enable | deduplication enabled |
expire | expiration delay for duplicate cache entries |
Definition at line 272 of file ipv4-deduplication-test.cc.
References DELAY, and ns3::Time::ToDouble().
Receive data.
[in] | socket | The receive socket. |
Definition at line 200 of file ipv4-deduplication-test.cc.
References ns3::Socket::GetNode(), ns3::Socket::GetRxAvailable(), ns3::Packet::GetSize(), m_packetCountMap, max, NS_TEST_ASSERT_MSG_EQ, and ns3::Socket::Recv().
Referenced by DoRun().
Send data.
socket | The sending socket. |
to | Destination address. |
Definition at line 254 of file ipv4-deduplication-test.cc.
References DoSendData().
Referenced by DoRun().
|
private |
Send data.
socket | The sending socket. |
packet | The packet to send. |
to | Destination address. |
Definition at line 260 of file ipv4-deduplication-test.cc.
References DoSendPacket(), ns3::Node::GetId(), ns3::Socket::GetNode(), and ns3::MilliSeconds().
Referenced by DoSendData().
|
staticprivate |
Channel delay.
Definition at line 124 of file ipv4-deduplication-test.cc.
Referenced by Ipv4DeduplicationTest(), DoRun(), and MakeName().
|
private |
map of received packets (node name, counter)
Definition at line 149 of file ipv4-deduplication-test.cc.
Referenced by CheckDrops(), and DropPkt().
|
private |
Expiration delay for duplicate cache entries.
Definition at line 145 of file ipv4-deduplication-test.cc.
Referenced by Ipv4DeduplicationTest(), and DoRun().
|
private |
Test type.
Definition at line 144 of file ipv4-deduplication-test.cc.
Referenced by Ipv4DeduplicationTest(), CheckDrops(), CheckPackets(), DoRun(), and DropPkt().
|
private |
map of received packets (node name, counter)
Definition at line 147 of file ipv4-deduplication-test.cc.
Referenced by CheckPackets(), DoRun(), and ReceivePkt().