From b529897c6cf6ec4358005274f807ed2472813f99 Mon Sep 17 00:00:00 2001 From: cbowers1020 Date: Mon, 30 Aug 2021 19:52:04 +0000 Subject: [PATCH] Fix Duplicate detection for ipv4 l3 multicast --- AUTHORS | 1 + CHANGES.html | 1 + RELEASE_NOTES | 1 + src/internet/model/ipv4-l3-protocol.cc | 4 ++++ src/internet/test/ipv4-deduplication-test.cc | 15 +++++++++------ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6caa71e5a9..9f0e98c952 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,6 +33,7 @@ Julien Boite (juboite@gmail.com) Biljana Bojovic (bbojovic@cttc.es) Elena Borovkova (borokovaes@iitp.ru) Rahul Bothra (rrbothra@gmail.com) +Caleb Bowers (caleb.bowers@nel.navy.mil, cbowers1020@gmail.com) Pavel Boyko (boyko@iitp.ru) Matthew Bradbury (matt-bradbury@live.co.uk) Dan Broyles (muxman@sbcglobal.net) diff --git a/CHANGES.html b/CHANGES.html index 642f0047ab..2a3c8b49e0 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -73,6 +73,7 @@

Changed behavior:


diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 09f44118ba..8dd510880b 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -38,6 +38,7 @@ New user-visible features Bugs fixed ---------- +- (internet) ipv4-l3-protocol.cc duplicate detection now accounts for sent packets, not just forwards. Release 3.34 ============= diff --git a/src/internet/model/ipv4-l3-protocol.cc b/src/internet/model/ipv4-l3-protocol.cc index d8c27b139b..d543f48b04 100644 --- a/src/internet/model/ipv4-l3-protocol.cc +++ b/src/internet/model/ipv4-l3-protocol.cc @@ -804,6 +804,10 @@ Ipv4L3Protocol::Send (Ptr packet, NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 1b: passed in with route and valid gateway"); int32_t interface = GetInterfaceForDevice (route->GetOutputDevice ()); m_sendOutgoingTrace (ipHeader, packet, interface); + if (m_enableDpd && ipHeader.GetDestination ().IsMulticast ()) + { + UpdateDuplicate (packet, ipHeader); + } SendRealOut (route, packet->Copy (), ipHeader); return; } diff --git a/src/internet/test/ipv4-deduplication-test.cc b/src/internet/test/ipv4-deduplication-test.cc index 57b5a1c530..f8a85deec2 100644 --- a/src/internet/test/ipv4-deduplication-test.cc +++ b/src/internet/test/ipv4-deduplication-test.cc @@ -424,6 +424,11 @@ Ipv4DeduplicationTest::CheckPackets (const std::string &name) std::map packets = { {"A", 14}, {"B", 16}, {"C", 16}, {"D", 16}, {"E", 4} }; + + // a priori determined packet receptions based on + std:: map packetsDuped = { + {"A", 0}, {"B", 1}, {"C", 1}, {"D", 1}, {"E", 1} + }; // a priori determined packet receptions based on initial TTL of 4, degenerate de-dup // There are TTL (4) rounds of packets. Each round a node will register a // received packet if another connected node transmits. A misses the 1st round @@ -433,12 +438,10 @@ Ipv4DeduplicationTest::CheckPackets (const std::string &name) {"A", 3}, {"B", 4}, {"C", 4}, {"D", 3}, {"E", 2} }; - NS_TEST_ASSERT_MSG_NE ((m_packetCountMap.find (name) == m_packetCountMap.end ()), true, - "No packets received for node " << name); switch (m_mode) { case ENABLED: - NS_TEST_EXPECT_MSG_EQ (m_packetCountMap[name], 1, "Wrong number of packets received for node " << name); + NS_TEST_ASSERT_MSG_EQ (m_packetCountMap[name], packetsDuped[name], "Wrong number of packets received for node " << name); break; case DISABLED: NS_TEST_EXPECT_MSG_EQ (m_packetCountMap[name], packets[name], "Wrong number of packets received for node " << name); @@ -457,10 +460,10 @@ Ipv4DeduplicationTest::CheckDrops (const std::string &name) { case ENABLED: // a priori determined packet drops based on initial TTL of 4, enabled de-dup; - // A hears from B & C + // A hears from B & C -- > 2 drops // D hears from B, C, AND E - // B (C) hears from A, C (B), D, and A again - drops = {{"A", 1}, {"B", 3}, {"C", 3}, {"D", 2}, {"E", 0}}; + // B (C) hears from A, C (B), D, + drops = {{"A", 2}, {"B", 2}, {"C", 2}, {"D", 2}, {"E", 0}}; break; case DISABLED: // a priori determined packet drops based on initial TTL of 4, disabled de-dup