View | Details | Raw Unified | Return to bug 1190
Collapse All | Expand All

(-)a/src/aodv/model/aodv-routing-protocol.cc (-27 / +37 lines)
 Lines 149-158    Link Here 
149
  m_rreqRateLimitTimer (Timer::CANCEL_ON_DESTROY),
149
  m_rreqRateLimitTimer (Timer::CANCEL_ON_DESTROY),
150
  m_rerrRateLimitTimer (Timer::CANCEL_ON_DESTROY)
150
  m_rerrRateLimitTimer (Timer::CANCEL_ON_DESTROY)
151
{
151
{
152
  if (EnableHello)
153
    {
154
      m_nb.SetCallback (MakeCallback (&RoutingProtocol::SendRerrWhenBreaksLinkToNextHop, this));
155
    }
156
}
152
}
157
153
158
TypeId
154
TypeId
 Lines 313-330    Link Here 
313
RoutingProtocol::Start ()
309
RoutingProtocol::Start ()
314
{
310
{
315
  NS_LOG_FUNCTION (this);
311
  NS_LOG_FUNCTION (this);
316
  if (EnableHello)
312
  m_nb.SetCallback (MakeCallback (&RoutingProtocol::SendRerrWhenBreaksLinkToNextHop, this));    //need not be dependent on whether hellos are enabled
317
    {
313
  m_nb.ScheduleTimer ();
318
      m_nb.ScheduleTimer ();
319
    }
320
  m_rreqRateLimitTimer.SetFunction (&RoutingProtocol::RreqRateLimitTimerExpire,
314
  m_rreqRateLimitTimer.SetFunction (&RoutingProtocol::RreqRateLimitTimerExpire,
321
                                    this);
315
                                    this);
322
  m_rreqRateLimitTimer.Schedule (Seconds (1));
316
  m_rreqRateLimitTimer.Schedule (Seconds (1));
323
324
  m_rerrRateLimitTimer.SetFunction (&RoutingProtocol::RerrRateLimitTimerExpire,
317
  m_rerrRateLimitTimer.SetFunction (&RoutingProtocol::RerrRateLimitTimerExpire,
325
                                    this);
318
                                    this);
326
  m_rerrRateLimitTimer.Schedule (Seconds (1));
319
  m_rerrRateLimitTimer.Schedule (Seconds (1));
327
328
}
320
}
329
321
330
Ptr<Ipv4Route>
322
Ptr<Ipv4Route>
 Lines 551-557    Link Here 
551
          m_routingTable.LookupRoute (origin, toOrigin);
543
          m_routingTable.LookupRoute (origin, toOrigin);
552
          UpdateRouteLifeTime (toOrigin.GetNextHop (), ActiveRouteTimeout);
544
          UpdateRouteLifeTime (toOrigin.GetNextHop (), ActiveRouteTimeout);
553
545
554
          m_nb.Update (route->GetGateway (), ActiveRouteTimeout);
546
          //m_nb.Update (route->GetGateway (), ActiveRouteTimeout);     //updating neighbor timeout only should be done if received from neighbor
555
          m_nb.Update (toOrigin.GetNextHop (), ActiveRouteTimeout);
547
          m_nb.Update (toOrigin.GetNextHop (), ActiveRouteTimeout);
556
548
557
          ucb (route, p, header);
549
          ucb (route, p, header);
 Lines 583-588    Link Here 
583
    {
575
    {
584
      m_htimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
576
      m_htimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
585
      m_htimer.Schedule (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 100)));
577
      m_htimer.Schedule (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 100)));
578
      m_lastBcastTime = Time (0);
586
    }
579
    }
587
580
588
  m_ipv4 = ipv4;
581
  m_ipv4 = ipv4;
 Lines 908-918    Link Here 
908
  ScheduleRreqRetry (dst);
901
  ScheduleRreqRetry (dst);
909
  if (EnableHello)
902
  if (EnableHello)
910
    {
903
    {
911
      if (!m_htimer.IsRunning ())
904
      m_lastBcastTime = Simulator::Now ();
912
        {
913
          m_htimer.Cancel ();
914
          m_htimer.Schedule (HelloInterval - Time (0.01 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))));
915
        }
916
    }
905
    }
917
}
906
}
918
907
 Lines 1027-1033    Link Here 
1027
          m_routingTable.Update (newEntry);
1016
          m_routingTable.Update (newEntry);
1028
        }
1017
        }
1029
    }
1018
    }
1030
1019
    
1020
  /*     
1021
   *   A node MAY determine connectivity by listening for packets from its
1022
   *   set of neighbors.  If, within the past DELETE_PERIOD, it has received  
1023
   *   Every HELLO_INTERVAL milliseconds, the node checks
1024
   *   whether it has sent a broadcast (e.g., a RREQ or an appropriate layer
1025
   *   2 message) within the last HELLO_INTERVAL.  If it has not...
1026
   *   ...
1027
   *   A node MAY determine connectivity by listening for packets from its
1028
   *   set of neighbors.  If, within the past DELETE_PERIOD, it has received
1029
   *   a Hello message from a neighbor, and then for that neighbor does not
1030
   *   receive any packets (Hello messages or otherwise) for more than
1031
   *   ALLOWED_HELLO_LOSS * HELLO_INTERVAL milliseconds, the node SHOULD
1032
   *   assume that the link to this neighbor is currently lost.
1033
   */
1034
  
1035
  if (EnableHello)
1036
    {
1037
      m_nb.Update (sender, Time (AllowedHelloLoss * HelloInterval));
1038
    }
1031
}
1039
}
1032
1040
1033
void
1041
void
 Lines 1175-1185    Link Here 
1175
1183
1176
  if (EnableHello)
1184
  if (EnableHello)
1177
    {
1185
    {
1178
      if (!m_htimer.IsRunning ())
1186
      m_lastBcastTime = Simulator::Now ();
1179
        {
1180
          m_htimer.Cancel ();
1181
          m_htimer.Schedule (HelloInterval - Time (0.1 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))));
1182
	}
1183
    }
1187
    }
1184
}
1188
}
1185
1189
 Lines 1435-1444    Link Here 
1435
      toNeighbor.SetInterface (m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0));
1439
      toNeighbor.SetInterface (m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0));
1436
      m_routingTable.Update (toNeighbor);
1440
      m_routingTable.Update (toNeighbor);
1437
    }
1441
    }
1438
  if (EnableHello)
1439
    {
1440
      m_nb.Update (rrepHeader.GetDst (), Time (AllowedHelloLoss * HelloInterval));
1441
    }
1442
}
1442
}
1443
1443
1444
void
1444
void
 Lines 1539-1545    Link Here 
1539
RoutingProtocol::HelloTimerExpire ()
1539
RoutingProtocol::HelloTimerExpire ()
1540
{
1540
{
1541
  NS_LOG_FUNCTION (this);
1541
  NS_LOG_FUNCTION (this);
1542
  SendHello ();
1542
  if (Simulator::Now () - m_lastBcastTime > HelloInterval)
1543
    if (m_routingTable.LookupPartOfAnyActiveRoutes ())
1544
      SendHello ();
1543
  m_htimer.Cancel ();
1545
  m_htimer.Cancel ();
1544
  Time t = Time (0.01 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 100)));
1546
  Time t = Time (0.01 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 100)));
1545
  m_htimer.Schedule (HelloInterval - t);
1547
  m_htimer.Schedule (HelloInterval - t);
 Lines 1724-1729    Link Here 
1724
            }
1726
            }
1725
          socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
1727
          socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
1726
        }
1728
        }
1729
    if (EnableHello)
1730
      {
1731
        m_lastBcastTime = Simulator::Now ();
1732
      }
1727
    }
1733
    }
1728
}
1734
}
1729
1735
 Lines 1793-1798    Link Here 
1793
      socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
1799
      socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
1794
      m_rerrCount++;
1800
      m_rerrCount++;
1795
    }
1801
    }
1802
  if (EnableHello)
1803
    {
1804
      m_lastBcastTime = Simulator::Now ();
1805
    }  
1796
}
1806
}
1797
1807
1798
Ptr<Socket>
1808
Ptr<Socket>
(-)a/src/aodv/model/aodv-routing-protocol.h (+2 lines)
 Lines 168-173    Link Here 
168
  uint16_t m_rreqCount;
168
  uint16_t m_rreqCount;
169
  /// Number of RERRs used for RERR rate control
169
  /// Number of RERRs used for RERR rate control
170
  uint16_t m_rerrCount;
170
  uint16_t m_rerrCount;
171
  /// Last time a control packet was broadcast
172
  Time m_lastBcastTime;
171
173
172
private:
174
private:
173
  /// Start protocol operation
175
  /// Start protocol operation
(-)a/src/aodv/model/aodv-rtable.cc (+16 lines)
 Lines 231-236    Link Here 
231
}
231
}
232
232
233
bool
233
bool
234
RoutingTable::LookupPartOfAnyActiveRoutes ()
235
{
236
  NS_LOG_FUNCTION (this);
237
  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
238
         m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i)
239
    {
240
      if (i->first != i->second.GetNextHop ())
241
        {
242
          if (i->second.GetFlag () == VALID);
243
            return true;
244
        }
245
    }  
246
  return false;
247
}
248
249
bool
234
RoutingTable::DeleteRoute (Ipv4Address dst)
250
RoutingTable::DeleteRoute (Ipv4Address dst)
235
{
251
{
236
  NS_LOG_FUNCTION (this << dst);
252
  NS_LOG_FUNCTION (this << dst);
(-)a/src/aodv/model/aodv-rtable.h (+2 lines)
 Lines 216-221    Link Here 
216
  bool LookupRoute (Ipv4Address dst, RoutingTableEntry & rt);
216
  bool LookupRoute (Ipv4Address dst, RoutingTableEntry & rt);
217
  /// Lookup route in VALID state
217
  /// Lookup route in VALID state
218
  bool LookupValidRoute (Ipv4Address dst, RoutingTableEntry & rt);
218
  bool LookupValidRoute (Ipv4Address dst, RoutingTableEntry & rt);
219
  /// Lookup if there are any active routes for which the node is part of the path.  Cannot be a neighbor route
220
  bool LookupPartOfAnyActiveRoutes ();
219
  /// Update routing table
221
  /// Update routing table
220
  bool Update (RoutingTableEntry & rt);
222
  bool Update (RoutingTableEntry & rt);
221
  /// Set routing table entry flags
223
  /// Set routing table entry flags

Return to bug 1190