29 #define NS_LOG_APPEND_CONTEXT \
30 if (GetObject<Node>()) \
32 std::clog << "[node " << GetObject<Node>()->GetId() << "] "; \
37 #include "ns3/boolean.h"
39 #include "ns3/inet-socket-address.h"
40 #include "ns3/ipv4-header.h"
41 #include "ns3/ipv4-packet-info-tag.h"
42 #include "ns3/ipv4-route.h"
43 #include "ns3/ipv4-routing-protocol.h"
44 #include "ns3/ipv4-routing-table-entry.h"
46 #include "ns3/names.h"
47 #include "ns3/simulator.h"
48 #include "ns3/socket-factory.h"
49 #include "ns3/trace-source-accessor.h"
50 #include "ns3/udp-socket-factory.h"
51 #include "ns3/uinteger.h"
64 (((time) < (Simulator::Now())) ? Seconds(0.000001) \
65 : (time - Simulator::Now() + Seconds(0.000001)))
72 #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
110 #define OLSR_WILL_NEVER 0
112 #define OLSR_WILL_LOW 1
114 #define OLSR_WILL_DEFAULT 3
116 #define OLSR_WILL_HIGH 6
118 #define OLSR_WILL_ALWAYS 7
123 #define OLSR_MAXJITTER (m_helloInterval.GetSeconds() / 4)
125 #define OLSR_MAX_SEQ_NUM 65535
127 #define JITTER (Seconds(m_uniformRandomVariable->GetValue(0, OLSR_MAXJITTER)))
130 #define OLSR_MAX_MSGS 64
133 #define OLSR_MAX_HELLOS 12
136 #define OLSR_MAX_ADDRS 64
157 TypeId(
"ns3::olsr::RoutingProtocol")
159 .SetGroupName(
"Olsr")
161 .AddAttribute(
"HelloInterval",
162 "HELLO messages emission interval.",
166 .AddAttribute(
"TcInterval",
167 "TC messages emission interval.",
171 .AddAttribute(
"MidInterval",
172 "MID messages emission interval. Normally it is equal to TcInterval.",
176 .AddAttribute(
"HnaInterval",
177 "HNA messages emission interval. Normally it is equal to TcInterval.",
181 .AddAttribute(
"Willingness",
182 "Willingness of a node to carry and forward traffic for other nodes.",
195 .AddTraceSource(
"Rx",
196 "Receive OLSR packet.",
198 "ns3::olsr::RoutingProtocol::PacketTxRxTracedCallback")
199 .AddTraceSource(
"Tx",
202 "ns3::olsr::RoutingProtocol::PacketTxRxTracedCallback")
203 .AddTraceSource(
"RoutingTableChanged",
204 "The OLSR routing table has changed.",
206 "ns3::olsr::RoutingProtocol::TableChangeTracedCallback");
211 : m_routingTableAssociation(nullptr),
213 m_helloTimer(
Timer::CANCEL_ON_DESTROY),
214 m_tcTimer(
Timer::CANCEL_ON_DESTROY),
215 m_midTimer(
Timer::CANCEL_ON_DESTROY),
216 m_hnaTimer(
Timer::CANCEL_ON_DESTROY),
217 m_queuedMessagesTimer(
Timer::CANCEL_ON_DESTROY)
268 iter->first->
Close();
281 std::ios oldState(
nullptr);
282 oldState.copyfmt(*os);
284 *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
286 *os <<
"Node: " <<
m_ipv4->GetObject<
Node>()->GetId() <<
", Time: " <<
Now().
As(unit)
287 <<
", Local time: " <<
m_ipv4->GetObject<
Node>()->GetLocalTime().As(unit)
288 <<
", OLSR Routing table" << std::endl;
290 *os << std::setw(16) <<
"Destination";
291 *os << std::setw(16) <<
"NextHop";
292 *os << std::setw(16) <<
"Interface";
293 *os <<
"Distance" << std::endl;
295 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin();
299 *os << std::setw(16) << iter->first;
300 *os << std::setw(16) << iter->second.nextAddr;
301 *os << std::setw(16);
308 *os << iter->second.interface;
310 *os << iter->second.distance << std::endl;
317 *os <<
"HNA Routing Table:" << std::endl;
322 *os <<
"HNA Routing Table: empty" << std::endl;
325 (*os).copyfmt(oldState);
334 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces(); i++)
338 if (addr != loopback)
352 bool canRunOlsr =
false;
353 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces(); i++)
356 if (addr == loopback)
400 if (socket->
Bind(inetAddr))
440 receivedPacket = socket->
RecvFrom(sourceAddress);
445 NS_ABORT_MSG(
"No incoming interface on OLSR message, aborting.");
447 uint32_t incomingIf = interfaceInfo.
GetRecvIf();
448 Ptr<Node> node = this->GetObject<Node>();
450 uint32_t recvInterfaceIndex =
m_ipv4->GetInterfaceForDevice(dev);
460 int32_t interfaceForAddress =
m_ipv4->GetInterfaceForAddress(senderIfaceAddr);
461 if (interfaceForAddress != -1)
467 Ipv4Address receiverIfaceAddr =
m_ipv4->GetAddress(recvInterfaceIndex, 0).GetLocal();
470 <<
" to " << receiverIfaceAddr);
499 messages.push_back(messageHeader);
504 for (MessageList::const_iterator messageIter = messages.begin(); messageIter != messages.end();
520 bool do_forwarding =
true;
536 if (duplicated ==
nullptr)
542 <<
" OLSR node " <<
m_mainAddress <<
" received HELLO message of size "
544 ProcessHello(messageHeader, receiverIfaceAddr, senderIfaceAddr);
549 <<
" OLSR node " <<
m_mainAddress <<
" received TC message of size "
551 ProcessTc(messageHeader, senderIfaceAddr);
556 <<
" OLSR node " <<
m_mainAddress <<
" received MID message of size "
562 <<
" OLSR node " <<
m_mainAddress <<
" received HNA message of size "
569 <<
" not implemented");
574 NS_LOG_DEBUG(
"OLSR message is duplicated, not reading it.");
578 for (std::vector<Ipv4Address>::const_iterator it = duplicated->
ifaceList.begin();
582 if (*it == receiverIfaceAddr)
584 do_forwarding =
false;
629 if (nb_tuple ==
nullptr)
651 std::set<Ipv4Address> toRemove;
652 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();
655 if (twoHopNeigh->neighborMainAddr == neighborMainAddr)
657 toRemove.insert(twoHopNeigh->twoHopNeighborAddr);
661 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();)
663 if (toRemove.find(twoHopNeigh->twoHopNeighborAddr) != toRemove.end())
665 twoHopNeigh = N2.erase(twoHopNeigh);
693 N.push_back(*neighbor);
718 for (NeighborSet::const_iterator neigh = N.begin(); neigh != N.end(); neigh++)
720 if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
742 for (NeighborSet::const_iterator neigh = N.begin(); neigh != N.end(); neigh++)
744 if (neigh->neighborMainAddr == twoHopNeigh->twoHopNeighborAddr)
753 N2.push_back(*twoHopNeigh);
757 #ifdef NS3_LOG_ENABLE
759 std::ostringstream os;
761 for (TwoHopNeighborSet::const_iterator iter = N2.begin(); iter != N2.end(); iter++)
763 TwoHopNeighborSet::const_iterator next = iter;
765 os << iter->neighborMainAddr <<
"->" << iter->twoHopNeighborAddr;
766 if (next != N2.end())
778 for (NeighborSet::const_iterator neighbor = N.begin(); neighbor != N.end(); neighbor++)
782 mprSet.insert(neighbor->neighborMainAddr);
794 std::set<Ipv4Address> coveredTwoHopNeighbors;
795 for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();
800 for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin();
801 otherTwoHopNeigh != N2.end();
804 if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr &&
805 otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr)
813 NS_LOG_LOGIC(
"Neighbor " << twoHopNeigh->neighborMainAddr
814 <<
" is the only that can reach 2-hop neigh. "
815 << twoHopNeigh->twoHopNeighborAddr <<
" => select as MPR.");
817 mprSet.insert(twoHopNeigh->neighborMainAddr);
820 for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin();
821 otherTwoHopNeigh != N2.end();
824 if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
826 coveredTwoHopNeighbors.insert(otherTwoHopNeigh->twoHopNeighborAddr);
832 for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();)
834 if (coveredTwoHopNeighbors.find(twoHopNeigh->twoHopNeighborAddr) !=
835 coveredTwoHopNeighbors.end())
840 NS_LOG_LOGIC(
"2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr
841 <<
" is already covered by an MPR.");
842 twoHopNeigh = N2.erase(twoHopNeigh);
852 while (N2.begin() != N2.end())
854 #ifdef NS3_LOG_ENABLE
856 std::ostringstream os;
858 for (TwoHopNeighborSet::const_iterator iter = N2.begin(); iter != N2.end(); iter++)
860 TwoHopNeighborSet::const_iterator next = iter;
862 os << iter->neighborMainAddr <<
"->" << iter->twoHopNeighborAddr;
863 if (next != N2.end())
877 std::map<int, std::vector<const NeighborTuple*>> reachability;
879 for (NeighborSet::iterator it = N.begin(); it != N.end(); it++)
883 for (TwoHopNeighborSet::iterator it2 = N2.begin(); it2 != N2.end(); it2++)
892 reachability[r].push_back(&nb_tuple);
905 for (std::set<int>::iterator it = rs.begin(); it != rs.end(); it++)
912 for (std::vector<const NeighborTuple*>::iterator it2 = reachability[r].begin();
913 it2 != reachability[r].end();
943 mprSet.insert(
max->neighborMainAddr);
945 NS_LOG_LOGIC(N2.size() <<
" 2-hop neighbors left to cover!");
949 #ifdef NS3_LOG_ENABLE
951 std::ostringstream os;
953 for (MprSet::const_iterator iter = mprSet.begin(); iter != mprSet.end(); iter++)
955 MprSet::const_iterator next = iter;
958 if (next != mprSet.end())
976 if (tuple !=
nullptr)
990 <<
" : Node " <<
m_mainAddress <<
": RoutingTableComputation begin...");
998 for (NeighborSet::const_iterator it = neighborSet.begin(); it != neighborSet.end(); it++)
1001 NS_LOG_DEBUG(
"Looking at neighbor tuple: " << nb_tuple);
1004 bool nb_main_addr =
false;
1007 for (LinkSet::const_iterator it2 = linkSet.begin(); it2 != linkSet.end(); it2++)
1018 <<
" => adding routing table entry to neighbor");
1026 nb_main_addr =
true;
1048 if (!nb_main_addr && lt !=
nullptr)
1050 NS_LOG_LOGIC(
"no R_dest_addr is equal to the main address of the neighbor "
1051 "=> adding additional routing entry");
1063 for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin();
1064 it != twoHopNeighbors.end();
1069 NS_LOG_LOGIC(
"Looking at two-hop neighbor tuple: " << nb2hop_tuple);
1074 NS_LOG_LOGIC(
"Two-hop neighbor tuple is also neighbor; skipped.");
1087 bool nb2hopOk =
false;
1088 for (NeighborSet::const_iterator neighbor = neighborSet.begin();
1089 neighbor != neighborSet.end();
1101 NS_LOG_LOGIC(
"Two-hop neighbor tuple skipped: 2-hop neighbor "
1104 <<
", which was not found in the Neighbor Set.");
1123 NS_LOG_LOGIC(
"Adding routing entry for two-hop neighbor.");
1128 NS_LOG_LOGIC(
"NOT adding routing entry for two-hop neighbor ("
1133 for (uint32_t h = 2;; h++)
1144 for (TopologySet::const_iterator it = topology.begin(); it != topology.end(); it++)
1147 NS_LOG_LOGIC(
"Looking at topology tuple: " << topology_tuple);
1151 bool have_destAddrEntry =
Lookup(topology_tuple.
destAddr, destAddrEntry);
1152 bool have_lastAddrEntry =
Lookup(topology_tuple.
lastAddr, lastAddrEntry);
1153 if (!have_destAddrEntry && have_lastAddrEntry && lastAddrEntry.
distance == h)
1155 NS_LOG_LOGIC(
"Adding routing table entry based on the topology tuple.");
1174 NS_LOG_LOGIC(
"NOT adding routing table entry based on the topology tuple: "
1175 "have_destAddrEntry="
1176 << have_destAddrEntry <<
" have_lastAddrEntry=" << have_lastAddrEntry
1177 <<
" lastAddrEntry.distance=" << (
int)lastAddrEntry.
distance
1178 <<
" (h=" << h <<
")");
1194 for (IfaceAssocSet::const_iterator it = ifaceAssocSet.begin(); it != ifaceAssocSet.end(); it++)
1201 if (have_entry1 && !have_entry2)
1226 for (AssociationSet::const_iterator it = associationSet.begin(); it != associationSet.end();
1234 bool goToNextAssociationTuple =
false;
1236 NS_LOG_DEBUG(
"Nb local associations: " << localHnaAssociations.size());
1237 for (Associations::const_iterator assocIterator = localHnaAssociations.begin();
1238 assocIterator != localHnaAssociations.end();
1241 const Association& localHnaAssoc = *assocIterator;
1245 NS_LOG_DEBUG(
"HNA association received from another GW is part of local HNA "
1246 "associations: no route added for network "
1248 goToNextAssociationTuple =
true;
1251 if (goToNextAssociationTuple)
1259 bool addRoute =
false;
1261 uint32_t routeIndex = 0;
1263 for (routeIndex = 0; routeIndex <
m_hnaRoutingTable->GetNRoutes(); routeIndex++)
1277 else if (gatewayEntryExists &&
1284 if (addRoute && gatewayEntryExists)
1307 LinkSensing(msg, hello, receiverIface, senderIface);
1309 #ifdef NS3_LOG_ENABLE
1313 <<
" ** BEGIN dump Link Set for OLSR Node " <<
m_mainAddress);
1314 for (LinkSet::const_iterator link = links.begin(); link != links.end(); link++)
1322 <<
" ** BEGIN dump Neighbor Set for OLSR Node " <<
m_mainAddress);
1323 for (NeighborSet::const_iterator neighbor = neighbors.begin(); neighbor != neighbors.end();
1335 #ifdef NS3_LOG_ENABLE
1339 <<
" ** BEGIN dump TwoHopNeighbor Set for OLSR Node " <<
m_mainAddress);
1340 for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin();
1341 tuple != twoHopNeighbors.end();
1363 if (link_tuple ==
nullptr)
1375 if (topologyTuple !=
nullptr)
1400 if (topologyTuple !=
nullptr)
1428 #ifdef NS3_LOG_ENABLE
1432 <<
" ** BEGIN dump TopologySet for OLSR Node " <<
m_mainAddress);
1433 for (TopologySet::const_iterator tuple = topology.begin(); tuple != topology.end(); tuple++)
1452 if (linkTuple ==
nullptr)
1455 <<
": the sender interface of this message is not in the "
1456 "symmetric 1-hop neighborhood of this node,"
1457 " the message MUST be discarded.");
1466 bool updated =
false;
1468 for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin(); tuple != ifaceAssoc.end(); tuple++)
1473 tuple->time = now + msg.
GetVTime();
1497 for (NeighborSet::iterator neighbor = neighbors.begin(); neighbor != neighbors.end();
1500 neighbor->neighborMainAddr =
GetMainAddress(neighbor->neighborMainAddr);
1504 for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin();
1505 twoHopNeighbor != twoHopNeighbors.end();
1508 twoHopNeighbor->neighborMainAddr =
GetMainAddress(twoHopNeighbor->neighborMainAddr);
1509 twoHopNeighbor->twoHopNeighborAddr =
GetMainAddress(twoHopNeighbor->twoHopNeighborAddr);
1523 if (link_tuple ==
nullptr)
1531 for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it =
1545 if (tuple !=
nullptr)
1585 if (linkTuple ==
nullptr)
1596 <<
" does not forward a message received"
1605 bool retransmitted =
false;
1610 if (mprselTuple !=
nullptr)
1617 retransmitted =
true;
1622 if (duplicated !=
nullptr)
1626 duplicated->
ifaceList.push_back(localIface);
1687 int numMessages = 0;
1693 for (std::vector<olsr::MessageHeader>::const_iterator message =
m_queuedMessages.begin();
1700 msglist.push_back(*message);
1707 packet = Create<Packet>();
1737 std::vector<olsr::MessageHeader::Hello::LinkMessage>& linkMessages = hello.
linkMessages;
1740 for (LinkSet::const_iterator link_tuple = links.begin(); link_tuple != links.end();
1744 link_tuple->time >= now))
1750 uint8_t nb_type = 0xff;
1753 if (link_tuple->symTime >= now)
1757 else if (link_tuple->asymTime >= now)
1770 <<
" to be MPR_NEIGH.");
1779 if (nb_tuple->neighborMainAddr ==
GetMainAddress(link_tuple->neighborIfaceAddr))
1785 <<
" to be SYM_NEIGH.");
1793 <<
" to be NOT_NEIGH.");
1797 NS_FATAL_ERROR(
"There is a neighbor tuple with an unknown status!\n");
1812 linkMessage.
linkCode = (link_type & 0x03) | ((nb_type << 2) & 0x0f);
1822 linkMessages.push_back(linkMessage);
1825 <<
int(linkMessages.size()) <<
" link messages)");
1877 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces(); i++)
1912 std::vector<olsr::MessageHeader::Hna::Association>& associations = hna.
associations;
1916 for (Associations::const_iterator it = localHnaAssociations.begin();
1917 it != localHnaAssociations.end();
1921 associations.push_back(assoc);
1924 if (associations.empty())
1939 for (Associations::const_iterator assocIterator = localHnaAssociations.begin();
1940 assocIterator != localHnaAssociations.end();
1943 const Association& localHnaAssoc = *assocIterator;
1946 NS_LOG_INFO(
"HNA association for network " << networkAddr <<
"/" << netmask
1947 <<
" already exists.");
1952 NS_LOG_INFO(
"Adding HNA association for network " << networkAddr <<
"/" << netmask <<
".");
1959 NS_LOG_INFO(
"Removing HNA association for network " << networkAddr <<
"/" << netmask <<
".");
1970 NS_LOG_INFO(
"Removing HNA entries coming from the old routing table association.");
1989 NS_LOG_DEBUG(
"Nb local associations before adding some entries from"
1990 " the associated routing table: "
2005 NS_LOG_DEBUG(
"Nb local associations after having added some entries from "
2006 "the associated routing table: "
2026 bool updated =
false;
2027 bool created =
false;
2029 <<
": LinkSensing(receiverIface=" << receiverIface
2030 <<
", senderIface=" << senderIface <<
") BEGIN");
2034 if (link_tuple ==
nullptr)
2044 NS_LOG_LOGIC(
"Existing link tuple did not exist => creating new one");
2048 NS_LOG_LOGIC(
"Existing link tuple already exists => will update it");
2053 for (std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator linkMessage =
2058 int lt = linkMessage->linkCode & 0x03;
2059 int nt = (linkMessage->linkCode >> 2) & 0x03;
2061 #ifdef NS3_LOG_ENABLE
2062 const char* linkTypeName;
2066 linkTypeName =
"UNSPEC_LINK";
2069 linkTypeName =
"ASYM_LINK";
2072 linkTypeName =
"SYM_LINK";
2075 linkTypeName =
"LOST_LINK";
2078 linkTypeName =
"(invalid value!)";
2081 const char* neighborTypeName;
2085 neighborTypeName =
"NOT_NEIGH";
2088 neighborTypeName =
"SYM_NEIGH";
2091 neighborTypeName =
"MPR_NEIGH";
2094 neighborTypeName =
"(invalid value!)";
2097 NS_LOG_DEBUG(
"Looking at HELLO link messages with Link Type "
2098 << lt <<
" (" << linkTypeName <<
") and Neighbor Type " << nt <<
" ("
2099 << neighborTypeName <<
")");
2106 NS_LOG_LOGIC(
"HELLO link code is invalid => IGNORING");
2110 for (std::vector<Ipv4Address>::const_iterator neighIfaceAddr =
2111 linkMessage->neighborInterfaceAddresses.begin();
2112 neighIfaceAddr != linkMessage->neighborInterfaceAddresses.end();
2116 if (*neighIfaceAddr == receiverIface)
2126 NS_LOG_DEBUG(*link_tuple <<
": link is SYM or ASYM => should become SYM now"
2127 " (symTime being increased to "
2141 NS_LOG_DEBUG(
" \\-> *neighIfaceAddr (" << *neighIfaceAddr
2142 <<
" != receiverIface (" << receiverIface
2143 <<
") => IGNORING!");
2172 if (nb_tuple !=
nullptr)
2190 NS_LOG_LOGIC(
"Looking at link tuple: " << *link_tuple);
2194 "Link tuple ignored: "
2195 "GetMainAddress (link_tuple->neighborIfaceAddr) != msg.GetOriginatorAddress ()");
2197 << link_tuple->neighborIfaceAddr
2203 if (link_tuple->symTime < now)
2209 typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
2210 for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin();
2214 int neighborType = (linkMessage->linkCode >> 2) & 0x3;
2215 #ifdef NS3_LOG_ENABLE
2216 const char* neighborTypeNames[3] = {
"NOT_NEIGH",
"SYM_NEIGH",
"MPR_NEIGH"};
2217 const char* neighborTypeName =
2218 ((neighborType < 3) ? neighborTypeNames[neighborType] :
"(invalid value)");
2219 NS_LOG_DEBUG(
"Looking at Link Message from HELLO message: neighborType="
2220 << neighborType <<
" (" << neighborTypeName <<
")");
2223 for (std::vector<Ipv4Address>::const_iterator nb2hop_addr_iter =
2224 linkMessage->neighborInterfaceAddresses.begin();
2225 nb2hop_addr_iter != linkMessage->neighborInterfaceAddresses.end();
2229 NS_LOG_DEBUG(
"Looking at 2-hop neighbor address from HELLO message: "
2230 << *nb2hop_addr_iter <<
" (main address is " << nb2hop_addr <<
")");
2238 NS_LOG_LOGIC(
"Ignoring 2-hop neighbor (it is the node itself)");
2246 << (nb2hop_tuple ?
" (refreshing existing entry)" :
""));
2247 if (nb2hop_tuple ==
nullptr)
2274 "2-hop neighbor is NOT_NEIGH => deleting matching 2-hop neighbor state");
2279 NS_LOG_LOGIC(
"*** WARNING *** Ignoring link message (inside HELLO) with bad"
2280 " neighbor type value: "
2298 typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
2299 for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin();
2303 int nt = linkMessage->linkCode >> 2;
2306 NS_LOG_DEBUG(
"Processing a link message with neighbor type MPR_NEIGH");
2308 for (std::vector<Ipv4Address>::const_iterator nb_iface_addr =
2309 linkMessage->neighborInterfaceAddresses.begin();
2310 nb_iface_addr != linkMessage->neighborInterfaceAddresses.end();
2315 NS_LOG_DEBUG(
"Adding entry to mpr selector set for neighbor "
2321 if (existing_mprsel_tuple ==
nullptr)
2359 struct hdr_ip* ih = HDR_IP (p);
2360 struct hdr_cmn* ch = HDR_CMN (p);
2362 debug(
"%f: Node %d MAC Layer detects a breakage on link to %d\n",
2364 OLSR::node_id (ra_addr ()),
2365 OLSR::node_id (ch->next_hop ()));
2367 if ((uint32_t)ih->daddr () == IP_BROADCAST)
2369 drop (p, DROP_RTR_MAC_CALLBACK);
2373 OLSR_link_tuple* link_tuple = state_.find_link_tuple(ch->next_hop());
2378 nb_loss(link_tuple);
2380 drop(p, DROP_RTR_MAC_CALLBACK);
2443 <<
": OLSR Node " <<
m_mainAddress <<
" LinkTuple " << tuple <<
" REMOVED.");
2455 <<
": OLSR Node " <<
m_mainAddress <<
" LinkTuple " << tuple <<
" UPDATED.");
2459 if (nb_tuple ==
nullptr)
2465 if (nb_tuple !=
nullptr)
2467 int statusBefore = nb_tuple->
status;
2469 bool hasSymmetricLink =
false;
2472 for (LinkSet::const_iterator it = linkSet.begin(); it != linkSet.end(); it++)
2478 hasSymmetricLink =
true;
2483 if (hasSymmetricLink)
2486 NS_LOG_DEBUG(*nb_tuple <<
"->status = STATUS_SYM; changed:"
2487 <<
int(statusBefore != nb_tuple->
status));
2492 NS_LOG_DEBUG(*nb_tuple <<
"->status = STATUS_NOT_SYM; changed:"
2493 <<
int(statusBefore != nb_tuple->
status));
2498 NS_LOG_WARN(
"ERROR! Wanted to update a NeighborTuple but none was found!");
2674 NS_LOG_DEBUG(
"Not sending any TC, no one selected me as MPR.");
2695 NS_LOG_DEBUG(
"Not sending any HNA, no associations to advertise.");
2704 if (tuple ==
nullptr)
2729 if (tuple ==
nullptr)
2733 if (tuple->
time < now)
2737 else if (tuple->
symTime < now)
2751 neighborIfaceAddr));
2758 neighborIfaceAddr));
2768 if (tuple ==
nullptr)
2782 twoHopNeighborAddr));
2790 if (tuple ==
nullptr)
2811 if (tuple ==
nullptr)
2833 if (tuple ==
nullptr)
2856 if (tuple ==
nullptr)
2892 std::map<Ipv4Address, RoutingTableEntry>::const_iterator it =
m_table.find(dest);
2898 outEntry = it->second;
2932 if (!foundSendEntry)
2936 uint32_t interfaceIdx = entry2.
interface;
2937 if (oif &&
m_ipv4->GetInterfaceForDevice(oif) !=
static_cast<int>(interfaceIdx))
2944 <<
" Route interface " << interfaceIdx
2945 <<
" does not match requested output interface "
2946 <<
m_ipv4->GetInterfaceForDevice(oif));
2950 rtentry = Create<Ipv4Route>();
2956 uint32_t numOifAddresses =
m_ipv4->GetNAddresses(interfaceIdx);
2959 if (numOifAddresses == 1)
2961 ifAddr =
m_ipv4->GetAddress(interfaceIdx, 0);
2968 rtentry->SetSource(ifAddr.
GetLocal());
2969 rtentry->SetGateway(entry2.
nextAddr);
2970 rtentry->SetOutputDevice(
m_ipv4->GetNetDevice(interfaceIdx));
2975 NS_LOG_DEBUG(
"Found route to " << rtentry->GetDestination() <<
" via nh "
2976 << rtentry->GetGateway() <<
" with source addr "
2977 << rtentry->GetSource() <<
" and output dev "
2978 << rtentry->GetOutputDevice());
2988 NS_LOG_DEBUG(
"Found route to " << rtentry->GetDestination() <<
" via nh "
2989 << rtentry->GetGateway() <<
" with source addr "
2990 << rtentry->GetSource() <<
" and output dev "
2991 << rtentry->GetOutputDevice());
3027 uint32_t iif =
m_ipv4->GetInterfaceForDevice(idev);
3028 if (
m_ipv4->IsDestinationAddress(dst, iif))
3033 lcb(p, header, iif);
3056 if (!foundSendEntry)
3060 rtentry = Create<Ipv4Route>();
3062 uint32_t interfaceIdx = entry2.
interface;
3067 uint32_t numOifAddresses =
m_ipv4->GetNAddresses(interfaceIdx);
3070 if (numOifAddresses == 1)
3072 ifAddr =
m_ipv4->GetAddress(interfaceIdx, 0);
3079 rtentry->SetSource(ifAddr.
GetLocal());
3080 rtentry->SetGateway(entry2.
nextAddr);
3081 rtentry->SetOutputDevice(
m_ipv4->GetNetDevice(interfaceIdx));
3087 ucb(rtentry, p, header);
3092 NS_LOG_LOGIC(
"No dynamic route, check network routes");
3099 #ifdef NS3_LOG_ENABLE
3102 <<
" --> NOT FOUND; ** Dumping routing table...");
3104 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin();
3108 NS_LOG_DEBUG(
"dest=" << iter->first <<
" --> next=" << iter->second.nextAddr
3109 <<
" via interface " << iter->second.interface);
3171 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces(); i++)
3173 for (uint32_t j = 0; j <
m_ipv4->GetNAddresses(i); j++)
3175 if (
m_ipv4->GetAddress(i, j).GetLocal() == interfaceAddress)
3186 std::vector<RoutingTableEntry>
3189 std::vector<RoutingTableEntry> retval;
3190 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin();
3194 retval.push_back(iter->second);
3261 #ifdef NS3_LOG_ENABLE
3276 if (now < iter->expirationTime)
3282 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter =
m_table.begin();
3286 NS_LOG_DEBUG(
" dest=" << iter->first <<
" --> next=" << iter->second.nextAddr
3287 <<
" via interface " << iter->second.interface);
a polymophic address class
bool IsNull() const
Check for null implementation.
Hold variables of type enum.
void Track(EventId event)
Tracks a new event.
Ipv4Address GetIpv4() 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.
Ipv4Address GetSubnetDirectedBroadcast(const Ipv4Mask &mask) const
Generate subnet-directed broadcast address corresponding to mask.
static Ipv4Address GetAny()
a class to store IPv4 address information on an interface
Ipv4Address GetLocal() 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() 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.
Ipv4Address GetDestNetwork() const
uint32_t GetInterface() const
Ipv4Mask GetDestNetworkMask() 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,...
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
virtual void DoDispose()
Destructor implementation.
std::ostream * GetStream()
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.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
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.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
virtual int ShutdownSend()=0
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
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...
virtual int Close()=0
Close a socket.
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.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Unit
The unit to use to interpret a number representing time.
AttributeValue implementation for Time.
A simple virtual Timer class.
void SetDelay(const Time &delay)
void Schedule()
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()
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.
void SendHna()
Creates a new OLSR HNA message which is buffered for being sent later on.
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.
const MprSelectorSet & GetMprSelectors() const
Gets the MPR selectors.
void SendQueuedMessages()
Creates as many OLSR packets as needed in order to send all buffered OLSR messages.
uint16_t m_messageSequenceNumber
Messages sequence number counter.
bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) override
Route an input packet (to be forwarded or locally delivered)
const TwoHopNeighborSet & GetTwoHopNeighbors() const
Get the two hop neighbors.
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.
void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) override
void NotifyInterfaceUp(uint32_t interface) override
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.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_sendSockets
Container of sockets and the interfaces they are opened onto.
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 SendPacket(Ptr< Packet > packet, const MessageList &containedMessages)
Send an OLSR message.
Timer m_tcTimer
Timer for the TC message.
void AddHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Injects the specified (networkAddr, netmask) tuple in the list of local HNA associations to be sent b...
const NeighborSet & GetNeighbors() const
Get the one hop neighbors.
Ptr< Ipv4StaticRouting > m_hnaRoutingTable
Routing table for HNA routes.
void SendHello()
Creates a new OLSR HELLO message which is buffered for being sent later on.
void DoDispose() override
Destructor implementation.
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.
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...
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 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 (...
MprSet GetMprSet() const
Gets the MPR set.
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.
void HelloTimerExpire()
Sends a HELLO message and reschedules the HELLO timer.
void AssociationTupleTimerExpire(Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
Removes association tuple_ if expired.
static const uint16_t OLSR_PORT_NUMBER
port number (698)
uint32_t GetSize() const
Returns the routing table size.
void SetMainInterface(uint32_t interface)
Set the OLSR main address to the first address on the indicated interface.
void RoutingTableComputation()
Creates the routing table of the node following RFC 3626 hints.
void SendMid()
Creates a new OLSR MID message which is buffered for being sent later on.
void AddEntry(const Ipv4Address &dest, const Ipv4Address &next, uint32_t interface, uint32_t distance)
Adds a new entry into the routing table.
void HnaTimerExpire()
Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer.
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.
const TopologySet & GetTopologySet() const
Gets the topology set.
void SendTc()
Creates a new OLSR TC message which is buffered for being sent later on.
void DupTupleTimerExpire(Ipv4Address address, uint16_t sequenceNumber)
Removes tuple if expired.
Ipv4Address GetMainAddress(Ipv4Address iface_addr) const
Gets the main address associated with a given interface address.
Timer m_midTimer
Timer for the MID message.
EventGarbageCollector m_events
Running events.
void SetIpv4(Ptr< Ipv4 > ipv4) override
bool Lookup(const Ipv4Address &dest, RoutingTableEntry &outEntry) const
Looks up an entry for the specified destination address.
void ProcessMid(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a MID message following RFC 3626 specification.
Ptr< const Ipv4StaticRouting > GetRoutingTableAssociation() const
Returns the internal HNA table.
Timer m_queuedMessagesTimer
timer for throttling outgoing messages
uint16_t m_ansn
Advertised Neighbor Set sequence number.
void RemoveIfaceAssocTuple(const IfaceAssocTuple &tuple)
Removed an interface association tuple to the Interface Association Set.
void NotifyInterfaceDown(uint32_t interface) override
void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override
Time m_midInterval
MID messages' emission interval.
void Clear()
Clears the routing table and frees the memory assigned to each one of its entries.
void TopologyTupleTimerExpire(Ipv4Address destAddr, Ipv4Address lastAddr)
Removes topology tuple_ if expired.
void MprComputation()
Computates MPR set of a node following RFC 3626 hints.
void ProcessHello(const olsr::MessageHeader &msg, const Ipv4Address &receiverIface, const Ipv4Address &senderIface)
Processes a HELLO message following RFC 3626 specification.
static TypeId GetTypeId()
Get the type ID.
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...
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.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const override
Print the Routing Table entries.
~RoutingProtocol() override
int Degree(const NeighborTuple &tuple)
This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set.
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.
Ptr< Socket > m_recvSocket
Receiving socket.
uint16_t GetPacketSequenceNumber()
Increments packet sequence number and returns the new value.
void DoInitialize() override
Initialize() implementation.
TracedCallback< const PacketHeader &, const MessageList & > m_txPacketTrace
Tx packet trace.
void IncrementAnsn()
Increments the ANSN counter.
Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr) override
Query routing cache for an existing route, for an outbound packet.
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.
std::vector< RoutingTableEntry > GetRoutingTableEntries() const
Get the routing table entries.
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 TcTimerExpire()
Sends a TC message (if there exists any MPR selector) and reschedules the TC timer.
TracedCallback< const PacketHeader &, const MessageList & > m_rxPacketTrace
Rx packet trace.
void Dump()
Dump the neighbor table, two-hop neighbor table, and routing table to logging output (NS_LOG_DEBUG lo...
void MidTimerExpire()
Sends a MID message (if the node has more than one interface) and resets the MID timer.
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.
Ptr< Ipv4StaticRouting > m_routingTableAssociation
Associations from an Ipv4StaticRouting instance.
bool m_linkTupleTimerFirstTime
Flag to indicate if it is the first time the LinkTupleTimer fires.
const OlsrState & GetOlsrState() const
Gets the underlying OLSR state object.
uint16_t GetMessageSequenceNumber()
Increments message sequence number and returns the new value.
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.
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()
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.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
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.
#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.
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
Status status
Status of the link.
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.