From 874d07b4278a2c1922af5342013f4d8c3a81ac26 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Wed, 29 Apr 2009 16:18:50 +0400 Subject: [PATCH] Fixed PREQ lifetime --- src/devices/mesh/dot11s/hwmp-protocol.cc | 62 ++++++++++++++++-------- src/devices/mesh/dot11s/hwmp-rtable.cc | 3 ++ src/devices/mesh/dot11s/hwmp-rtable.h | 7 ++- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index e9a1b5a8a..4ba3dbe03 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -47,6 +47,17 @@ HwmpProtocol::GetTypeId () static TypeId tid = TypeId ("ns3::dot11s::HwmpProtocol") .SetParent () .AddConstructor () + .AddAttribute ("RandomStart", "Random delay at first proactive PREQ", + TimeValue (Seconds (0.1)), + MakeTimeAccessor (&HwmpProtocol::m_randomStart), + MakeTimeChecker () + ) + .AddAttribute ("maxQueueSize", + "Maximum number of packets we can store when resolving route", + UintegerValue (255), + MakeUintegerAccessor (&HwmpProtocol::m_maxQueueSize), + MakeUintegerChecker (1) + ) .AddAttribute ("dot11MeshHWMPmaxPREQretries", "Maximum number of retries before we suppose the destination to be unreachable", UintegerValue (3), @@ -95,52 +106,41 @@ HwmpProtocol::GetTypeId () MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPrannInterval), MakeTimeChecker () ) - .AddAttribute ("maxQueueSize", - "Maximum number of packets we can store when resolving route", - UintegerValue (255), - MakeUintegerAccessor (&HwmpProtocol::m_maxQueueSize), - MakeUintegerChecker (1) - ) - .AddAttribute ("maxTtl", + .AddAttribute ("maxTtl", "Initial value of Time To Live field", UintegerValue (32), MakeUintegerAccessor (&HwmpProtocol::m_maxTtl), MakeUintegerChecker (2) ) - .AddAttribute ("unicastPerrThreshold", + .AddAttribute ("unicastPerrThreshold", "Maximum number of PERR receivers, when we send a PERR as a chain of unicasts", UintegerValue (32), MakeUintegerAccessor (&HwmpProtocol::m_unicastPerrThreshold), MakeUintegerChecker (1) ) - .AddAttribute ("unicastPreqThreshold", + .AddAttribute ("unicastPreqThreshold", "Maximum number of PREQ receivers, when we send a PREQ as a chain of unicasts", UintegerValue (1), MakeUintegerAccessor (&HwmpProtocol::m_unicastPreqThreshold), MakeUintegerChecker (1) ) - .AddAttribute ("unicastDataThreshold", + .AddAttribute ("unicastDataThreshold", "Maximum number ofbroadcast receivers, when we send a broadcast as a chain of unicasts", UintegerValue (1), MakeUintegerAccessor (&HwmpProtocol::m_unicastDataThreshold), MakeUintegerChecker (1) ) - .AddAttribute ("doFlag", + .AddAttribute ("doFlag", "Destination only HWMP flag", BooleanValue (true), MakeUintegerAccessor (&HwmpProtocol::m_doFlag), MakeUintegerChecker () ) - .AddAttribute ("rfFlag", + .AddAttribute ("rfFlag", "Reply and forward flag", BooleanValue (false), MakeUintegerAccessor (&HwmpProtocol::m_rfFlag), MakeUintegerChecker () - ) - .AddAttribute ("RandomStart", "Random delay at first proactive PREQ", - TimeValue (Seconds (0.1)), - MakeTimeAccessor (&HwmpProtocol::m_randomStart), - MakeTimeChecker () ); return tid; } @@ -149,8 +149,26 @@ HwmpProtocol::HwmpProtocol (): m_hwmpSeqno (1), m_preqId (0), m_rtable (CreateObject ()), - m_isRoot(false) + m_randomStart(Seconds (0.1)), + m_maxQueueSize (255), + m_dot11MeshHWMPmaxPREQretries (3), + m_dot11MeshHWMPnetDiameterTraversalTime (MicroSeconds (1024*100)), + m_dot11MeshHWMPpreqMinInterval (MicroSeconds (1024*100)), + m_dot11MeshHWMPperrMinInterval (MicroSeconds (1024*100)), + m_dot11MeshHWMPactiveRootTimeout (MicroSeconds (1024*5000)), + m_dot11MeshHWMPactivePathTimeout (MicroSeconds (1024*5000)), + m_dot11MeshHWMPpathToRootInterval (MicroSeconds (1024*2000)), + m_dot11MeshHWMPrannInterval (MicroSeconds (1024*5000)), + m_isRoot (false), + m_maxTtl (32), + m_unicastPerrThreshold (32), + m_unicastPreqThreshold (1), + m_unicastDataThreshold (1), + m_doFlag (false), + m_rfFlag (false) { + if(m_isRoot) + SetRoot (); } HwmpProtocol::~HwmpProtocol () @@ -379,6 +397,12 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, u if ((! ((*i)->IsDo())) && (result.retransmitter != Mac48Address::GetBroadcast())) { //have a valid information and can answer + //!NB: If there is information from peer - set lifetime as + //we have got from PREQ, and set the rest lifetime of the + //route if the information is correct + uint32_t lifetime = preq.GetLifetime (); + if(result.lifetime != Seconds (0.0)) + lifetime = result.lifetime.GetMicroSeconds () / 1024; SendPrep ( (*i)->GetDestinationAddress (), preq.GetOriginatorAddress (), @@ -386,7 +410,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, u result.metric, preq.GetOriginatorSeqNumber (), result.seqnum +1, - preq.GetLifetime (), + lifetime, interface ); diff --git a/src/devices/mesh/dot11s/hwmp-rtable.cc b/src/devices/mesh/dot11s/hwmp-rtable.cc index 3823d9112..3dbba3dfb 100644 --- a/src/devices/mesh/dot11s/hwmp-rtable.cc +++ b/src/devices/mesh/dot11s/hwmp-rtable.cc @@ -171,6 +171,9 @@ HwmpRtable::LookupReactive (Mac48Address destination) NS_LOG_DEBUG ("Reactive route has expired, sorry."); return LookupResult(); } + Time lifetime = Seconds (0.0); + if (i->second.whenExpire != Seconds (0)) + lifetime = i->second.whenExpire - Simulator::Now (); return LookupResult (i->second.retransmitter, i->second.interface, i->second.metric, i->second.seqnum); } diff --git a/src/devices/mesh/dot11s/hwmp-rtable.h b/src/devices/mesh/dot11s/hwmp-rtable.h index ef49e4eaf..8084f02b2 100644 --- a/src/devices/mesh/dot11s/hwmp-rtable.h +++ b/src/devices/mesh/dot11s/hwmp-rtable.h @@ -48,15 +48,18 @@ public: uint32_t ifIndex; uint32_t metric; uint32_t seqnum; + Time lifetime; LookupResult(Mac48Address r = Mac48Address::GetBroadcast (), uint32_t i = INTERFACE_ANY, uint32_t m = MAX_METRIC, - uint32_t s = 0) + uint32_t s = 0, + Time l = Seconds(0.0)) : retransmitter (r), ifIndex (i), metric (m), - seqnum (s) + seqnum (s), + lifetime (l) { }