internet: (fixes #2482) Migrating ICMPv6 timers to Attributes
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "ns3/ipv6-route.h"
|
||||
#include "ns3/pointer.h"
|
||||
#include "ns3/string.h"
|
||||
#include "ns3/integer.h"
|
||||
|
||||
#include "ipv6-raw-socket-factory-impl.h"
|
||||
#include "ipv6-l3-protocol.h"
|
||||
@@ -54,13 +55,9 @@ const uint8_t Icmpv6L4Protocol::PROT_NUMBER = 58;
|
||||
//const uint8_t Icmpv6L4Protocol::RTR_SOLICITATION_INTERVAL = 4; // RS interval.
|
||||
//const uint8_t Icmpv6L4Protocol::MAX_RTR_SOLICITATIONS = 3; // max RS transmission.
|
||||
|
||||
const uint8_t Icmpv6L4Protocol::MAX_MULTICAST_SOLICIT = 3;
|
||||
const uint8_t Icmpv6L4Protocol::MAX_UNICAST_SOLICIT = 3;
|
||||
//const uint8_t Icmpv6L4Protocol::MAX_ANYCAST_DELAY_TIME = 1; // max anycast delay.
|
||||
//const uint8_t Icmpv6L4Protocol::MAX_NEIGHBOR_ADVERTISEMENT = 3; // max NA transmission.
|
||||
const uint32_t Icmpv6L4Protocol::REACHABLE_TIME = 30000;
|
||||
const uint32_t Icmpv6L4Protocol::RETRANS_TIMER = 1000;
|
||||
const uint8_t Icmpv6L4Protocol::DELAY_FIRST_PROBE_TIME = 5;
|
||||
|
||||
//const double Icmpv6L4Protocol::MIN_RANDOM_FACTOR = 0.5; // min random factor.
|
||||
//const double Icmpv6L4Protocol::MAX_RANDOM_FACTOR = 1.5; // max random factor.
|
||||
|
||||
@@ -74,12 +71,31 @@ TypeId Icmpv6L4Protocol::GetTypeId ()
|
||||
BooleanValue (true),
|
||||
MakeBooleanAccessor (&Icmpv6L4Protocol::m_alwaysDad),
|
||||
MakeBooleanChecker ())
|
||||
.AddAttribute ("SolicitationJitter", "The jitter in ms a node is allowed to wait before sending any solicitation . Some jitter aims to prevent collisions. By default, the model will wait for a duration in ms defined by a uniform random-variable between 0 and SolicitationJitter",
|
||||
.AddAttribute ("SolicitationJitter", "The jitter in ms a node is allowed to wait before sending any solicitation. Some jitter aims to prevent collisions. By default, the model will wait for a duration in ms defined by a uniform random-variable between 0 and SolicitationJitter",
|
||||
StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=10.0]"),
|
||||
MakePointerAccessor (&Icmpv6L4Protocol::m_solicitationJitter),
|
||||
MakePointerChecker<RandomVariableStream> ())
|
||||
|
||||
;
|
||||
.AddAttribute ("MaxMulticastSolicit", "Neighbor Discovery node constants: max multicast solicitations.",
|
||||
IntegerValue (3),
|
||||
MakeIntegerAccessor (&Icmpv6L4Protocol::m_maxMulticastSolicit),
|
||||
MakeIntegerChecker<uint8_t> ())
|
||||
.AddAttribute ("MaxUnicastSolicit", "Neighbor Discovery node constants: max unicast solicitations.",
|
||||
IntegerValue (3),
|
||||
MakeIntegerAccessor (&Icmpv6L4Protocol::m_maxUnicastSolicit),
|
||||
MakeIntegerChecker<uint8_t> ())
|
||||
.AddAttribute ("ReachableTime", "Neighbor Discovery node constants: reachable time.",
|
||||
TimeValue (Seconds (30)),
|
||||
MakeTimeAccessor (&Icmpv6L4Protocol::m_reachableTime),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("RetransmissionTime", "Neighbor Discovery node constants: retransmission timer.",
|
||||
TimeValue (Seconds (1)),
|
||||
MakeTimeAccessor (&Icmpv6L4Protocol::m_retransmissionTime),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("DelayFirstProbe", "Neighbor Discovery node constants: delay for the first probe.",
|
||||
TimeValue (Seconds (5)),
|
||||
MakeTimeAccessor (&Icmpv6L4Protocol::m_delayFirstProbe),
|
||||
MakeTimeChecker ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -1454,5 +1470,36 @@ Icmpv6L4Protocol::GetDownTarget6 (void) const
|
||||
return m_downTarget;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Icmpv6L4Protocol::GetMaxMulticastSolicit () const
|
||||
{
|
||||
return m_maxMulticastSolicit;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
Icmpv6L4Protocol::GetMaxUnicastSolicit () const
|
||||
{
|
||||
return m_maxUnicastSolicit;
|
||||
}
|
||||
|
||||
Time
|
||||
Icmpv6L4Protocol::GetReachableTime () const
|
||||
{
|
||||
return m_reachableTime;
|
||||
}
|
||||
|
||||
Time
|
||||
Icmpv6L4Protocol::GetRetransmissionTime () const
|
||||
{
|
||||
return m_retransmissionTime;
|
||||
}
|
||||
|
||||
Time
|
||||
Icmpv6L4Protocol::GetDelayFirstProbe () const
|
||||
{
|
||||
return m_delayFirstProbe;
|
||||
}
|
||||
|
||||
|
||||
} /* namespace ns3 */
|
||||
|
||||
|
||||
@@ -64,29 +64,34 @@ public:
|
||||
static const uint8_t PROT_NUMBER;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants : max multicast solicitations.
|
||||
* \brief Neighbor Discovery node constants: max multicast solicitations.
|
||||
* \returns The max multicast solicitations number.
|
||||
*/
|
||||
static const uint8_t MAX_MULTICAST_SOLICIT;
|
||||
uint8_t GetMaxMulticastSolicit () const;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants : max unicast solicitations.
|
||||
* \brief Neighbor Discovery node constants: max unicast solicitations.
|
||||
* \returns The max unicast solicitations number.
|
||||
*/
|
||||
static const uint8_t MAX_UNICAST_SOLICIT;
|
||||
uint8_t GetMaxUnicastSolicit () const;;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants : reachable time.
|
||||
* \brief Neighbor Discovery node constants: reachable time.
|
||||
* \returns The Reachable time for an Neighbor cache entry.
|
||||
*/
|
||||
static const uint32_t REACHABLE_TIME;
|
||||
Time GetReachableTime () const;;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants : retransmission timer.
|
||||
* \brief Neighbor Discovery node constants: retransmission timer.
|
||||
* \returns The Retransmission time for an Neighbor cache entry probe.
|
||||
*/
|
||||
static const uint32_t RETRANS_TIMER;
|
||||
Time GetRetransmissionTime () const;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants : delay for the first probe.
|
||||
* \returns The time before a first probe for an Neighbor cache entry.
|
||||
*/
|
||||
static const uint8_t DELAY_FIRST_PROBE_TIME;
|
||||
Time GetDelayFirstProbe () const;
|
||||
|
||||
/**
|
||||
* \brief Get ICMPv6 protocol number.
|
||||
@@ -378,6 +383,32 @@ protected:
|
||||
private:
|
||||
typedef std::list<Ptr<NdiscCache> > CacheList; //!< container of NdiscCaches
|
||||
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants: max multicast solicitations.
|
||||
*/
|
||||
uint8_t m_maxMulticastSolicit;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants: max unicast solicitations.
|
||||
*/
|
||||
uint8_t m_maxUnicastSolicit;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants: reachable time.
|
||||
*/
|
||||
Time m_reachableTime;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants: retransmission timer.
|
||||
*/
|
||||
Time m_retransmissionTime;
|
||||
|
||||
/**
|
||||
* \brief Neighbor Discovery node constants: delay for the first probe.
|
||||
*/
|
||||
Time m_delayFirstProbe;
|
||||
|
||||
/**
|
||||
* \brief The node.
|
||||
*/
|
||||
|
||||
@@ -271,7 +271,7 @@ void NdiscCache::Entry::FunctionReachableTimeout ()
|
||||
void NdiscCache::Entry::FunctionRetransmitTimeout ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Ipv6L3Protocol> ()->GetIcmpv6 ();
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
Ipv6Address addr;
|
||||
|
||||
/* determine source address */
|
||||
@@ -291,7 +291,7 @@ void NdiscCache::Entry::FunctionRetransmitTimeout ()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_nsRetransmit < icmpv6->MAX_MULTICAST_SOLICIT)
|
||||
if (m_nsRetransmit < icmpv6->GetMaxMulticastSolicit ())
|
||||
{
|
||||
m_nsRetransmit++;
|
||||
|
||||
@@ -358,10 +358,10 @@ void NdiscCache::Entry::FunctionDelayTimeout ()
|
||||
void NdiscCache::Entry::FunctionProbeTimeout ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Ipv6L3Protocol> ipv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Ipv6L3Protocol> ();
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = ipv6->GetIcmpv6 ();
|
||||
|
||||
if (m_nsRetransmit < icmpv6->MAX_UNICAST_SOLICIT)
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
if (m_nsRetransmit < icmpv6->GetMaxUnicastSolicit ())
|
||||
{
|
||||
m_nsRetransmit++;
|
||||
|
||||
@@ -422,9 +422,11 @@ void NdiscCache::Entry::StartReachableTimer ()
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_lastReachabilityConfirmation = Simulator::Now ();
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionReachableTimeout, this);
|
||||
m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::REACHABLE_TIME));
|
||||
m_nudTimer.SetDelay (icmpv6->GetReachableTime ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
@@ -450,8 +452,11 @@ void NdiscCache::Entry::StartProbeTimer ()
|
||||
{
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionProbeTimeout, this);
|
||||
m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::RETRANS_TIMER));
|
||||
m_nudTimer.SetDelay (icmpv6->GetRetransmissionTime ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
@@ -462,8 +467,11 @@ void NdiscCache::Entry::StartDelayTimer ()
|
||||
{
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionDelayTimeout, this);
|
||||
m_nudTimer.SetDelay (Seconds (Icmpv6L4Protocol::DELAY_FIRST_PROBE_TIME));
|
||||
m_nudTimer.SetDelay (icmpv6->GetDelayFirstProbe ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
@@ -474,8 +482,11 @@ void NdiscCache::Entry::StartRetransmitTimer ()
|
||||
{
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionRetransmitTimeout, this);
|
||||
m_nudTimer.SetDelay (MilliSeconds (Icmpv6L4Protocol::RETRANS_TIMER));
|
||||
m_nudTimer.SetDelay (icmpv6->GetRetransmissionTime ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user