|
|
| 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 |
|
|
| 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> |
|
|
| 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); |
|
|
| 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; |
|
|
| 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 |
|
|
|
| 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 |
|
|
| 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 |
|
|
|
| 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 |
|
|
| 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); |
|
|
| 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 |
|
|
|
| 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> |