|
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)), |
|
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 |
{ |
|
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)), |
|
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> |
|
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); |
|
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; |
|
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 |
{ |
|
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 |
} |
|
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 |
|