31 #define NS_LOG_APPEND_CONTEXT \
32 if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId () << "] "; }
36 #include "ns3/socket-factory.h"
37 #include "ns3/udp-socket-factory.h"
38 #include "ns3/simulator.h"
40 #include "ns3/names.h"
41 #include "ns3/inet-socket-address.h"
42 #include "ns3/ipv4-routing-protocol.h"
43 #include "ns3/ipv4-routing-table-entry.h"
44 #include "ns3/ipv4-route.h"
45 #include "ns3/boolean.h"
46 #include "ns3/uinteger.h"
48 #include "ns3/trace-source-accessor.h"
49 #include "ns3/ipv4-header.h"
59 #define DELAY(time) (((time) < (Simulator::Now ())) ? Seconds (0.000001) : \
60 (time - Simulator::Now () + Seconds (0.000001)))
69 #define OLSR_REFRESH_INTERVAL m_helloInterval
75 #define OLSR_NEIGHB_HOLD_TIME Time (3 * OLSR_REFRESH_INTERVAL)
76 #define OLSR_TOP_HOLD_TIME Time (3 * m_tcInterval)
78 #define OLSR_DUP_HOLD_TIME Seconds (30)
80 #define OLSR_MID_HOLD_TIME Time (3 * m_midInterval)
82 #define OLSR_HNA_HOLD_TIME Time (3 * m_hnaInterval)
88 #define OLSR_UNSPEC_LINK 0
89 #define OLSR_ASYM_LINK 1
91 #define OLSR_SYM_LINK 2
93 #define OLSR_LOST_LINK 3
99 #define OLSR_NOT_NEIGH 0
100 #define OLSR_SYM_NEIGH 1
102 #define OLSR_MPR_NEIGH 2
109 #define OLSR_WILL_NEVER 0
110 #define OLSR_WILL_LOW 1
112 #define OLSR_WILL_DEFAULT 3
114 #define OLSR_WILL_HIGH 6
116 #define OLSR_WILL_ALWAYS 7
123 #define OLSR_MAXJITTER (m_helloInterval.GetSeconds () / 4)
124 #define OLSR_MAX_SEQ_NUM 65535
126 #define JITTER (Seconds (m_uniformRandomVariable->GetValue (0, OLSR_MAXJITTER)))
130 #define OLSR_PORT_NUMBER 698
131 #define OLSR_MAX_MSGS 64
135 #define OLSR_MAX_HELLOS 12
138 #define OLSR_MAX_ADDRS 64
154 static TypeId tid =
TypeId (
"ns3::olsr::RoutingProtocol")
156 .AddConstructor<RoutingProtocol> ()
157 .AddAttribute (
"HelloInterval",
"HELLO messages emission interval.",
161 .AddAttribute (
"TcInterval",
"TC messages emission interval.",
165 .AddAttribute (
"MidInterval",
"MID messages emission interval. Normally it is equal to TcInterval.",
169 .AddAttribute (
"HnaInterval",
"HNA messages emission interval. Normally it is equal to TcInterval.",
173 .AddAttribute (
"Willingness",
"Willingness of a node to carry and forward traffic for other nodes.",
181 .AddTraceSource (
"Rx",
"Receive OLSR packet.",
183 .AddTraceSource (
"Tx",
"Send OLSR packet.",
185 .AddTraceSource (
"RoutingTableChanged",
"The OLSR routing table has changed.",
193 : m_routingTableAssociation (0),
195 m_helloTimer (
Timer::CANCEL_ON_DESTROY),
196 m_tcTimer (
Timer::CANCEL_ON_DESTROY),
197 m_midTimer (
Timer::CANCEL_ON_DESTROY),
198 m_hnaTimer (
Timer::CANCEL_ON_DESTROY),
199 m_queuedMessagesTimer (
Timer::CANCEL_ON_DESTROY)
242 iter->first->Close ();
253 *os <<
"Destination\t\tNextHop\t\tInterface\tDistance\n";
255 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin ();
256 iter !=
m_table.end (); iter++)
258 *os << iter->first <<
"\t\t";
259 *os << iter->second.nextAddr <<
"\t\t";
266 *os << iter->second.interface <<
"\t\t";
268 *os << iter->second.distance <<
"\t";
272 *os <<
" HNA Routing Table:\n";
281 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
285 if (addr != loopback)
299 bool canRunOlsr =
false;
300 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
303 if (addr == loopback)
327 if (socket->
Bind (inetAddr))
365 receivedPacket = socket->
RecvFrom (sourceAddress);
372 << senderIfaceAddr <<
" to " << receiverIfaceAddr);
381 packet->RemoveHeader (olsrPacketHeader);
390 if (packet->RemoveHeader (messageHeader) == 0)
399 messages.push_back (messageHeader);
404 for (MessageList::const_iterator messageIter = messages.begin ();
405 messageIter != messages.end (); messageIter++)
420 bool do_forwarding =
true;
437 if (duplicated == NULL)
445 ProcessHello (messageHeader, receiverIfaceAddr, senderIfaceAddr);
452 ProcessTc (messageHeader, senderIfaceAddr);
476 NS_LOG_DEBUG (
"OLSR message is duplicated, not reading it.");
480 for (std::vector<Ipv4Address>::const_iterator it = duplicated->
ifaceList.begin ();
481 it != duplicated->
ifaceList.end (); it++)
483 if (*it == receiverIfaceAddr)
485 do_forwarding =
false;
499 receiverIfaceAddr, inetSourceAddr.
GetIpv4 ());
526 if (nb_tuple == NULL)
541 std::set<Ipv4Address> toRemove;
542 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
544 if (twoHopNeigh->neighborMainAddr == neighborMainAddr)
546 toRemove.insert (twoHopNeigh->twoHopNeighborAddr);
550 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); )
552 if (toRemove.find (twoHopNeigh->twoHopNeighborAddr) != toRemove.end ())
554 twoHopNeigh = N2.erase (twoHopNeigh);
584 N.push_back (*neighbor);
608 for (NeighborSet::const_iterator neigh = N.begin ();
609 neigh != N.end (); neigh++)
611 if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
633 for (NeighborSet::const_iterator neigh = N.begin ();
634 neigh != N.end (); neigh++)
636 if (neigh->neighborMainAddr == twoHopNeigh->twoHopNeighborAddr)
645 N2.push_back (*twoHopNeigh);
649 #ifdef NS3_LOG_ENABLE
651 std::ostringstream os;
653 for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
654 iter != N2.end (); iter++)
656 TwoHopNeighborSet::const_iterator next = iter;
658 os << iter->neighborMainAddr <<
"->" << iter->twoHopNeighborAddr;
659 if (next != N2.end ())
665 #endif //NS3_LOG_ENABLE
669 for (NeighborSet::const_iterator neighbor = N.begin (); neighbor != N.end (); neighbor++)
673 mprSet.insert (neighbor->neighborMainAddr);
685 std::set<Ipv4Address> coveredTwoHopNeighbors;
686 for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
690 for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin (); otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
692 if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr
693 && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr)
701 NS_LOG_LOGIC (
"Neighbor " << twoHopNeigh->neighborMainAddr
702 <<
" is the only that can reach 2-hop neigh. "
703 << twoHopNeigh->twoHopNeighborAddr
704 <<
" => select as MPR.");
706 mprSet.insert (twoHopNeigh->neighborMainAddr);
709 for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin ();
710 otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
712 if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
714 coveredTwoHopNeighbors.insert (otherTwoHopNeigh->twoHopNeighborAddr);
720 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin ();
721 twoHopNeigh != N2.end (); )
723 if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ())
727 NS_LOG_LOGIC (
"2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr <<
" is already covered by an MPR.");
728 twoHopNeigh = N2.erase (twoHopNeigh);
738 while (N2.begin () != N2.end ())
741 #ifdef NS3_LOG_ENABLE
743 std::ostringstream os;
745 for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
746 iter != N2.end (); iter++)
748 TwoHopNeighborSet::const_iterator next = iter;
750 os << iter->neighborMainAddr <<
"->" << iter->twoHopNeighborAddr;
751 if (next != N2.end ())
757 #endif //NS3_LOG_ENABLE
764 std::map<int, std::vector<const NeighborTuple *> > reachability;
766 for (NeighborSet::iterator it = N.begin (); it != N.end (); it++)
770 for (TwoHopNeighborSet::iterator it2 = N2.begin (); it2 != N2.end (); it2++)
777 reachability[r].push_back (&nb_tuple);
790 for (std::set<int>::iterator it = rs.begin (); it != rs.end (); it++)
797 for (std::vector<const NeighborTuple *>::iterator it2 = reachability[r].begin ();
798 it2 != reachability[r].end (); it2++)
829 NS_LOG_LOGIC (N2.size () <<
" 2-hop neighbors left to cover!");
833 #ifdef NS3_LOG_ENABLE
835 std::ostringstream os;
837 for (MprSet::const_iterator iter = mprSet.begin ();
838 iter != mprSet.end (); iter++)
840 MprSet::const_iterator next = iter;
843 if (next != mprSet.end ())
849 #endif //NS3_LOG_ENABLE
879 <<
": RoutingTableComputation begin...");
887 for (NeighborSet::const_iterator it = neighborSet.begin ();
888 it != neighborSet.end (); it++)
891 NS_LOG_DEBUG (
"Looking at neighbor tuple: " << nb_tuple);
894 bool nb_main_addr =
false;
897 for (LinkSet::const_iterator it2 = linkSet.begin ();
898 it2 != linkSet.end (); it2++)
907 <<
" => adding routing table entry to neighbor");
936 if (!nb_main_addr && lt != NULL)
938 NS_LOG_LOGIC (
"no R_dest_addr is equal to the main address of the neighbor "
939 "=> adding additional routing entry");
954 for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin ();
955 it != twoHopNeighbors.end (); it++)
959 NS_LOG_LOGIC (
"Looking at two-hop neighbor tuple: " << nb2hop_tuple);
964 NS_LOG_LOGIC (
"Two-hop neighbor tuple is also neighbor; skipped.");
977 bool nb2hopOk =
false;
978 for (NeighborSet::const_iterator neighbor = neighborSet.begin ();
979 neighbor != neighborSet.end (); neighbor++)
990 NS_LOG_LOGIC (
"Two-hop neighbor tuple skipped: 2-hop neighbor "
993 <<
", which was not found in the Neighbor Set.");
1012 NS_LOG_LOGIC (
"Adding routing entry for two-hop neighbor.");
1020 NS_LOG_LOGIC (
"NOT adding routing entry for two-hop neighbor ("
1022 <<
" not found in the routing table)");
1026 for (uint32_t h = 2;; h++)
1037 for (TopologySet::const_iterator it = topology.begin ();
1038 it != topology.end (); it++)
1041 NS_LOG_LOGIC (
"Looking at topology tuple: " << topology_tuple);
1044 bool have_destAddrEntry =
Lookup (topology_tuple.
destAddr, destAddrEntry);
1045 bool have_lastAddrEntry =
Lookup (topology_tuple.
lastAddr, lastAddrEntry);
1046 if (!have_destAddrEntry && have_lastAddrEntry && lastAddrEntry.
distance == h)
1048 NS_LOG_LOGIC (
"Adding routing table entry based on the topology tuple.");
1067 NS_LOG_LOGIC (
"NOT adding routing table entry based on the topology tuple: "
1068 "have_destAddrEntry=" << have_destAddrEntry
1069 <<
" have_lastAddrEntry=" << have_lastAddrEntry
1070 <<
" lastAddrEntry.distance=" << (
int) lastAddrEntry.
distance
1071 <<
" (h=" << h <<
")");
1085 for (IfaceAssocSet::const_iterator it = ifaceAssocSet.begin ();
1086 it != ifaceAssocSet.end (); it++)
1092 if (have_entry1 && !have_entry2)
1120 for (AssociationSet::const_iterator it = associationSet.begin ();
1121 it != associationSet.end (); it++)
1128 bool goToNextAssociationTuple =
false;
1130 NS_LOG_DEBUG (
"Nb local associations: " << localHnaAssociations.size ());
1131 for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
1132 assocIterator != localHnaAssociations.end (); assocIterator++)
1134 Association const &localHnaAssoc = *assocIterator;
1137 NS_LOG_DEBUG (
"HNA association received from another GW is part of local HNA associations: no route added for network "
1139 goToNextAssociationTuple =
true;
1142 if (goToNextAssociationTuple)
1150 bool addRoute =
false;
1152 uint32_t routeIndex = 0;
1154 for (routeIndex = 0; routeIndex <
m_hnaRoutingTable->GetNRoutes (); routeIndex++)
1174 if(addRoute && gatewayEntryExists)
1209 LinkSensing (msg, hello, receiverIface, senderIface);
1211 #ifdef NS3_LOG_ENABLE
1215 <<
"s ** BEGIN dump Link Set for OLSR Node " <<
m_mainAddress);
1216 for (LinkSet::const_iterator link = links.begin (); link != links.end (); link++)
1224 <<
"s ** BEGIN dump Neighbor Set for OLSR Node " <<
m_mainAddress);
1225 for (NeighborSet::const_iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++)
1231 #endif // NS3_LOG_ENABLE
1236 #ifdef NS3_LOG_ENABLE
1240 <<
"s ** BEGIN dump TwoHopNeighbor Set for OLSR Node " <<
m_mainAddress);
1241 for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin ();
1242 tuple != twoHopNeighbors.end (); tuple++)
1248 #endif // NS3_LOG_ENABLE
1273 if (link_tuple == NULL)
1283 if (topologyTuple != NULL)
1294 for (std::vector<Ipv4Address>::const_iterator i = tc.
neighborAddresses.begin ();
1306 if (topologyTuple != NULL)
1334 #ifdef NS3_LOG_ENABLE
1338 <<
"s ** BEGIN dump TopologySet for OLSR Node " <<
m_mainAddress);
1339 for (TopologySet::const_iterator tuple = topology.begin ();
1340 tuple != topology.end (); tuple++)
1346 #endif // NS3_LOG_ENABLE
1369 if (linkTuple == NULL)
1372 ": the sender interface of this message is not in the "
1373 "symmetric 1-hop neighborhood of this node,"
1374 " the message MUST be discarded.");
1382 bool updated =
false;
1384 for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin ();
1385 tuple != ifaceAssoc.end (); tuple++)
1387 if (tuple->ifaceAddr == *i
1391 tuple->time = now + msg.
GetVTime ();
1413 for (NeighborSet::iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++)
1415 neighbor->neighborMainAddr =
GetMainAddress (neighbor->neighborMainAddr);
1419 for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin ();
1420 twoHopNeighbor != twoHopNeighbors.end (); twoHopNeighbor++)
1422 twoHopNeighbor->neighborMainAddr =
GetMainAddress (twoHopNeighbor->neighborMainAddr);
1423 twoHopNeighbor->twoHopNeighborAddr =
GetMainAddress (twoHopNeighbor->twoHopNeighborAddr);
1448 if (link_tuple == NULL)
1454 for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it = hna.
associations.begin ();
1516 if (linkTuple == NULL)
1531 bool retransmitted =
false;
1536 if (mprselTuple != NULL)
1543 retransmitted =
true;
1548 if (duplicated != NULL)
1552 duplicated->
ifaceList.push_back (localIface);
1562 newDup.
ifaceList.push_back (localIface);
1626 int numMessages = 0;
1632 for (std::vector<olsr::MessageHeader>::const_iterator message =
m_queuedMessages.begin ();
1639 msglist.push_back (*message);
1646 packet = Create<Packet> ();
1679 std::vector<olsr::MessageHeader::Hello::LinkMessage>
1683 for (LinkSet::const_iterator link_tuple = links.begin ();
1684 link_tuple != links.end (); link_tuple++)
1687 && link_tuple->time >= now))
1692 uint8_t link_type, nb_type = 0xff;
1695 if (link_tuple->symTime >= now)
1699 else if (link_tuple->asymTime >= now)
1712 <<
" to be MPR_NEIGH.");
1721 if (nb_tuple->neighborMainAddr ==
GetMainAddress (link_tuple->neighborIfaceAddr))
1726 <<
" to be SYM_NEIGH.");
1733 <<
" to be NOT_NEIGH.");
1737 NS_FATAL_ERROR (
"There is a neighbor tuple with an unknown status!\n");
1751 linkMessage.
linkCode = (link_type & 0x03) | ((nb_type << 2) & 0x0f);
1753 (link_tuple->neighborIfaceAddr);
1760 interfaces.begin (), interfaces.end ());
1762 linkMessages.push_back (linkMessage);
1765 <<
" (with " <<
int (linkMessages.size ()) <<
" link messages)");
1822 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
1856 std::vector<olsr::MessageHeader::Hna::Association> &associations = hna.
associations;
1860 for (Associations::const_iterator it = localHnaAssociations.begin ();
1861 it != localHnaAssociations.end (); it++)
1864 associations.push_back (assoc);
1867 if (associations.size () == 0)
1887 for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
1888 assocIterator != localHnaAssociations.end (); assocIterator++)
1890 Association const &localHnaAssoc = *assocIterator;
1893 NS_LOG_INFO (
"HNA association for network " << networkAddr <<
"/" << netmask <<
" already exists.");
1898 NS_LOG_INFO (
"Adding HNA association for network " << networkAddr <<
"/" << netmask <<
".");
1910 NS_LOG_INFO (
"Removing HNA association for network " << networkAddr <<
"/" << netmask <<
".");
1931 NS_LOG_INFO (
"Removing HNA entries coming from the old routing table association.");
1950 NS_LOG_DEBUG (
"Nb local associations before adding some entries from"
1965 NS_LOG_DEBUG (
"Nb local associations after having added some entries from "
1993 bool updated =
false;
1994 bool created =
false;
1996 <<
": LinkSensing(receiverIface=" << receiverIface
1997 <<
", senderIface=" << senderIface <<
") BEGIN");
2001 if (link_tuple == NULL)
2007 newLinkTuple.
symTime = now - Seconds (1);
2011 NS_LOG_LOGIC (
"Existing link tuple did not exist => creating new one");
2015 NS_LOG_LOGIC (
"Existing link tuple already exists => will update it");
2019 link_tuple->asymTime = now + msg.
GetVTime ();
2020 for (std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator linkMessage =
2025 int lt = linkMessage->linkCode & 0x03;
2026 int nt = (linkMessage->linkCode >> 2) & 0x03;
2028 #ifdef NS3_LOG_ENABLE
2029 const char *linkTypeName;
2041 const char *neighborTypeName;
2047 default: neighborTypeName =
"(invalid value!)";
2050 NS_LOG_DEBUG (
"Looking at HELLO link messages with Link Type "
2051 << lt <<
" (" << linkTypeName
2052 <<
") and Neighbor Type " << nt
2053 <<
" (" << neighborTypeName <<
")");
2054 #endif // NS3_LOG_ENABLE
2061 NS_LOG_LOGIC (
"HELLO link code is invalid => IGNORING");
2065 for (std::vector<Ipv4Address>::const_iterator neighIfaceAddr =
2066 linkMessage->neighborInterfaceAddresses.begin ();
2067 neighIfaceAddr != linkMessage->neighborInterfaceAddresses.end ();
2071 if (*neighIfaceAddr == receiverIface)
2076 link_tuple->symTime = now - Seconds (1);
2081 NS_LOG_DEBUG (*link_tuple <<
": link is SYM or ASYM => should become SYM now"
2082 " (symTime being increased to " << now + msg.
GetVTime ());
2083 link_tuple->symTime = now + msg.
GetVTime ();
2095 NS_LOG_DEBUG (
" \\-> *neighIfaceAddr (" << *neighIfaceAddr
2096 <<
" != receiverIface (" << receiverIface <<
") => IGNORING!");
2099 NS_LOG_DEBUG (
"Link tuple updated: " <<
int (updated));
2101 link_tuple->time = std::max (link_tuple->time, link_tuple->asymTime);
2114 link_tuple->neighborIfaceAddr));
2117 <<
": LinkSensing END");
2128 if (nb_tuple != NULL)
2146 for (LinkSet::const_iterator link_tuple =
m_state.
GetLinks ().begin ();
2149 NS_LOG_LOGIC (
"Looking at link tuple: " << *link_tuple);
2153 "GetMainAddress (link_tuple->neighborIfaceAddr) != msg.GetOriginatorAddress ()");
2154 NS_LOG_LOGIC (
"(GetMainAddress(" << link_tuple->neighborIfaceAddr <<
"): "
2160 if (link_tuple->symTime < now)
2166 typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
2167 for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin ();
2168 linkMessage != hello.
linkMessages.end (); linkMessage++)
2170 int neighborType = (linkMessage->linkCode >> 2) & 0x3;
2171 #ifdef NS3_LOG_ENABLE
2172 const char *neighborTypeNames[3] = {
"NOT_NEIGH",
"SYM_NEIGH",
"MPR_NEIGH" };
2173 const char *neighborTypeName = ((neighborType < 3) ?
2174 neighborTypeNames[neighborType]
2175 :
"(invalid value)");
2176 NS_LOG_DEBUG (
"Looking at Link Message from HELLO message: neighborType="
2177 << neighborType <<
" (" << neighborTypeName <<
")");
2178 #endif // NS3_LOG_ENABLE
2180 for (std::vector<Ipv4Address>::const_iterator nb2hop_addr_iter =
2181 linkMessage->neighborInterfaceAddresses.begin ();
2182 nb2hop_addr_iter != linkMessage->neighborInterfaceAddresses.end ();
2186 NS_LOG_DEBUG (
"Looking at 2-hop neighbor address from HELLO message: "
2187 << *nb2hop_addr_iter
2188 <<
" (main address is " << nb2hop_addr <<
")");
2196 NS_LOG_LOGIC (
"Ignoring 2-hop neighbor (it is the node itself)");
2204 << (nb2hop_tuple ?
" (refreshing existing entry)" :
""));
2205 if (nb2hop_tuple == NULL)
2230 NS_LOG_LOGIC (
"2-hop neighbor is NOT_NEIGH => deleting matching 2-hop neighbor state");
2235 NS_LOG_LOGIC (
"*** WARNING *** Ignoring link message (inside HELLO) with bad"
2236 " neighbor type value: " << neighborType);
2258 typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
2259 for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin ();
2263 int nt = linkMessage->linkCode >> 2;
2266 NS_LOG_DEBUG (
"Processing a link message with neighbor type MPR_NEIGH");
2268 for (std::vector<Ipv4Address>::const_iterator nb_iface_addr =
2269 linkMessage->neighborInterfaceAddresses.begin ();
2270 nb_iface_addr != linkMessage->neighborInterfaceAddresses.end ();
2275 NS_LOG_DEBUG (
"Adding entry to mpr selector set for neighbor " << *nb_iface_addr);
2280 if (existing_mprsel_tuple == NULL)
2317 struct hdr_ip* ih = HDR_IP (p);
2318 struct hdr_cmn* ch = HDR_CMN (p);
2320 debug (
"%f: Node %d MAC Layer detects a breakage on link to %d\n",
2322 OLSR::node_id (ra_addr ()),
2323 OLSR::node_id (ch->next_hop ()));
2325 if ((u_int32_t)ih->daddr () == IP_BROADCAST) {
2326 drop (p, DROP_RTR_MAC_CALLBACK);
2330 OLSR_link_tuple* link_tuple = state_.find_link_tuple (ch->next_hop ());
2331 if (link_tuple != NULL) {
2334 nb_loss (link_tuple);
2336 drop (p, DROP_RTR_MAC_CALLBACK);
2426 <<
" LinkTuple " << tuple <<
" REMOVED.");
2446 <<
" LinkTuple " << tuple <<
" UPDATED.");
2451 if (nb_tuple == NULL)
2457 if (nb_tuple != NULL)
2459 #ifdef NS3_LOG_ENABLE
2460 int statusBefore = nb_tuple->
status;
2461 #endif // NS3_LOG_ENABLE
2463 bool hasSymmetricLink =
false;
2466 for (LinkSet::const_iterator it = linkSet.begin ();
2467 it != linkSet.end (); it++)
2473 hasSymmetricLink =
true;
2478 if (hasSymmetricLink)
2481 NS_LOG_DEBUG (*nb_tuple <<
"->status = STATUS_SYM; changed:"
2482 <<
int (statusBefore != nb_tuple->
status));
2487 NS_LOG_DEBUG (*nb_tuple <<
"->status = STATUS_NOT_SYM; changed:"
2488 <<
int (statusBefore != nb_tuple->
status));
2493 NS_LOG_WARN (
"ERROR! Wanted to update a NeighborTuple but none was found!");
2743 NS_LOG_DEBUG (
"Not sending any TC, no one selected me as MPR.");
2771 NS_LOG_DEBUG (
"Not sending any HNA, no associations to advertise.");
2800 address, sequenceNumber));
2826 if (tuple->
time < now)
2830 else if (tuple->
symTime < now)
2839 neighborIfaceAddr));
2845 neighborIfaceAddr));
2873 this, neighborMainAddr, twoHopNeighborAddr));
2974 this, gatewayAddr, networkAddr, netmask));
3009 std::map<Ipv4Address, RoutingTableEntry>::const_iterator it =
3014 outEntry = it->second;
3058 if (!foundSendEntry)
3062 uint32_t interfaceIdx = entry2.
interface;
3063 if (oif &&
m_ipv4->GetInterfaceForDevice (oif) !=
static_cast<int> (interfaceIdx))
3070 <<
" Route interface " << interfaceIdx
3071 <<
" does not match requested output interface "
3072 <<
m_ipv4->GetInterfaceForDevice (oif));
3076 rtentry = Create<Ipv4Route> ();
3082 uint32_t numOifAddresses =
m_ipv4->GetNAddresses (interfaceIdx);
3085 if (numOifAddresses == 1) {
3086 ifAddr =
m_ipv4->GetAddress (interfaceIdx, 0);
3089 NS_FATAL_ERROR (
"XXX Not implemented yet: IP aliasing and OLSR");
3091 rtentry->SetSource (ifAddr.
GetLocal ());
3092 rtentry->SetGateway (entry2.
nextAddr);
3093 rtentry->SetOutputDevice (
m_ipv4->GetNetDevice (interfaceIdx));
3097 <<
" --> nextHop=" << entry2.
nextAddr
3099 NS_LOG_DEBUG (
"Found route to " << rtentry->GetDestination () <<
" via nh " << rtentry->GetGateway () <<
" with source addr " << rtentry->GetSource () <<
" and output dev " << rtentry->GetOutputDevice ());
3109 NS_LOG_DEBUG (
"Found route to " << rtentry->GetDestination () <<
" via nh " << rtentry->GetGateway () <<
" with source addr " << rtentry->GetSource () <<
" and output dev " << rtentry->GetOutputDevice ());
3117 <<
" No route to host");
3141 uint32_t iif =
m_ipv4->GetInterfaceForDevice (idev);
3142 if (
m_ipv4->IsDestinationAddress (dst, iif))
3147 lcb (p, header, iif);
3167 if (!foundSendEntry)
3169 rtentry = Create<Ipv4Route> ();
3171 uint32_t interfaceIdx = entry2.
interface;
3176 uint32_t numOifAddresses =
m_ipv4->GetNAddresses (interfaceIdx);
3179 if (numOifAddresses == 1) {
3180 ifAddr =
m_ipv4->GetAddress (interfaceIdx, 0);
3183 NS_FATAL_ERROR (
"XXX Not implemented yet: IP aliasing and OLSR");
3191 <<
" --> nextHop=" << entry2.
nextAddr
3194 ucb (rtentry, p, header);
3206 #ifdef NS3_LOG_ENABLE
3209 <<
" --> NOT FOUND; ** Dumping routing table...");
3211 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin ();
3212 iter !=
m_table.end (); iter++)
3214 NS_LOG_DEBUG (
"dest=" << iter->first <<
" --> next=" << iter->second.nextAddr
3215 <<
" via interface " << iter->second.interface);
3219 #endif // NS3_LOG_ENABLE
3280 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
3282 for (uint32_t j = 0; j <
m_ipv4->GetNAddresses (i); j++)
3284 if (
m_ipv4->GetAddress (i,j).GetLocal () == interfaceAddress)
3286 AddEntry (dest, next, i, distance);
3292 AddEntry (dest, next, 0, distance);
3296 std::vector<RoutingTableEntry>
3299 std::vector<RoutingTableEntry> retval;
3300 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin ();
3301 iter !=
m_table.end (); iter++)
3303 retval.push_back (iter->second);
3334 #ifdef NS3_LOG_ENABLE
3347 if (now < iter->expirationTime)
3353 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin (); iter !=
m_table.end (); iter++)
3355 NS_LOG_DEBUG (
" dest=" << iter->first <<
" --> next=" << iter->second.nextAddr <<
" via interface " << iter->second.interface);
3358 #endif //NS3_LOG_ENABLE
std::vector< TopologyTuple > TopologySet
Topology Set type.
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr.
static TypeId GetTypeId(void)
std::set< uint32_t > m_interfaceExclusions
#define JITTER
Random number between [0-OLSR_MAXJITTER] used to jitter OLSR packet transmission. ...
An OLSR's routing table entry.
uint32_t distance
Distance in hops to the destination.
#define OLSR_MPR_NEIGH
Asymmetric neighbor type.
keep track of time values and allow control of global simulation resolution
void HelloTimerExpire()
Sends a HELLO message and reschedules the HELLO timer.
void AddTopologyTuple(const TopologyTuple &tuple)
Adds a topology tuple to the Topology Set.
void EraseDuplicateTuple(const DuplicateTuple &tuple)
Ipv4Address GetIpv4(void) const
#define OLSR_MAX_SEQ_NUM
Maximum allowed sequence number.
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
void IfaceAssocTupleTimerExpire(Ipv4Address ifaceAddr)
Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time(). ...
uint16_t sequenceNumber
Sequence number.
void RemoveMprSelectorTuple(const MprSelectorTuple &tuple)
Removes an MPR selector tuple from the MPR Selector Set.
#define OLSR_WILL_DEFAULT
Willingness for forwarding packets from other nodes: medium.
uint16_t GetPacketSequenceNumber()
Increments packet sequence number and returns the new value.
std::vector< Association > Associations
Association Set type.
Time m_midInterval
MID messages' emission interval.
#define OLSR_DUP_HOLD_TIME
Dup holding time.
void Clear()
Clears the routing table and frees the memory assigned to each one of its entries.
Ipv4Address GetLocal(void) const
uint16_t m_messageSequenceNumber
Messages sequence number counter.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
void InsertAssociation(const Association &tuple)
LinkTuple * FindSymLinkTuple(const Ipv4Address &ifaceAddr, Time time)
Ipv4Address destAddr
Address of the destination node.
a class to represent an Ipv4 address mask
NS_LOG_COMPONENT_DEFINE("OlsrHeader")
void HnaTimerExpire()
Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer...
#define OLSR_TOP_HOLD_TIME
Top holding time.
void LinkTupleUpdated(const LinkTuple &tuple, uint8_t willingness)
This function is invoked when a link tuple is updated. Its aim is to also update the corresponding ne...
void LinkSensing(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello, const Ipv4Address &receiverIface, const Ipv4Address &sender_iface)
Updates Link Set according to a new received HELLO message (following RFC 3626 specification). Neighbor Set is also updated if needed.
uint16_t m_ansn
Advertised Neighbor Set sequence number.
#define NS_ASSERT(condition)
Ipv4Address GetDestNetwork(void) const
#define OLSR_WILL_ALWAYS
Willingness for forwarding packets from other nodes: always.
void AddEntry(const Ipv4Address &dest, const Ipv4Address &next, uint32_t interface, uint32_t distance)
Adds a new entry into the routing table.
bool m_linkTupleTimerFirstTime
uint32_t GetSize(void) const
virtual void NotifyInterfaceUp(uint32_t interface)
void SendTc()
Creates a new OLSR TC message which is buffered for being sent later on.
void EraseAssociationTuple(const AssociationTuple &tuple)
int64_t AssignStreams(int64_t stream)
virtual void DoDispose(void)
void DupTupleTimerExpire(Ipv4Address address, uint16_t sequenceNumber)
Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime.
Time time
Time at which this tuple expires and must be removed.
IfaceAssocTuple * FindIfaceAssocTuple(const Ipv4Address &ifaceAddr)
enum ns3::olsr::NeighborTuple::Status status
Timer m_queuedMessagesTimer
void AddHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Inject Association to be sent in HNA message.
#define NS_LOG_FUNCTION_NOARGS()
Ipv4Address m_mainAddress
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Time expirationTime
Time at which this tuple expires and must be removed.
#define OLSR_WILL_LOW
Willingness for forwarding packets from other nodes: low.
void EraseOlderTopologyTuples(const Ipv4Address &lastAddr, uint16_t ansn)
void LinkTupleTimerExpire(Ipv4Address neighborIfaceAddr)
Removes tuple_ if expired. Else if symmetric time has expired then it is assumed a neighbor loss and ...
void SetMainInterface(uint32_t interface)
Set the OLSR main address to the first address on the indicated interface.
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr.
void InsertTopologyTuple(const TopologyTuple &tuple)
void EraseTopologyTuple(const TopologyTuple &tuple)
const LinkSet & GetLinks() const
void Nb2hopTupleTimerExpire(Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr)
Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
void RemoveAssociationTuple(const AssociationTuple &tuple)
Removes a host network association tuple from the Association Set.
DuplicateTuple * FindDuplicateTuple(const Ipv4Address &address, uint16_t sequenceNumber)
#define NS_FATAL_ERROR(msg)
fatal error handling
void ProcessTc(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a TC message following RFC 3626 specification.
Ipv4Address GetSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
#define OLSR_NEIGHB_HOLD_TIME
Neighbor holding time.
a polymophic address class
bool IsRunning(void) const
NS_OBJECT_ENSURE_REGISTERED(PacketHeader)
void MprSelTupleTimerExpire(Ipv4Address mainAddr)
Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
#define OLSR_SYM_LINK
Symmetric link type.
void SetSource(Ipv4Address src)
std::map< Ipv4Address, RoutingTableEntry > m_table
Data structure for the routing table.
TracedCallback< const PacketHeader &, const MessageList & > m_rxPacketTrace
void RemoveIfaceAssocTuple(const IfaceAssocTuple &tuple)
Removes an interface association tuple from the Interface Association Set.
uint32_t GetInterface(void) const
EventGarbageCollector m_events
double GetSeconds(void) const
void AddAtEnd(Ptr< const Packet > packet)
virtual ~RoutingProtocol()
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination.
void EraseTwoHopNeighborTuples(const Ipv4Address &neighbor)
uint8_t m_willingness
Willingness for forwarding packets on behalf of other nodes.
void PopulateNeighborSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the Neighbor Set according to the information contained in a new received HELLO message (foll...
Time expirationTime
Time at which this tuple expires and must be removed.
void RemoveHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Removes Association sent in HNA message.
hold variables of type 'enum'
Ipv4Address mainAddr
Main address of the node.
void AddIfaceAssocTuple(const IfaceAssocTuple &tuple)
Adds an interface association tuple to the Interface Association Set.
void QueueMessage(const olsr::MessageHeader &message, Time delay)
Enques an OLSR message which will be sent with a delay of (0, delay].
hold objects of type ns3::Time
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR.
void SendPacket(Ptr< Packet > packet, const MessageList &containedMessages)
TopologyTuple * FindTopologyTuple(const Ipv4Address &destAddr, const Ipv4Address &lastAddr)
void SetGateway(Ipv4Address gw)
void ProcessHello(const olsr::MessageHeader &msg, const Ipv4Address &receiverIface, const Ipv4Address &senderIface)
Processes a HELLO message following RFC 3626 specification.
#define DELAY(time)
Gets the delay between a given time and the current time.
void InsertTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
void AddAssociationTuple(const AssociationTuple &tuple)
Adds a host network association tuple to the Association Set.
Ptr< Ipv4StaticRouting > m_hnaRoutingTable
Time expirationTime
Time at which this tuple expires and must be removed.
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
void MprComputation()
Computates MPR set of a node following RFC 3626 hints.
std::vector< LinkTuple > LinkSet
Link Set type.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void RemoveDuplicateTuple(const DuplicateTuple &tuple)
Removes a duplicate tuple from the Duplicate Set.
Time symTime
The link is considered bidirectional until this time.
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
void EraseAssociation(const Association &tuple)
const Associations & GetAssociations() const
void CoverTwoHopNeighbors(Ipv4Address neighborMainAddr, TwoHopNeighborSet &N2)
Remove all covered 2-hop neighbors from N2 set. This is a helper function used by MprComputation algo...
Time m_helloInterval
HELLO messages' emission interval.
LinkTuple & InsertLinkTuple(const LinkTuple &tuple)
void SetDelay(const Time &delay)
#define NS_LOG_LOGIC(msg)
#define OLSR_UNSPEC_LINK
Unspecified link type.
#define OLSR_NOT_NEIGH
Not neighbor type.
#define OLSR_ASYM_LINK
Asymmetric link type.
void SetRoutingTableAssociation(Ptr< Ipv4StaticRouting > routingTable)
Inject Associations from an Ipv4StaticRouting instance.
Ipv4Address destAddr
Main address of the destination.
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
void SetMprSet(MprSet mprSet)
MprSet is set by routing protocol after MprCompute.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketAddresses
void TopologyTupleTimerExpire(Ipv4Address destAddr, Ipv4Address lastAddr)
Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
Time m_tcInterval
TC messages' emission interval.
const IfaceAssocSet & GetIfaceAssocSet() const
void AddTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.
void AssociationTupleTimerExpire(Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time(). ...
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the Routing Table entries.
void NeighborLoss(const LinkTuple &tuple)
Performs all actions needed when a neighbor loss occurs.
void RemoveTopologyTuple(const TopologyTuple &tuple)
Removes a topology tuple from the Topology Set.
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes...
Time expirationTime
Time at which this tuple expires and must be removed.
void SendMid()
Creates a new OLSR MID message which is buffered for being sent later on.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void InsertDuplicateTuple(const DuplicateTuple &tuple)
static InetSocketAddress ConvertFrom(const Address &address)
void RecvOlsr(Ptr< Socket > socket)
Ipv4Address neighborMainAddr
Main address of a neighbor node.
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
static TypeId GetTypeId(void)
TopologyTuple * FindNewerTopologyTuple(const Ipv4Address &lastAddr, uint16_t ansn)
AssociationTuple * FindAssociationTuple(const Ipv4Address &gatewayAddr, const Ipv4Address &networkAddr, const Ipv4Mask &netmask)
void MidTimerExpire()
Sends a MID message (if the node has more than one interface) and resets the MID timer.
Ptr< Ipv4StaticRouting > m_routingTableAssociation
void EraseTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
void AddNeighborTuple(const NeighborTuple &tuple)
Adds a neighbor tuple to the Neighbor Set.
void SendHello()
Creates a new OLSR HELLO message which is buffered for being sent later on.
std::vector< Ipv4Address > FindNeighborInterfaces(const Ipv4Address &neighborMainAddr) const
void RemoveLinkTuple(const LinkTuple &tuple)
Removes a link tuple from the Link Set.
bool UsesNonOlsrOutgoingInterface(const Ipv4RoutingTableEntry &route)
Tests whether or not the specified route uses a non-OLSR outgoing interface. Returns true if the outg...
LinkTuple * FindLinkTuple(const Ipv4Address &ifaceAddr)
bool Lookup(const Ipv4Address &dest, RoutingTableEntry &outEntry) const
Looks up an entry for the specified destination address.
std::vector< MessageHeader > MessageList
Ipv4Address localIfaceAddr
Interface address of the local node.
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Time time
Time at which this tuple expires and must be removed.
virtual void NotifyInterfaceDown(uint32_t interface)
uint16_t m_packetSequenceNumber
Packets sequence number counter.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void PopulateTwoHopNeighborSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the 2-hop Neighbor Set according to the information contained in a new received HELLO message...
void InsertMprSelectorTuple(const MprSelectorTuple &tuple)
Ipv4Address GetMainAddress(Ipv4Address iface_addr) const
Gets the main address associated with a given interface address.
void RoutingTableComputation()
Creates the routing table of the node following RFC 3626 hints.
void RemoveTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.
void EraseIfaceAssocTuple(const IfaceAssocTuple &tuple)
void RemoveEntry(const Ipv4Address &dest)
Deletes the entry whose destination address is given.
void ForwardDefault(olsr::MessageHeader olsrMessage, DuplicateTuple *duplicated, const Ipv4Address &localIface, const Ipv4Address &senderAddress)
OLSR's default forwarding algorithm.
void ProcessHna(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a HNA message following RFC 3626 specification.
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
int Degree(NeighborTuple const &tuple)
This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set.
#define OLSR_WILL_HIGH
Willingness for forwarding packets from other nodes: high.
uint32_t interface
Interface index.
Ipv4 addresses are stored in host order in this class.
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
bool IsMyOwnAddress(const Ipv4Address &a) const
Check that address is one of my interfaces.
uint32_t GetId(void) const
void EraseLinkTuple(const LinkTuple &tuple)
a class to store IPv4 address information on an interface
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
void PopulateMprSelectorSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the MPR Selector Set according to the information contained in a new received HELLO message (...
void SendQueuedMessages()
Creates as many OLSR packets as needed in order to send all buffered OLSR messages.
Ipv4Address ifaceAddr
Interface address of a node.
#define OLSR_LOST_LINK
Lost link type.
Ipv4Address nextAddr
Address of the next hop.
TracedCallback< const PacketHeader &, const MessageList & > m_txPacketTrace
void EraseMprSelectorTuple(const MprSelectorTuple &tuple)
std::set< Ipv4Address > MprSet
MPR Set type.
#define OLSR_SYM_NEIGH
Symmetric neighbor type.
#define NS_LOG_DEBUG(msg)
bool FindMprAddress(const Ipv4Address &address)
void SendHna()
Creates a new OLSR HNA message which is buffered for being sent later on.
const TwoHopNeighborSet & GetTwoHopNeighbors() const
#define OLSR_MID_HOLD_TIME
MID holding time.
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
void Track(EventId event)
Tracks a new event.
const AssociationSet & GetAssociationSet() const
static std::string FindName(Ptr< Object > object)
MprSelectorTuple * FindMprSelectorTuple(const Ipv4Address &mainAddr)
Abstract base class for IPv4 routing protocols.
#define OLSR_WILL_NEVER
Willingness for forwarding packets from other nodes: never.
#define OLSR_MAX_MSGS
Maximum number of messages per packet.
TwoHopNeighborTuple * FindTwoHopNeighborTuple(const Ipv4Address &neighbor, const Ipv4Address &twoHopNeighbor)
void LinkTupleAdded(const LinkTuple &tuple, uint8_t willingness)
void SetInterfaceExclusions(std::set< uint32_t > exceptions)
Time m_hnaInterval
HNA messages' emission interval.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
const NeighborSet & GetNeighbors() const
void EraseMprSelectorTuples(const Ipv4Address &mainAddr)
uint16_t GetPort(void) const
Ipv4Address neighborMainAddr
Main address of a neighbor.
virtual void DoInitialize(void)
std::vector< RoutingTableEntry > GetRoutingTableEntries() const
void InsertNeighborTuple(const NeighborTuple &tuple)
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
void AddDuplicateTuple(const DuplicateTuple &tuple)
Adds a duplicate tuple to the Duplicate Set.
void TcTimerExpire()
Sends a TC message (if there exists any MPR selector) and reschedules the TC timer.
Ipv4Address address
Originator address of the message.
const MprSelectorSet & GetMprSelectors() const
void RemoveNeighborTuple(const NeighborTuple &tuple)
Removes a neighbor tuple from the Neighbor Set.
uint16_t GetMessageSequenceNumber()
Increments message sequence number and returns the new value.
IfaceAssocSet & GetIfaceAssocSetMutable()
void EraseNeighborTuple(const NeighborTuple &neighborTuple)
Ipv4Address gatewayAddr
Main address of the gateway.
OlsrState m_state
Internal state with all needed data structs.
void AddMprSelectorTuple(const MprSelectorTuple &tuple)
Adds an MPR selector tuple to the MPR Selector Set.
TracedCallback< uint32_t > m_routingTableChanged
NeighborTuple * FindNeighborTuple(const Ipv4Address &mainAddr)
Ipv4Address neighborIfaceAddr
Interface address of the neighbor node.
#define OLSR_HNA_HOLD_TIME
HNA holding time.
std::string PrintMprSelectorSet() const
Ipv4Mask GetDestNetworkMask(void) const
a unique identifier for an interface.
An Interface Association Tuple.
bool retransmitted
Indicates whether the message has been retransmitted or not.
TypeId SetParent(TypeId tid)
The type "list of interface addresses".
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
std::ostream * GetStream(void)
uint16_t sequenceNumber
Message sequence number.
std::vector< AssociationTuple > AssociationSet
Association Set type.
void AddHeader(const Header &header)
olsr::MessageList m_queuedMessages
A list of pending messages which are buffered awaiting for being sent.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
void SetDestination(Ipv4Address dest)
const NeighborTuple * FindSymNeighborTuple(const Ipv4Address &mainAddr) const
bool FindSendEntry(const RoutingTableEntry &entry, RoutingTableEntry &outEntry) const
Finds the appropiate entry which must be used in order to forward a data packet to a next hop (given ...
const TopologySet & GetTopologySet() const
void InsertIfaceAssocTuple(const IfaceAssocTuple &tuple)
Time expirationTime
Time at which this tuple expires and must be removed.
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on.
void InsertAssociationTuple(const AssociationTuple &tuple)
void ProcessMid(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a MID message following RFC 3626 specification.