LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 IITP RAS | 3 * Copyright (c) 2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 MyRouteTimeout (Time (2 * std::max (PathDiscoveryTime, ActiveRouteTimeout))), | 127 MyRouteTimeout (Time (2 * std::max (PathDiscoveryTime, ActiveRouteTimeout))), |
128 HelloInterval (Seconds (1)), | 128 HelloInterval (Seconds (1)), |
129 AllowedHelloLoss (2), | 129 AllowedHelloLoss (2), |
130 DeletePeriod (Time (5 * std::max (ActiveRouteTimeout, HelloInterval))), | 130 DeletePeriod (Time (5 * std::max (ActiveRouteTimeout, HelloInterval))), |
131 NextHopWait (NodeTraversalTime + MilliSeconds (10)), | 131 NextHopWait (NodeTraversalTime + MilliSeconds (10)), |
132 BlackListTimeout (Time (RreqRetries * NetTraversalTime)), | 132 BlackListTimeout (Time (RreqRetries * NetTraversalTime)), |
133 MaxQueueLen (64), | 133 MaxQueueLen (64), |
134 MaxQueueTime (Seconds (30)), | 134 MaxQueueTime (Seconds (30)), |
135 DestinationOnly (false), | 135 DestinationOnly (false), |
136 GratuitousReply (true), | 136 GratuitousReply (true), |
137 EnableHello (true), | 137 EnableHello (false), |
138 m_routingTable (DeletePeriod), | 138 m_routingTable (DeletePeriod), |
139 m_queue (MaxQueueLen, MaxQueueTime), | 139 m_queue (MaxQueueLen, MaxQueueTime), |
140 m_requestId (0), | 140 m_requestId (0), |
141 m_seqNo (0), | 141 m_seqNo (0), |
142 m_rreqIdCache (PathDiscoveryTime), | 142 m_rreqIdCache (PathDiscoveryTime), |
143 m_dpd (PathDiscoveryTime), | 143 m_dpd (PathDiscoveryTime), |
144 m_nb (HelloInterval), | 144 m_nb (HelloInterval), |
145 m_rreqCount (0), | 145 m_rreqCount (0), |
146 m_rerrCount (0), | 146 m_rerrCount (0), |
147 m_htimer (Timer::CANCEL_ON_DESTROY), | 147 m_htimer (Timer::CANCEL_ON_DESTROY), |
148 m_rreqRateLimitTimer (Timer::CANCEL_ON_DESTROY), | 148 m_rreqRateLimitTimer (Timer::CANCEL_ON_DESTROY), |
149 m_rerrRateLimitTimer (Timer::CANCEL_ON_DESTROY) | 149 m_rerrRateLimitTimer (Timer::CANCEL_ON_DESTROY), |
150 { | 150 m_lastBcastTime (Seconds (0)) |
151 if (EnableHello) | 151 { |
152 { | 152 m_nb.SetCallback (MakeCallback (&RoutingProtocol::SendRerrWhenBreaksLinkToNext
Hop, this)); |
153 m_nb.SetCallback (MakeCallback (&RoutingProtocol::SendRerrWhenBreaksLinkTo
NextHop, this)); | |
154 } | |
155 } | 153 } |
156 | 154 |
157 TypeId | 155 TypeId |
158 RoutingProtocol::GetTypeId (void) | 156 RoutingProtocol::GetTypeId (void) |
159 { | 157 { |
160 static TypeId tid = TypeId ("ns3::aodv::RoutingProtocol") | 158 static TypeId tid = TypeId ("ns3::aodv::RoutingProtocol") |
161 .SetParent<Ipv4RoutingProtocol> () | 159 .SetParent<Ipv4RoutingProtocol> () |
162 .AddConstructor<RoutingProtocol> () | 160 .AddConstructor<RoutingProtocol> () |
163 .AddAttribute ("HelloInterval", "HELLO messages emission interval.", | 161 .AddAttribute ("HelloInterval", "HELLO messages emission interval.", |
164 TimeValue (Seconds (1)), | 162 TimeValue (Seconds (1)), |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 319 |
322 } | 320 } |
323 | 321 |
324 Ptr<Ipv4Route> | 322 Ptr<Ipv4Route> |
325 RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, | 323 RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, |
326 Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) | 324 Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) |
327 { | 325 { |
328 NS_LOG_FUNCTION (this << header << (oif ? oif->GetIfIndex () : 0)); | 326 NS_LOG_FUNCTION (this << header << (oif ? oif->GetIfIndex () : 0)); |
329 if (!p) | 327 if (!p) |
330 { | 328 { |
| 329 NS_LOG_DEBUG("Packet is == 0"); |
331 return LoopbackRoute (header, oif); // later | 330 return LoopbackRoute (header, oif); // later |
332 } | 331 } |
333 if (m_socketAddresses.empty ()) | 332 if (m_socketAddresses.empty ()) |
334 { | 333 { |
335 sockerr = Socket::ERROR_NOROUTETOHOST; | 334 sockerr = Socket::ERROR_NOROUTETOHOST; |
336 NS_LOG_LOGIC ("No aodv interfaces"); | 335 NS_LOG_LOGIC ("No aodv interfaces"); |
337 Ptr<Ipv4Route> route; | 336 Ptr<Ipv4Route> route; |
338 return route; | 337 return route; |
339 } | 338 } |
340 sockerr = Socket::ERROR_NOTERROR; | 339 sockerr = Socket::ERROR_NOTERROR; |
(...skipping 14 matching lines...) Expand all Loading... |
355 UpdateRouteLifeTime (dst, ActiveRouteTimeout); | 354 UpdateRouteLifeTime (dst, ActiveRouteTimeout); |
356 UpdateRouteLifeTime (route->GetGateway (), ActiveRouteTimeout); | 355 UpdateRouteLifeTime (route->GetGateway (), ActiveRouteTimeout); |
357 return route; | 356 return route; |
358 } | 357 } |
359 | 358 |
360 // Valid route not found, in this case we return loopback.· | 359 // Valid route not found, in this case we return loopback.· |
361 // Actual route request will be deferred until packet will be fully formed,· | 360 // Actual route request will be deferred until packet will be fully formed,· |
362 // routed to loopback, received from loopback and passed to RouteInput (see be
low) | 361 // routed to loopback, received from loopback and passed to RouteInput (see be
low) |
363 uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1); | 362 uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1); |
364 DeferredRouteOutputTag tag (iif); | 363 DeferredRouteOutputTag tag (iif); |
| 364 NS_LOG_DEBUG ("Valid Route not found"); |
365 if (!p->PeekPacketTag (tag)) | 365 if (!p->PeekPacketTag (tag)) |
366 { | 366 { |
367 p->AddPacketTag (tag); | 367 p->AddPacketTag (tag); |
368 } | 368 } |
369 return LoopbackRoute (header, oif); | 369 return LoopbackRoute (header, oif); |
370 } | 370 } |
371 | 371 |
372 void | 372 void |
373 RoutingProtocol::DeferredRouteOutput (Ptr<const Packet> p, const Ipv4Header & he
ader,· | 373 RoutingProtocol::DeferredRouteOutput (Ptr<const Packet> p, const Ipv4Header & he
ader,· |
374 UnicastForwardCallback ucb, ErrorCallback
ecb) | 374 UnicastForwardCallback ucb, ErrorCallback
ecb) |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 Ipv4Address destination; | 890 Ipv4Address destination; |
891 if (iface.GetMask () == Ipv4Mask::GetOnes ()) | 891 if (iface.GetMask () == Ipv4Mask::GetOnes ()) |
892 { | 892 { |
893 destination = Ipv4Address ("255.255.255.255"); | 893 destination = Ipv4Address ("255.255.255.255"); |
894 } | 894 } |
895 else | 895 else |
896 {· | 896 {· |
897 destination = iface.GetBroadcast (); | 897 destination = iface.GetBroadcast (); |
898 } | 898 } |
899 NS_LOG_DEBUG ("Send RREQ with id " << rreqHeader.GetId () << " to socket")
; | 899 NS_LOG_DEBUG ("Send RREQ with id " << rreqHeader.GetId () << " to socket")
; |
900 socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); | 900 m_lastBcastTime = Simulator::Now (); |
| 901 Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetInteg
er (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, destination);· |
901 } | 902 } |
902 ScheduleRreqRetry (dst); | 903 ScheduleRreqRetry (dst); |
903 if (EnableHello) | 904 } |
904 { | 905 |
905 if (!m_htimer.IsRunning ()) | 906 void |
906 { | 907 RoutingProtocol::SendTo (Ptr<Socket> socket, Ptr<Packet> packet, Ipv4Address des
tination) |
907 m_htimer.Cancel (); | 908 { |
908 m_htimer.Schedule (HelloInterval - Time (0.01 * MilliSeconds (m_unifor
mRandomVariable->GetInteger (0, 10)))); | 909 socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); |
909 } | 910 |
910 } | 911 } |
911 } | |
912 | |
913 void | 912 void |
914 RoutingProtocol::ScheduleRreqRetry (Ipv4Address dst) | 913 RoutingProtocol::ScheduleRreqRetry (Ipv4Address dst) |
915 { | 914 { |
916 NS_LOG_FUNCTION (this << dst); | 915 NS_LOG_FUNCTION (this << dst); |
917 if (m_addressReqTimer.find (dst) == m_addressReqTimer.end ()) | 916 if (m_addressReqTimer.find (dst) == m_addressReqTimer.end ()) |
918 { | 917 { |
919 Timer timer (Timer::CANCEL_ON_DESTROY); | 918 Timer timer (Timer::CANCEL_ON_DESTROY); |
920 m_addressReqTimer[dst] = timer; | 919 m_addressReqTimer[dst] = timer; |
921 } | 920 } |
922 m_addressReqTimer[dst].SetFunction (&RoutingProtocol::RouteRequestTimerExpire,
this); | 921 m_addressReqTimer[dst].SetFunction (&RoutingProtocol::RouteRequestTimerExpire,
this); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 else | 1087 else |
1089 toOrigin.SetSeqNo (rreqHeader.GetOriginSeqno ()); | 1088 toOrigin.SetSeqNo (rreqHeader.GetOriginSeqno ()); |
1090 toOrigin.SetValidSeqNo (true); | 1089 toOrigin.SetValidSeqNo (true); |
1091 toOrigin.SetNextHop (src); | 1090 toOrigin.SetNextHop (src); |
1092 toOrigin.SetOutputDevice (m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAdd
ress (receiver))); | 1091 toOrigin.SetOutputDevice (m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAdd
ress (receiver))); |
1093 toOrigin.SetInterface (m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress
(receiver), 0)); | 1092 toOrigin.SetInterface (m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress
(receiver), 0)); |
1094 toOrigin.SetHop (hop); | 1093 toOrigin.SetHop (hop); |
1095 toOrigin.SetLifeTime (std::max (Time (2 * NetTraversalTime - 2 * hop * Nod
eTraversalTime), | 1094 toOrigin.SetLifeTime (std::max (Time (2 * NetTraversalTime - 2 * hop * Nod
eTraversalTime), |
1096 toOrigin.GetLifeTime ())); | 1095 toOrigin.GetLifeTime ())); |
1097 m_routingTable.Update (toOrigin); | 1096 m_routingTable.Update (toOrigin); |
1098 } | 1097 //m_nb.Update (src, Time (AllowedHelloLoss * HelloInterval)); |
| 1098 } |
| 1099 |
| 1100 |
| 1101 RoutingTableEntry toNeighbor; |
| 1102 if (!m_routingTable.LookupRoute (src, toNeighbor)) |
| 1103 { |
| 1104 NS_LOG_DEBUG ("Neighbor:" << src << " not found in routing table. Creating
an entry");· |
| 1105 Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress
(receiver)); |
| 1106 RoutingTableEntry newEntry (dev, src, false, rreqHeader.GetOriginSeqno (), |
| 1107 m_ipv4->GetAddress (m_ipv4->GetInt
erfaceForAddress (receiver), 0), |
| 1108 1, src, ActiveRouteTimeout); |
| 1109 m_routingTable.AddRoute (newEntry); |
| 1110 } |
| 1111 else |
| 1112 { |
| 1113 toNeighbor.SetLifeTime (ActiveRouteTimeout); |
| 1114 toNeighbor.SetValidSeqNo (false); |
| 1115 toNeighbor.SetSeqNo (rreqHeader.GetOriginSeqno ());· |
| 1116 toNeighbor.SetFlag (VALID); |
| 1117 toNeighbor.SetOutputDevice (m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForA
ddress (receiver))); |
| 1118 toNeighbor.SetInterface (m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddres
s (receiver), 0)); |
| 1119 m_routingTable.Update (toNeighbor); |
| 1120 } |
| 1121 m_nb.Update (src, Time (AllowedHelloLoss * HelloInterval)); |
| 1122 |
1099 NS_LOG_LOGIC (receiver << " receive RREQ with hop count " << static_cast<uint3
2_t>(rreqHeader.GetHopCount ())· | 1123 NS_LOG_LOGIC (receiver << " receive RREQ with hop count " << static_cast<uint3
2_t>(rreqHeader.GetHopCount ())· |
1100 << " ID " << rreqHeader.GetId () | 1124 << " ID " << rreqHeader.GetId () |
1101 << " to destination " << rreqHeader.GetDst ()); | 1125 << " to destination " << rreqHeader.GetDst ()); |
1102 | 1126 |
1103 // A node generates a RREP if either: | 1127 // A node generates a RREP if either: |
1104 // (i) it is itself the destination, | 1128 // (i) it is itself the destination, |
1105 if (IsMyOwnAddress (rreqHeader.GetDst ())) | 1129 if (IsMyOwnAddress (rreqHeader.GetDst ())) |
1106 { | 1130 { |
1107 m_routingTable.LookupRoute (origin, toOrigin); | 1131 m_routingTable.LookupRoute (origin, toOrigin); |
1108 NS_LOG_DEBUG ("Send reply since I am the destination"); | 1132 NS_LOG_DEBUG ("Send reply since I am the destination"); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise | 1181 // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise |
1158 Ipv4Address destination; | 1182 Ipv4Address destination; |
1159 if (iface.GetMask () == Ipv4Mask::GetOnes ()) | 1183 if (iface.GetMask () == Ipv4Mask::GetOnes ()) |
1160 { | 1184 { |
1161 destination = Ipv4Address ("255.255.255.255"); | 1185 destination = Ipv4Address ("255.255.255.255"); |
1162 } | 1186 } |
1163 else | 1187 else |
1164 {· | 1188 {· |
1165 destination = iface.GetBroadcast (); | 1189 destination = iface.GetBroadcast (); |
1166 } | 1190 } |
1167 socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); | 1191 m_lastBcastTime = Simulator::Now (); |
1168 } | 1192 Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetInteg
er (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, destination);· |
1169 | 1193 |
1170 if (EnableHello) | |
1171 { | |
1172 if (!m_htimer.IsRunning ()) | |
1173 { | |
1174 m_htimer.Cancel (); | |
1175 m_htimer.Schedule (HelloInterval - Time (0.1 * MilliSeconds (m_uniform
RandomVariable->GetInteger (0, 10)))); | |
1176 » } | |
1177 } | 1194 } |
1178 } | 1195 } |
1179 | 1196 |
1180 void | 1197 void |
1181 RoutingProtocol::SendReply (RreqHeader const & rreqHeader, RoutingTableEntry con
st & toOrigin) | 1198 RoutingProtocol::SendReply (RreqHeader const & rreqHeader, RoutingTableEntry con
st & toOrigin) |
1182 { | 1199 { |
1183 NS_LOG_FUNCTION (this << toOrigin.GetDestination ()); | 1200 NS_LOG_FUNCTION (this << toOrigin.GetDestination ()); |
1184 /* | 1201 /* |
1185 * Destination node MUST increment its own sequence number by one if the seque
nce number in the RREQ packet is equal to that | 1202 * Destination node MUST increment its own sequence number by one if the seque
nce number in the RREQ packet is equal to that |
1186 * incremented value. Otherwise, the destination does not change its sequence
number before generating the RREP message. | 1203 * incremented value. Otherwise, the destination does not change its sequence
number before generating the RREP message. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 m_addressReqTimer.erase (dst); | 1543 m_addressReqTimer.erase (dst); |
1527 m_routingTable.DeleteRoute (dst); | 1544 m_routingTable.DeleteRoute (dst); |
1528 m_queue.DropPacketWithDst (dst); | 1545 m_queue.DropPacketWithDst (dst); |
1529 } | 1546 } |
1530 } | 1547 } |
1531 | 1548 |
1532 void | 1549 void |
1533 RoutingProtocol::HelloTimerExpire () | 1550 RoutingProtocol::HelloTimerExpire () |
1534 { | 1551 { |
1535 NS_LOG_FUNCTION (this); | 1552 NS_LOG_FUNCTION (this); |
1536 SendHello (); | 1553 Time offset = Time (Seconds (0)); |
| 1554 if (m_lastBcastTime > Time (Seconds (0))) |
| 1555 { |
| 1556 offset = Simulator::Now () - m_lastBcastTime; |
| 1557 NS_LOG_DEBUG ("Hello deferred due to last bcast at:" << m_lastBcastTime); |
| 1558 } |
| 1559 else |
| 1560 { |
| 1561 SendHello (); |
| 1562 } |
1537 m_htimer.Cancel (); | 1563 m_htimer.Cancel (); |
1538 Time t = Time (0.01 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10
0))); | 1564 Time diff = HelloInterval - offset; |
1539 m_htimer.Schedule (HelloInterval - t); | 1565 m_htimer.Schedule (std::max (Time (Seconds (0)), diff)); |
| 1566 m_lastBcastTime = Time (Seconds (0)); |
1540 } | 1567 } |
1541 | 1568 |
1542 void | 1569 void |
1543 RoutingProtocol::RreqRateLimitTimerExpire () | 1570 RoutingProtocol::RreqRateLimitTimerExpire () |
1544 { | 1571 { |
1545 NS_LOG_FUNCTION (this); | 1572 NS_LOG_FUNCTION (this); |
1546 m_rreqCount = 0; | 1573 m_rreqCount = 0; |
1547 m_rreqRateLimitTimer.Schedule (Seconds (1)); | 1574 m_rreqRateLimitTimer.Schedule (Seconds (1)); |
1548 } | 1575 } |
1549 | 1576 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise | 1612 // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise |
1586 Ipv4Address destination; | 1613 Ipv4Address destination; |
1587 if (iface.GetMask () == Ipv4Mask::GetOnes ()) | 1614 if (iface.GetMask () == Ipv4Mask::GetOnes ()) |
1588 { | 1615 { |
1589 destination = Ipv4Address ("255.255.255.255"); | 1616 destination = Ipv4Address ("255.255.255.255"); |
1590 } | 1617 } |
1591 else | 1618 else |
1592 {· | 1619 {· |
1593 destination = iface.GetBroadcast (); | 1620 destination = iface.GetBroadcast (); |
1594 } | 1621 } |
1595 socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); | 1622 Time jitter = Time (MilliSeconds (m_uniformRandomVariable->GetInteger (0,
10))); |
| 1623 Simulator::Schedule (jitter, &RoutingProtocol::SendTo, this , socket, pack
et, destination); |
1596 } | 1624 } |
1597 } | 1625 } |
1598 | 1626 |
1599 void | 1627 void |
1600 RoutingProtocol::SendPacketFromQueue (Ipv4Address dst, Ptr<Ipv4Route> route) | 1628 RoutingProtocol::SendPacketFromQueue (Ipv4Address dst, Ptr<Ipv4Route> route) |
1601 { | 1629 { |
1602 NS_LOG_FUNCTION (this); | 1630 NS_LOG_FUNCTION (this); |
1603 QueueEntry queueEntry; | 1631 QueueEntry queueEntry; |
1604 while (m_queue.Dequeue (dst, queueEntry)) | 1632 while (m_queue.Dequeue (dst, queueEntry)) |
1605 { | 1633 { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 } | 1772 } |
1745 // If there is only one precursor, RERR SHOULD be unicast toward that precurso
r | 1773 // If there is only one precursor, RERR SHOULD be unicast toward that precurso
r |
1746 if (precursors.size () == 1) | 1774 if (precursors.size () == 1) |
1747 { | 1775 { |
1748 RoutingTableEntry toPrecursor; | 1776 RoutingTableEntry toPrecursor; |
1749 if (m_routingTable.LookupValidRoute (precursors.front (), toPrecursor)) | 1777 if (m_routingTable.LookupValidRoute (precursors.front (), toPrecursor)) |
1750 { | 1778 { |
1751 Ptr<Socket> socket = FindSocketWithInterfaceAddress (toPrecursor.GetIn
terface ()); | 1779 Ptr<Socket> socket = FindSocketWithInterfaceAddress (toPrecursor.GetIn
terface ()); |
1752 NS_ASSERT (socket); | 1780 NS_ASSERT (socket); |
1753 NS_LOG_LOGIC ("one precursor => unicast RERR to " << toPrecursor.GetDe
stination () << " from " << toPrecursor.GetInterface ().GetLocal ()); | 1781 NS_LOG_LOGIC ("one precursor => unicast RERR to " << toPrecursor.GetDe
stination () << " from " << toPrecursor.GetInterface ().GetLocal ()); |
1754 socket->SendTo (packet, 0, InetSocketAddress (precursors.front (), AOD
V_PORT)); | 1782 Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetI
nteger (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, precursors.fro
nt ()); |
1755 m_rerrCount++; | 1783 m_rerrCount++; |
1756 } | 1784 } |
1757 return; | 1785 return; |
1758 } | 1786 } |
1759 | 1787 |
1760 // Should only transmit RERR on those interfaces which have precursor nodes f
or the broken route | 1788 // Should only transmit RERR on those interfaces which have precursor nodes f
or the broken route |
1761 std::vector<Ipv4InterfaceAddress> ifaces; | 1789 std::vector<Ipv4InterfaceAddress> ifaces; |
1762 RoutingTableEntry toPrecursor; | 1790 RoutingTableEntry toPrecursor; |
1763 for (std::vector<Ipv4Address>::const_iterator i = precursors.begin (); i != pr
ecursors.end (); ++i) | 1791 for (std::vector<Ipv4Address>::const_iterator i = precursors.begin (); i != pr
ecursors.end (); ++i) |
1764 { | 1792 { |
(...skipping 12 matching lines...) Expand all Loading... |
1777 // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise | 1805 // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise |
1778 Ipv4Address destination; | 1806 Ipv4Address destination; |
1779 if (i->GetMask () == Ipv4Mask::GetOnes ()) | 1807 if (i->GetMask () == Ipv4Mask::GetOnes ()) |
1780 { | 1808 { |
1781 destination = Ipv4Address ("255.255.255.255"); | 1809 destination = Ipv4Address ("255.255.255.255"); |
1782 } | 1810 } |
1783 else | 1811 else |
1784 {· | 1812 {· |
1785 destination = i->GetBroadcast (); | 1813 destination = i->GetBroadcast (); |
1786 } | 1814 } |
1787 socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); | 1815 Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetInteg
er (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, destination); |
1788 m_rerrCount++; | |
1789 } | 1816 } |
1790 } | 1817 } |
1791 | 1818 |
1792 Ptr<Socket> | 1819 Ptr<Socket> |
1793 RoutingProtocol::FindSocketWithInterfaceAddress (Ipv4InterfaceAddress addr ) con
st | 1820 RoutingProtocol::FindSocketWithInterfaceAddress (Ipv4InterfaceAddress addr ) con
st |
1794 { | 1821 { |
1795 NS_LOG_FUNCTION (this << addr); | 1822 NS_LOG_FUNCTION (this << addr); |
1796 for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j = | 1823 for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j = |
1797 m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) | 1824 m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j) |
1798 { | 1825 { |
1799 Ptr<Socket> socket = j->first; | 1826 Ptr<Socket> socket = j->first; |
1800 Ipv4InterfaceAddress iface = j->second; | 1827 Ipv4InterfaceAddress iface = j->second; |
1801 if (iface == addr) | 1828 if (iface == addr) |
1802 return socket; | 1829 return socket; |
1803 } | 1830 } |
1804 Ptr<Socket> socket; | 1831 Ptr<Socket> socket; |
1805 return socket; | 1832 return socket; |
1806 } | 1833 } |
1807 | 1834 |
1808 } | 1835 } |
1809 } | 1836 } |
LEFT | RIGHT |