src/devices/mesh/dot11s/hwmp-protocol.cc
changeset 4892 cdd13648776b
parent 4891 b8db474bce60
child 4893 d390c2dd2f14
equal deleted inserted replaced
4891:b8db474bce60 4892:cdd13648776b
    39 NS_OBJECT_ENSURE_REGISTERED (HwmpProtocol);
    39 NS_OBJECT_ENSURE_REGISTERED (HwmpProtocol);
    40 TypeId
    40 TypeId
    41 HwmpProtocol::GetTypeId ()
    41 HwmpProtocol::GetTypeId ()
    42 {
    42 {
    43   static TypeId tid = TypeId ("ns3::HwmpProtocol")
    43   static TypeId tid = TypeId ("ns3::HwmpProtocol")
    44                       .SetParent<MeshL2RoutingProtocol> ()
    44     .SetParent<MeshL2RoutingProtocol> ()
    45                       .AddConstructor<HwmpProtocol> ();
    45     .AddConstructor<HwmpProtocol> ()
       
    46     .AddAttribute ("dot11MeshHWMPmaxPREQretries",
       
    47         "Maximum number of retries before we suppose the destination to be unreachable",
       
    48         UintegerValue (3),
       
    49         MakeUintegerAccessor (&HwmpProtocol::m_dot11MeshHWMPmaxPREQretries),
       
    50         MakeUintegerChecker<uint8_t> (1)
       
    51         )
       
    52     .AddAttribute ("dot11MeshHWMPnetDiameterTraversalTime",
       
    53         "Time we suppose the packet to go from one edge of the network to another",
       
    54         TimeValue (MicroSeconds (1024*10)),
       
    55         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPnetDiameterTraversalTime),
       
    56         MakeTimeChecker ()
       
    57         )
       
    58     .AddAttribute ("dot11MeshHWMPpreqMinInterva",
       
    59         "Minimal interval between to successive PREQs",
       
    60         TimeValue (MicroSeconds (1024*100)),
       
    61         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPpreqMinInterval),
       
    62         MakeTimeChecker ()
       
    63         )
       
    64     .AddAttribute ("dot11MeshHWMPperrMinInterval",
       
    65         "Minimal interval between to successive PREQs",
       
    66         TimeValue (MicroSeconds (1024*100)),
       
    67         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPperrMinInterval),
       
    68         MakeTimeChecker ()
       
    69         )
       
    70     .AddAttribute ("dot11MeshHWMPactiveRootTimeout",
       
    71         "Lifetime of poractive routing information",
       
    72         TimeValue (MicroSeconds (1024*5000)),
       
    73         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPactiveRootTimeout),
       
    74         MakeTimeChecker ()
       
    75         )
       
    76     .AddAttribute ("dot11MeshHWMPactiveRootTimeout",
       
    77         "Lifetime of poractive routing information",
       
    78         TimeValue (MicroSeconds (1024*5000)),
       
    79         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPactiveRootTimeout),
       
    80         MakeTimeChecker ()
       
    81         )
       
    82     .AddAttribute ("dot11MeshHWMPactivePathTimeout",
       
    83         "Lifetime of reactive routing information",
       
    84         TimeValue (MicroSeconds (1024*5000)),
       
    85         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPactivePathTimeout),
       
    86         MakeTimeChecker ()
       
    87         )
       
    88     .AddAttribute ("dot11MeshHWMPpathToRootInterval",
       
    89         "Interval between two successive proactive PREQs",
       
    90         TimeValue (MicroSeconds (1024*5000)),
       
    91         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPpathToRootInterval),
       
    92         MakeTimeChecker ()
       
    93         )
       
    94     .AddAttribute ("dot11MeshHWMPrannInterval",
       
    95         "Lifetime of poractive routing information",
       
    96         TimeValue (MicroSeconds (1024*5000)),
       
    97         MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPrannInterval),
       
    98         MakeTimeChecker ()
       
    99         );
    46   return tid;
   100   return tid;
    47 }
   101 }
    48 HwmpProtocol::HwmpProtocol ():
   102 HwmpProtocol::HwmpProtocol ():
    49     m_dataSeqno(0),
   103     m_dataSeqno(0),
    50     m_hwmpSeqno(0),
   104     m_hwmpSeqno(0),
    59 
   113 
    60 void
   114 void
    61 HwmpProtocol::DoDispose ()
   115 HwmpProtocol::DoDispose ()
    62 {
   116 {
    63 #if 0
   117 #if 0
    64   for (std::map<Mac48Address, EventId>::iterator i = m_timeoutDatabase.begin (); i != m_timeoutDatabase.end(); i ++)
   118   for (std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.begin (); i != m_preqTimeouts.end(); i ++)
    65     i->second.Cancel ();
   119     i->second.Cancel ();
    66   m_timeoutDatabase.clear ();
   120   m_preqTimeouts.clear ();
    67   m_seqnoDatabase.clear ();
   121   m_seqnoDatabase.clear ();
    68   m_rtable = 0;
   122   m_rtable = 0;
    69 
   123 
    70   /**
   124   /**
    71    * clear routing queue:
   125    * clear routing queue:
   529       packet.pkt->AddTag (tag);
   583       packet.pkt->AddTag (tag);
   530       packet.reply (true, packet.pkt, packet.src, packet.dst, packet.protocol, result.ifIndex);
   584       packet.reply (true, packet.pkt, packet.src, packet.dst, packet.protocol, result.ifIndex);
   531     }
   585     }
   532 #endif
   586 #endif
   533 }
   587 }
   534 #if 0
       
   535 bool
   588 bool
   536 HwmpProtocol::ShouldSendPreq (Mac48Address dst)
   589 HwmpProtocol::ShouldSendPreq (Mac48Address dst)
   537 {
   590 {
   538   std::map<Mac48Address, EventId>::iterator i = m_timeoutDatabase.find (dst);
   591   std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
   539   if (i == m_timeoutDatabase.end ())
   592   if (i == m_preqTimeouts.end ())
   540     {
   593     {
   541       m_timeoutDatabase[dst] = Simulator::Schedule (
   594       m_preqTimeouts[dst] = Simulator::Schedule (
   542                                  MilliSeconds (2*(dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
   595           MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
   543                                  &HwmpProtocol::RetryPathDiscovery, this, dst, 0);
   596           &HwmpProtocol::RetryPathDiscovery, this, dst, 0);
   544       return true;
   597       return true;
   545     }
   598     }
   546   return false;
   599   return false;
   547 }
   600 }
   548 void
   601 void
   549 HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
   602 HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
   550 {
   603 {
       
   604 #if 0
   551   HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst);
   605   HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst);
   552   if (result.retransmitter != Mac48Address::GetBroadcast ())
   606   if (result.retransmitter != Mac48Address::GetBroadcast ())
   553     {
   607     {
   554       std::map<Mac48Address, EventId>::iterator i = m_timeoutDatabase.find (dst);
   608       std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
   555       NS_ASSERT (i !=  m_timeoutDatabase.end());
   609       NS_ASSERT (i !=  m_preqTimeouts.end());
   556       m_timeoutDatabase.erase (i);
   610       m_preqTimeouts.erase (i);
   557       return;
   611       return;
   558     }
   612     }
   559   numOfRetry++;
   613   numOfRetry++;
   560   if (numOfRetry > dot11sParameters::dot11MeshHWMPmaxPREQretries)
   614   if (numOfRetry > dot11sParameters::dot11MeshHWMPmaxPREQretries)
   561     {
   615     {
   566           packet = DequeuePacket (dst);
   620           packet = DequeuePacket (dst);
   567           if (packet.pkt == NULL)
   621           if (packet.pkt == NULL)
   568             break;
   622             break;
   569           packet.reply (false, packet.pkt, packet.src, packet.dst, packet.protocol, HwmpRtable::MAX_METRIC);
   623           packet.reply (false, packet.pkt, packet.src, packet.dst, packet.protocol, HwmpRtable::MAX_METRIC);
   570         }
   624         }
   571       std::map<Mac48Address, EventId>::iterator i = m_timeoutDatabase.find (dst);
   625       std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
   572       NS_ASSERT (i !=  m_timeoutDatabase.end());
   626       NS_ASSERT (i !=  m_preqTimeouts.end());
   573       m_timeoutDatabase.erase (i);
   627       m_preqTimeouts.erase (i);
   574       return;
   628       return;
   575     }
   629     }
       
   630 #if 0
   576   for (unsigned int i = 0; i < m_requestCallback.size (); i++)
   631   for (unsigned int i = 0; i < m_requestCallback.size (); i++)
   577     if ((m_modes[i] == REACTIVE) || (m_modes[i] == ROOT))
   632     if ((m_modes[i] == REACTIVE) || (m_modes[i] == ROOT))
   578       m_requestCallback[i] (dst);
   633       m_requestCallback[i] (dst);
   579   m_timeoutDatabase[dst] = Simulator::Schedule (
   634 #endif
       
   635   m_preqTimeouts[dst] = Simulator::Schedule (
   580                              MilliSeconds (2*(dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
   636                              MilliSeconds (2*(dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
   581                              &HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);
   637                              &HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);
   582 }
   638 #endif
   583 #endif
   639 }
   584 } //namespace dot11s
   640 } //namespace dot11s
   585 } //namespace ns3
   641 } //namespace ns3