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

(-)a/src/aodv/model/aodv-routing-protocol.cc (-1 / +45 lines)
 Lines 96-101    Link Here 
96
RoutingProtocol::RoutingProtocol () :
96
RoutingProtocol::RoutingProtocol () :
97
  RreqRetries (2),
97
  RreqRetries (2),
98
  RreqRateLimit (10),
98
  RreqRateLimit (10),
99
  RerrRateLimit (10),
99
  ActiveRouteTimeout (Seconds (3)),
100
  ActiveRouteTimeout (Seconds (3)),
100
  NetDiameter (35),
101
  NetDiameter (35),
101
  NodeTraversalTime (MilliSeconds (40)),
102
  NodeTraversalTime (MilliSeconds (40)),
 Lines 121-128    Link Here 
121
  m_dpd (PathDiscoveryTime),
122
  m_dpd (PathDiscoveryTime),
122
  m_nb(HelloInterval),
123
  m_nb(HelloInterval),
123
  m_rreqCount (0),
124
  m_rreqCount (0),
125
  m_rerrCount (0),
124
  m_htimer (Timer::CANCEL_ON_DESTROY),
126
  m_htimer (Timer::CANCEL_ON_DESTROY),
125
  m_rreqRateLimitTimer (Timer::CANCEL_ON_DESTROY)
127
  m_rreqRateLimitTimer (Timer::CANCEL_ON_DESTROY),
128
  m_rerrRateLimitTimer (Timer::CANCEL_ON_DESTROY)
126
{
129
{
127
  if (EnableHello)
130
  if (EnableHello)
128
    {
131
    {
 Lines 148-153    Link Here 
148
                     UintegerValue (10),
151
                     UintegerValue (10),
149
                     MakeUintegerAccessor (&RoutingProtocol::RreqRateLimit),
152
                     MakeUintegerAccessor (&RoutingProtocol::RreqRateLimit),
150
                     MakeUintegerChecker<uint32_t> ())
153
                     MakeUintegerChecker<uint32_t> ())
154
      .AddAttribute ("RerrRateLimit", "Maximum number of RERR per second.",
155
                     UintegerValue (10),
156
                     MakeUintegerAccessor (&RoutingProtocol::RerrRateLimit),
157
                     MakeUintegerChecker<uint32_t> ())
151
      .AddAttribute ("NodeTraversalTime", "Conservative estimate of the average one hop traversal time for packets and should include "
158
      .AddAttribute ("NodeTraversalTime", "Conservative estimate of the average one hop traversal time for packets and should include "
152
                     "queuing delays, interrupt processing times and transfer times.",
159
                     "queuing delays, interrupt processing times and transfer times.",
153
                     TimeValue (MilliSeconds (40)),
160
                     TimeValue (MilliSeconds (40)),
 Lines 278-283    Link Here 
278
  m_rreqRateLimitTimer.SetFunction (&RoutingProtocol::RreqRateLimitTimerExpire,
285
  m_rreqRateLimitTimer.SetFunction (&RoutingProtocol::RreqRateLimitTimerExpire,
279
      this);
286
      this);
280
  m_rreqRateLimitTimer.Schedule (Seconds (1));
287
  m_rreqRateLimitTimer.Schedule (Seconds (1));
288
289
  m_rerrRateLimitTimer.SetFunction (&RoutingProtocol::RerrRateLimitTimerExpire,
290
      this);
291
  m_rerrRateLimitTimer.Schedule (Seconds (1));
292
281
}
293
}
282
294
283
Ptr<Ipv4Route>
295
Ptr<Ipv4Route>
 Lines 1494-1499    Link Here 
1494
}
1506
}
1495
1507
1496
void
1508
void
1509
RoutingProtocol::RerrRateLimitTimerExpire ()
1510
{
1511
  NS_LOG_FUNCTION (this);
1512
  m_rerrCount = 0;
1513
  m_rerrRateLimitTimer.Schedule (Seconds (1));
1514
}
1515
1516
void
1497
RoutingProtocol::AckTimerExpire (Ipv4Address neighbor, Time blacklistTimeout)
1517
RoutingProtocol::AckTimerExpire (Ipv4Address neighbor, Time blacklistTimeout)
1498
{
1518
{
1499
  NS_LOG_FUNCTION (this);
1519
  NS_LOG_FUNCTION (this);
 Lines 1610-1615    Link Here 
1610
    uint32_t dstSeqNo, Ipv4Address origin)
1630
    uint32_t dstSeqNo, Ipv4Address origin)
1611
{
1631
{
1612
  NS_LOG_FUNCTION (this);
1632
  NS_LOG_FUNCTION (this);
1633
  // A node SHOULD NOT originate more than RERR_RATELIMIT RERR messages per second.
1634
  if (m_rerrCount == RerrRateLimit)
1635
    {
1636
      // Just make sure that the RerrRateLimit timer is running and will expire
1637
      NS_ASSERT (m_rerrRateLimitTimer.IsRunning ());
1638
      // discard the packet and return
1639
      NS_LOG_LOGIC ("RerrRateLimit reached at " << Simulator::Now ().GetSeconds () << " with timer delay left " 
1640
                    << m_rerrRateLimitTimer.GetDelayLeft ().GetSeconds ()
1641
                    << "; suppressing RERR");
1642
      return;
1643
    }
1613
  RerrHeader rerrHeader;
1644
  RerrHeader rerrHeader;
1614
  rerrHeader.AddUnDestination (dst, dstSeqNo);
1645
  rerrHeader.AddUnDestination (dst, dstSeqNo);
1615
  RoutingTableEntry toOrigin;
1646
  RoutingTableEntry toOrigin;
 Lines 1658-1663    Link Here 
1658
      NS_LOG_LOGIC ("No precursors");
1689
      NS_LOG_LOGIC ("No precursors");
1659
      return;
1690
      return;
1660
    }
1691
    }
1692
  // A node SHOULD NOT originate more than RERR_RATELIMIT RERR messages per second.
1693
  if (m_rerrCount == RerrRateLimit)
1694
    {
1695
      // Just make sure that the RerrRateLimit timer is running and will expire
1696
      NS_ASSERT (m_rerrRateLimitTimer.IsRunning ());
1697
      // discard the packet and return
1698
      NS_LOG_LOGIC ("RerrRateLimit reached at " << Simulator::Now ().GetSeconds () << " with timer delay left " 
1699
                    << m_rerrRateLimitTimer.GetDelayLeft ().GetSeconds ()
1700
                    << "; suppressing RERR");
1701
      return;
1702
    }
1661
  // If there is only one precursor, RERR SHOULD be unicast toward that precursor
1703
  // If there is only one precursor, RERR SHOULD be unicast toward that precursor
1662
  if (precursors.size () == 1)
1704
  if (precursors.size () == 1)
1663
    {
1705
    {
 Lines 1668-1673    Link Here 
1668
          NS_ASSERT (socket);
1710
          NS_ASSERT (socket);
1669
          NS_LOG_LOGIC ("one precursor => unicast RERR to " << toPrecursor.GetDestination() << " from " << toPrecursor.GetInterface ().GetLocal ());
1711
          NS_LOG_LOGIC ("one precursor => unicast RERR to " << toPrecursor.GetDestination() << " from " << toPrecursor.GetInterface ().GetLocal ());
1670
          socket->SendTo (packet, 0, InetSocketAddress (precursors.front (), AODV_PORT));
1712
          socket->SendTo (packet, 0, InetSocketAddress (precursors.front (), AODV_PORT));
1713
          m_rerrCount++;
1671
        }
1714
        }
1672
      return;
1715
      return;
1673
    }
1716
    }
 Lines 1700-1705    Link Here 
1700
          destination = i->GetBroadcast ();
1743
          destination = i->GetBroadcast ();
1701
        }
1744
        }
1702
      socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
1745
      socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
1746
      m_rerrCount++;
1703
    }
1747
    }
1704
}
1748
}
1705
1749
(-)a/src/aodv/model/aodv-routing-protocol.h (+7 lines)
 Lines 94-99    Link Here 
94
  //\{
94
  //\{
95
  uint32_t RreqRetries;             ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route
95
  uint32_t RreqRetries;             ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route
96
  uint16_t RreqRateLimit;           ///< Maximum number of RREQ per second.
96
  uint16_t RreqRateLimit;           ///< Maximum number of RREQ per second.
97
  uint16_t RerrRateLimit;           ///< Maximum number of REER per second.
97
  Time ActiveRouteTimeout;          ///< Period of time during which the route is considered to be valid.
98
  Time ActiveRouteTimeout;          ///< Period of time during which the route is considered to be valid.
98
  uint32_t NetDiameter;             ///< Net diameter measures the maximum possible number of hops between two nodes in the network
99
  uint32_t NetDiameter;             ///< Net diameter measures the maximum possible number of hops between two nodes in the network
99
  /**
100
  /**
 Lines 153-158    Link Here 
153
  Neighbors m_nb;
154
  Neighbors m_nb;
154
  /// Number of RREQs used for RREQ rate control
155
  /// Number of RREQs used for RREQ rate control
155
  uint16_t m_rreqCount;
156
  uint16_t m_rreqCount;
157
  /// Number of RERRs used for RERR rate control
158
  uint16_t m_rerrCount;
156
159
157
private:
160
private:
158
  /// Start protocol operation
161
  /// Start protocol operation
 Lines 241-246    Link Here 
241
  Timer m_rreqRateLimitTimer;
244
  Timer m_rreqRateLimitTimer;
242
  /// Reset RREQ count and schedule RREQ rate limit timer with delay 1 sec.
245
  /// Reset RREQ count and schedule RREQ rate limit timer with delay 1 sec.
243
  void RreqRateLimitTimerExpire ();
246
  void RreqRateLimitTimerExpire ();
247
  /// RERR rate limit timer
248
  Timer m_rerrRateLimitTimer;
249
  /// Reset RERR count and schedule RERR rate limit timer with delay 1 sec.
250
  void RerrRateLimitTimerExpire ();
244
  /// Map IP address + RREQ timer.
251
  /// Map IP address + RREQ timer.
245
  std::map<Ipv4Address, Timer> m_addressReqTimer;
252
  std::map<Ipv4Address, Timer> m_addressReqTimer;
246
  /// Handle route discovery process
253
  /// Handle route discovery process

Return to bug 1042