31 #define NS_LOG_APPEND_CONTEXT \
32 if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId () << "] "; }
37 #include "ns3/socket-factory.h"
38 #include "ns3/udp-socket-factory.h"
39 #include "ns3/simulator.h"
41 #include "ns3/names.h"
42 #include "ns3/inet-socket-address.h"
43 #include "ns3/ipv4-routing-protocol.h"
44 #include "ns3/ipv4-routing-table-entry.h"
45 #include "ns3/ipv4-route.h"
46 #include "ns3/boolean.h"
47 #include "ns3/uinteger.h"
49 #include "ns3/trace-source-accessor.h"
50 #include "ns3/ipv4-header.h"
51 #include "ns3/ipv4-packet-info-tag.h"
61 #define DELAY(time) (((time) < (Simulator::Now ())) ? Seconds (0.000001) : \
62 (time - Simulator::Now () + Seconds (0.000001)))
71 #define OLSR_REFRESH_INTERVAL m_helloInterval
77 #define OLSR_NEIGHB_HOLD_TIME Time (3 * OLSR_REFRESH_INTERVAL)
79 #define OLSR_TOP_HOLD_TIME Time (3 * m_tcInterval)
81 #define OLSR_DUP_HOLD_TIME Seconds (30)
83 #define OLSR_MID_HOLD_TIME Time (3 * m_midInterval)
85 #define OLSR_HNA_HOLD_TIME Time (3 * m_hnaInterval)
90 #define OLSR_UNSPEC_LINK 0
92 #define OLSR_ASYM_LINK 1
94 #define OLSR_SYM_LINK 2
96 #define OLSR_LOST_LINK 3
101 #define OLSR_NOT_NEIGH 0
103 #define OLSR_SYM_NEIGH 1
105 #define OLSR_MPR_NEIGH 2
111 #define OLSR_WILL_NEVER 0
113 #define OLSR_WILL_LOW 1
115 #define OLSR_WILL_DEFAULT 3
117 #define OLSR_WILL_HIGH 6
119 #define OLSR_WILL_ALWAYS 7
125 #define OLSR_MAXJITTER (m_helloInterval.GetSeconds () / 4)
127 #define OLSR_MAX_SEQ_NUM 65535
129 #define JITTER (Seconds (m_uniformRandomVariable->GetValue (0, OLSR_MAXJITTER)))
133 #define OLSR_MAX_MSGS 64
136 #define OLSR_MAX_HELLOS 12
139 #define OLSR_MAX_ADDRS 64
158 static TypeId tid =
TypeId (
"ns3::olsr::RoutingProtocol")
160 .SetGroupName (
"Olsr")
162 .AddAttribute (
"HelloInterval",
"HELLO messages emission interval.",
166 .AddAttribute (
"TcInterval",
"TC messages emission interval.",
170 .AddAttribute (
"MidInterval",
"MID messages emission interval. Normally it is equal to TcInterval.",
174 .AddAttribute (
"HnaInterval",
"HNA messages emission interval. Normally it is equal to TcInterval.",
178 .AddAttribute (
"Willingness",
"Willingness of a node to carry and forward traffic for other nodes.",
186 .AddTraceSource (
"Rx",
"Receive OLSR packet.",
188 "ns3::olsr::RoutingProtocol::PacketTxRxTracedCallback")
189 .AddTraceSource (
"Tx",
"Send OLSR packet.",
191 "ns3::olsr::RoutingProtocol::PacketTxRxTracedCallback")
192 .AddTraceSource (
"RoutingTableChanged",
"The OLSR routing table has changed.",
194 "ns3::olsr::RoutingProtocol::TableChangeTracedCallback")
201 : m_routingTableAssociation (0),
203 m_helloTimer (
Timer::CANCEL_ON_DESTROY),
204 m_tcTimer (
Timer::CANCEL_ON_DESTROY),
205 m_midTimer (
Timer::CANCEL_ON_DESTROY),
206 m_hnaTimer (
Timer::CANCEL_ON_DESTROY),
207 m_queuedMessagesTimer (
Timer::CANCEL_ON_DESTROY)
262 iter->first->
Close ();
275 std::ios oldState (
nullptr);
276 oldState.copyfmt (*os);
278 *os << std::resetiosflags (std::ios::adjustfield) << std::setiosflags (std::ios::left);
280 *os <<
"Node: " <<
m_ipv4->GetObject<
Node> ()->GetId ()
281 <<
", Time: " <<
Now ().
As (unit)
282 <<
", Local time: " <<
m_ipv4->GetObject<
Node> ()->GetLocalTime ().As (unit)
283 <<
", OLSR Routing table" << std::endl;
285 *os << std::setw (16) <<
"Destination";
286 *os << std::setw (16) <<
"NextHop";
287 *os << std::setw (16) <<
"Interface";
288 *os <<
"Distance" << std::endl;
290 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin ();
291 iter !=
m_table.end (); iter++)
293 *os << std::setw (16) << iter->first;
294 *os << std::setw (16) << iter->second.nextAddr;
295 *os << std::setw (16);
302 *os << iter->second.interface;
304 *os << iter->second.distance << std::endl;
311 *os <<
"HNA Routing Table:" << std::endl;
316 *os <<
"HNA Routing Table: empty" << std::endl;
319 (*os).copyfmt (oldState);
327 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
331 if (addr != loopback)
345 bool canRunOlsr =
false;
346 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
349 if (addr == loopback)
395 if (socket->
Bind (inetAddr))
433 receivedPacket = socket->
RecvFrom (sourceAddress);
438 NS_ABORT_MSG (
"No incoming interface on OLSR message, aborting.");
440 uint32_t incomingIf = interfaceInfo.
GetRecvIf ();
441 Ptr<Node> node = this->GetObject<Node> ();
443 uint32_t recvInterfaceIndex =
m_ipv4->GetInterfaceForDevice (dev);
454 int32_t interfaceForAddress =
m_ipv4->GetInterfaceForAddress (senderIfaceAddr);
455 if (interfaceForAddress != -1)
461 Ipv4Address receiverIfaceAddr =
m_ipv4->GetAddress (recvInterfaceIndex, 0).GetLocal ();
464 << senderIfaceAddr <<
" to " << receiverIfaceAddr);
493 messages.push_back (messageHeader);
498 for (MessageList::const_iterator messageIter = messages.begin ();
499 messageIter != messages.end (); messageIter++)
514 bool do_forwarding =
true;
531 if (duplicated == NULL)
539 ProcessHello (messageHeader, receiverIfaceAddr, senderIfaceAddr);
546 ProcessTc (messageHeader, senderIfaceAddr);
570 NS_LOG_DEBUG (
"OLSR message is duplicated, not reading it.");
574 for (std::vector<Ipv4Address>::const_iterator it = duplicated->
ifaceList.begin ();
575 it != duplicated->
ifaceList.end (); it++)
577 if (*it == receiverIfaceAddr)
579 do_forwarding =
false;
593 receiverIfaceAddr, inetSourceAddr.
GetIpv4 ());
620 if (nb_tuple == NULL)
641 std::set<Ipv4Address> toRemove;
642 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
644 if (twoHopNeigh->neighborMainAddr == neighborMainAddr)
646 toRemove.insert (twoHopNeigh->twoHopNeighborAddr);
650 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); )
652 if (toRemove.find (twoHopNeigh->twoHopNeighborAddr) != toRemove.end ())
654 twoHopNeigh = N2.erase (twoHopNeigh);
681 N.push_back (*neighbor);
705 for (NeighborSet::const_iterator neigh = N.begin ();
706 neigh != N.end (); neigh++)
708 if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
730 for (NeighborSet::const_iterator neigh = N.begin ();
731 neigh != N.end (); neigh++)
733 if (neigh->neighborMainAddr == twoHopNeigh->twoHopNeighborAddr)
742 N2.push_back (*twoHopNeigh);
746 #ifdef NS3_LOG_ENABLE
748 std::ostringstream os;
750 for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
751 iter != N2.end (); iter++)
753 TwoHopNeighborSet::const_iterator next = iter;
755 os << iter->neighborMainAddr <<
"->" << iter->twoHopNeighborAddr;
756 if (next != N2.end ())
768 for (NeighborSet::const_iterator neighbor = N.begin (); neighbor != N.end (); neighbor++)
772 mprSet.insert (neighbor->neighborMainAddr);
784 std::set<Ipv4Address> coveredTwoHopNeighbors;
785 for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
789 for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin (); otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
791 if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr
792 && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr)
800 NS_LOG_LOGIC (
"Neighbor " << twoHopNeigh->neighborMainAddr
801 <<
" is the only that can reach 2-hop neigh. "
802 << twoHopNeigh->twoHopNeighborAddr
803 <<
" => select as MPR.");
805 mprSet.insert (twoHopNeigh->neighborMainAddr);
808 for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin ();
809 otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
811 if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
813 coveredTwoHopNeighbors.insert (otherTwoHopNeigh->twoHopNeighborAddr);
819 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin ();
820 twoHopNeigh != N2.end (); )
822 if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ())
826 NS_LOG_LOGIC (
"2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr <<
" is already covered by an MPR.");
827 twoHopNeigh = N2.erase (twoHopNeigh);
837 while (N2.begin () != N2.end ())
840 #ifdef NS3_LOG_ENABLE
842 std::ostringstream os;
844 for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
845 iter != N2.end (); iter++)
847 TwoHopNeighborSet::const_iterator next = iter;
849 os << iter->neighborMainAddr <<
"->" << iter->twoHopNeighborAddr;
850 if (next != N2.end ())
865 std::map<int, std::vector<const NeighborTuple *> > reachability;
867 for (NeighborSet::iterator it = N.begin (); it != N.end (); it++)
871 for (TwoHopNeighborSet::iterator it2 = N2.begin (); it2 != N2.end (); it2++)
880 reachability[r].push_back (&nb_tuple);
893 for (std::set<int>::iterator it = rs.begin (); it != rs.end (); it++)
900 for (std::vector<const NeighborTuple *>::iterator it2 = reachability[r].begin ();
901 it2 != reachability[r].end (); it2++)
930 mprSet.insert (
max->neighborMainAddr);
932 NS_LOG_LOGIC (N2.size () <<
" 2-hop neighbors left to cover!");
936 #ifdef NS3_LOG_ENABLE
938 std::ostringstream os;
940 for (MprSet::const_iterator iter = mprSet.begin ();
941 iter != mprSet.end (); iter++)
943 MprSet::const_iterator next = iter;
946 if (next != mprSet.end ())
979 <<
": RoutingTableComputation begin...");
987 for (NeighborSet::const_iterator it = neighborSet.begin ();
988 it != neighborSet.end (); it++)
991 NS_LOG_DEBUG (
"Looking at neighbor tuple: " << nb_tuple);
994 bool nb_main_addr =
false;
997 for (LinkSet::const_iterator it2 = linkSet.begin ();
998 it2 != linkSet.end (); it2++)
1007 <<
" => adding routing table entry to neighbor");
1015 nb_main_addr =
true;
1036 if (!nb_main_addr && lt != NULL)
1038 NS_LOG_LOGIC (
"no R_dest_addr is equal to the main address of the neighbor "
1039 "=> adding additional routing entry");
1054 for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin ();
1055 it != twoHopNeighbors.end (); it++)
1059 NS_LOG_LOGIC (
"Looking at two-hop neighbor tuple: " << nb2hop_tuple);
1064 NS_LOG_LOGIC (
"Two-hop neighbor tuple is also neighbor; skipped.");
1077 bool nb2hopOk =
false;
1078 for (NeighborSet::const_iterator neighbor = neighborSet.begin ();
1079 neighbor != neighborSet.end (); neighbor++)
1090 NS_LOG_LOGIC (
"Two-hop neighbor tuple skipped: 2-hop neighbor "
1093 <<
", which was not found in the Neighbor Set.");
1112 NS_LOG_LOGIC (
"Adding routing entry for two-hop neighbor.");
1120 NS_LOG_LOGIC (
"NOT adding routing entry for two-hop neighbor ("
1122 <<
" not found in the routing table)");
1126 for (uint32_t h = 2;; h++)
1137 for (TopologySet::const_iterator it = topology.begin ();
1138 it != topology.end (); it++)
1141 NS_LOG_LOGIC (
"Looking at topology tuple: " << topology_tuple);
1144 bool have_destAddrEntry =
Lookup (topology_tuple.
destAddr, destAddrEntry);
1145 bool have_lastAddrEntry =
Lookup (topology_tuple.
lastAddr, lastAddrEntry);
1146 if (!have_destAddrEntry && have_lastAddrEntry && lastAddrEntry.
distance == h)
1148 NS_LOG_LOGIC (
"Adding routing table entry based on the topology tuple.");
1167 NS_LOG_LOGIC (
"NOT adding routing table entry based on the topology tuple: "
1168 "have_destAddrEntry=" << have_destAddrEntry
1169 <<
" have_lastAddrEntry=" << have_lastAddrEntry
1170 <<
" lastAddrEntry.distance=" << (
int) lastAddrEntry.
distance
1171 <<
" (h=" << h <<
")");
1187 for (IfaceAssocSet::const_iterator it = ifaceAssocSet.begin ();
1188 it != ifaceAssocSet.end (); it++)
1194 if (have_entry1 && !have_entry2)
1222 for (AssociationSet::const_iterator it = associationSet.begin ();
1223 it != associationSet.end (); it++)
1230 bool goToNextAssociationTuple =
false;
1232 NS_LOG_DEBUG (
"Nb local associations: " << localHnaAssociations.size ());
1233 for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
1234 assocIterator != localHnaAssociations.end (); assocIterator++)
1236 Association const &localHnaAssoc = *assocIterator;
1239 NS_LOG_DEBUG (
"HNA association received from another GW is part of local HNA associations: no route added for network "
1241 goToNextAssociationTuple =
true;
1244 if (goToNextAssociationTuple)
1252 bool addRoute =
false;
1254 uint32_t routeIndex = 0;
1256 for (routeIndex = 0; routeIndex <
m_hnaRoutingTable->GetNRoutes (); routeIndex++)
1276 if (addRoute && gatewayEntryExists)
1301 LinkSensing (msg, hello, receiverIface, senderIface);
1303 #ifdef NS3_LOG_ENABLE
1307 <<
" ** BEGIN dump Link Set for OLSR Node " <<
m_mainAddress);
1308 for (LinkSet::const_iterator link = links.begin (); link != links.end (); link++)
1316 <<
" ** BEGIN dump Neighbor Set for OLSR Node " <<
m_mainAddress);
1317 for (NeighborSet::const_iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++)
1328 #ifdef NS3_LOG_ENABLE
1332 <<
" ** BEGIN dump TwoHopNeighbor Set for OLSR Node " <<
m_mainAddress);
1333 for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin ();
1334 tuple != twoHopNeighbors.end (); tuple++)
1356 if (link_tuple == NULL)
1368 if (topologyTuple != NULL)
1381 for (std::vector<Ipv4Address>::const_iterator i = tc.
neighborAddresses.begin ();
1393 if (topologyTuple != NULL)
1421 #ifdef NS3_LOG_ENABLE
1425 <<
" ** BEGIN dump TopologySet for OLSR Node " <<
m_mainAddress);
1426 for (TopologySet::const_iterator tuple = topology.begin ();
1427 tuple != topology.end (); tuple++)
1447 if (linkTuple == NULL)
1450 ": the sender interface of this message is not in the "
1451 "symmetric 1-hop neighborhood of this node,"
1452 " the message MUST be discarded.");
1460 bool updated =
false;
1462 for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin ();
1463 tuple != ifaceAssoc.end (); tuple++)
1465 if (tuple->ifaceAddr == *i
1469 tuple->time = now + msg.
GetVTime ();
1491 for (NeighborSet::iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++)
1493 neighbor->neighborMainAddr =
GetMainAddress (neighbor->neighborMainAddr);
1497 for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin ();
1498 twoHopNeighbor != twoHopNeighbors.end (); twoHopNeighbor++)
1500 twoHopNeighbor->neighborMainAddr =
GetMainAddress (twoHopNeighbor->neighborMainAddr);
1501 twoHopNeighbor->twoHopNeighborAddr =
GetMainAddress (twoHopNeighbor->twoHopNeighborAddr);
1517 if (link_tuple == NULL)
1525 for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it = hna.
associations.begin ();
1576 if (linkTuple == NULL)
1593 bool retransmitted =
false;
1598 if (mprselTuple != NULL)
1605 retransmitted =
true;
1610 if (duplicated != NULL)
1614 duplicated->
ifaceList.push_back (localIface);
1624 newDup.
ifaceList.push_back (localIface);
1673 int numMessages = 0;
1679 for (std::vector<olsr::MessageHeader>::const_iterator message =
m_queuedMessages.begin ();
1686 msglist.push_back (*message);
1693 packet = Create<Packet> ();
1723 std::vector<olsr::MessageHeader::Hello::LinkMessage>
1727 for (LinkSet::const_iterator link_tuple = links.begin ();
1728 link_tuple != links.end (); link_tuple++)
1731 && link_tuple->time >= now))
1736 uint8_t link_type, nb_type = 0xff;
1739 if (link_tuple->symTime >= now)
1743 else if (link_tuple->asymTime >= now)
1756 <<
" to be MPR_NEIGH.");
1765 if (nb_tuple->neighborMainAddr ==
GetMainAddress (link_tuple->neighborIfaceAddr))
1770 <<
" to be SYM_NEIGH.");
1777 <<
" to be NOT_NEIGH.");
1781 NS_FATAL_ERROR (
"There is a neighbor tuple with an unknown status!\n");
1795 linkMessage.
linkCode = (link_type & 0x03) | ((nb_type << 2) & 0x0f);
1797 (link_tuple->neighborIfaceAddr);
1806 linkMessages.push_back (linkMessage);
1809 <<
" (with " << int (linkMessages.size ()) <<
" link messages)");
1860 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
1895 std::vector<olsr::MessageHeader::Hna::Association> &associations = hna.
associations;
1899 for (Associations::const_iterator it = localHnaAssociations.begin ();
1900 it != localHnaAssociations.end (); it++)
1903 associations.push_back (assoc);
1906 if (associations.size () == 0)
1921 for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
1922 assocIterator != localHnaAssociations.end (); assocIterator++)
1924 Association const &localHnaAssoc = *assocIterator;
1927 NS_LOG_INFO (
"HNA association for network " << networkAddr <<
"/" << netmask <<
" already exists.");
1932 NS_LOG_INFO (
"Adding HNA association for network " << networkAddr <<
"/" << netmask <<
".");
1939 NS_LOG_INFO (
"Removing HNA association for network " << networkAddr <<
"/" << netmask <<
".");
1950 NS_LOG_INFO (
"Removing HNA entries coming from the old routing table association.");
1969 NS_LOG_DEBUG (
"Nb local associations before adding some entries from"
1984 NS_LOG_DEBUG (
"Nb local associations after having added some entries from "
2004 bool updated =
false;
2005 bool created =
false;
2007 <<
": LinkSensing(receiverIface=" << receiverIface
2008 <<
", senderIface=" << senderIface <<
") BEGIN");
2012 if (link_tuple == NULL)
2022 NS_LOG_LOGIC (
"Existing link tuple did not exist => creating new one");
2026 NS_LOG_LOGIC (
"Existing link tuple already exists => will update it");
2031 for (std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator linkMessage =
2036 int lt = linkMessage->linkCode & 0x03;
2037 int nt = (linkMessage->linkCode >> 2) & 0x03;
2039 #ifdef NS3_LOG_ENABLE
2040 const char *linkTypeName;
2044 linkTypeName =
"UNSPEC_LINK";
2047 linkTypeName =
"ASYM_LINK";
2050 linkTypeName =
"SYM_LINK";
2053 linkTypeName =
"LOST_LINK";
2056 linkTypeName =
"(invalid value!)";
2060 const char *neighborTypeName;
2064 neighborTypeName =
"NOT_NEIGH";
2067 neighborTypeName =
"SYM_NEIGH";
2070 neighborTypeName =
"MPR_NEIGH";
2073 neighborTypeName =
"(invalid value!)";
2076 NS_LOG_DEBUG (
"Looking at HELLO link messages with Link Type "
2077 << lt <<
" (" << linkTypeName
2078 <<
") and Neighbor Type " << nt
2079 <<
" (" << neighborTypeName <<
")");
2087 NS_LOG_LOGIC (
"HELLO link code is invalid => IGNORING");
2091 for (std::vector<Ipv4Address>::const_iterator neighIfaceAddr =
2092 linkMessage->neighborInterfaceAddresses.begin ();
2093 neighIfaceAddr != linkMessage->neighborInterfaceAddresses.end ();
2097 if (*neighIfaceAddr == receiverIface)
2107 NS_LOG_DEBUG (*link_tuple <<
": link is SYM or ASYM => should become SYM now"
2108 " (symTime being increased to " << now + msg.
GetVTime ());
2121 NS_LOG_DEBUG (
" \\-> *neighIfaceAddr (" << *neighIfaceAddr
2122 <<
" != receiverIface (" << receiverIface <<
") => IGNORING!");
2125 NS_LOG_DEBUG (
"Link tuple updated: " <<
int (updated));
2143 <<
": LinkSensing END");
2151 if (nb_tuple != NULL)
2165 for (LinkSet::const_iterator link_tuple =
m_state.
GetLinks ().begin ();
2168 NS_LOG_LOGIC (
"Looking at link tuple: " << *link_tuple);
2172 "GetMainAddress (link_tuple->neighborIfaceAddr) != msg.GetOriginatorAddress ()");
2173 NS_LOG_LOGIC (
"(GetMainAddress(" << link_tuple->neighborIfaceAddr <<
"): "
2179 if (link_tuple->symTime < now)
2185 typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
2186 for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin ();
2187 linkMessage != hello.
linkMessages.end (); linkMessage++)
2189 int neighborType = (linkMessage->linkCode >> 2) & 0x3;
2190 #ifdef NS3_LOG_ENABLE
2191 const char *neighborTypeNames[3] = {
"NOT_NEIGH",
"SYM_NEIGH",
"MPR_NEIGH" };
2192 const char *neighborTypeName = ((neighborType < 3) ?
2193 neighborTypeNames[neighborType]
2194 :
"(invalid value)");
2195 NS_LOG_DEBUG (
"Looking at Link Message from HELLO message: neighborType="
2196 << neighborType <<
" (" << neighborTypeName <<
")");
2199 for (std::vector<Ipv4Address>::const_iterator nb2hop_addr_iter =
2200 linkMessage->neighborInterfaceAddresses.begin ();
2201 nb2hop_addr_iter != linkMessage->neighborInterfaceAddresses.end ();
2205 NS_LOG_DEBUG (
"Looking at 2-hop neighbor address from HELLO message: "
2206 << *nb2hop_addr_iter
2207 <<
" (main address is " << nb2hop_addr <<
")");
2215 NS_LOG_LOGIC (
"Ignoring 2-hop neighbor (it is the node itself)");
2223 << (nb2hop_tuple ?
" (refreshing existing entry)" :
""));
2224 if (nb2hop_tuple == NULL)
2249 NS_LOG_LOGIC (
"2-hop neighbor is NOT_NEIGH => deleting matching 2-hop neighbor state");
2254 NS_LOG_LOGIC (
"*** WARNING *** Ignoring link message (inside HELLO) with bad"
2255 " neighbor type value: " << neighborType);
2272 typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
2273 for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin ();
2277 int nt = linkMessage->linkCode >> 2;
2280 NS_LOG_DEBUG (
"Processing a link message with neighbor type MPR_NEIGH");
2282 for (std::vector<Ipv4Address>::const_iterator nb_iface_addr =
2283 linkMessage->neighborInterfaceAddresses.begin ();
2284 nb_iface_addr != linkMessage->neighborInterfaceAddresses.end ();
2289 NS_LOG_DEBUG (
"Adding entry to mpr selector set for neighbor " << *nb_iface_addr);
2294 if (existing_mprsel_tuple == NULL)
2332 struct hdr_ip* ih = HDR_IP (p);
2333 struct hdr_cmn* ch = HDR_CMN (p);
2335 debug (
"%f: Node %d MAC Layer detects a breakage on link to %d\n",
2337 OLSR::node_id (ra_addr ()),
2338 OLSR::node_id (ch->next_hop ()));
2340 if ((uint32_t)ih->daddr () == IP_BROADCAST)
2342 drop (p, DROP_RTR_MAC_CALLBACK);
2346 OLSR_link_tuple* link_tuple = state_.find_link_tuple (ch->next_hop ());
2347 if (link_tuple != NULL)
2351 nb_loss (link_tuple);
2353 drop (p, DROP_RTR_MAC_CALLBACK);
2421 <<
" LinkTuple " << tuple <<
" REMOVED.");
2434 <<
" LinkTuple " << tuple <<
" UPDATED.");
2439 if (nb_tuple == NULL)
2445 if (nb_tuple != NULL)
2447 int statusBefore = nb_tuple->
status;
2449 bool hasSymmetricLink =
false;
2452 for (LinkSet::const_iterator it = linkSet.begin ();
2453 it != linkSet.end (); it++)
2459 hasSymmetricLink =
true;
2464 if (hasSymmetricLink)
2467 NS_LOG_DEBUG (*nb_tuple <<
"->status = STATUS_SYM; changed:"
2468 <<
int (statusBefore != nb_tuple->
status));
2473 NS_LOG_DEBUG (*nb_tuple <<
"->status = STATUS_NOT_SYM; changed:"
2474 <<
int (statusBefore != nb_tuple->
status));
2479 NS_LOG_WARN (
"ERROR! Wanted to update a NeighborTuple but none was found!");
2653 NS_LOG_DEBUG (
"Not sending any TC, no one selected me as MPR.");
2674 NS_LOG_DEBUG (
"Not sending any HNA, no associations to advertise.");
2711 if (tuple->
time < now)
2715 else if (tuple->
symTime < now)
2728 neighborIfaceAddr));
2734 neighborIfaceAddr));
2755 this, neighborMainAddr, twoHopNeighborAddr));
2835 this, gatewayAddr, networkAddr, netmask));
2857 std::map<Ipv4Address, RoutingTableEntry>::const_iterator it =
2864 outEntry = it->second;
2894 if (!foundSendEntry)
2898 uint32_t interfaceIdx = entry2.
interface;
2899 if (oif &&
m_ipv4->GetInterfaceForDevice (oif) !=
static_cast<int> (interfaceIdx))
2906 <<
" Route interface " << interfaceIdx
2907 <<
" does not match requested output interface "
2908 <<
m_ipv4->GetInterfaceForDevice (oif));
2912 rtentry = Create<Ipv4Route> ();
2918 uint32_t numOifAddresses =
m_ipv4->GetNAddresses (interfaceIdx);
2921 if (numOifAddresses == 1)
2923 ifAddr =
m_ipv4->GetAddress (interfaceIdx, 0);
2928 NS_FATAL_ERROR (
"XXX Not implemented yet: IP aliasing and OLSR");
2930 rtentry->SetSource (ifAddr.
GetLocal ());
2931 rtentry->SetGateway (entry2.
nextAddr);
2932 rtentry->SetOutputDevice (
m_ipv4->GetNetDevice (interfaceIdx));
2936 <<
" --> nextHop=" << entry2.
nextAddr
2938 NS_LOG_DEBUG (
"Found route to " << rtentry->GetDestination () <<
" via nh " << rtentry->GetGateway () <<
" with source addr " << rtentry->GetSource () <<
" and output dev " << rtentry->GetOutputDevice ());
2948 NS_LOG_DEBUG (
"Found route to " << rtentry->GetDestination () <<
" via nh " << rtentry->GetGateway () <<
" with source addr " << rtentry->GetSource () <<
" and output dev " << rtentry->GetOutputDevice ());
2956 <<
" No route to host");
2980 uint32_t iif =
m_ipv4->GetInterfaceForDevice (idev);
2981 if (
m_ipv4->IsDestinationAddress (dst, iif))
2986 lcb (p, header, iif);
3008 if (!foundSendEntry)
3012 rtentry = Create<Ipv4Route> ();
3014 uint32_t interfaceIdx = entry2.
interface;
3019 uint32_t numOifAddresses =
m_ipv4->GetNAddresses (interfaceIdx);
3022 if (numOifAddresses == 1)
3024 ifAddr =
m_ipv4->GetAddress (interfaceIdx, 0);
3029 NS_FATAL_ERROR (
"XXX Not implemented yet: IP aliasing and OLSR");
3031 rtentry->SetSource (ifAddr.
GetLocal ());
3032 rtentry->SetGateway (entry2.
nextAddr);
3033 rtentry->SetOutputDevice (
m_ipv4->GetNetDevice (interfaceIdx));
3037 <<
" --> nextHop=" << entry2.
nextAddr
3040 ucb (rtentry, p, header);
3045 NS_LOG_LOGIC (
"No dynamic route, check network routes");
3053 #ifdef NS3_LOG_ENABLE
3056 <<
" --> NOT FOUND; ** Dumping routing table...");
3058 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin ();
3059 iter !=
m_table.end (); iter++)
3061 NS_LOG_DEBUG (
"dest=" << iter->first <<
" --> next=" << iter->second.nextAddr
3062 <<
" via interface " << iter->second.interface);
3121 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
3123 for (uint32_t j = 0; j <
m_ipv4->GetNAddresses (i); j++)
3125 if (
m_ipv4->GetAddress (i,j).GetLocal () == interfaceAddress)
3127 AddEntry (dest, next, i, distance);
3133 AddEntry (dest, next, 0, distance);
3137 std::vector<RoutingTableEntry>
3140 std::vector<RoutingTableEntry> retval;
3141 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin ();
3142 iter !=
m_table.end (); iter++)
3144 retval.push_back (iter->second);
3211 #ifdef NS3_LOG_ENABLE
3224 if (now < iter->expirationTime)
3230 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin (); iter !=
m_table.end (); iter++)
3232 NS_LOG_DEBUG (
" dest=" << iter->first <<
" --> next=" << iter->second.nextAddr <<
" via interface " << iter->second.interface);
a polymophic address class
bool IsNull(void) const
Check for null implementation.
Hold variables of type enum.
void Track(EventId event)
Tracks a new event.
uint16_t GetPort(void) const
Ipv4Address GetIpv4(void) const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny(void)
Ipv4Address GetSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
a class to store IPv4 address information on an interface
Ipv4Address GetLocal(void) const
Get the local address.
a class to represent an Ipv4 address mask
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
Abstract base class for IPv4 routing protocols.
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
uint32_t GetInterface(void) const
Ipv4Address GetDestNetwork(void) const
Ipv4Mask GetDestNetworkMask(void) const
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and,...
uint32_t GetId(void) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
virtual void DoDispose(void)
Destructor implementation.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void AddHeader(const Header &header)
Add header to this packet.
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now(void)
Return the current simulation virtual time.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
virtual int ShutdownSend(void)=0
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
virtual int Close(void)=0
Close a socket.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
SocketErrno
Enumeration of the possible errors returned by a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
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.
Simulation virtual time values and global simulation resolution.
Unit
The unit to use to interpret a number representing time.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
A simple virtual Timer class.
void SetDelay(const Time &delay)
bool IsRunning(void) const
void Schedule(void)
Schedule a new event using the currently-configured delay, function, and arguments.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static TypeId GetTypeId(void)
Get the type ID.
This class encapsulates all data structures needed for maintaining internal state of an OLSR node.
MprSet GetMprSet() const
Gets the MPR set.
void EraseAssociation(const Association &tuple)
Erases an association.
void EraseIfaceAssocTuple(const IfaceAssocTuple &tuple)
Erases a interface association tuple.
const TwoHopNeighborSet & GetTwoHopNeighbors() const
Gets the 2-hop neighbor set.
void InsertTopologyTuple(const TopologyTuple &tuple)
Inserts a topology tuple.
IfaceAssocTuple * FindIfaceAssocTuple(const Ipv4Address &ifaceAddr)
Finds a interface association tuple.
std::string PrintMprSelectorSet() const
Prints the MPR selector sets.
TwoHopNeighborTuple * FindTwoHopNeighborTuple(const Ipv4Address &neighbor, const Ipv4Address &twoHopNeighbor)
Finds a 2-hop neighbor tuple.
void EraseTwoHopNeighborTuples(const Ipv4Address &neighbor)
Erases the 2-hop neighbor tuples with the same 1-hop neighbor.
void InsertAssociation(const Association &tuple)
Inserts an association tuple.
const AssociationSet & GetAssociationSet() const
Gets the association set known to the node.
LinkTuple * FindSymLinkTuple(const Ipv4Address &ifaceAddr, Time time)
Finds a symmetrical link tuple.
const NeighborTuple * FindSymNeighborTuple(const Ipv4Address &mainAddr) const
Finds a symmetrical neighbor tuple.
const IfaceAssocSet & GetIfaceAssocSet() const
Gets the interface association set.
void EraseNeighborTuple(const NeighborTuple &neighborTuple)
Erases a neighbor tuple.
const TopologySet & GetTopologySet() const
Gets the topology set.
TopologyTuple * FindNewerTopologyTuple(const Ipv4Address &lastAddr, uint16_t ansn)
Finds a topology tuple.
void InsertDuplicateTuple(const DuplicateTuple &tuple)
Inserts a duplicate tuple.
void EraseMprSelectorTuples(const Ipv4Address &mainAddr)
Erases all MPR selector tuples belonging to the same address.
MprSelectorTuple * FindMprSelectorTuple(const Ipv4Address &mainAddr)
Finds a MPR selector tuple.
void SetMprSet(MprSet mprSet)
Sets the MPR set to the one specified.
const LinkSet & GetLinks() const
Gets the Link set.
void EraseAssociationTuple(const AssociationTuple &tuple)
Erases a known association tuple.
void InsertNeighborTuple(const NeighborTuple &tuple)
Inserts a neighbor tuple.
const MprSelectorSet & GetMprSelectors() const
Gets the MPR selectors.
TopologyTuple * FindTopologyTuple(const Ipv4Address &destAddr, const Ipv4Address &lastAddr)
Finds a topology tuple.
AssociationTuple * FindAssociationTuple(const Ipv4Address &gatewayAddr, const Ipv4Address &networkAddr, const Ipv4Mask &netmask)
Finds an association tuple.
std::vector< Ipv4Address > FindNeighborInterfaces(const Ipv4Address &neighborMainAddr) const
Returns a vector of all interfaces of a given neighbor, with the exception of the "main" one.
bool FindMprAddress(const Ipv4Address &address)
Checks if there's an MPR with a specific address.
void EraseLinkTuple(const LinkTuple &tuple)
Erases a link tuple.
DuplicateTuple * FindDuplicateTuple(const Ipv4Address &address, uint16_t sequenceNumber)
Finds a duplicate tuple.
void InsertTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Inserts a 2-hop neighbor tuple.
LinkTuple * FindLinkTuple(const Ipv4Address &ifaceAddr)
Finds a link tuple.
const Associations & GetAssociations() const
Gets the association set the node has.
void InsertAssociationTuple(const AssociationTuple &tuple)
Inserts a known association tuple.
void InsertMprSelectorTuple(const MprSelectorTuple &tuple)
Inserts a MPR selector tuple.
LinkTuple & InsertLinkTuple(const LinkTuple &tuple)
Inserts a link tuple.
void EraseTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Erases a 2-hop neighbor tuple.
const NeighborSet & GetNeighbors() const
Gets the neighbor set.
void InsertIfaceAssocTuple(const IfaceAssocTuple &tuple)
Inserts a interface association tuple.
void EraseTopologyTuple(const TopologyTuple &tuple)
Erases a topology tuple.
NeighborTuple * FindNeighborTuple(const Ipv4Address &mainAddr)
Finds a neighbor tuple.
void EraseOlderTopologyTuples(const Ipv4Address &lastAddr, uint16_t ansn)
Erases a topology tuple.
void EraseDuplicateTuple(const DuplicateTuple &tuple)
Erases a duplicate tuple.
void EraseMprSelectorTuple(const MprSelectorTuple &tuple)
Erases a MPR selector tuple.
IfaceAssocSet & GetIfaceAssocSetMutable()
Gets a mutable reference to the interface association set.
OLSR routing protocol for IPv4.
void LinkTupleUpdated(const LinkTuple &tuple, uint8_t willingness)
This function is invoked when a link tuple is updated.
MprSet GetMprSet(void) const
Gets the MPR set.
void SendQueuedMessages(void)
Creates as many OLSR packets as needed in order to send all buffered OLSR messages.
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
void RemoveHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Removes the specified (networkAddr, netmask) tuple from the list of local HNA associations to be sent...
OlsrState m_state
Internal state with all needed data structs.
void AddTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.
Time m_hnaInterval
HNA messages' emission interval.
uint16_t m_messageSequenceNumber
Messages sequence number counter.
olsr::MessageList m_queuedMessages
A list of pending messages which are buffered awaiting for being sent.
void RemoveLinkTuple(const LinkTuple &tuple)
Removes a link tuple from the Link Set.
const TopologySet & GetTopologySet(void) const
Gets the topology set.
TracedCallback< uint32_t > m_routingTableChanged
Routing table chanes challback.
void QueueMessage(const olsr::MessageHeader &message, Time delay)
Enques an OLSR message which will be sent with a delay of (0, delay].
void AddNeighborTuple(const NeighborTuple &tuple)
Adds a neighbor tuple to the Neighbor Set.
void LinkSensing(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello, const Ipv4Address &receiverIface, const Ipv4Address &senderIface)
Updates Link Set according to a new received HELLO message (following RFC 3626 specification).
uint8_t m_willingness
Willingness for forwarding packets on behalf of other nodes.
void SendHna(void)
Creates a new OLSR HNA message which is buffered for being sent later on.
void SendPacket(Ptr< Packet > packet, const MessageList &containedMessages)
Send an OLSR message.
Timer m_tcTimer
Timer for the TC message.
void HelloTimerExpire(void)
Sends a HELLO message and reschedules the HELLO timer.
void AddHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Injects the specified (networkAddr, netmask) tuple in the list of local HNA associations to be sent b...
void HnaTimerExpire(void)
Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer.
virtual void NotifyInterfaceUp(uint32_t interface)
uint32_t GetSize(void) const
Returns the routing table size.
Ptr< Ipv4StaticRouting > m_hnaRoutingTable
Routing table for HNA routes.
void MidTimerExpire(void)
Sends a MID message (if the node has more than one interface) and resets the MID timer.
bool IsMyOwnAddress(const Ipv4Address &a) const
Check that address is one of my interfaces.
bool FindSendEntry(const RoutingTableEntry &entry, RoutingTableEntry &outEntry) const
Finds the appropriate entry which must be used in order to forward a data packet to a next hop (given...
void LinkTupleTimerExpire(Ipv4Address neighborIfaceAddr)
Removes tuple_ if expired.
const NeighborSet & GetNeighbors(void) const
Get the one hop neighbors.
void MprSelTupleTimerExpire(Ipv4Address mainAddr)
Removes MPR selector tuple_ if expired.
void RemoveTopologyTuple(const TopologyTuple &tuple)
Removes a topology tuple to the Topology Set.
void LinkTupleAdded(const LinkTuple &tuple, uint8_t willingness)
Adds a link tuple.
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...
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.
void AddTopologyTuple(const TopologyTuple &tuple)
Adds a topology tuple to the Topology Set.
void ProcessTc(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a TC message following RFC 3626 specification.
void SendHello(void)
Creates a new OLSR HELLO message which is buffered for being sent later on.
void SetRoutingTableAssociation(Ptr< Ipv4StaticRouting > routingTable)
Associates the specified Ipv4StaticRouting routing table to the OLSR routing protocol.
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 (...
Ipv4Address m_mainAddress
the node main address.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
void Nb2hopTupleTimerExpire(Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr)
Removes 2_hop neighbor tuple_ if expired.
uint16_t GetPacketSequenceNumber(void)
Increments packet sequence number and returns the new value.
void AssociationTupleTimerExpire(Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
Removes association tuple_ if expired.
static const uint16_t OLSR_PORT_NUMBER
port number (698)
void SetMainInterface(uint32_t interface)
Set the OLSR main address to the first address on the indicated interface.
void TcTimerExpire(void)
Sends a TC message (if there exists any MPR selector) and reschedules the TC timer.
void AddEntry(const Ipv4Address &dest, const Ipv4Address &next, uint32_t interface, uint32_t distance)
Adds a new entry into the routing table.
void AddIfaceAssocTuple(const IfaceAssocTuple &tuple)
Adds an interface association tuple to the Interface Association Set.
void RemoveDuplicateTuple(const DuplicateTuple &tuple)
Removes a duplicate tuple from the Duplicate Set.
void DupTupleTimerExpire(Ipv4Address address, uint16_t sequenceNumber)
Removes tuple if expired.
std::vector< RoutingTableEntry > GetRoutingTableEntries(void) const
Get the routing table entries.
Ipv4Address GetMainAddress(Ipv4Address iface_addr) const
Gets the main address associated with a given interface address.
Timer m_midTimer
Timer for the MID message.
void SendMid(void)
Creates a new OLSR MID message which is buffered for being sent later on.
EventGarbageCollector m_events
Running events.
void RoutingTableComputation(void)
Creates the routing table of the node following RFC 3626 hints.
virtual NS_DEPRECATED_3_34 Ptr< Ipv4 > GetIpv4(void) const
bool Lookup(const Ipv4Address &dest, RoutingTableEntry &outEntry) const
Looks up an entry for the specified destination address.
TracedCallback< const PacketHeader &, const MessageList & > m_rxPacketTrace
Rx packet trace.
void ProcessMid(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a MID message following RFC 3626 specification.
Timer m_queuedMessagesTimer
timer for throttling outgoing messages
static TypeId GetTypeId(void)
Get the type ID.
uint16_t m_ansn
Advertised Neighbor Set sequence number.
void RemoveIfaceAssocTuple(const IfaceAssocTuple &tuple)
Removed an interface association tuple to the Interface Association Set.
virtual void NotifyInterfaceDown(uint32_t interface)
Time m_midInterval
MID messages' emission interval.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_sendSockets
Container of sockets and the interfaces they are opened onto.
void TopologyTupleTimerExpire(Ipv4Address destAddr, Ipv4Address lastAddr)
Removes topology tuple_ if expired.
void ProcessHello(const olsr::MessageHeader &msg, const Ipv4Address &receiverIface, const Ipv4Address &senderIface)
Processes a HELLO message following RFC 3626 specification.
const OlsrState & GetOlsrState(void) const
Gets the underlying OLSR state object.
std::map< Ipv4Address, RoutingTableEntry > m_table
Data structure for the routing table.
void RemoveEntry(const Ipv4Address &dest)
Deletes the entry whose destination address is given.
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...
virtual ~RoutingProtocol(void)
void MprComputation(void)
Computates MPR set of a node following RFC 3626 hints.
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)
uint16_t GetMessageSequenceNumber(void)
Increments message sequence number and returns the new value.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
uint16_t m_packetSequenceNumber
Packets sequence number counter.
Timer m_helloTimer
Timer for the HELLO message.
TracedCallback< const PacketHeader &, const MessageList & > m_txPacketTrace
Tx packet trace.
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
void RemoveMprSelectorTuple(const MprSelectorTuple &tuple)
Removes an MPR selector tuple from the MPR Selector Set.
void ProcessHna(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a HNA message following RFC 3626 specification.
const MprSelectorSet & GetMprSelectors(void) const
Gets the MPR selectors.
Ptr< Socket > m_recvSocket
Receiving socket.
void Dump(void)
Dump the neighbor table, two-hop neighbor table, and routing table to logging output (NS_LOG_DEBUG lo...
void IncrementAnsn(void)
Increments the ANSN counter.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
void SetInterfaceExclusions(std::set< uint32_t > exceptions)
Set the interfaces to be excluded.
void ForwardDefault(olsr::MessageHeader olsrMessage, DuplicateTuple *duplicated, const Ipv4Address &localIface, const Ipv4Address &senderAddress)
OLSR's default forwarding algorithm.
Time m_helloInterval
HELLO messages' emission interval.
Timer m_hnaTimer
Timer for the HNA message.
void SendTc(void)
Creates a new OLSR TC message which is buffered for being sent later on.
void AddAssociationTuple(const AssociationTuple &tuple)
Adds a host network association tuple to the Association Set.
void AddDuplicateTuple(const DuplicateTuple &tuple)
Adds a duplicate tuple to the Duplicate Set.
void RemoveTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.
void RemoveAssociationTuple(const AssociationTuple &tuple)
Removes a host network association tuple to the Association Set.
Time m_tcInterval
TC messages' emission interval.
bool UsesNonOlsrOutgoingInterface(const Ipv4RoutingTableEntry &route)
Tests whether or not the specified route uses a non-OLSR outgoing interface.
void Clear(void)
Clears the routing table and frees the memory assigned to each one of its entries.
Ptr< Ipv4StaticRouting > m_routingTableAssociation
Associations from an Ipv4StaticRouting instance.
bool m_linkTupleTimerFirstTime
Flag to indicate if it is the first time the LinkTupleTimer fires.
virtual void DoDispose(void)
Destructor implementation.
Ptr< const Ipv4StaticRouting > GetRoutingTableAssociation(void) const
Returns the internal HNA table.
int Degree(NeighborTuple const &tuple)
This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set.
const TwoHopNeighborSet & GetTwoHopNeighbors(void) const
Get the two hop neighbors.
void RemoveNeighborTuple(const NeighborTuple &tuple)
Removes a neighbor tuple from the Neighbor Set.
void IfaceAssocTupleTimerExpire(Ipv4Address ifaceAddr)
Removes interface association tuple_ if expired.
void RecvOlsr(Ptr< Socket > socket)
Receive an OLSR message.
std::set< uint32_t > m_interfaceExclusions
Set of interfaces excluded by OSLR.
void NeighborLoss(const LinkTuple &tuple)
Performs all actions needed when a neighbor loss occurs.
virtual void DoInitialize(void)
Initialize() implementation.
Ptr< Ipv4 > m_ipv4
IPv4 object the routing is linked to.
void AddMprSelectorTuple(const MprSelectorTuple &tuple)
Adds an MPR selector tuple to the MPR Selector Set.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void CoverTwoHopNeighbors(Ipv4Address neighborMainAddr, TwoHopNeighborSet &N2)
Remove all covered 2-hop neighbors from N2 set.
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
std::vector< AssociationTuple > AssociationSet
Association Set type.
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
std::vector< LinkTuple > LinkSet
Link Set type.
std::vector< Association > Associations
Association Set type.
std::vector< TopologyTuple > TopologySet
Topology Set type.
std::set< Ipv4Address > MprSet
MPR Set type.
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
std::vector< MessageHeader > MessageList
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define JITTER
Random number between [0-OLSR_MAXJITTER] used to jitter OLSR packet transmission.
#define OLSR_MPR_NEIGH
Asymmetric neighbor type.
#define OLSR_WILL_DEFAULT
Willingness for forwarding packets from other nodes: medium.
#define OLSR_WILL_NEVER
Willingness for forwarding packets from other nodes: never.
#define OLSR_HNA_HOLD_TIME
HNA holding time.
#define OLSR_NEIGHB_HOLD_TIME
Neighbor holding time.
#define OLSR_MAX_SEQ_NUM
Maximum allowed sequence number.
#define OLSR_SYM_NEIGH
Symmetric neighbor type.
#define OLSR_WILL_ALWAYS
Willingness for forwarding packets from other nodes: always.
#define OLSR_TOP_HOLD_TIME
Top holding time.
#define OLSR_UNSPEC_LINK
Unspecified link type.
#define OLSR_NOT_NEIGH
Not neighbor type.
#define OLSR_MID_HOLD_TIME
MID holding time.
#define OLSR_ASYM_LINK
Asymmetric link type.
#define OLSR_SYM_LINK
Symmetric link type.
#define OLSR_DUP_HOLD_TIME
Dup holding time.
#define OLSR_LOST_LINK
Lost link type.
#define OLSR_WILL_HIGH
Willingness for forwarding packets from other nodes: high.
#define OLSR_MAX_MSGS
Maximum number of messages per packet.
#define DELAY(time)
Gets the delay between a given time and the current time.
#define OLSR_WILL_LOW
Willingness for forwarding packets from other nodes: low.
Ipv4Address networkAddr
IPv4 Network address.
Ipv4Mask netmask
IPv4 Network mask.
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr.
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address gatewayAddr
Main address of the gateway.
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on.
Ipv4Address address
Originator address of the message.
uint16_t sequenceNumber
Message sequence number.
bool retransmitted
Indicates whether the message has been retransmitted or not.
Time expirationTime
Time at which this tuple expires and must be removed.
An Interface Association Tuple.
Ipv4Address ifaceAddr
Interface address of a node.
Time time
Time at which this tuple expires and must be removed.
Ipv4Address mainAddr
Main address of the node.
Time time
Time at which this tuple expires and must be removed.
Ipv4Address localIfaceAddr
Interface address of the local node.
Time asymTime
The link is considered unidirectional until this time.
Time symTime
The link is considered bidirectional until this time.
Ipv4Address neighborIfaceAddr
Interface address of the neighbor node.
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address neighborMainAddr
Main address of a neighbor node.
enum ns3::olsr::NeighborTuple::Status status
Status of the link.
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
An OLSR's routing table entry.
uint32_t distance
Distance in hops to the destination.
Ipv4Address nextAddr
Address of the next hop.
uint32_t interface
Interface index.
Ipv4Address destAddr
Address of the destination node.
Ipv4Address destAddr
Main address of the destination.
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination.
uint16_t sequenceNumber
Sequence number.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
Ipv4Address neighborMainAddr
Main address of a neighbor.
Time expirationTime
Time at which this tuple expires and must be removed.