|
41 |
#include "ns3/random-variable.h" |
41 |
#include "ns3/random-variable.h" |
42 |
#include "ns3/inet-socket-address.h" |
42 |
#include "ns3/inet-socket-address.h" |
43 |
#include "ns3/ipv4-routing-protocol.h" |
43 |
#include "ns3/ipv4-routing-protocol.h" |
|
|
44 |
#include "ns3/ipv4-routing-table-entry.h" |
44 |
#include "ns3/ipv4-route.h" |
45 |
#include "ns3/ipv4-route.h" |
45 |
#include "ns3/boolean.h" |
46 |
#include "ns3/boolean.h" |
46 |
#include "ns3/uinteger.h" |
47 |
#include "ns3/uinteger.h" |
|
79 |
#define OLSR_DUP_HOLD_TIME Seconds (30) |
80 |
#define OLSR_DUP_HOLD_TIME Seconds (30) |
80 |
/// MID holding time. |
81 |
/// MID holding time. |
81 |
#define OLSR_MID_HOLD_TIME (Scalar (3) * m_midInterval) |
82 |
#define OLSR_MID_HOLD_TIME (Scalar (3) * m_midInterval) |
82 |
|
83 |
/// HNA holding time. |
|
|
84 |
#define OLSR_HNA_HOLD_TIME (Scalar (3) * m_hnaInterval) |
83 |
|
85 |
|
84 |
/********** Link types **********/ |
86 |
/********** Link types **********/ |
85 |
|
87 |
|
|
165 |
TimeValue (Seconds (5)), |
167 |
TimeValue (Seconds (5)), |
166 |
MakeTimeAccessor (&RoutingProtocol::m_midInterval), |
168 |
MakeTimeAccessor (&RoutingProtocol::m_midInterval), |
167 |
MakeTimeChecker ()) |
169 |
MakeTimeChecker ()) |
|
|
170 |
.AddAttribute ("HnaInterval", "HNA messages emission interval. Normally it is equal to TcInterval.", |
171 |
TimeValue (Seconds (5)), |
172 |
MakeTimeAccessor (&RoutingProtocol::m_hnaInterval), |
173 |
MakeTimeChecker ()) |
168 |
.AddAttribute ("Willingness", "Willingness of a node to carry and forward traffic for other nodes.", |
174 |
.AddAttribute ("Willingness", "Willingness of a node to carry and forward traffic for other nodes.", |
169 |
EnumValue (OLSR_WILL_DEFAULT), |
175 |
EnumValue (OLSR_WILL_DEFAULT), |
170 |
MakeEnumAccessor (&RoutingProtocol::m_willingness), |
176 |
MakeEnumAccessor (&RoutingProtocol::m_willingness), |
|
185 |
|
191 |
|
186 |
|
192 |
|
187 |
RoutingProtocol::RoutingProtocol () |
193 |
RoutingProtocol::RoutingProtocol () |
188 |
: m_ipv4 (0), |
194 |
: m_routingTableAssociation (0), |
|
|
195 |
m_ipv4 (0), |
189 |
m_helloTimer (Timer::CANCEL_ON_DESTROY), |
196 |
m_helloTimer (Timer::CANCEL_ON_DESTROY), |
190 |
m_tcTimer (Timer::CANCEL_ON_DESTROY), |
197 |
m_tcTimer (Timer::CANCEL_ON_DESTROY), |
191 |
m_midTimer (Timer::CANCEL_ON_DESTROY), |
198 |
m_midTimer (Timer::CANCEL_ON_DESTROY), |
|
|
199 |
m_hnaTimer (Timer::CANCEL_ON_DESTROY), |
192 |
m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY) |
200 |
m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY) |
193 |
{} |
201 |
{ |
|
|
202 |
m_hnaRoutingTable = Create<Ipv4StaticRouting> (); |
203 |
} |
194 |
|
204 |
|
195 |
RoutingProtocol::~RoutingProtocol () |
205 |
RoutingProtocol::~RoutingProtocol () |
196 |
{} |
206 |
{ |
|
|
207 |
} |
197 |
|
208 |
|
198 |
void |
209 |
void |
199 |
RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4) |
210 |
RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4) |
|
204 |
m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this); |
215 |
m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this); |
205 |
m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this); |
216 |
m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this); |
206 |
m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this); |
217 |
m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this); |
|
|
218 |
m_hnaTimer.SetFunction (&RoutingProtocol::HnaTimerExpire, this); |
207 |
m_queuedMessagesTimer.SetFunction (&RoutingProtocol::SendQueuedMessages, this); |
219 |
m_queuedMessagesTimer.SetFunction (&RoutingProtocol::SendQueuedMessages, this); |
208 |
|
220 |
|
209 |
m_packetSequenceNumber = OLSR_MAX_SEQ_NUM; |
221 |
m_packetSequenceNumber = OLSR_MAX_SEQ_NUM; |
|
213 |
m_linkTupleTimerFirstTime = true; |
225 |
m_linkTupleTimerFirstTime = true; |
214 |
|
226 |
|
215 |
m_ipv4 = ipv4; |
227 |
m_ipv4 = ipv4; |
|
|
228 |
|
229 |
m_hnaRoutingTable->SetIpv4 (ipv4); |
216 |
} |
230 |
} |
217 |
|
231 |
|
218 |
void RoutingProtocol::DoDispose () |
232 |
void RoutingProtocol::DoDispose () |
219 |
{ |
233 |
{ |
220 |
m_ipv4 = 0; |
234 |
m_ipv4 = 0; |
|
|
235 |
m_hnaRoutingTable = 0; |
221 |
|
236 |
|
222 |
for (std::map< Ptr<Socket>, Ipv4InterfaceAddress >::iterator iter = m_socketAddresses.begin (); |
237 |
for (std::map< Ptr<Socket>, Ipv4InterfaceAddress >::iterator iter = m_socketAddresses.begin (); |
223 |
iter != m_socketAddresses.end (); iter++) |
238 |
iter != m_socketAddresses.end (); iter++) |
|
251 |
NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress); |
266 |
NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress); |
252 |
|
267 |
|
253 |
Ipv4Address loopback ("127.0.0.1"); |
268 |
Ipv4Address loopback ("127.0.0.1"); |
|
|
269 |
|
270 |
bool canRunOlsr = false; |
254 |
for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++) |
271 |
for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++) |
255 |
{ |
272 |
{ |
256 |
Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal (); |
273 |
Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal (); |
|
269 |
NS_ASSERT (GetMainAddress (addr) == m_mainAddress); |
286 |
NS_ASSERT (GetMainAddress (addr) == m_mainAddress); |
270 |
} |
287 |
} |
271 |
|
288 |
|
|
|
289 |
if(m_interfaceExclusions.find (i) != m_interfaceExclusions.end ()) |
290 |
continue; |
291 |
|
272 |
// Create a socket to listen only on this interface |
292 |
// Create a socket to listen only on this interface |
273 |
Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), |
293 |
Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), |
274 |
UdpSocketFactory::GetTypeId()); |
294 |
UdpSocketFactory::GetTypeId()); |
|
279 |
} |
299 |
} |
280 |
socket->Connect (InetSocketAddress (Ipv4Address (0xffffffff), OLSR_PORT_NUMBER)); |
300 |
socket->Connect (InetSocketAddress (Ipv4Address (0xffffffff), OLSR_PORT_NUMBER)); |
281 |
m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0); |
301 |
m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0); |
|
|
302 |
|
303 |
canRunOlsr = true; |
282 |
} |
304 |
} |
283 |
|
305 |
|
284 |
HelloTimerExpire (); |
306 |
if(canRunOlsr) |
285 |
TcTimerExpire (); |
307 |
{ |
286 |
MidTimerExpire (); |
308 |
HelloTimerExpire (); |
|
|
309 |
TcTimerExpire (); |
310 |
MidTimerExpire (); |
311 |
HnaTimerExpire (); |
287 |
|
312 |
|
288 |
NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started"); |
313 |
NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started"); |
|
|
314 |
} |
289 |
} |
315 |
} |
290 |
|
316 |
|
291 |
void RoutingProtocol::SetMainInterface (uint32_t interface) |
317 |
void RoutingProtocol::SetMainInterface (uint32_t interface) |
|
293 |
m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal (); |
319 |
m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal (); |
294 |
} |
320 |
} |
295 |
|
321 |
|
|
|
322 |
void RoutingProtocol::SetInterfaceExclusions (std::set<uint32_t> exceptions) |
323 |
{ |
324 |
m_interfaceExclusions = exceptions; |
325 |
} |
296 |
|
326 |
|
297 |
// |
327 |
// |
298 |
// \brief Processes an incoming %OLSR packet following RFC 3626 specification. |
328 |
// \brief Processes an incoming %OLSR packet following RFC 3626 specification. |
|
397 |
<< " received MID message of size " << messageHeader.GetSerializedSize ()); |
427 |
<< " received MID message of size " << messageHeader.GetSerializedSize ()); |
398 |
ProcessMid (messageHeader, senderIfaceAddr); |
428 |
ProcessMid (messageHeader, senderIfaceAddr); |
399 |
break; |
429 |
break; |
|
|
430 |
case olsr::MessageHeader::HNA_MESSAGE: |
431 |
NS_LOG_DEBUG (Simulator::Now ().GetSeconds () |
432 |
<< "s OLSR node " << m_mainAddress |
433 |
<< " received HNA message of size " << messageHeader.GetSerializedSize ()); |
434 |
ProcessHna (messageHeader, senderIfaceAddr); |
435 |
break; |
400 |
|
436 |
|
401 |
default: |
437 |
default: |
402 |
NS_LOG_DEBUG ("OLSR message type " << |
438 |
NS_LOG_DEBUG ("OLSR message type " << |
|
1039 |
} |
1075 |
} |
1040 |
} |
1076 |
} |
1041 |
|
1077 |
|
|
|
1078 |
// 5. For each tuple in the association set, |
1079 |
// If there is no entry in the routing table with: |
1080 |
// R_dest_addr == A_network_addr/A_netmask |
1081 |
// then a new routing entry is created. |
1082 |
const AssociationSet &associationSet = m_state.GetAssociationSet (); |
1083 |
for (AssociationSet::const_iterator it = associationSet.begin (); |
1084 |
it != associationSet.end (); it++) |
1085 |
{ |
1086 |
AssociationTuple const &tuple = *it; |
1087 |
RoutingTableEntry gatewayEntry; |
1088 |
|
1089 |
bool gatewayEntryExists = Lookup (tuple.gatewayAddr, gatewayEntry); |
1090 |
bool addRoute = false; |
1091 |
|
1092 |
uint32_t routeIndex = 0; |
1093 |
|
1094 |
for (routeIndex = 0; routeIndex < m_hnaRoutingTable->GetNRoutes (); routeIndex++) |
1095 |
{ |
1096 |
Ipv4RoutingTableEntry route = m_hnaRoutingTable->GetRoute (routeIndex); |
1097 |
if (route.GetDestNetwork () == tuple.networkAddr && |
1098 |
route.GetDestNetworkMask () == tuple.netmask) |
1099 |
{ |
1100 |
break; |
1101 |
} |
1102 |
} |
1103 |
|
1104 |
if (routeIndex == m_hnaRoutingTable->GetNRoutes ()) |
1105 |
{ |
1106 |
addRoute = true; |
1107 |
} |
1108 |
else if(gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance) |
1109 |
{ |
1110 |
m_hnaRoutingTable->RemoveRoute(routeIndex); |
1111 |
addRoute = true; |
1112 |
} |
1113 |
|
1114 |
if(addRoute && gatewayEntryExists) |
1115 |
{ |
1116 |
m_hnaRoutingTable->AddNetworkRouteTo (tuple.networkAddr, |
1117 |
tuple.netmask, |
1118 |
gatewayEntry.nextAddr, |
1119 |
gatewayEntry.interface, |
1120 |
gatewayEntry.distance); |
1121 |
|
1122 |
} |
1123 |
} |
1124 |
|
1042 |
NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end."); |
1125 |
NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end."); |
1043 |
m_routingTableChanged (GetSize ()); |
1126 |
m_routingTableChanged (GetSize ()); |
1044 |
} |
1127 |
} |
|
1280 |
NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface << " -> END."); |
1363 |
NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface << " -> END."); |
1281 |
} |
1364 |
} |
1282 |
|
1365 |
|
|
|
1366 |
/// |
1367 |
/// \brief Processes a HNA message following RFC 3626 specification. |
1368 |
/// |
1369 |
/// The Host Network Association Set is updated (if needed) with the information |
1370 |
/// of the received HNA message. |
1371 |
/// |
1372 |
/// \param msg the %OLSR message which contains the HNA message. |
1373 |
/// \param sender_iface the address of the interface where the message was sent from. |
1374 |
/// |
1375 |
void |
1376 |
RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg, |
1377 |
const Ipv4Address &senderIface) |
1378 |
{ |
1379 |
|
1380 |
const olsr::MessageHeader::Hna &hna = msg.GetHna (); |
1381 |
Time now = Simulator::Now (); |
1382 |
|
1383 |
// 1. If the sender interface of this message is not in the symmetric |
1384 |
// 1-hop neighborhood of this node, the message MUST be discarded. |
1385 |
const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now); |
1386 |
if (link_tuple == NULL) |
1387 |
return; |
1388 |
|
1389 |
// 2. Otherwise, for each (network address, netmask) pair in the |
1390 |
// message: |
1391 |
|
1392 |
for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it = hna.associations.begin(); |
1393 |
it != hna.associations.end() ; it++) |
1394 |
{ |
1395 |
AssociationTuple *tuple = m_state.FindAssociationTuple(msg.GetOriginatorAddress(),it->address,it->mask); |
1396 |
|
1397 |
// 2.1 if an entry in the association set already exists, where: |
1398 |
// A_gateway_addr == originator address |
1399 |
// A_network_addr == network address |
1400 |
// A_netmask == netmask |
1401 |
// then the holding time for that tuple MUST be set to: |
1402 |
// A_time = current time + validity time |
1403 |
if(tuple != NULL) |
1404 |
{ |
1405 |
tuple->expirationTime = now + msg.GetVTime (); |
1406 |
} |
1407 |
|
1408 |
// 2.2 otherwise, a new tuple MUST be recorded with: |
1409 |
// A_gateway_addr = originator address |
1410 |
// A_network_addr = network address |
1411 |
// A_netmask = netmask |
1412 |
// A_time = current time + validity time |
1413 |
else |
1414 |
{ |
1415 |
const AssociationTuple &assocTuple = (AssociationTuple){msg.GetOriginatorAddress(),it->address,it->mask,now + msg.GetVTime ()}; |
1416 |
|
1417 |
AddAssociationTuple (assocTuple); |
1418 |
|
1419 |
//Schedule Association Tuple deletion |
1420 |
Simulator::Schedule (DELAY (assocTuple.expirationTime), |
1421 |
&RoutingProtocol::AssociationTupleTimerExpire, this, |
1422 |
assocTuple.gatewayAddr,assocTuple.networkAddr,assocTuple.netmask); |
1423 |
} |
1424 |
|
1425 |
} |
1426 |
} |
1283 |
|
1427 |
|
1284 |
/// |
1428 |
/// |
1285 |
/// \brief OLSR's default forwarding algorithm. |
1429 |
/// \brief OLSR's default forwarding algorithm. |
|
1622 |
} |
1766 |
} |
1623 |
|
1767 |
|
1624 |
/// |
1768 |
/// |
|
|
1769 |
/// \brief Creates a new %OLSR HNA message which is buffered for being sent later on. |
1770 |
/// |
1771 |
void |
1772 |
RoutingProtocol::SendHna () |
1773 |
{ |
1774 |
|
1775 |
olsr::MessageHeader msg; |
1776 |
|
1777 |
msg.SetVTime (OLSR_HNA_HOLD_TIME); |
1778 |
msg.SetOriginatorAddress (m_mainAddress); |
1779 |
msg.SetTimeToLive (255); |
1780 |
msg.SetHopCount (0); |
1781 |
msg.SetMessageSequenceNumber (GetMessageSequenceNumber ()); |
1782 |
olsr::MessageHeader::Hna &hna = msg.GetHna (); |
1783 |
|
1784 |
std::vector<olsr::MessageHeader::Hna::Association> |
1785 |
&associations = hna.associations; |
1786 |
|
1787 |
if (m_routingTableAssociation != 0) |
1788 |
{ |
1789 |
// Add (NetworkAddr, Netmask) entries from Associated Routing Table to HNA message. |
1790 |
for (uint32_t i = 0; i < m_routingTableAssociation->GetNRoutes (); i++) |
1791 |
{ |
1792 |
Ipv4RoutingTableEntry route = m_routingTableAssociation->GetRoute (i); |
1793 |
if (m_interfaceExclusions.find (route.GetInterface ()) != m_interfaceExclusions.end ()) |
1794 |
{ |
1795 |
associations.push_back((olsr::MessageHeader::Hna::Association){route.GetDestNetwork (), route.GetDestNetworkMask ()}); |
1796 |
} |
1797 |
} |
1798 |
} |
1799 |
|
1800 |
int size = associations.size (); |
1801 |
|
1802 |
// Add (NetworkAddr, Netmask) entries specified using AddHostNetworkAssociation () to HNA message. |
1803 |
for (Associations::const_iterator it = m_state.GetAssociations ().begin (); |
1804 |
it != m_state.GetAssociations ().end (); it++) |
1805 |
{ |
1806 |
// Check if the entry has already been added from the Associated Routing Table |
1807 |
std::vector<olsr::MessageHeader::Hna::Association>::const_iterator ci = associations.begin (); |
1808 |
bool found = false; |
1809 |
for (int i = 0; i < size; i++) |
1810 |
{ |
1811 |
if (it->networkAddr == ci->address && it->netmask == ci->mask) |
1812 |
{ |
1813 |
found = true; |
1814 |
break; |
1815 |
} |
1816 |
ci++; |
1817 |
} |
1818 |
|
1819 |
if(!found) |
1820 |
associations.push_back((olsr::MessageHeader::Hna::Association){it->networkAddr,it->netmask}); |
1821 |
} |
1822 |
|
1823 |
if(associations.size () == 0) |
1824 |
return; |
1825 |
|
1826 |
QueueMessage (msg, JITTER); |
1827 |
} |
1828 |
|
1829 |
/// |
1830 |
/// \brief Injects a (networkAddr, netmask) tuple for which the node |
1831 |
/// can generate an HNA message for |
1832 |
/// |
1833 |
void |
1834 |
RoutingProtocol::AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask) |
1835 |
{ |
1836 |
m_state.InsertAssociation ((Association) {networkAddr, netmask}); |
1837 |
} |
1838 |
|
1839 |
/// |
1840 |
/// \brief Adds an Ipv4StaticRouting protocol Association |
1841 |
/// can generate an HNA message for |
1842 |
/// |
1843 |
void |
1844 |
RoutingProtocol::AddRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable) |
1845 |
{ |
1846 |
m_routingTableAssociation = routingTable; |
1847 |
} |
1848 |
|
1849 |
|
1850 |
/// |
1625 |
/// \brief Updates Link Set according to a new received HELLO message (following RFC 3626 |
1851 |
/// \brief Updates Link Set according to a new received HELLO message (following RFC 3626 |
1626 |
/// specification). Neighbor Set is also updated if needed. |
1852 |
/// specification). Neighbor Set is also updated if needed. |
1627 |
void |
1853 |
void |
|
2301 |
m_state.EraseIfaceAssocTuple (tuple); |
2527 |
m_state.EraseIfaceAssocTuple (tuple); |
2302 |
} |
2528 |
} |
2303 |
|
2529 |
|
|
|
2530 |
/// |
2531 |
/// \brief Adds a host network association tuple to the Association Set. |
2532 |
/// |
2533 |
/// \param tuple the host network association tuple to be added. |
2534 |
/// |
2535 |
void |
2536 |
RoutingProtocol::AddAssociationTuple (const AssociationTuple &tuple) |
2537 |
{ |
2538 |
m_state.InsertAssociationTuple (tuple); |
2539 |
} |
2540 |
|
2541 |
/// |
2542 |
/// \brief Removes a host network association tuple from the Association Set. |
2543 |
/// |
2544 |
/// \param tuple the host network association tuple to be removed. |
2545 |
/// |
2546 |
void |
2547 |
RoutingProtocol::RemoveAssociationTuple (const AssociationTuple &tuple) |
2548 |
{ |
2549 |
m_state.EraseAssociationTuple (tuple); |
2550 |
} |
2551 |
|
2552 |
|
2304 |
|
2553 |
|
2305 |
uint16_t RoutingProtocol::GetPacketSequenceNumber () |
2554 |
uint16_t RoutingProtocol::GetPacketSequenceNumber () |
2306 |
{ |
2555 |
{ |
|
2357 |
m_midTimer.Schedule (m_midInterval); |
2606 |
m_midTimer.Schedule (m_midInterval); |
2358 |
} |
2607 |
} |
2359 |
|
2608 |
|
|
|
2609 |
/// \brief Sends an HNA message (if the node implements support for non-OLSR interfaces). |
2610 |
/// \warning Currently it does nothing because there is no support for mixed interfaces. |
2611 |
/// \param e The event which has expired. |
2612 |
/// |
2613 |
void |
2614 |
RoutingProtocol::HnaTimerExpire () |
2615 |
{ |
2616 |
SendHna (); |
2617 |
m_hnaTimer.Schedule (m_hnaInterval); |
2618 |
} |
2619 |
|
2360 |
/// |
2620 |
/// |
2361 |
/// \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime. |
2621 |
/// \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime. |
2362 |
/// |
2622 |
/// |
|
2537 |
} |
2797 |
} |
2538 |
} |
2798 |
} |
2539 |
|
2799 |
|
|
|
2800 |
/// \brief Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time(). |
2801 |
/// \warning Actually this is never invoked because there is no support for mixed interfaces. |
2802 |
/// \param e The event which has expired. |
2803 |
/// |
2804 |
void |
2805 |
RoutingProtocol::AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask) |
2806 |
{ |
2807 |
AssociationTuple *tuple = m_state.FindAssociationTuple (gatewayAddr, networkAddr, netmask); |
2808 |
if (tuple == NULL) |
2809 |
{ |
2810 |
return; |
2811 |
} |
2812 |
if (tuple->expirationTime < Simulator::Now ()) |
2813 |
{ |
2814 |
RemoveAssociationTuple (*tuple); |
2815 |
} |
2816 |
else |
2817 |
{ |
2818 |
m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime), |
2819 |
&RoutingProtocol::AssociationTupleTimerExpire, |
2820 |
this, gatewayAddr, networkAddr, netmask)); |
2821 |
} |
2822 |
} |
2823 |
|
2540 |
/// |
2824 |
/// |
2541 |
/// \brief Clears the routing table and frees the memory assigned to each one of its entries. |
2825 |
/// \brief Clears the routing table and frees the memory assigned to each one of its entries. |
2542 |
/// |
2826 |
/// |
|
2612 |
NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination () << " " << oif); |
2896 |
NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination () << " " << oif); |
2613 |
Ptr<Ipv4Route> rtentry; |
2897 |
Ptr<Ipv4Route> rtentry; |
2614 |
RoutingTableEntry entry1, entry2; |
2898 |
RoutingTableEntry entry1, entry2; |
|
|
2899 |
bool found = false; |
2900 |
|
2615 |
if (Lookup (header.GetDestination (), entry1) != 0) |
2901 |
if (Lookup (header.GetDestination (), entry1) != 0) |
2616 |
{ |
2902 |
{ |
2617 |
bool foundSendEntry = FindSendEntry (entry1, entry2); |
2903 |
bool foundSendEntry = FindSendEntry (entry1, entry2); |
|
2654 |
NS_LOG_DEBUG ("Olsr node " << m_mainAddress |
2940 |
NS_LOG_DEBUG ("Olsr node " << m_mainAddress |
2655 |
<< ": RouteOutput for dest=" << header.GetDestination () |
2941 |
<< ": RouteOutput for dest=" << header.GetDestination () |
2656 |
<< " --> nextHop=" << entry2.nextAddr |
2942 |
<< " --> nextHop=" << entry2.nextAddr |
2657 |
<< " interface=" << entry2.interface); NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice()); |
2943 |
<< " interface=" << entry2.interface); |
|
|
2944 |
NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice()); |
2945 |
found = true; |
2658 |
} |
2946 |
} |
2659 |
else |
2947 |
else |
2660 |
{ |
2948 |
{ |
|
|
2949 |
rtentry = m_hnaRoutingTable->RouteOutput (p, header, oif, sockerr); |
2950 |
|
2951 |
NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice()); |
2952 |
|
2953 |
if (rtentry) |
2954 |
found = true; |
2955 |
} |
2956 |
|
2957 |
if (!found) |
2958 |
{ |
2661 |
NS_LOG_DEBUG ("Olsr node " << m_mainAddress |
2959 |
NS_LOG_DEBUG ("Olsr node " << m_mainAddress |
2662 |
<< ": RouteOutput for dest=" << header.GetDestination () |
2960 |
<< ": RouteOutput for dest=" << header.GetDestination () |
2663 |
<< " No route to host"); |
2961 |
<< " No route to host"); |
|
2729 |
} |
3027 |
} |
2730 |
else |
3028 |
else |
2731 |
{ |
3029 |
{ |
|
|
3030 |
if(m_hnaRoutingTable->RouteInput (p, header, idev, ucb, mcb, lcb, ecb)) |
3031 |
{ |
3032 |
return true; |
3033 |
} |
3034 |
else |
3035 |
{ |
3036 |
|
2732 |
#ifdef NS3_LOG_ENABLE |
3037 |
#ifdef NS3_LOG_ENABLE |
2733 |
NS_LOG_DEBUG ("Olsr node " << m_mainAddress |
3038 |
NS_LOG_DEBUG ("Olsr node " << m_mainAddress |
2734 |
<< ": RouteInput for dest=" << header.GetDestination () |
3039 |
<< ": RouteInput for dest=" << header.GetDestination () |
2735 |
<< " --> NOT FOUND; ** Dumping routing table..."); for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin (); |
3040 |
<< " --> NOT FOUND; ** Dumping routing table..."); |
2736 |
iter != m_table.end (); iter++) |
3041 |
|
2737 |
{ NS_LOG_DEBUG ("dest=" << iter->first << " --> next=" << iter->second.nextAddr |
3042 |
for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin (); |
|
|
3043 |
iter != m_table.end (); iter++) |
3044 |
{ |
3045 |
NS_LOG_DEBUG ("dest=" << iter->first << " --> next=" << iter->second.nextAddr |
2738 |
<< " via interface " << iter->second.interface); |
3046 |
<< " via interface " << iter->second.interface); |
|
|
3047 |
} |
3048 |
|
3049 |
NS_LOG_DEBUG ("** Routing table dump end."); |
3050 |
#endif // NS3_LOG_ENABLE |
3051 |
|
3052 |
return false; |
2739 |
} |
3053 |
} |
2740 |
|
|
|
2741 |
NS_LOG_DEBUG ("** Routing table dump end."); |
2742 |
#endif // NS3_LOG_ENABLE |
2743 |
return false; |
2744 |
} |
3054 |
} |
2745 |
} |
3055 |
} |
2746 |
void |
3056 |
void |