31 #define NS_LOG_APPEND_CONTEXT                                   \ 
   32   if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId () << "] "; } 
   36 #include "ns3/socket-factory.h" 
   37 #include "ns3/udp-socket-factory.h" 
   38 #include "ns3/simulator.h" 
   40 #include "ns3/names.h" 
   41 #include "ns3/inet-socket-address.h" 
   42 #include "ns3/ipv4-routing-protocol.h" 
   43 #include "ns3/ipv4-routing-table-entry.h" 
   44 #include "ns3/ipv4-route.h" 
   45 #include "ns3/boolean.h" 
   46 #include "ns3/uinteger.h" 
   48 #include "ns3/trace-source-accessor.h" 
   49 #include "ns3/ipv4-header.h" 
   59 #define DELAY(time) (((time) < (Simulator::Now ())) ? Seconds (0.000001) : \ 
   60                      (time - Simulator::Now () + Seconds (0.000001))) 
   69 #define OLSR_REFRESH_INTERVAL   m_helloInterval 
   75 #define OLSR_NEIGHB_HOLD_TIME   Time (3 * OLSR_REFRESH_INTERVAL) 
   76 #define OLSR_TOP_HOLD_TIME      Time (3 * m_tcInterval) 
   78 #define OLSR_DUP_HOLD_TIME      Seconds (30) 
   80 #define OLSR_MID_HOLD_TIME      Time (3 * m_midInterval) 
   82 #define OLSR_HNA_HOLD_TIME      Time (3 * m_hnaInterval) 
   88 #define OLSR_UNSPEC_LINK        0 
   89 #define OLSR_ASYM_LINK          1 
   91 #define OLSR_SYM_LINK           2 
   93 #define OLSR_LOST_LINK          3 
   99 #define OLSR_NOT_NEIGH          0 
  100 #define OLSR_SYM_NEIGH          1 
  102 #define OLSR_MPR_NEIGH          2 
  109 #define OLSR_WILL_NEVER         0 
  110 #define OLSR_WILL_LOW           1 
  112 #define OLSR_WILL_DEFAULT       3 
  114 #define OLSR_WILL_HIGH          6 
  116 #define OLSR_WILL_ALWAYS        7 
  123 #define OLSR_MAXJITTER          (m_helloInterval.GetSeconds () / 4) 
  124 #define OLSR_MAX_SEQ_NUM        65535 
  126 #define JITTER (Seconds (m_uniformRandomVariable->GetValue (0, OLSR_MAXJITTER))) 
  130 #define OLSR_PORT_NUMBER 698 
  131 #define OLSR_MAX_MSGS           64 
  135 #define OLSR_MAX_HELLOS         12 
  138 #define OLSR_MAX_ADDRS          64 
  154   static TypeId tid = 
TypeId (
"ns3::olsr::RoutingProtocol")
 
  156     .SetGroupName (
"Olsr")
 
  158     .AddAttribute (
"HelloInterval", 
"HELLO messages emission interval.",
 
  162     .AddAttribute (
"TcInterval", 
"TC messages emission interval.",
 
  166     .AddAttribute (
"MidInterval", 
"MID messages emission interval.  Normally it is equal to TcInterval.",
 
  170     .AddAttribute (
"HnaInterval", 
"HNA messages emission interval.  Normally it is equal to TcInterval.",
 
  174     .AddAttribute (
"Willingness", 
"Willingness of a node to carry and forward traffic for other nodes.",
 
  182     .AddTraceSource (
"Rx", 
"Receive OLSR packet.",
 
  184                      "ns3::olsr::RoutingProtocol::PacketTxRxTracedCallback")
 
  185     .AddTraceSource (
"Tx", 
"Send OLSR packet.",
 
  187                      "ns3::olsr::RoutingProtocol::PacketTxRxTracedCallback")
 
  188     .AddTraceSource (
"RoutingTableChanged", 
"The OLSR routing table has changed.",
 
  190                      "ns3::olsr::RoutingProtocol::TableChangeTracedCallback")
 
  197   : m_routingTableAssociation (0),
 
  199     m_helloTimer (
Timer::CANCEL_ON_DESTROY),
 
  200     m_tcTimer (
Timer::CANCEL_ON_DESTROY),
 
  201     m_midTimer (
Timer::CANCEL_ON_DESTROY),
 
  202     m_hnaTimer (
Timer::CANCEL_ON_DESTROY),
 
  203     m_queuedMessagesTimer (
Timer::CANCEL_ON_DESTROY)
 
  246       iter->first->Close ();
 
  258   *os << 
"Node: " << 
m_ipv4->GetObject<
Node> ()->GetId ()
 
  260       << 
", Local time: " << GetObject<Node> ()->GetLocalTime ().As (
Time::S)
 
  261       << 
", OLSR Routing table" << std::endl;
 
  263   *os << 
"Destination\t\tNextHop\t\tInterface\tDistance\n";
 
  265   for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = 
m_table.begin ();
 
  266        iter != 
m_table.end (); iter++)
 
  268       *os << iter->first << 
"\t\t";
 
  269       *os << iter->second.nextAddr << 
"\t\t";
 
  276           *os << iter->second.interface << 
"\t\t";
 
  278       *os << iter->second.distance << 
"\t";
 
  285       *os << 
" HNA Routing Table: ";
 
  290       *os << 
" HNA Routing Table: empty" << std::endl;
 
  299       for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
 
  303           if (addr != loopback)
 
  317   bool canRunOlsr = 
false;
 
  318   for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
 
  321       if (addr == loopback)
 
  345       if (socket->
Bind (inetAddr))
 
  383   receivedPacket = socket->
RecvFrom (sourceAddress);
 
  390                              << senderIfaceAddr << 
" to " << receiverIfaceAddr);
 
  399   packet->RemoveHeader (olsrPacketHeader);
 
  408       if (packet->RemoveHeader (messageHeader) == 0)
 
  417       messages.push_back (messageHeader);
 
  422   for (MessageList::const_iterator messageIter = messages.begin ();
 
  423        messageIter != messages.end (); messageIter++)
 
  438       bool do_forwarding = 
true;
 
  455       if (duplicated == NULL)
 
  463               ProcessHello (messageHeader, receiverIfaceAddr, senderIfaceAddr);
 
  470               ProcessTc (messageHeader, senderIfaceAddr);
 
  494           NS_LOG_DEBUG (
"OLSR message is duplicated, not reading it.");
 
  498           for (std::vector<Ipv4Address>::const_iterator it = duplicated->
ifaceList.begin ();
 
  499                it != duplicated->
ifaceList.end (); it++)
 
  501               if (*it == receiverIfaceAddr)
 
  503                   do_forwarding = 
false;
 
  517                               receiverIfaceAddr, inetSourceAddr.
GetIpv4 ());
 
  544           if (nb_tuple == NULL)
 
  559   std::set<Ipv4Address> toRemove;
 
  560   for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
 
  562       if (twoHopNeigh->neighborMainAddr == neighborMainAddr)
 
  564           toRemove.insert (twoHopNeigh->twoHopNeighborAddr);
 
  568   for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); )
 
  570       if (toRemove.find (twoHopNeigh->twoHopNeighborAddr) != toRemove.end ())
 
  572           twoHopNeigh = N2.erase (twoHopNeigh);
 
  602           N.push_back (*neighbor);
 
  626       for (NeighborSet::const_iterator neigh = N.begin ();
 
  627            neigh != N.end (); neigh++)
 
  629           if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
 
  651       for (NeighborSet::const_iterator neigh = N.begin ();
 
  652            neigh != N.end (); neigh++)
 
  654           if (neigh->neighborMainAddr == twoHopNeigh->twoHopNeighborAddr)
 
  663           N2.push_back (*twoHopNeigh);
 
  667 #ifdef NS3_LOG_ENABLE 
  669     std::ostringstream os;
 
  671     for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
 
  672          iter != N2.end (); iter++)
 
  674         TwoHopNeighborSet::const_iterator next = iter;
 
  676         os << iter->neighborMainAddr << 
"->" << iter->twoHopNeighborAddr;
 
  677         if (next != N2.end ())
 
  683 #endif  //NS3_LOG_ENABLE 
  687   for (NeighborSet::const_iterator neighbor = N.begin (); neighbor != N.end (); neighbor++)
 
  691           mprSet.insert (neighbor->neighborMainAddr);
 
  703   std::set<Ipv4Address> coveredTwoHopNeighbors;
 
  704   for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
 
  708       for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin (); otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
 
  710           if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr
 
  711               && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr)
 
  719           NS_LOG_LOGIC (
"Neighbor " << twoHopNeigh->neighborMainAddr
 
  720                                     << 
" is the only that can reach 2-hop neigh. " 
  721                                     << twoHopNeigh->twoHopNeighborAddr
 
  722                                     << 
" => select as MPR.");
 
  724           mprSet.insert (twoHopNeigh->neighborMainAddr);
 
  727           for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin ();
 
  728                otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
 
  730               if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
 
  732                   coveredTwoHopNeighbors.insert (otherTwoHopNeigh->twoHopNeighborAddr);
 
  738   for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin ();
 
  739        twoHopNeigh != N2.end (); )
 
  741       if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ())
 
  745           NS_LOG_LOGIC (
"2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr << 
" is already covered by an MPR.");
 
  746           twoHopNeigh = N2.erase (twoHopNeigh);
 
  756   while (N2.begin () != N2.end ())
 
  759 #ifdef NS3_LOG_ENABLE 
  761         std::ostringstream os;
 
  763         for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
 
  764              iter != N2.end (); iter++)
 
  766             TwoHopNeighborSet::const_iterator next = iter;
 
  768             os << iter->neighborMainAddr << 
"->" << iter->twoHopNeighborAddr;
 
  769             if (next != N2.end ())
 
  775 #endif  //NS3_LOG_ENABLE 
  782       std::map<int, std::vector<const NeighborTuple *> > reachability;
 
  784       for (NeighborSet::iterator it = N.begin (); it != N.end (); it++)
 
  788           for (TwoHopNeighborSet::iterator it2 = N2.begin (); it2 != N2.end (); it2++)
 
  795           reachability[r].push_back (&nb_tuple);
 
  808       for (std::set<int>::iterator it = rs.begin (); it != rs.end (); it++)
 
  815           for (std::vector<const NeighborTuple *>::iterator it2 = reachability[r].begin ();
 
  816                it2 != reachability[r].end (); it2++)
 
  847           NS_LOG_LOGIC (N2.size () << 
" 2-hop neighbors left to cover!");
 
  851 #ifdef NS3_LOG_ENABLE 
  853     std::ostringstream os;
 
  855     for (MprSet::const_iterator iter = mprSet.begin ();
 
  856          iter != mprSet.end (); iter++)
 
  858         MprSet::const_iterator next = iter;
 
  861         if (next != mprSet.end ())
 
  867 #endif  //NS3_LOG_ENABLE 
  897                                                 << 
": RoutingTableComputation begin...");
 
  905   for (NeighborSet::const_iterator it = neighborSet.begin ();
 
  906        it != neighborSet.end (); it++)
 
  909       NS_LOG_DEBUG (
"Looking at neighbor tuple: " << nb_tuple);
 
  912           bool nb_main_addr = 
false;
 
  915           for (LinkSet::const_iterator it2 = linkSet.begin ();
 
  916                it2 != linkSet.end (); it2++)
 
  925                                                                << 
" => adding routing table entry to neighbor");
 
  954           if (!nb_main_addr && lt != NULL)
 
  956               NS_LOG_LOGIC (
"no R_dest_addr is equal to the main address of the neighbor " 
  957                             "=> adding additional routing entry");
 
  972   for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin ();
 
  973        it != twoHopNeighbors.end (); it++)
 
  977       NS_LOG_LOGIC (
"Looking at two-hop neighbor tuple: " << nb2hop_tuple);
 
  982           NS_LOG_LOGIC (
"Two-hop neighbor tuple is also neighbor; skipped.");
 
  995       bool nb2hopOk = 
false;
 
  996       for (NeighborSet::const_iterator neighbor = neighborSet.begin ();
 
  997            neighbor != neighborSet.end (); neighbor++)
 
 1008           NS_LOG_LOGIC (
"Two-hop neighbor tuple skipped: 2-hop neighbor " 
 1011                         << 
", which was not found in the Neighbor Set.");
 
 1030           NS_LOG_LOGIC (
"Adding routing entry for two-hop neighbor.");
 
 1038           NS_LOG_LOGIC (
"NOT adding routing entry for two-hop neighbor (" 
 1040                         << 
" not found in the routing table)");
 
 1044   for (uint32_t h = 2;; h++)
 
 1055       for (TopologySet::const_iterator it = topology.begin ();
 
 1056            it != topology.end (); it++)
 
 1059           NS_LOG_LOGIC (
"Looking at topology tuple: " << topology_tuple);
 
 1062           bool have_destAddrEntry = 
Lookup (topology_tuple.
destAddr, destAddrEntry);
 
 1063           bool have_lastAddrEntry = 
Lookup (topology_tuple.
lastAddr, lastAddrEntry);
 
 1064           if (!have_destAddrEntry && have_lastAddrEntry && lastAddrEntry.
distance == h)
 
 1066               NS_LOG_LOGIC (
"Adding routing table entry based on the topology tuple.");
 
 1085               NS_LOG_LOGIC (
"NOT adding routing table entry based on the topology tuple: " 
 1086                             "have_destAddrEntry=" << have_destAddrEntry
 
 1087                                                   << 
" have_lastAddrEntry=" << have_lastAddrEntry
 
 1088                                                   << 
" lastAddrEntry.distance=" << (
int) lastAddrEntry.
distance 
 1089                                                   << 
" (h=" << h << 
")");
 
 1103   for (IfaceAssocSet::const_iterator it = ifaceAssocSet.begin ();
 
 1104        it != ifaceAssocSet.end (); it++)
 
 1110       if (have_entry1 && !have_entry2)
 
 1138   for (AssociationSet::const_iterator it = associationSet.begin ();
 
 1139        it != associationSet.end (); it++)
 
 1146       bool goToNextAssociationTuple = 
false;
 
 1148       NS_LOG_DEBUG (
"Nb local associations: " << localHnaAssociations.size ());
 
 1149       for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
 
 1150            assocIterator != localHnaAssociations.end (); assocIterator++)
 
 1152           Association const &localHnaAssoc = *assocIterator;
 
 1155               NS_LOG_DEBUG (
"HNA association received from another GW is part of local HNA associations: no route added for network " 
 1157               goToNextAssociationTuple = 
true;
 
 1160       if (goToNextAssociationTuple)
 
 1168       bool addRoute = 
false;
 
 1170       uint32_t routeIndex = 0;
 
 1172       for (routeIndex = 0; routeIndex < 
m_hnaRoutingTable->GetNRoutes (); routeIndex++)
 
 1192       if(addRoute && gatewayEntryExists)
 
 1227   LinkSensing (msg, hello, receiverIface, senderIface);
 
 1229 #ifdef NS3_LOG_ENABLE 
 1233                   << 
"s ** BEGIN dump Link Set for OLSR Node " << 
m_mainAddress);
 
 1234     for (LinkSet::const_iterator link = links.begin (); link != links.end (); link++)
 
 1242                   << 
"s ** BEGIN dump Neighbor Set for OLSR Node " << 
m_mainAddress);
 
 1243     for (NeighborSet::const_iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++)
 
 1249 #endif // NS3_LOG_ENABLE 
 1254 #ifdef NS3_LOG_ENABLE 
 1258                   << 
"s ** BEGIN dump TwoHopNeighbor Set for OLSR Node " << 
m_mainAddress);
 
 1259     for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin ();
 
 1260          tuple != twoHopNeighbors.end (); tuple++)
 
 1266 #endif // NS3_LOG_ENABLE 
 1291   if (link_tuple == NULL)
 
 1301   if (topologyTuple != NULL)
 
 1312   for (std::vector<Ipv4Address>::const_iterator i = tc.
neighborAddresses.begin ();
 
 1324       if (topologyTuple != NULL)
 
 1352 #ifdef NS3_LOG_ENABLE 
 1356                   << 
"s ** BEGIN dump TopologySet for OLSR Node " << 
m_mainAddress);
 
 1357     for (TopologySet::const_iterator tuple = topology.begin ();
 
 1358          tuple != topology.end (); tuple++)
 
 1364 #endif // NS3_LOG_ENABLE 
 1387   if (linkTuple == NULL)
 
 1390                     ": the sender interface of this message is not in the " 
 1391                     "symmetric 1-hop neighborhood of this node," 
 1392                     " the message MUST be discarded.");
 
 1400       bool updated = 
false;
 
 1402       for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin ();
 
 1403            tuple != ifaceAssoc.end (); tuple++)
 
 1405           if (tuple->ifaceAddr == *i
 
 1409               tuple->time = now + msg.
GetVTime ();
 
 1431   for (NeighborSet::iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++)
 
 1433       neighbor->neighborMainAddr = 
GetMainAddress (neighbor->neighborMainAddr);
 
 1437   for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin ();
 
 1438        twoHopNeighbor != twoHopNeighbors.end (); twoHopNeighbor++)
 
 1440       twoHopNeighbor->neighborMainAddr = 
GetMainAddress (twoHopNeighbor->neighborMainAddr);
 
 1441       twoHopNeighbor->twoHopNeighborAddr = 
GetMainAddress (twoHopNeighbor->twoHopNeighborAddr);
 
 1466   if (link_tuple == NULL)
 
 1472   for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it = hna.
associations.begin ();
 
 1534   if (linkTuple == NULL)
 
 1549   bool retransmitted = 
false;
 
 1554       if (mprselTuple != NULL)
 
 1561           retransmitted = 
true;
 
 1566   if (duplicated != NULL)
 
 1570       duplicated->
ifaceList.push_back (localIface);
 
 1580       newDup.
ifaceList.push_back (localIface);
 
 1644   int numMessages = 0;
 
 1650   for (std::vector<olsr::MessageHeader>::const_iterator message = 
m_queuedMessages.begin ();
 
 1657       msglist.push_back (*message);
 
 1664           packet = Create<Packet> ();
 
 1697   std::vector<olsr::MessageHeader::Hello::LinkMessage>
 
 1701   for (LinkSet::const_iterator link_tuple = links.begin ();
 
 1702        link_tuple != links.end (); link_tuple++)
 
 1705             && link_tuple->time >= now))
 
 1710       uint8_t link_type, nb_type = 0xff;
 
 1713       if (link_tuple->symTime >= now)
 
 1717       else if (link_tuple->asymTime >= now)
 
 1730                                                << 
" to be MPR_NEIGH.");
 
 1739               if (nb_tuple->neighborMainAddr == 
GetMainAddress (link_tuple->neighborIfaceAddr))
 
 1744                                                            << 
" to be SYM_NEIGH.");
 
 1751                                                            << 
" to be NOT_NEIGH.");
 
 1755                       NS_FATAL_ERROR (
"There is a neighbor tuple with an unknown status!\n");
 
 1769       linkMessage.
linkCode = (link_type & 0x03) | ((nb_type << 2) & 0x0f);
 
 1771         (link_tuple->neighborIfaceAddr);
 
 1778         interfaces.begin (), interfaces.end ());
 
 1780       linkMessages.push_back (linkMessage);
 
 1783                                             << 
" (with " << 
int (linkMessages.size ()) << 
" link messages)");
 
 1840   for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
 
 1874   std::vector<olsr::MessageHeader::Hna::Association> &associations = hna.
associations;
 
 1878   for (Associations::const_iterator it = localHnaAssociations.begin ();
 
 1879        it != localHnaAssociations.end (); it++)
 
 1882       associations.push_back (assoc);
 
 1885   if (associations.size () == 0)
 
 1905   for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
 
 1906        assocIterator != localHnaAssociations.end (); assocIterator++)
 
 1908       Association const &localHnaAssoc = *assocIterator;
 
 1911           NS_LOG_INFO (
"HNA association for network " << networkAddr << 
"/" << netmask << 
" already exists.");
 
 1916   NS_LOG_INFO (
"Adding HNA association for network " << networkAddr << 
"/" << netmask << 
".");
 
 1928   NS_LOG_INFO (
"Removing HNA association for network " << networkAddr << 
"/" << netmask << 
".");
 
 1949       NS_LOG_INFO (
"Removing HNA entries coming from the old routing table association.");
 
 1968   NS_LOG_DEBUG (
"Nb local associations before adding some entries from" 
 1983   NS_LOG_DEBUG (
"Nb local associations after having added some entries from " 
 2011   bool updated = 
false;
 
 2012   bool created = 
false;
 
 2014                     << 
": LinkSensing(receiverIface=" << receiverIface
 
 2015                     << 
", senderIface=" << senderIface << 
") BEGIN");
 
 2019   if (link_tuple == NULL)
 
 2029       NS_LOG_LOGIC (
"Existing link tuple did not exist => creating new one");
 
 2033       NS_LOG_LOGIC (
"Existing link tuple already exists => will update it");
 
 2037   link_tuple->asymTime = now + msg.
GetVTime ();
 
 2038   for (std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator linkMessage =
 
 2043       int lt = linkMessage->linkCode & 0x03; 
 
 2044       int nt = (linkMessage->linkCode >> 2) & 0x03; 
 
 2046 #ifdef NS3_LOG_ENABLE 
 2047       const char *linkTypeName;
 
 2059       const char *neighborTypeName;
 
 2065         default: neighborTypeName = 
"(invalid value!)";
 
 2068       NS_LOG_DEBUG (
"Looking at HELLO link messages with Link Type " 
 2069                     << lt << 
" (" << linkTypeName
 
 2070                     << 
") and Neighbor Type " << nt
 
 2071                     << 
" (" << neighborTypeName << 
")");
 
 2072 #endif // NS3_LOG_ENABLE 
 2079           NS_LOG_LOGIC (
"HELLO link code is invalid => IGNORING");
 
 2083       for (std::vector<Ipv4Address>::const_iterator neighIfaceAddr =
 
 2084              linkMessage->neighborInterfaceAddresses.begin ();
 
 2085            neighIfaceAddr != linkMessage->neighborInterfaceAddresses.end ();
 
 2089           if (*neighIfaceAddr == receiverIface)
 
 2094                   link_tuple->symTime = now - 
Seconds (1);
 
 2099                   NS_LOG_DEBUG (*link_tuple << 
": link is SYM or ASYM => should become SYM now" 
 2100                                 " (symTime being increased to " << now + msg.
GetVTime ());
 
 2101                   link_tuple->symTime = now + msg.
GetVTime ();
 
 2113               NS_LOG_DEBUG (
"     \\-> *neighIfaceAddr (" << *neighIfaceAddr
 
 2114                                                           << 
" != receiverIface (" << receiverIface << 
") => IGNORING!");
 
 2117       NS_LOG_DEBUG (
"Link tuple updated: " << 
int (updated));
 
 2119   link_tuple->time = std::max (link_tuple->time, link_tuple->asymTime);
 
 2132                                            link_tuple->neighborIfaceAddr));
 
 2135                     << 
": LinkSensing END");
 
 2146   if (nb_tuple != NULL)
 
 2164   for (LinkSet::const_iterator link_tuple = 
m_state.
GetLinks ().begin ();
 
 2167       NS_LOG_LOGIC (
"Looking at link tuple: " << *link_tuple);
 
 2171                         "GetMainAddress (link_tuple->neighborIfaceAddr) != msg.GetOriginatorAddress ()");
 
 2172           NS_LOG_LOGIC (
"(GetMainAddress(" << link_tuple->neighborIfaceAddr << 
"): " 
 2178       if (link_tuple->symTime < now)
 
 2184       typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
 
 2185       for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin ();
 
 2186            linkMessage != hello.
linkMessages.end (); linkMessage++)
 
 2188           int neighborType = (linkMessage->linkCode >> 2) & 0x3;
 
 2189 #ifdef NS3_LOG_ENABLE 
 2190           const char *neighborTypeNames[3] = { 
"NOT_NEIGH", 
"SYM_NEIGH", 
"MPR_NEIGH" };
 
 2191           const char *neighborTypeName = ((neighborType < 3) ?
 
 2192                                           neighborTypeNames[neighborType]
 
 2193                                           : 
"(invalid value)");
 
 2194           NS_LOG_DEBUG (
"Looking at Link Message from HELLO message: neighborType=" 
 2195                         << neighborType << 
" (" << neighborTypeName << 
")");
 
 2196 #endif // NS3_LOG_ENABLE 
 2198           for (std::vector<Ipv4Address>::const_iterator nb2hop_addr_iter =
 
 2199                  linkMessage->neighborInterfaceAddresses.begin ();
 
 2200                nb2hop_addr_iter != linkMessage->neighborInterfaceAddresses.end ();
 
 2204               NS_LOG_DEBUG (
"Looking at 2-hop neighbor address from HELLO message: " 
 2205                             << *nb2hop_addr_iter
 
 2206                             << 
" (main address is " << nb2hop_addr << 
")");
 
 2214                       NS_LOG_LOGIC (
"Ignoring 2-hop neighbor (it is the node itself)");
 
 2222                                 << (nb2hop_tuple ? 
" (refreshing existing entry)" : 
""));
 
 2223                   if (nb2hop_tuple == NULL)
 
 2248                   NS_LOG_LOGIC (
"2-hop neighbor is NOT_NEIGH => deleting matching 2-hop neighbor state");
 
 2253                   NS_LOG_LOGIC (
"*** WARNING *** Ignoring link message (inside HELLO) with bad" 
 2254                                 " neighbor type value: " << neighborType);
 
 2276   typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
 
 2277   for (LinkMessageVec::const_iterator linkMessage = hello.
linkMessages.begin ();
 
 2281       int nt = linkMessage->linkCode >> 2;
 
 2284           NS_LOG_DEBUG (
"Processing a link message with neighbor type MPR_NEIGH");
 
 2286           for (std::vector<Ipv4Address>::const_iterator nb_iface_addr =
 
 2287                  linkMessage->neighborInterfaceAddresses.begin ();
 
 2288                nb_iface_addr != linkMessage->neighborInterfaceAddresses.end ();
 
 2293                   NS_LOG_DEBUG (
"Adding entry to mpr selector set for neighbor " << *nb_iface_addr);
 
 2298                   if (existing_mprsel_tuple == NULL)
 
 2335   struct hdr_ip* ih       = HDR_IP (p);
 
 2336   struct hdr_cmn* ch      = HDR_CMN (p);
 
 2338   debug (
"%f: Node %d MAC Layer detects a breakage on link to %d\n",
 
 2340          OLSR::node_id (ra_addr ()),
 
 2341          OLSR::node_id (ch->next_hop ()));
 
 2343   if ((u_int32_t)ih->daddr () == IP_BROADCAST) {
 
 2344       drop (p, DROP_RTR_MAC_CALLBACK);
 
 2348   OLSR_link_tuple* link_tuple = state_.find_link_tuple (ch->next_hop ());
 
 2349   if (link_tuple != NULL) {
 
 2352       nb_loss (link_tuple);
 
 2354   drop (p, DROP_RTR_MAC_CALLBACK);
 
 2444                 << 
" LinkTuple " << tuple << 
" REMOVED.");
 
 2463                 << 
" LinkTuple " << tuple << 
" UPDATED.");
 
 2468   if (nb_tuple == NULL)
 
 2474   if (nb_tuple != NULL)
 
 2476       int statusBefore = nb_tuple->
status;
 
 2478       bool hasSymmetricLink = 
false;
 
 2481       for (LinkSet::const_iterator it = linkSet.begin ();
 
 2482            it != linkSet.end (); it++)
 
 2488               hasSymmetricLink = 
true;
 
 2493       if (hasSymmetricLink)
 
 2496           NS_LOG_DEBUG (*nb_tuple << 
"->status = STATUS_SYM; changed:" 
 2497                                   << 
int (statusBefore != nb_tuple->
status));
 
 2502           NS_LOG_DEBUG (*nb_tuple << 
"->status = STATUS_NOT_SYM; changed:" 
 2503                                   << 
int (statusBefore != nb_tuple->
status));
 
 2508       NS_LOG_WARN (
"ERROR! Wanted to update a NeighborTuple but none was found!");
 
 2758       NS_LOG_DEBUG (
"Not sending any TC, no one selected me as MPR.");
 
 2786       NS_LOG_DEBUG (
"Not sending any HNA, no associations to advertise.");
 
 2815                                            address, sequenceNumber));
 
 2841   if (tuple->
time < now)
 
 2845   else if (tuple->
symTime < now)
 
 2854                                            neighborIfaceAddr));
 
 2860                                            neighborIfaceAddr));
 
 2888                                            this, neighborMainAddr, twoHopNeighborAddr));
 
 2989                                            this, gatewayAddr, networkAddr, netmask));
 
 3024   std::map<Ipv4Address, RoutingTableEntry>::const_iterator it =
 
 3029   outEntry = it->second;
 
 3073       if (!foundSendEntry)
 
 3077       uint32_t interfaceIdx = entry2.
interface;
 
 3078       if (oif && 
m_ipv4->GetInterfaceForDevice (oif) != 
static_cast<int> (interfaceIdx))
 
 3085                                      << 
" Route interface " << interfaceIdx
 
 3086                                      << 
" does not match requested output interface " 
 3087                                      << 
m_ipv4->GetInterfaceForDevice (oif));
 
 3091       rtentry = Create<Ipv4Route> ();
 
 3097       uint32_t numOifAddresses = 
m_ipv4->GetNAddresses (interfaceIdx);
 
 3100       if (numOifAddresses == 1) {
 
 3101           ifAddr = 
m_ipv4->GetAddress (interfaceIdx, 0);
 
 3104           NS_FATAL_ERROR (
"XXX Not implemented yet:  IP aliasing and OLSR");
 
 3106       rtentry->SetSource (ifAddr.
GetLocal ());
 
 3107       rtentry->SetGateway (entry2.
nextAddr);
 
 3108       rtentry->SetOutputDevice (
m_ipv4->GetNetDevice (interfaceIdx));
 
 3112                                  << 
" --> nextHop=" << entry2.
nextAddr 
 3114       NS_LOG_DEBUG (
"Found route to " << rtentry->GetDestination () << 
" via nh " << rtentry->GetGateway () << 
" with source addr " << rtentry->GetSource () << 
" and output dev " << rtentry->GetOutputDevice ());
 
 3124           NS_LOG_DEBUG (
"Found route to " << rtentry->GetDestination () << 
" via nh " << rtentry->GetGateway () << 
" with source addr " << rtentry->GetSource () << 
" and output dev " << rtentry->GetOutputDevice ());
 
 3132                                  << 
" No route to host");
 
 3156   uint32_t iif = 
m_ipv4->GetInterfaceForDevice (idev);
 
 3157   if (
m_ipv4->IsDestinationAddress (dst, iif))
 
 3162           lcb (p, header, iif);
 
 3182       if (!foundSendEntry)
 
 3184       rtentry = Create<Ipv4Route> ();
 
 3186       uint32_t interfaceIdx = entry2.
interface;
 
 3191       uint32_t numOifAddresses = 
m_ipv4->GetNAddresses (interfaceIdx);
 
 3194       if (numOifAddresses == 1) {
 
 3195           ifAddr = 
m_ipv4->GetAddress (interfaceIdx, 0);
 
 3198           NS_FATAL_ERROR (
"XXX Not implemented yet:  IP aliasing and OLSR");
 
 3206                                  << 
" --> nextHop=" << entry2.
nextAddr 
 3209       ucb (rtentry, p, header);
 
 3221 #ifdef NS3_LOG_ENABLE 
 3224                                      << 
" --> NOT FOUND; ** Dumping routing table...");
 
 3226           for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = 
m_table.begin ();
 
 3227                iter != 
m_table.end (); iter++)
 
 3229               NS_LOG_DEBUG (
"dest=" << iter->first << 
" --> next=" << iter->second.nextAddr
 
 3230                                     << 
" via interface " << iter->second.interface);
 
 3234 #endif // NS3_LOG_ENABLE 
 3295   for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
 
 3297       for (uint32_t j = 0; j < 
m_ipv4->GetNAddresses (i); j++)
 
 3299           if (
m_ipv4->GetAddress (i,j).GetLocal () == interfaceAddress)
 
 3301               AddEntry (dest, next, i, distance);
 
 3307   AddEntry (dest, next, 0, distance);
 
 3311 std::vector<RoutingTableEntry>
 
 3314   std::vector<RoutingTableEntry> retval;
 
 3315   for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = 
m_table.begin ();
 
 3316        iter != 
m_table.end (); iter++)
 
 3318       retval.push_back (iter->second);
 
 3349 #ifdef NS3_LOG_ENABLE 
 3362       if (now < iter->expirationTime)
 
 3368   for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = 
m_table.begin (); iter != 
m_table.end (); iter++)
 
 3370       NS_LOG_DEBUG (
"  dest=" << iter->first << 
" --> next=" << iter->second.nextAddr << 
" via interface " << iter->second.interface);
 
 3373 #endif  //NS3_LOG_ENABLE 
std::vector< TopologyTuple > TopologySet
Topology Set type. 
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr. 
static TypeId GetTypeId(void)
Get the type ID. 
std::set< uint32_t > m_interfaceExclusions
const MprSelectorSet & GetMprSelectors() const 
#define JITTER
Random number between [0-OLSR_MAXJITTER] used to jitter OLSR packet transmission. ...
An OLSR's routing table entry. 
uint32_t distance
Distance in hops to the destination. 
#define OLSR_MPR_NEIGH
Asymmetric neighbor type. 
Simulation virtual time values and global simulation resolution. 
IfaceAssocSet & GetIfaceAssocSetMutable()
void HelloTimerExpire()
Sends a HELLO message and reschedules the HELLO timer. 
void AddTopologyTuple(const TopologyTuple &tuple)
Adds a topology tuple to the Topology Set. 
Ipv4Address GetIpv4(void) const 
#define OLSR_MAX_SEQ_NUM
Maximum allowed sequence number. 
Smart pointer class similar to boost::intrusive_ptr. 
void DoDispose()
Destructor implementation. 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream. 
TwoHopNeighborTuple * FindTwoHopNeighborTuple(const Ipv4Address &neighbor, const Ipv4Address &twoHopNeighbor)
SocketErrno
Enumeration of the possible errors returned by a socket. 
void IfaceAssocTupleTimerExpire(Ipv4Address ifaceAddr)
Removes tuple_ if expired. 
uint16_t sequenceNumber
Sequence number. 
void RemoveMprSelectorTuple(const MprSelectorTuple &tuple)
Removes an MPR selector tuple from the MPR Selector Set. 
#define OLSR_WILL_DEFAULT
Willingness for forwarding packets from other nodes: medium. 
uint16_t GetPacketSequenceNumber()
Increments packet sequence number and returns the new value. 
std::vector< Association > Associations
Association Set type. 
Time m_midInterval
MID messages' emission interval. 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
#define OLSR_DUP_HOLD_TIME
Dup holding time. 
void EraseMprSelectorTuples(const Ipv4Address &mainAddr)
void Clear()
Clears the routing table and frees the memory assigned to each one of its entries. 
Ipv4Address GetLocal(void) const 
Get the local address. 
uint16_t m_messageSequenceNumber
Messages sequence number counter. 
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed. 
void InsertAssociationTuple(const AssociationTuple &tuple)
const Associations & GetAssociations() const 
Ipv4Address destAddr
Address of the destination node. 
a class to represent an Ipv4 address mask 
const NeighborTuple * FindSymNeighborTuple(const Ipv4Address &mainAddr) const 
std::string PrintMprSelectorSet() const 
void HnaTimerExpire()
Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer...
#define OLSR_TOP_HOLD_TIME
Top holding time. 
void LinkTupleUpdated(const LinkTuple &tuple, uint8_t willingness)
This function is invoked when a link tuple is updated. 
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void InsertNeighborTuple(const NeighborTuple &tuple)
std::vector< Ipv4Address > FindNeighborInterfaces(const Ipv4Address &neighborMainAddr) const 
void LinkSensing(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello, const Ipv4Address &receiverIface, const Ipv4Address &sender_iface)
Updates Link Set according to a new received HELLO message (following RFC 3626 specification). 
uint16_t m_ansn
Advertised Neighbor Set sequence number. 
bool IsNull(void) const 
Check for null implementation. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Ipv4Address GetDestNetwork(void) const 
#define OLSR_WILL_ALWAYS
Willingness for forwarding packets from other nodes: always. 
void SetMprSet(MprSet mprSet)
MprSet is set by routing protocol after MprCompute. 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
void AddEntry(const Ipv4Address &dest, const Ipv4Address &next, uint32_t interface, uint32_t distance)
Adds a new entry into the routing table. 
bool m_linkTupleTimerFirstTime
uint32_t GetSize(void) const 
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
virtual void NotifyInterfaceUp(uint32_t interface)
void SendTc()
Creates a new OLSR TC message which is buffered for being sent later on. 
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void DupTupleTimerExpire(Ipv4Address address, uint16_t sequenceNumber)
Removes tuple if expired. 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
bool FindMprAddress(const Ipv4Address &address)
Time time
Time at which this tuple expires and must be removed. 
enum ns3::olsr::NeighborTuple::Status status
Timer m_queuedMessagesTimer
virtual void DoDispose(void)
Destructor implementation. 
void InsertMprSelectorTuple(const MprSelectorTuple &tuple)
void AddHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Inject Association to be sent in HNA message. 
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
Ipv4Address m_mainAddress
Time expirationTime
Time at which this tuple expires and must be removed. 
NeighborTuple * FindNeighborTuple(const Ipv4Address &mainAddr)
#define OLSR_WILL_LOW
Willingness for forwarding packets from other nodes: low. 
void LinkTupleTimerExpire(Ipv4Address neighborIfaceAddr)
Removes tuple_ if expired. 
void EraseIfaceAssocTuple(const IfaceAssocTuple &tuple)
void SetMainInterface(uint32_t interface)
Set the OLSR main address to the first address on the indicated interface. 
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr. 
void Nb2hopTupleTimerExpire(Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr)
Removes tuple_ if expired. 
void RemoveAssociationTuple(const AssociationTuple &tuple)
Removes a host network association tuple from the Association Set. 
void ProcessTc(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a TC message following RFC 3626 specification. 
Ipv4Address GetSubnetDirectedBroadcast(Ipv4Mask const &mask) const 
Generate subnet-directed broadcast address corresponding to mask. 
#define OLSR_NEIGHB_HOLD_TIME
Neighbor holding time. 
LinkTuple * FindSymLinkTuple(const Ipv4Address &ifaceAddr, Time time)
a polymophic address class 
LinkTuple * FindLinkTuple(const Ipv4Address &ifaceAddr)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source. 
bool IsRunning(void) const 
void EraseDuplicateTuple(const DuplicateTuple &tuple)
void EraseTopologyTuple(const TopologyTuple &tuple)
void MprSelTupleTimerExpire(Ipv4Address mainAddr)
Removes tuple_ if expired. 
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. 
#define OLSR_SYM_LINK
Symmetric link type. 
void SetSource(Ipv4Address src)
std::map< Ipv4Address, RoutingTableEntry > m_table
Data structure for the routing table. 
TracedCallback< const PacketHeader &, const MessageList & > m_rxPacketTrace
void RemoveIfaceAssocTuple(const IfaceAssocTuple &tuple)
Removes an interface association tuple from the Interface Association Set. 
uint32_t GetInterface(void) const 
EventGarbageCollector m_events
double GetSeconds(void) const 
Get an approximation of the time stored in this instance in the indicated unit. 
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet. 
virtual ~RoutingProtocol()
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination. 
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting. 
uint8_t m_willingness
Willingness for forwarding packets on behalf of other nodes. 
void PopulateNeighborSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the Neighbor Set according to the information contained in a new received HELLO message (foll...
Time expirationTime
Time at which this tuple expires and must be removed. 
void EraseOlderTopologyTuples(const Ipv4Address &lastAddr, uint16_t ansn)
void RemoveHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask netmask)
Removes Association sent in HNA message. 
Hold variables of type enum. 
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay. 
const TopologySet & GetTopologySet() const 
Ipv4Address mainAddr
Main address of the node. 
TopologyTuple * FindTopologyTuple(const Ipv4Address &destAddr, const Ipv4Address &lastAddr)
void AddIfaceAssocTuple(const IfaceAssocTuple &tuple)
Adds an interface association tuple to the Interface Association Set. 
void QueueMessage(const olsr::MessageHeader &message, Time delay)
Enques an OLSR message which will be sent with a delay of (0, delay]. 
AttributeValue implementation for Time. 
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR. 
void SendPacket(Ptr< Packet > packet, const MessageList &containedMessages)
void Schedule(void)
Schedule a new event using the currently-configured delay, function, and arguments. 
const AssociationSet & GetAssociationSet() const 
void SetGateway(Ipv4Address gw)
OLSR routing protocol for IPv4. 
void ProcessHello(const olsr::MessageHeader &msg, const Ipv4Address &receiverIface, const Ipv4Address &senderIface)
Processes a HELLO message following RFC 3626 specification. 
#define DELAY(time)
Gets the delay between a given time and the current time. 
IfaceAssocTuple * FindIfaceAssocTuple(const Ipv4Address &ifaceAddr)
void AddAssociationTuple(const AssociationTuple &tuple)
Adds a host network association tuple to the Association Set. 
Ptr< Ipv4StaticRouting > m_hnaRoutingTable
Time expirationTime
Time at which this tuple expires and must be removed. 
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered) 
void MprComputation()
Computates MPR set of a node following RFC 3626 hints. 
void InsertDuplicateTuple(const DuplicateTuple &tuple)
std::vector< LinkTuple > LinkSet
Link Set type. 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void RemoveDuplicateTuple(const DuplicateTuple &tuple)
Removes a duplicate tuple from the Duplicate Set. 
Time symTime
The link is considered bidirectional until this time. 
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read. 
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
void EraseLinkTuple(const LinkTuple &tuple)
void CoverTwoHopNeighbors(Ipv4Address neighborMainAddr, TwoHopNeighborSet &N2)
Remove all covered 2-hop neighbors from N2 set. 
Time m_helloInterval
HELLO messages' emission interval. 
void SetDelay(const Time &delay)
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC. 
#define OLSR_UNSPEC_LINK
Unspecified link type. 
#define OLSR_NOT_NEIGH
Not neighbor type. 
#define OLSR_ASYM_LINK
Asymmetric link type. 
void SetRoutingTableAssociation(Ptr< Ipv4StaticRouting > routingTable)
Inject Associations from an Ipv4StaticRouting instance. 
Ipv4Address destAddr
Main address of the destination. 
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type. 
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketAddresses
AssociationTuple * FindAssociationTuple(const Ipv4Address &gatewayAddr, const Ipv4Address &networkAddr, const Ipv4Mask &netmask)
void TopologyTupleTimerExpire(Ipv4Address destAddr, Ipv4Address lastAddr)
Removes tuple_ if expired. 
Time m_tcInterval
TC messages' emission interval. 
void AddTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set. 
void AssociationTupleTimerExpire(Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
Removes tuple_ if expired. 
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const 
Print the Routing Table entries. 
void NeighborLoss(const LinkTuple &tuple)
Performs all actions needed when a neighbor loss occurs. 
void RemoveTopologyTuple(const TopologyTuple &tuple)
Removes a topology tuple from the Topology Set. 
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes...
Time expirationTime
Time at which this tuple expires and must be removed. 
void SendMid()
Creates a new OLSR MID message which is buffered for being sent later on. 
void InsertIfaceAssocTuple(const IfaceAssocTuple &tuple)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address. 
void RecvOlsr(Ptr< Socket > socket)
Ipv4Address neighborMainAddr
Main address of a neighbor node. 
const NeighborSet & GetNeighbors() const 
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr. 
static TypeId GetTypeId(void)
void MidTimerExpire()
Sends a MID message (if the node has more than one interface) and resets the MID timer. 
Ptr< Ipv4StaticRouting > m_routingTableAssociation
Ptr< const Ipv4StaticRouting > GetRoutingTableAssociation() const 
Returns the internal HNA table. 
void AddNeighborTuple(const NeighborTuple &tuple)
Adds a neighbor tuple to the Neighbor Set. 
void SendHello()
Creates a new OLSR HELLO message which is buffered for being sent later on. 
MprSelectorTuple * FindMprSelectorTuple(const Ipv4Address &mainAddr)
void RemoveLinkTuple(const LinkTuple &tuple)
Removes a link tuple from the Link Set. 
bool UsesNonOlsrOutgoingInterface(const Ipv4RoutingTableEntry &route)
Tests whether or not the specified route uses a non-OLSR outgoing interface. 
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
bool Lookup(const Ipv4Address &dest, RoutingTableEntry &outEntry) const 
Looks up an entry for the specified destination address. 
std::vector< MessageHeader > MessageList
void EraseAssociationTuple(const AssociationTuple &tuple)
Ipv4Address localIfaceAddr
Interface address of the local node. 
static Time Now(void)
Return the current simulation virtual time. 
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev. 
Time time
Time at which this tuple expires and must be removed. 
virtual void NotifyInterfaceDown(uint32_t interface)
uint16_t m_packetSequenceNumber
Packets sequence number counter. 
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device. 
void PopulateTwoHopNeighborSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the 2-hop Neighbor Set according to the information contained in a new received HELLO message...
Ipv4Address GetMainAddress(Ipv4Address iface_addr) const 
Gets the main address associated with a given interface address. 
void RoutingTableComputation()
Creates the routing table of the node following RFC 3626 hints. 
void RemoveTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set. 
void RemoveEntry(const Ipv4Address &dest)
Deletes the entry whose destination address is given. 
void ForwardDefault(olsr::MessageHeader olsrMessage, DuplicateTuple *duplicated, const Ipv4Address &localIface, const Ipv4Address &senderAddress)
OLSR's default forwarding algorithm. 
void ProcessHna(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a HNA message following RFC 3626 specification. 
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet. 
int Degree(NeighborTuple const &tuple)
This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set. 
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name. 
#define OLSR_WILL_HIGH
Willingness for forwarding packets from other nodes: high. 
uint32_t interface
Interface index. 
Ipv4 addresses are stored in host order in this class. 
std::vector< NeighborTuple > NeighborSet
Neighbor Set type. 
bool IsMyOwnAddress(const Ipv4Address &a) const 
Check that address is one of my interfaces. 
void EraseAssociation(const Association &tuple)
TimeWithUnit As(const enum Unit unit) const 
Attach a unit to a Time, to facilitate output in a specific unit. 
uint32_t GetId(void) const 
a class to store IPv4 address information on an interface 
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
void PopulateMprSelectorSet(const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello)
Updates the MPR Selector Set according to the information contained in a new received HELLO message (...
void SendQueuedMessages()
Creates as many OLSR packets as needed in order to send all buffered OLSR messages. 
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN. 
DuplicateTuple * FindDuplicateTuple(const Ipv4Address &address, uint16_t sequenceNumber)
void InsertTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Ipv4Address ifaceAddr
Interface address of a node. 
const IfaceAssocSet & GetIfaceAssocSet() const 
#define OLSR_LOST_LINK
Lost link type. 
Ipv4Address nextAddr
Address of the next hop. 
TracedCallback< const PacketHeader &, const MessageList & > m_txPacketTrace
std::set< Ipv4Address > MprSet
MPR Set type. 
#define OLSR_SYM_NEIGH
Symmetric neighbor type. 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
const LinkSet & GetLinks() const 
Time Seconds(double value)
Construct a Time in the indicated unit. 
void SendHna()
Creates a new OLSR HNA message which is buffered for being sent later on. 
#define OLSR_MID_HOLD_TIME
MID holding time. 
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type. 
void EraseTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
void Track(EventId event)
Tracks a new event. 
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...
Abstract base class for IPv4 routing protocols. 
#define OLSR_WILL_NEVER
Willingness for forwarding packets from other nodes: never. 
#define OLSR_MAX_MSGS
Maximum number of messages per packet. 
void LinkTupleAdded(const LinkTuple &tuple, uint8_t willingness)
void SetInterfaceExclusions(std::set< uint32_t > exceptions)
LinkTuple & InsertLinkTuple(const LinkTuple &tuple)
Time m_hnaInterval
HNA messages' emission interval. 
void Dump(void)
Dump the neighbor table, two-hop neighbor table, and routing table to logging output (NS_LOG_DEBUG lo...
Time Now(void)
create an ns3::Time instance which contains the current simulation time. 
uint16_t GetPort(void) const 
Ipv4Address neighborMainAddr
Main address of a neighbor. 
virtual void DoInitialize(void)
Initialize() implementation. 
std::vector< RoutingTableEntry > GetRoutingTableEntries() const 
Return the list of routing table entries discovered by OLSR. 
void EraseNeighborTuple(const NeighborTuple &neighborTuple)
const TwoHopNeighborSet & GetTwoHopNeighbors() const 
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address. 
void AddDuplicateTuple(const DuplicateTuple &tuple)
Adds a duplicate tuple to the Duplicate Set. 
void TcTimerExpire()
Sends a TC message (if there exists any MPR selector) and reschedules the TC timer. 
Ipv4Address address
Originator address of the message. 
TopologyTuple * FindNewerTopologyTuple(const Ipv4Address &lastAddr, uint16_t ansn)
void RemoveNeighborTuple(const NeighborTuple &tuple)
Removes a neighbor tuple from the Neighbor Set. 
uint16_t GetMessageSequenceNumber()
Increments message sequence number and returns the new value. 
Ipv4Address gatewayAddr
Main address of the gateway. 
OlsrState m_state
Internal state with all needed data structs. 
void AddMprSelectorTuple(const MprSelectorTuple &tuple)
Adds an MPR selector tuple to the MPR Selector Set. 
TracedCallback< uint32_t > m_routingTableChanged
Ipv4Address neighborIfaceAddr
Interface address of the neighbor node. 
#define OLSR_HNA_HOLD_TIME
HNA holding time. 
Ipv4Mask GetDestNetworkMask(void) const 
a unique identifier for an interface. 
An Interface Association Tuple. 
bool retransmitted
Indicates whether the message has been retransmitted or not. 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
The type "list of interface addresses". 
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
void EraseMprSelectorTuple(const MprSelectorTuple &tuple)
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper. 
void InsertAssociation(const Association &tuple)
uint16_t sequenceNumber
Message sequence number. 
std::vector< AssociationTuple > AssociationSet
Association Set type. 
void AddHeader(const Header &header)
Add header to this packet. 
olsr::MessageList m_queuedMessages
A list of pending messages which are buffered awaiting for being sent. 
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables. 
void SetDestination(Ipv4Address dest)
bool FindSendEntry(const RoutingTableEntry &entry, RoutingTableEntry &outEntry) const 
Finds the appropiate entry which must be used in order to forward a data packet to a next hop (given ...
Time expirationTime
Time at which this tuple expires and must be removed. 
void EraseTwoHopNeighborTuples(const Ipv4Address &neighbor)
void InsertTopologyTuple(const TopologyTuple &tuple)
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on. 
void ProcessMid(const olsr::MessageHeader &msg, const Ipv4Address &senderIface)
Processes a MID message following RFC 3626 specification.