|
356 |
bool result = m_routingTable.LookupRoute(header.GetDestination (), rt); |
356 |
bool result = m_routingTable.LookupRoute(header.GetDestination (), rt); |
357 |
if(!result || ((rt.GetFlag() != IN_SEARCH) && result)) |
357 |
if(!result || ((rt.GetFlag() != IN_SEARCH) && result)) |
358 |
{ |
358 |
{ |
359 |
NS_LOG_LOGIC ("Send RREQ to" <<header.GetDestination ()); |
359 |
NS_LOG_LOGIC ("Send new RREQ for outbound packet to " <<header.GetDestination ()); |
360 |
SendRequest (header.GetDestination ()); |
360 |
SendRequest (header.GetDestination ()); |
361 |
} |
361 |
} |
362 |
} |
362 |
} |
|
867 |
{ |
867 |
{ |
868 |
destination = iface.GetBroadcast (); |
868 |
destination = iface.GetBroadcast (); |
869 |
} |
869 |
} |
|
|
870 |
NS_LOG_DEBUG ("Send RREQ with id " << rreqHeader.GetId () << " to socket"); |
870 |
socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); |
871 |
socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); |
871 |
} |
872 |
} |
872 |
ScheduleRreqRetry (dst); |
873 |
ScheduleRreqRetry (dst); |
|
894 |
rt.IncrementRreqCnt (); |
895 |
rt.IncrementRreqCnt (); |
895 |
m_routingTable.Update (rt); |
896 |
m_routingTable.Update (rt); |
896 |
m_addressReqTimer[dst].Schedule (Time (rt.GetRreqCnt () * NetTraversalTime)); |
897 |
m_addressReqTimer[dst].Schedule (Time (rt.GetRreqCnt () * NetTraversalTime)); |
|
|
898 |
NS_LOG_LOGIC ("Scheduled RREQ retry in " << Time (rt.GetRreqCnt () * NetTraversalTime).GetSeconds () << " seconds"); |
897 |
} |
899 |
} |
898 |
|
900 |
|
899 |
void |
901 |
void |
|
1002 |
if (m_routingTable.LookupRoute (src, toPrev)) |
1004 |
if (m_routingTable.LookupRoute (src, toPrev)) |
1003 |
{ |
1005 |
{ |
1004 |
if (toPrev.IsUnidirectional ()) |
1006 |
if (toPrev.IsUnidirectional ()) |
1005 |
return; |
1007 |
{ |
|
|
1008 |
NS_LOG_DEBUG ("Ignoring RREQ from node in blacklist"); |
1009 |
return; |
1010 |
} |
1006 |
} |
1011 |
} |
1007 |
|
1012 |
|
1008 |
uint32_t id = rreqHeader.GetId (); |
1013 |
uint32_t id = rreqHeader.GetId (); |
|
1014 |
*/ |
1019 |
*/ |
1015 |
if (m_rreqIdCache.IsDuplicate (origin, id)) |
1020 |
if (m_rreqIdCache.IsDuplicate (origin, id)) |
1016 |
{ |
1021 |
{ |
|
|
1022 |
NS_LOG_DEBUG ("Ignoring RREQ due to duplicate"); |
1017 |
return; |
1023 |
return; |
1018 |
} |
1024 |
} |
1019 |
|
1025 |
|
|
1058 |
toOrigin.GetLifeTime ())); |
1064 |
toOrigin.GetLifeTime ())); |
1059 |
m_routingTable.Update (toOrigin); |
1065 |
m_routingTable.Update (toOrigin); |
1060 |
} |
1066 |
} |
1061 |
NS_LOG_LOGIC (receiver << " receive RREQ to destination " << rreqHeader.GetDst ()); |
1067 |
NS_LOG_LOGIC (receiver << " receive RREQ with hop count " << static_cast<uint32_t>(rreqHeader.GetHopCount ()) |
|
|
1068 |
<< " ID " << rreqHeader.GetId () |
1069 |
<< " to destination " << rreqHeader.GetDst ()); |
1062 |
|
1070 |
|
1063 |
// A node generates a RREP if either: |
1071 |
// A node generates a RREP if either: |
1064 |
// (i) it is itself the destination, |
1072 |
// (i) it is itself the destination, |
1065 |
if (IsMyOwnAddress (rreqHeader.GetDst ())) |
1073 |
if (IsMyOwnAddress (rreqHeader.GetDst ())) |
1066 |
{ |
1074 |
{ |
1067 |
m_routingTable.LookupRoute (origin, toOrigin); |
1075 |
m_routingTable.LookupRoute (origin, toOrigin); |
|
|
1076 |
NS_LOG_DEBUG ("Send reply since I am the destination"); |
1068 |
SendReply (rreqHeader, toOrigin); |
1077 |
SendReply (rreqHeader, toOrigin); |
1069 |
return; |
1078 |
return; |
1070 |
} |
1079 |
} |
|
1468 |
*/ |
1477 |
*/ |
1469 |
if (toDst.GetRreqCnt () == RreqRetries) |
1478 |
if (toDst.GetRreqCnt () == RreqRetries) |
1470 |
{ |
1479 |
{ |
1471 |
NS_LOG_LOGIC("route discovery to " << dst << " has been attempted RreqRetries times"); |
1480 |
NS_LOG_LOGIC("route discovery to " << dst << " has been attempted RreqRetries (" << RreqRetries << ") times"); |
1472 |
m_addressReqTimer.erase (dst); |
1481 |
m_addressReqTimer.erase (dst); |
1473 |
m_routingTable.DeleteRoute (dst); |
1482 |
m_routingTable.DeleteRoute (dst); |
1474 |
NS_LOG_DEBUG ("Route not found. Drop packet with dst " << dst); |
1483 |
NS_LOG_DEBUG ("Route not found. Drop all packets with dst " << dst); |
1475 |
m_queue.DropPacketWithDst (dst); |
1484 |
m_queue.DropPacketWithDst (dst); |
1476 |
return; |
1485 |
return; |
1477 |
} |
1486 |
} |
1478 |
|
1487 |
|
1479 |
if (toDst.GetFlag () == IN_SEARCH) |
1488 |
if (toDst.GetFlag () == IN_SEARCH) |
1480 |
{ |
1489 |
{ |
1481 |
NS_LOG_LOGIC ("Send new RREQ to " << dst << " ttl " << NetDiameter); |
1490 |
NS_LOG_LOGIC ("Resend RREQ to " << dst << " ttl " << NetDiameter); |
1482 |
SendRequest (dst); |
1491 |
SendRequest (dst); |
1483 |
} |
1492 |
} |
1484 |
else |
1493 |
else |