Add a way to disable DAD via an Icmpv6L4Protocol attribute.
This commit is contained in:
1 parent
09d982b017
commit
65e1ffe5c4
4 files changed
+29
-2
No files matched your search
@@ -69,6 +69,10 @@ TypeId Icmpv6L4Protocol::GetTypeId ()
|
||||
static TypeId tid = TypeId ("ns3::Icmpv6L4Protocol")
|
||||
.SetParent<Ipv6L4Protocol> ()
|
||||
.AddConstructor<Icmpv6L4Protocol> ()
|
||||
.AddAttribute ("DAD", "Always do DAD check.",
|
||||
BooleanValue (true),
|
||||
MakeBooleanAccessor (&Icmpv6L4Protocol::m_alwaysDad),
|
||||
MakeBooleanChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -144,14 +148,24 @@ int Icmpv6L4Protocol::GetVersion () const
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool Icmpv6L4Protocol::IsAlwaysDad () const
|
||||
{
|
||||
return m_alwaysDad;
|
||||
}
|
||||
|
||||
void Icmpv6L4Protocol::DoDAD (Ipv6Address target, Ptr<Ipv6Interface> interface)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << target << interface);
|
||||
Ipv6Address addr;
|
||||
|
||||
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
|
||||
|
||||
NS_ASSERT (ipv6);
|
||||
|
||||
if(!m_alwaysDad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO : disable multicast loopback to prevent NS probing to be received by the sender */
|
||||
|
||||
Ptr<Packet> p = ForgeNS ("::" ,Ipv6Address::MakeSolicitedAddress (target), target, interface->GetDevice ()->GetAddress ());
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/buffer.h"
|
||||
#include "ns3/boolean.h"
|
||||
#include "icmpv6-header.h"
|
||||
#include "ipv6-l4-protocol.h"
|
||||
#include "ndisc-cache.h"
|
||||
@@ -387,6 +388,12 @@ class Icmpv6L4Protocol : public Ipv6L4Protocol
|
||||
*/
|
||||
Ptr<NdiscCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
|
||||
|
||||
/**
|
||||
* \brief Is the node must do DAD.
|
||||
* \return true if node has to do DAD.
|
||||
*/
|
||||
bool IsAlwaysDad () const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* \brief Dispose this object.
|
||||
@@ -407,6 +414,11 @@ class Icmpv6L4Protocol : public Ipv6L4Protocol
|
||||
*/
|
||||
CacheList m_cacheList;
|
||||
|
||||
/**
|
||||
* \brief Always do DAD ?
|
||||
*/
|
||||
bool m_alwaysDad;
|
||||
|
||||
/**
|
||||
* \brief Receive Neighbor Solicitation method.
|
||||
* \param p the packet
|
||||
|
||||
@@ -196,7 +196,7 @@ bool Ipv6Interface::AddAddress (Ipv6InterfaceAddress iface)
|
||||
/* DAD handling */
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_node->GetObject<Ipv6L3Protocol> ()->GetIcmpv6 ();
|
||||
|
||||
if (icmpv6)
|
||||
if (icmpv6 && icmpv6->IsAlwaysDad ())
|
||||
{
|
||||
Simulator::Schedule (Seconds (0.), &Icmpv6L4Protocol::DoDAD, icmpv6, addr, this);
|
||||
Simulator::Schedule (Seconds (1.), &Icmpv6L4Protocol::FunctionDadTimeout, icmpv6, this, addr);
|
||||
|
||||
@@ -78,6 +78,7 @@ bool Ipv6L3ProtocolTest::RunTests ()
|
||||
uint32_t index = 0;
|
||||
|
||||
/* init */
|
||||
icmpv6->SetAttribute ("DAD", BooleanValue (false));
|
||||
node->AggregateObject (ipv6);
|
||||
node->AggregateObject (icmpv6);
|
||||
ipv6->Insert (icmpv6);
|
||||
|
||||
Reference in new issue
Block a user