Skip to content

Commit

Permalink
internet: Add TracedCallback to trace invalid address on DAD failure
Browse files Browse the repository at this point in the history
  • Loading branch information
kavyabhat02 committed Jul 7, 2024
1 parent 5c5481e commit cc7fc01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/internet/model/icmpv6-l4-protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ Icmpv6L4Protocol::GetTypeId()
"Multicast RS maximum retransmission duration (0 means unbound).",
TimeValue(Seconds(0)),
MakeTimeAccessor(&Icmpv6L4Protocol::m_rsMaxRetransmissionDuration),
MakeTimeChecker());
MakeTimeChecker())
.AddTraceSource("FailedDad",
"Duplicate Address detected during DAD, the address is now INVALID",
MakeTraceSourceAccessor(&Icmpv6L4Protocol::m_failedDadAddressTrace),
"ns3::Ipv6Address::TracedCallback");
return tid;
}

Expand Down Expand Up @@ -873,6 +877,7 @@ Icmpv6L4Protocol::HandleNA(Ptr<Packet> packet,
if (ifaddr.GetState() == Ipv6InterfaceAddress::TENTATIVE ||
ifaddr.GetState() == Ipv6InterfaceAddress::TENTATIVE_OPTIMISTIC)
{
m_failedDadAddressTrace(ifaddr.GetAddress());
interface->SetState(ifaddr.GetAddress(), Ipv6InterfaceAddress::INVALID);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/internet/model/icmpv6-l4-protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "ns3/ipv6-address.h"
#include "ns3/random-variable-stream.h"
#include "ns3/traced-callback.h"

#include <list>

Expand Down Expand Up @@ -697,6 +698,12 @@ class Icmpv6L4Protocol : public IpL4Protocol
EventId m_handleRsTimeoutEvent;

IpL4Protocol::DownTargetCallback6 m_downTarget; //!< callback to Ipv6::Send

/**
* The trace fired when a DAD fails, changing the address state to INVALID.
* Includes the address whose state has been changed.
*/
ns3::TracedCallback<const Ipv6Address&> m_failedDadAddressTrace;
};

} /* namespace ns3 */
Expand Down

0 comments on commit cc7fc01

Please sign in to comment.