32 #define NS_LOG_APPEND_CONTEXT                                   \    33   if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId () << "] "; }    42 #include "ns3/config.h"    44 #include "ns3/string.h"    47 #include "ns3/assert.h"    48 #include "ns3/uinteger.h"    49 #include "ns3/net-device.h"    50 #include "ns3/packet.h"    51 #include "ns3/boolean.h"    52 #include "ns3/node-list.h"    53 #include "ns3/double.h"    54 #include "ns3/pointer.h"    55 #include "ns3/timer.h"    56 #include "ns3/object-vector.h"    57 #include "ns3/ipv4-address.h"    58 #include "ns3/ipv4-header.h"    59 #include "ns3/ipv4-l3-protocol.h"    60 #include "ns3/ipv4-route.h"    61 #include "ns3/trace-source-accessor.h"    62 #include "ns3/icmpv4-l4-protocol.h"    63 #include "ns3/adhoc-wifi-mac.h"    64 #include "ns3/wifi-net-device.h"    65 #include "ns3/inet-socket-address.h"    66 #include "ns3/udp-l4-protocol.h"    67 #include "ns3/udp-socket-factory.h"    68 #include "ns3/tcp-socket-factory.h"    69 #include "ns3/llc-snap-header.h"    70 #include "ns3/arp-header.h"    71 #include "ns3/ipv6-interface.h"   112     .SetGroupName (
"Dsr")
   114     .AddAttribute (
"RouteCache",
   115                    "The route cache for saving routes from "   116                    "route discovery process.",
   120                    MakePointerChecker<DsrRouteCache> ())
   121     .AddAttribute (
"RreqTable",
   122                    "The request table to manage route requests.",
   126                    MakePointerChecker<DsrRreqTable> ())
   127     .AddAttribute (
"PassiveBuffer",
   128                    "The passive buffer to manage "   129                    "promisucously received passive ack.",
   133                    MakePointerChecker<DsrPassiveBuffer> ())
   134     .AddAttribute (
"MaxSendBuffLen",
   135                    "Maximum number of packets that can be stored "   139                    MakeUintegerChecker<uint32_t> ())
   140     .AddAttribute (
"MaxSendBuffTime",
   141                    "Maximum time packets can be queued in the send buffer .",
   145     .AddAttribute (
"MaxMaintLen",
   146                    "Maximum number of packets that can be stored "   147                    "in maintenance buffer.",
   150                    MakeUintegerChecker<uint32_t> ())
   151     .AddAttribute (
"MaxMaintTime",
   152                    "Maximum time packets can be queued in maintenance buffer.",
   156     .AddAttribute (
"MaxCacheLen",
   157                    "Maximum number of route entries that can be stored "   161                    MakeUintegerChecker<uint32_t> ())
   162     .AddAttribute (
"RouteCacheTimeout",
   163                    "Maximum time the route cache can be queued in "   168     .AddAttribute (
"MaxEntriesEachDst",
   169                    "Maximum number of route entries for a "   170                    "single destination to respond.",
   173                    MakeUintegerChecker<uint32_t> ())
   174     .AddAttribute (
"SendBuffInterval",
   175                    "How often to check send buffer for packet with route.",
   179     .AddAttribute (
"NodeTraversalTime",
   180                    "The time it takes to traverse two neighboring nodes.",
   184     .AddAttribute (
"RreqRetries",
   185                    "Maximum number of retransmissions for "   186                    "request discovery of a route.",
   189                    MakeUintegerChecker<uint32_t> ())
   190     .AddAttribute (
"MaintenanceRetries",
   191                    "Maximum number of retransmissions for "   192                    "data packets from maintenance buffer.",
   195                    MakeUintegerChecker<uint32_t> ())
   196     .AddAttribute (
"RequestTableSize",
   197                    "Maximum number of request entries in the request table, "   198                    "set this as the number of nodes in the simulation.",
   201                    MakeUintegerChecker<uint32_t> ())
   202     .AddAttribute (
"RequestIdSize",
   203                    "Maximum number of request source Ids in "   204                    "the request table.",
   207                    MakeUintegerChecker<uint32_t> ())
   208     .AddAttribute (
"UniqueRequestIdSize",
   209                    "Maximum number of request Ids in "   210                    "the request table for a single destination.",
   213                    MakeUintegerChecker<uint32_t> ())
   214     .AddAttribute (
"NonPropRequestTimeout",
   215                    "The timeout value for non-propagation request.",
   219     .AddAttribute (
"DiscoveryHopLimit",
   220                    "The max discovery hop limit for route requests.",
   223                    MakeUintegerChecker<uint32_t> ())
   224     .AddAttribute (
"MaxSalvageCount",
   225                    "The max salvage count for a single data packet.",
   228                    MakeUintegerChecker<uint8_t> ())
   229     .AddAttribute (
"BlacklistTimeout",
   230                    "The time for a neighbor to stay in blacklist.",
   234     .AddAttribute (
"GratReplyHoldoff",
   235                    "The time for gratuitous reply entry to expire.",
   239     .AddAttribute (
"BroadcastJitter",
   240                    "The jitter time to avoid collision for broadcast packets.",
   243                    MakeUintegerChecker<uint32_t> ())
   244     .AddAttribute (
"LinkAckTimeout",
   245                    "The time a packet in maintenance buffer wait for "   246                    "link acknowledgment.",
   250     .AddAttribute (
"TryLinkAcks",
   251                    "The number of link acknowledgment to use.",
   254                    MakeUintegerChecker<uint32_t> ())
   255     .AddAttribute (
"PassiveAckTimeout",
   256                    "The time a packet in maintenance buffer wait for "   257                    "passive acknowledgment.",
   261     .AddAttribute (
"TryPassiveAcks",
   262                    "The number of passive acknowledgment to use.",
   265                    MakeUintegerChecker<uint32_t> ())
   266     .AddAttribute (
"RequestPeriod",
   267                    "The base time interval between route requests.",
   271     .AddAttribute (
"MaxRequestPeriod",
   272                    "The max time interval between route requests.",
   276     .AddAttribute (
"GraReplyTableSize",
   277                    "The gratuitous reply table size.",
   280                    MakeUintegerChecker<uint32_t> ())
   281     .AddAttribute (
"CacheType",
   282                    "Use Link Cache or use Path Cache",
   286     .AddAttribute (
"StabilityDecrFactor",
   287                    "The stability decrease factor for link cache",
   290                    MakeUintegerChecker<uint32_t> ())
   291     .AddAttribute (
"StabilityIncrFactor",
   292                    "The stability increase factor for link cache",
   295                    MakeUintegerChecker<uint32_t> ())
   296     .AddAttribute (
"InitStability",
   297                    "The initial stability factor for link cache",
   301     .AddAttribute (
"MinLifeTime",
   302                    "The minimal life time for link cache",
   306     .AddAttribute (
"UseExtends",
   307                    "The extension time for link cache",
   311     .AddAttribute (
"EnableSubRoute",
   312                    "Enables saving of sub route when receiving "   313                    "route error messages, only available when "   314                    "using path route cache",
   318     .AddAttribute (
"RetransIncr",
   319                    "The increase time for retransmission timer "   320                    "when facing network congestion",
   324     .AddAttribute (
"MaxNetworkQueueSize",
   325                    "The max number of packet to save in the network queue.",
   328                    MakeUintegerChecker<uint32_t> ())
   329     .AddAttribute (
"MaxNetworkQueueDelay",
   330                    "The max time for a packet to stay in the network queue.",
   334     .AddAttribute (
"NumPriorityQueues",
   335                    "The max number of packet to save in the network queue.",
   338                    MakeUintegerChecker<uint32_t> ())
   339     .AddAttribute (
"LinkAcknowledgment",
   340                    "Enable Link layer acknowledgment mechanism",
   344     .AddTraceSource (
"Tx",
   347                      "ns3::dsr::DsrOptionSRHeader::TracedCallback")
   348     .AddTraceSource (
"Drop",
   351                      "ns3::Packet::TracedCallback")
   402       Ptr<Node> node = this->GetObject<Node> ();
   405           m_ipv4 = this->GetObject<Ipv4L3Protocol> ();
   434       std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator, 
bool> result_i = 
m_priorityQueue.insert (std::make_pair (i, queue_i));
   466       for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
   471           if (addr != loopback)
   489               routeCache->ScheduleTimer ();
   512               routeCache->AddArpCache (
m_ipv4->GetInterface (i)->GetArpCache ());
   530   return n->GetDevice (atoi (elements[3].c_str ()));
   533 std::vector<std::string>
   536   std::vector <std::string> elements;
   537   size_t pos1 = 0, pos2;
   538   while (pos1 != context.npos)
   540       pos1 = context.find (
"/",pos1);
   541       pos2 = context.find (
"/",pos1 + 1);
   542       elements.push_back (context.substr (pos1 + 1,pos2 - (pos1 + 1)));
   553   for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
   563               mac->TraceDisconnectWithoutContext (
"TxErrHeader",
   629   for (int32_t i = 0; i < nNodes; ++i)
   633       int32_t ifIndex = ipv4->GetInterfaceForAddress (ipv4Address);
   666   std::vector<Ipv4Address> nodelist = rt.
GetVector ();
   674   m_routeCache->DeleteAllRoutesIncludeLink (errorSrc, unreachNode, node);
   684   return m_rreqTable->FindSourceEntry (src, dst, 
id);
   692   for (int32_t i = 0; i < nNodes; ++i)
   698       if (netDevice->GetAddress () == 
address)
   700           return ipv4->GetAddress (1, 0).GetLocal ();
   719       for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i)
   731   if (vec.size () == 2)
   739       if (ipv4Address == vec.back ())
   741           NS_LOG_DEBUG (
"We have reached to the final destination " << ipv4Address << 
" " << vec.back ());
   744       for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i)
   746           if (ipv4Address == (*i))
   780   for (int32_t i = 0; i < nNodes; ++i)
   784       if (ipv4->GetAddress (1, 0).GetLocal () == 
address)
   804       return ipv4->GetAddress (1, 0).GetLocal ();
   838       NS_LOG_DEBUG (
"Here we try to find the data packet in the send buffer");
   841       bool findRoute = 
m_routeCache->LookupRoute (destination, toDst);
   844           NS_LOG_INFO (
"We have found a route for the packet");
   847           uint8_t protocol = i->GetProtocol ();
   862           uint32_t size = copyP->
GetSize ();
   863           uint8_t *
data = 
new uint8_t[size];
   866           uint8_t optionType = 0;
   867           optionType = *(
data);
   873               uint8_t errorType = *(
data + 2);
   889                   std::vector<Ipv4Address> errorRoute = toDst.
GetVector ();
   901                   if (nextHop == 
"0.0.0.0")
   908                   uint8_t length = (sourceRoute.
GetLength () + newUnreach.GetLength ());
   923                   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
   925                   NS_LOG_LOGIC (
"Will be inserting into priority queue number: " << priority);
   932                   if (dsrNetworkQueue->Enqueue (newEntry))
   938                       NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
   950               std::vector<Ipv4Address> nodeList = toDst.
GetVector (); 
   952               if (nextHop == 
"0.0.0.0")
   966               uint8_t length = sourceRoute.
GetLength ();
   979                   networkKey.
m_ackId = newEntry.GetAckId ();
   980                   networkKey.
m_ourAdd = newEntry.GetOurAdd ();
   981                   networkKey.
m_nextHop = newEntry.GetNextHop ();
   982                   networkKey.
m_source = newEntry.GetSrc ();
   987                   passiveKey.
m_source = newEntry.GetSrc ();
   989                   passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
   992                   linkKey.
m_source = newEntry.GetSrc ();
   994                   linkKey.
m_ourAdd = newEntry.GetOurAdd ();
   995                   linkKey.
m_nextHop = newEntry.GetNextHop ();
  1008                       if (nextHop != destination)
  1085       newEntry.SetSrc (sourceIp);
  1086       newEntry.SetDst (destinationIp);
  1088       newEntry.SetOurAdd (previousHop);
  1089       newEntry.SetNextHop (ourAddress);
  1095       dsr->CancelLinkPacketTimer (newEntry);
  1102       NS_LOG_INFO (
this << from << to << packetType << *pktMinusIpHdr);
  1114       uint32_t size = pktMinusIpHdr->
GetSize ();
  1115       uint8_t *
data = 
new uint8_t[size];
  1117       uint8_t optionType = 0;
  1118       optionType = *(
data);
  1122       if (optionType == 96)        
  1128                         " overhearing packet PID: " << pktMinusIpHdr->
GetUid () <<
  1129                         " from " << promiscSource <<
  1131                         " with source IP " << ipv4Header.
GetSource () <<
  1133                         " and packet : " << *pktMinusDsrHdr);
  1135           bool isPromisc = 
true;                     
  1136           dsrOption->Process (pktMinusIpHdr, pktMinusDsrHdr, 
m_mainAddress, source, ipv4Header, nextHeader, isPromisc, promiscSource);
  1150   NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)protocol);
  1153   bool findRoute = 
m_routeCache->LookupRoute (destination, toDst);
  1158                    << 
"s " << 
m_mainAddress << 
" there is no route for this packet, queue the packet");
  1166                        << 
"s Add packet PID: " << packet->
GetUid () << 
" to queue. Packet: " << *packet);
  1188       std::vector<Ipv4Address> nodeList = toDst.
GetVector ();     
  1190       if (nextHop == 
"0.0.0.0")
  1195       uint8_t salvage = 0;
  1205       uint8_t length = sourceRoute.
GetLength ();
  1213                                                source,  destination,  0,
  1220           networkKey.
m_ackId = newEntry.GetAckId ();
  1221           networkKey.
m_ourAdd = newEntry.GetOurAdd ();
  1222           networkKey.
m_nextHop = newEntry.GetNextHop ();
  1223           networkKey.
m_source = newEntry.GetSrc ();
  1228           passiveKey.
m_source = newEntry.GetSrc ();
  1230           passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
  1233           linkKey.
m_source = newEntry.GetSrc ();
  1235           linkKey.
m_ourAdd = newEntry.GetOurAdd ();
  1236           linkKey.
m_nextHop = newEntry.GetNextHop ();
  1249               if (nextHop != destination)
  1266   NS_LOG_FUNCTION (
this << unreachNode << destination << originalDst << (uint32_t)salvage << (uint32_t)protocol);
  1280   uint8_t rerrLength = rerrUnreachHeader.
GetLength ();
  1284   bool findRoute = 
m_routeCache->LookupRoute (destination, toDst);
  1291           NS_LOG_INFO (
"We are the error source, send request to original dst " << originalDst);
  1298                        << 
"s " << 
m_mainAddress << 
" there is no route for this packet, queue the packet");
  1302           newPacket->
AddHeader (dsrRoutingHeader);
  1310                            << 
"s Add packet PID: " << p->
GetUid () << 
" to queue. Packet: " << *p);
  1314                   NS_LOG_DEBUG (
"When there is no existing route request for " << destination << 
", initialize one");
  1325       std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
  1327       if (nextHop == 
"0.0.0.0")
  1341       uint8_t srLength = sourceRoute.
GetLength ();
  1342       uint8_t length = (srLength + rerrLength);
  1347       newPacket->
AddHeader (dsrRoutingHeader);
  1355       std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  1357       NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue << 
" number: " << priority);
  1364       if (dsrNetworkQueue->Enqueue (newEntry))
  1370           NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  1382   NS_LOG_FUNCTION (
this << rerr << sourceRoute << nextHop << (uint32_t)protocol << route);
  1386   dsrRoutingHeader.SetMessageType (1);
  1391   dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 4);
  1392   dsrRoutingHeader.AddDsrOption (rerr);
  1393   dsrRoutingHeader.AddDsrOption (sourceRoute);
  1400   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  1402   NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue << 
" number: " << priority);
  1409   if (dsrNetworkQueue->Enqueue (newEntry))
  1415       NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  1426   NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)protocol << route);
  1431       NS_LOG_INFO (
"Drop packet. Not handling ICMP packet for now");
  1437       bool findRoute = 
m_routeCache->LookupRoute (destination, toDst);
  1442                        << 
"s " << 
m_mainAddress << 
" there is no route for this packet, queue the packet");
  1450                            << 
"s Add packet PID: " << packet->
GetUid () << 
" to send buffer. Packet: " << *packet);
  1462                   NS_LOG_LOGIC (
"There is existing route request timer with request count " << 
m_rreqTable->GetRreqCnt (destination));
  1476           std::vector<Ipv4Address> nodeList = toDst.
GetVector ();       
  1478           if (nextHop == 
"0.0.0.0")
  1483           uint8_t salvage = 0;
  1493           uint8_t length = sourceRoute.
GetLength ();
  1503                                                    source,  destination,  0,
  1509               networkKey.
m_ackId = newEntry.GetAckId ();
  1510               networkKey.
m_ourAdd = newEntry.GetOurAdd ();
  1511               networkKey.
m_nextHop = newEntry.GetNextHop ();
  1512               networkKey.
m_source = newEntry.GetSrc ();
  1517               passiveKey.
m_source = newEntry.GetSrc ();
  1519               passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
  1522               linkKey.
m_source = newEntry.GetSrc ();
  1524               linkKey.
m_ourAdd = newEntry.GetOurAdd ();
  1525               linkKey.
m_nextHop = newEntry.GetNextHop ();
  1538                   if (nextHop != destination)
  1571   uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
  1572   uint32_t destinationId = dsrRoutingHeader.
GetDestId ();
  1579   uint8_t numberAddress = (buf[1] - 2) / 4;
  1592   newDsrRoutingHeader.
SetDestId (destinationId);
  1605   NS_LOG_FUNCTION (
this << packet << source << nextHop << (uint32_t)protocol);
  1612   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  1614   NS_LOG_INFO (
"Will be inserting into priority queue number: " << priority);
  1621   if (dsrNetworkQueue->Enqueue (newEntry))
  1627       NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  1642   uint32_t numPriorities;
  1643   if (continueWithFirst)
  1649       numPriorities = priority;
  1654       std::map<uint32_t, Ptr<DsrNetworkQueue> >::iterator q = 
m_priorityQueue.find (i);
  1656       uint32_t queueSize = dsrNetworkQueue->GetSize ();
  1670           uint32_t totalQueueSize = 0;
  1673               NS_LOG_INFO (
"The size of the network queue for " << j->first << 
" is " << j->second->GetSize ());
  1674               totalQueueSize += j->second->GetSize ();
  1675               NS_LOG_INFO (
"The total network queue size is " << totalQueueSize);
  1677           if (totalQueueSize > 5)
  1683           dsrNetworkQueue->Dequeue (newEntry);
  1686               NS_LOG_LOGIC (
"Packet sent by Dsr. Calling PriorityScheduler after some time");
  1695               NS_LOG_LOGIC (
"Packet dropped by Dsr. Calling PriorityScheduler immediately");
  1717   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  1720   std::vector<DsrNetworkQueueEntry> newNetworkQueue = dsrNetworkQueue->GetQueue ();
  1721   for (std::vector<DsrNetworkQueueEntry>::iterator i = newNetworkQueue.begin (); i != newNetworkQueue.end (); i++)
  1726           if (nextHop == j->first.m_nextHop)
  1728               NS_LOG_DEBUG (
"The network delay left is " << j->second.GetDelayLeft ());
  1729               j->second.SetDelay (j->second.GetDelayLeft () + 
m_retransIncr);
  1757   NS_LOG_INFO (
"The nexthop address " << nextHop << 
" the source " << source << 
" the destination " << destination);
  1763       NS_LOG_DEBUG (
"destination over here " << destination);
  1782           uint8_t length = sourceRoute.
GetLength ();
  1791                                        source,  destination,  0,
  1798               networkKey.
m_ackId = newEntry.GetAckId ();
  1799               networkKey.
m_ourAdd = newEntry.GetOurAdd ();
  1800               networkKey.
m_nextHop = newEntry.GetNextHop ();
  1801               networkKey.
m_source = newEntry.GetSrc ();
  1806               passiveKey.
m_source = newEntry.GetSrc ();
  1808               passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
  1811               linkKey.
m_source = newEntry.GetSrc ();
  1813               linkKey.
m_ourAdd = newEntry.GetOurAdd ();
  1814               linkKey.
m_nextHop = newEntry.GetNextHop ();
  1827                   if (nextHop != destination)
  1842               NS_LOG_LOGIC (
"Schedule sending the next packet in send buffer");
  1849           NS_LOG_LOGIC (
"All queued packets are out-dated for the destination in send buffer");
  1867           uint32_t offset = dsrRoutingHeader.GetDsrOptionsOffset ();
  1872           uint32_t size = copyP->
GetSize ();
  1873           uint8_t *
data = 
new uint8_t[size];
  1876           uint8_t optionType = 0;
  1877           optionType = *(
data);
  1878           NS_LOG_DEBUG (
"The option type value in send packet " << (uint32_t)optionType);
  1879           if (optionType == 3)
  1885               uint8_t errorType = *(
data + 2);
  1889                   NS_LOG_DEBUG (
"The packet is route error unreach packet");
  1919                   newPacket->
AddHeader (newRoutingHeader);       
  1924                   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  1926                   NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue << 
" number: " << priority);
  1933                   if (dsrNetworkQueue->Enqueue (newEntry))
  1939                       NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  1946               NS_LOG_LOGIC (
"Schedule sending the next packet in error buffer");
  1954       NS_LOG_DEBUG (
"Packet not found in either the send or error buffer");
  1960                                uint16_t fragmentOffset, uint16_t identification, 
bool saveEntry)
  1981       NS_LOG_DEBUG (
"We get the all equal for passive buffer here");
  1986       mbEntry.
SetDst (destination);
  2013   newEntry.
SetSrc (source);
  2014   newEntry.
SetDst (destination);
  2031   NS_LOG_FUNCTION (
this << (uint32_t)ackId << ipv4Header << realSrc << realDst);
  2040                                            realSrc,  realDst,  ackId,
  2073   std::map<LinkKey, Timer>::const_iterator i =
  2100       NS_LOG_INFO (
"Link acknowledgment received, remove same maintenance buffer entry");
  2121                         << 
" source " << mb.
GetSrc () << 
" destination " << mb.
GetDst ()
  2125   std::map<NetworkKey, Timer>::const_iterator i =
  2150       NS_LOG_INFO (
"Remove same maintenance buffer entry based on network acknowledgment");
  2168   std::map<PassiveKey, Timer>::const_iterator j =
  2196   std::vector<Ipv4Address> previousErrorDst;
  2213       uint8_t numberAddress = (buf[1] - 2) / 4;
  2214       NS_LOG_DEBUG (
"The number of addresses " << (uint32_t)numberAddress);
  2230           errorDst = address1;
  2237       if (std::find (previousErrorDst.begin (), previousErrorDst.end (), destination) == previousErrorDst.end ())
  2239           NS_LOG_DEBUG (
"have not seen this dst before " << errorDst << 
" in " << previousErrorDst.size ());
  2241           previousErrorDst.push_back (errorDst);
  2253           NS_LOG_INFO (
"Cancel the packet timer for next maintenance entry");
  2260       NS_LOG_INFO (
"Maintenance buffer entry not found");
  2268   NS_LOG_FUNCTION (
this << packet << source << dst << (uint32_t)protocol);
  2281   newPacket->
CopyData (buf, 
sizeof(buf));
  2282   uint8_t numberAddress = (buf[1] - 2) / 4;
  2292   bool findRoute = 
m_routeCache->LookupRoute (dst, toDst);
  2302       std::vector<Ipv4Address> nodeList = toDst.
GetVector ();     
  2304       if (nextHop == 
"0.0.0.0")
  2320       uint8_t length = sourceRoute.
GetLength ();
  2332       std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  2334       NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue << 
" number: " << priority);
  2341       if (dsrNetworkQueue->Enqueue (newEntry))
  2347           NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  2358       NS_LOG_DEBUG (
"Will not salvage this packet, silently drop");
  2416   NS_LOG_DEBUG (
"The passive acknowledgment option for data packet");
  2433   NS_LOG_DEBUG (
"is the first retry or not " << isFirst);
  2454       networkKey.m_ackId = newEntry.
GetAckId ();
  2455       networkKey.m_ourAdd = newEntry.
GetOurAdd ();
  2456       networkKey.m_nextHop = newEntry.
GetNextHop ();
  2457       networkKey.m_source = newEntry.
GetSrc ();
  2458       networkKey.m_destination = newEntry.
GetDst ();
  2483       networkKey.m_ackId = mb.
GetAckId ();
  2486       networkKey.m_source = mb.
GetSrc ();
  2487       networkKey.m_destination = mb.
GetDst ();
  2502       NS_LOG_DEBUG (
"The packet with dsr header " << dsrP->GetSize ());
  2503       networkKey.m_ackId = mb.
GetAckId ();
  2506       networkKey.m_source = mb.
GetSrc ();
  2507       networkKey.m_destination = mb.
GetDst ();
  2565       NS_LOG_INFO (
"We need to send error messages now");
  2673   NS_LOG_FUNCTION (
this << packet << sourceRoute << source << nextHop << targetAddress << (uint32_t)protocol << route);
  2678   dsrRoutingHeader.SetMessageType (2);
  2679   dsrRoutingHeader.SetSourceId (
GetIDfromIP (source));
  2680   dsrRoutingHeader.SetDestId (
GetIDfromIP (targetAddress));
  2684   uint8_t length = sourceRoute.
GetLength ();
  2685   dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
  2686   dsrRoutingHeader.AddDsrOption (sourceRoute);
  2692                                source,  targetAddress,  
m_ackId,
  2699       networkKey.
m_ackId = newEntry.GetAckId ();
  2700       networkKey.
m_ourAdd = newEntry.GetOurAdd ();
  2701       networkKey.
m_nextHop = newEntry.GetNextHop ();
  2702       networkKey.
m_source = newEntry.GetSrc ();
  2707       passiveKey.
m_source = newEntry.GetSrc ();
  2709       passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
  2712       linkKey.
m_source = newEntry.GetSrc ();
  2714       linkKey.
m_ourAdd = newEntry.GetOurAdd ();
  2715       linkKey.
m_nextHop = newEntry.GetNextHop ();
  2728           if (nextHop != targetAddress)
  2746   NS_LOG_FUNCTION (
this << source << destination << (uint32_t)protocol);
  2767   uint8_t length = rreqHeader.
GetLength ();
  2769   packet->AddHeader (dsrRoutingHeader);
  2772   bool nonProp = 
true;
  2773   std::vector<Ipv4Address> 
address;
  2775   address.push_back (destination);
  2807       std::vector<Ipv4Address> ip = toDst.GetVector ();
  2819       if (nextHop == 
"0.0.0.0")
  2837       NS_LOG_INFO (
"No route found, initiate route error request");
  2854       rreqHeader.SetTarget (originalDst);
  2860       uint8_t length = rreqHeader.GetLength () + rerr.
GetLength ();
  2864       bool nonProp = 
false;
  2865       std::vector<Ipv4Address> 
address;
  2867       address.push_back (originalDst);
  2878           NS_LOG_INFO (
"Only when there is no existing route request time when the initial route request is scheduled");
  2884           NS_LOG_INFO (
"There is existing route request, find the existing route request entry");
  2902       NS_LOG_DEBUG (
"Did not find the non-propagation timer");
  2947   NS_LOG_FUNCTION (
this << packet << nonProp << requestId << (uint32_t)protocol);
  2958       std::vector<Ipv4Address> 
address;
  2982       std::vector<Ipv4Address> 
address;
  3034       std::vector<Ipv4Address> ip = toDst.
GetVector ();
  3045       NS_LOG_INFO (
"The nextHop address is " << nextHop);
  3046       if (nextHop == 
"0.0.0.0")
  3072       NS_LOG_DEBUG (
"Route not found. Drop packet with dst " << dst);
  3084       NS_LOG_DEBUG (
"Check the route request entry " << source << 
" " << dst);
  3101   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  3103   NS_LOG_LOGIC (
"Inserting into priority queue number: " << priority);
  3109   if (dsrNetworkQueue->Enqueue (newEntry))
  3115       NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  3147       std::vector<Ipv4Address>::iterator before = find (nodeList.begin (), nodeList.end (), srcAddress);
  3148       for (std::vector<Ipv4Address>::iterator i = nodeList.begin (); i != before; ++i)
  3153       std::vector<Ipv4Address>::iterator after = find (nodeList.begin (), nodeList.end (), 
m_mainAddress);
  3154       for (std::vector<Ipv4Address>::iterator j = after; j != nodeList.end (); ++j)
  3180       newPacket->
AddHeader (dsrRoutingHeader);
  3189       NS_LOG_INFO (
"The same gratuitous route reply has already sent");
  3204   NS_LOG_INFO (
"The output device " << dev << 
" packet is: " << *packet);
  3207   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  3209   NS_LOG_INFO (
"Inserting into priority queue number: " << priority);
  3215   if (dsrNetworkQueue->Enqueue (newEntry))
  3221       NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  3233                           packet, source, nextHop, route);
  3255   NS_LOG_FUNCTION (
this << ackId << destination << realSrc << realDst << (uint32_t)protocol << route);
  3261   dsrRoutingHeader.SetMessageType (1);
  3263   dsrRoutingHeader.SetDestId (
GetIDfromIP (destination));
  3274   dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
  3275   dsrRoutingHeader.AddDsrOption (ack);
  3283   std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = 
m_priorityQueue.find (priority);
  3286   NS_LOG_LOGIC (
"Will be inserting into priority queue " << dsrNetworkQueue << 
" number: " << priority);
  3292   if (dsrNetworkQueue->Enqueue (newEntry))
  3298       NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
  3320   uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
  3322   NS_LOG_INFO (
"The source address " << source << 
" with source id " << sourceId);
  3328   bool isPromisc = 
false;
  3339   uint32_t size = p->
GetSize ();
  3340   uint8_t *
data = 
new uint8_t[size];
  3343   uint8_t optionType = 0;
  3344   uint8_t optionLength = 0;
  3345   uint8_t segmentsLeft = 0;
  3347   optionType = *(
data);
  3348   NS_LOG_LOGIC (
"The option type value " << (uint32_t)optionType << 
" with packet id " << p->
GetUid ());
  3351   if (optionType == 1)        
  3356           NS_LOG_INFO (
"Discard this packet due to unidirectional link");
  3361       optionLength = dsrOption->Process (p, packet, 
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
  3363       if (optionLength == 0)
  3369   else if (optionType == 2)
  3372       optionLength = dsrOption->Process (p, packet, 
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
  3374       if (optionLength == 0)
  3381   else if (optionType == 32)       
  3385       optionLength = dsrOption->Process (p, packet, 
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
  3387       if (optionLength == 0)
  3394   else if (optionType == 3)       
  3397       NS_LOG_INFO (
"The option type value " << (uint32_t)optionType);
  3400       optionLength = dsrOption->Process (p, packet, 
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
  3402       if (optionLength == 0)
  3407       NS_LOG_INFO (
"The option Length " << (uint32_t)optionLength);
  3410   else if (optionType == 96)       
  3413       optionLength = dsrOption->Process (p, packet, 
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
  3414       segmentsLeft = *(
data + 3);
  3415       if (optionLength == 0)
  3422           if (segmentsLeft == 0)
  3434                     nextProto->Receive (copy, ip, incomingInterface);
  3461               NS_LOG_INFO (
"This is not the final destination, the packet has already been forward to next hop");
  3471       uint8_t salvage = 0;
  3533       if ((*i)->GetOptionNumber () == optionNumber)
 
uint32_t m_sendRetries
of retries have been sent for network acknowledgment
uint32_t m_stabilityDecrFactor
The initial decrease factor for link cache. 
uint8_t GetSegsLeft() const
Get segments left. 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer. 
uint32_t GetSize()
Number of entries. 
Ptr< const AttributeChecker > MakeStringChecker(void)
  
void SetDownTarget(IpL4Protocol::DownTargetCallback callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
uint32_t GetSize()
Returns the number of entries in the queue. 
Ipv4Address m_ourAdd
local address 
void UseExtends(DsrRouteCacheEntry::IP_VECTOR rt)
functions used to direct to route cache 
void SetRequestTable(Ptr< dsr::DsrRreqTable > r)
Set the node. 
std::string m_cacheType
The type of route cache. 
uint64_t GetUid(void) const
Returns the packet's Uid. 
Simulation virtual time values and global simulation resolution. 
DsrRouteCacheEntry class for entries in the route cache. 
Smart pointer class similar to boost::intrusive_ptr. 
#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 the RngStream. 
bool PassiveEntryCheck(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft, uint16_t fragmentOffset, uint16_t identification, bool saveEntry)
Find the same passive entry. 
static uint32_t GetNNodes(void)
  AttributeValue implementation for Boolean. 
Packet addressed to someone else. 
virtual void DoDispose(void)
Drop trace callback. 
uint32_t m_maxSendBuffLen
The maximum number of packets that we allow a routing protocol to buffer. 
uint16_t m_ackId
acknowledge ID 
void ScheduleInterRequest(Ptr< Packet > packet)
Schedule the intermediate route request. 
bool IsBroadcast(void) const
uint32_t m_stabilityIncrFactor
The initial increase factor for link cache. 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
bool LookupRoute(Ipv4Address id, DsrRouteCacheEntry &rt)
functions used to direct to route cache 
void SetMaxQueueLen(uint32_t len)
Set maximum queue length. 
void SendInitialRequest(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Broadcast the route request packet in subnet. 
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found. 
Hold variables of type string. 
void SendBuffTimerExpire()
The send buffer timer expire. 
static Ptr< Node > GetNode(uint32_t n)
Ipv4Address m_source
source address 
void Scheduler(uint32_t priority)
This function is called to schedule sending packets from the network queue. 
bool NetworkEqual(DsrMaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for network ack. 
DSR Maintain Buffer Entry. 
Ipv4Address m_destination
destination address 
void SalvagePacket(Ptr< const Packet > packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol)
Salvage the packet which has been transmitted for 3 times. 
Time m_sendBuffInterval
how often to check send buffer 
Time m_passiveAckTimeout
The timeout value for passive acknowledge. 
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint32_t m_discoveryHopLimit
Maximum hops to go for route request. 
uint32_t GetPriority(DsrMessageType messageType)
Set the priority of the packet in network queue. 
Ptr< Ipv4 > m_ip
The ip ptr. 
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue. 
uint32_t m_linkRetries
of retries have been sent for link acknowledgment
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit. 
TracedCallback< const DsrOptionSRHeader & > m_txPacketTrace
packet trace callback 
Ptr< dsr::DsrRouteCache > GetRouteCache() const
Get the route cache. 
void SetDst(Ipv4Address n)
Set destination address. 
void DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
functions used to direct to route cache 
Time m_maxRequestPeriod
The max request period. 
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector. 
std::vector< DsrSendBuffEntry > & GetBuffer()
Return a pointer to the internal queue. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit. 
uint32_t m_maxEntriesEachDst
Max number of route entries to save for each destination. 
Ipv4Address GetDst() const
Get destination address. 
void IncreaseRetransTimer()
This function is called to increase the retransmission timer for data packet in the network queue...
bool IsSuspended(void) const
Ipv4Address m_mainAddress
Our own Ip address. 
bool AllEqual(DsrMaintainBuffEntry &entry)
Verify if all the elements in the maintenance buffer entry is the same. 
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Get the next hop of the route. 
#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. 
void CancelPacketAllTimer(DsrMaintainBuffEntry &mb)
Cancel all the packet timers. 
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time. 
bool IsLinkCache()
functions used to direct to route cache 
virtual void DoDispose(void)
Destructor implementation. 
Time m_linkAckTimeout
The timeout value for link acknowledge. 
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
bool PromiscReceive(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Promiscuous receive data packets destined to some other node. 
Ipv4Address m_source
source address 
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
void SetSegsLeft(uint8_t segs)
Set segments left. 
uint32_t m_requestTableSize
The max size of the request table size. 
void ScheduleCachedReply(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, Ptr< Ipv4Route > route, double hops)
Schedule the cached reply to a random start time to avoid possible route reply storm. 
Ipv4Address GetNextHopAddress() const
Get next hop address function. 
uint32_t m_tryLinkAcks
Maximum number of packet transmission using link acknowledgment. 
Ipv4Address m_nextHop
next hop 
Ipv4Address m_destination
destination address 
void ForwardErrPacket(DsrOptionRerrUnreachHeader &rerr, DsrOptionSRHeader &sourceRoute, Ipv4Address nextHop, uint8_t protocol, Ptr< Ipv4Route > route)
 This function is responsible for forwarding error packets along the route 
Ptr< const Packet > GetPacket() const
Get pointer to entry's packet. 
Time m_maxCacheTime
Max time for caching the route cache entry. 
Time m_gratReplyHoldoff
The max gratuitous reply hold off time. 
a polymophic address class 
uint32_t m_maxMaintainLen
Max # of entries for maintenance buffer. 
void SendRequest(Ptr< Packet > packet, Ipv4Address source)
Forward the route request if the node is not the destination. 
Ipv4Address GetIPfromID(uint16_t id)
Get the ip address from id. 
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source. 
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. 
std::vector< Ipv4Address > m_finalRoute
The route cache. 
static TypeId GetTypeId()
Get the type identificator. 
void SetSource(Ipv4Address src)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
bool Dequeue(Ipv4Address dst, DsrErrorBuffEntry &entry)
Return first found (the earliest) entry for given destination. 
uint32_t m_graReplyTableSize
Set the gratuitous reply table size. 
bool AddRoute(DsrRouteCacheEntry &rt)
functions used to direct to route cache 
DsrMaintainBuffer m_maintainBuffer
The declaration of maintain buffer. 
void SetDestination(Ipv4Address d)
Set destination address function. 
Ipv4Address m_destination
destination address 
Time m_maxNetworkDelay
Maximum network delay. 
bool IsMulticast(void) const
Ptr< dsr::DsrRreqTable > GetRequestTable() const
Get the request table. 
uint16_t m_ackId
The ack id assigned to each acknowledge. 
uint32_t GetDsrOptionsOffset()
Get the offset where the options begin, measured from the start of the extension header. 
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution. 
IP_VECTOR GetVector() const
Get the IP vector. 
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst. 
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet. 
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay. 
DsrGraReply m_graReply
The gratuitous route reply. 
void DropPacketForErrLink(Ipv4Address source, Ipv4Address nextHop)
Remove all packets with the error link. 
void SetTtl(uint8_t ttl)
Set the tag's TTL. 
  AttributeValue implementation for Time. 
void Schedule(void)
Schedule a new event using the currently-configured delay, function, and arguments. 
void CancelPassivePacketTimer(DsrMaintainBuffEntry &mb)
Cancel the passive packet retransmission timer for a specific maintenance entry. 
void SetGateway(Ipv4Address gw)
void SendUnreachError(Ipv4Address unreachNode, Ipv4Address destination, Ipv4Address originalDst, uint8_t salvage, uint8_t protocol)
This function is responsible for sending error packets in case of break link to next hop...
void SetErrorBufferTimeout(Time t)
Set error buffer timeout. 
Hold an unsigned integer type. 
Time m_sendBufferTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for. 
Ipv4Address m_broadcast
The broadcast IP address. 
uint32_t GetSize()
Number of entries. 
void SetSendBufferTimeout(Time t)
Set the entry lifetime in the queue. 
uint32_t m_numPriorityQueues
The number of priority queues used. 
uint32_t m_broadcastJitter
The max time to delay route request broadcast. 
void ScheduleLinkPacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on link-layer acknowledgment. 
void SetNode(Ptr< Node > node)
Set the node. 
static const uint8_t PROT_NUMBER
Define the dsr protocol number. 
uint8_t m_segsLeft
segments left 
uint32_t m_requestId
The id assigned to each route request. 
DsrErrorBuffer m_errorBuffer
The error buffer to save the error messages. 
Hold together all Wifi-related objects. 
void NetworkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using network acknowledgment. 
bool Find(Ipv4Address nextHop)
Finds whether a packet with next hop dst exists in the queue. 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetDownTarget6(IpL4Protocol::DownTargetCallback6 callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
Ptr< Ipv4L3Protocol > m_ipv4
Ipv4l3Protocol. 
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
uint32_t m_requestTableIds
The request table identifiers. 
bool AddRoute_Link(DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
functions used to direct to route cache 
void SendReply(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, Ptr< Ipv4Route > route)
Send the route reply back to the request originator with the cumulated route. 
uint8_t segsLeft
The segment left value from SR header. 
bool UpdateRouteEntry(Ipv4Address dst)
functions used to direct to route cache 
Time m_minLifeTime
The min life time. 
void SetFragmentOffset(uint16_t f)
Set fragment offset function. 
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address. 
Time m_useExtends
The use extension of the life time for link cache. 
DSR Passive Buffer Entry. 
void SetMaxQueueLen(uint32_t len)
Set maximum queue length. 
void SchedulePassivePacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on passive acknowledgment. 
Ptr< const Packet > GetPacket() const
Get packet. 
bool Find(Ipv4Address dst)
Check if a packet with destination dst exists in the queue. 
void ScheduleInitialReply(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, Ptr< Ipv4Route > route)
this is a generating the initial route reply from the destination address, a random delay time [0...
Time m_blacklistTimeout
The black list time out. 
bool Enqueue(DsrErrorBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
std::map< NetworkKey, Timer > m_addressForwardTimer
Map network key + forward timer. 
static Mac48Address ConvertFrom(const Address &address)
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer. 
void SetPassiveBuffer(Ptr< dsr::DsrPassiveBuffer > r)
Set the node. 
Ipv4Address GetSrc() const
Get source address. 
Access to the IPv4 forwarding table, interfaces, and configuration. 
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object. 
bool PromiscEqual(DsrMaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for promiscuous ack. 
void LinkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using link acknowledgment. 
void SendPacketFromBuffer(DsrOptionSRHeader const &sourceRoute, Ipv4Address nextHop, uint8_t protocol)
This function is responsible for sending out data packets when have route, if no route found...
This policy cancels the event from the destructor of the Timer to verify that the event has already e...
uint8_t m_maxSalvageCount
Maximum # times to salvage a packet. 
Time m_initStability
The initial stability value for link cache. 
Ipv4Address m_nextHop
next hop address 
void SetExpireTime(Time exp)
Set expiration time. 
The maintenance buffer is responsible for maintaining packet next hop delivery The data packet is sav...
The gratuitous table entries, it maintains the already sent gratuitous route reply entries...
Time m_requestPeriod
The base time interval between route requests. 
Implement the IPv4 layer. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
Ptr< dsr::DsrOptions > GetOption(int optionNumber)
Get the option corresponding to optionNumber. 
uint16_t GetIDfromIP(Ipv4Address address)
Get the node id from ip address. 
Hold objects of type Ptr<T>. 
Ptr< Node > m_node
The node ptr. 
void CallCancelPacketTimer(uint16_t ackId, Ipv4Header const &ipv4Header, Ipv4Address realSrc, Ipv4Address realDst)
Call the cancel packet retransmission timer function. 
bool Enqueue(DsrSendBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
  
uint32_t m_passiveRetries
of retries have been sent for passive acknowledgment
uint32_t m_maxNetworkSize
Maximum network queue size. 
void SetMaintainBufferTimeout(Time t)
Set maintain buffer timeout. 
Ptr< Ipv4Route > SetRoute(Ipv4Address nextHop, Ipv4Address srcAddress)
Set the route to use for data packets, used by the option headers when sending data/control packets...
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
This function is called by higher layer protocol when sending packets. 
uint32_t m_tryPassiveAcks
Maximum number of packet transmission using passive acknowledgment. 
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get the netdevice from the context. 
void SetAckId(uint16_t ackId)
Set acknowledge ID. 
uint32_t m_maxMaintRexmt
Maximum number of retransmissions of data packets. 
Ptr< Packet > Copy(void) const
performs a COW copy of the packet. 
Ptr< dsr::DsrPassiveBuffer > GetPassiveBuffer() const
Get the passive buffer. 
void CancelLinkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the link packet retransmission timer for a specific maintenance entry. 
void Resume(void)
Restart the timer to expire within the amount of time left saved during Suspend. 
uint16_t AddAckReqHeader(Ptr< Packet > &packet, Ipv4Address nextHop)
This function is called to add ack request header for network acknowledgement. 
void PacketNewRoute(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol)
When route vector corrupted, originate a new packet, normally not happening. 
Ipv4Address m_source
source address 
Time m_retransIncr
the increase time for retransmission timer when face network congestion 
void ForwardPacket(Ptr< const Packet > packet, DsrOptionSRHeader &sourceRoute, Ipv4Header const &ipv4Header, Ipv4Address source, Ipv4Address destination, Ipv4Address targetAddress, uint8_t protocol, Ptr< Ipv4Route > route)
Forward the packet using the route saved in the source route option header. 
std::map< LinkKey, Timer > m_linkAckTimer
The timer for link acknowledgment. 
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now. 
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
L4 Protocol abstract base class. 
static Time Now(void)
Return the current simulation virtual time. 
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev. 
IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
void SendPacket(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol)
This function is called by when really sending out the packet. 
int GetProtocolNumber(void) const
Get the dsr protocol number. 
void SetSegsLeft(uint8_t seg)
Set segments left. 
void ScheduleRreqRetry(Ptr< Packet > packet, std::vector< Ipv4Address > address, bool nonProp, uint32_t requestId, uint8_t protocol)
Schedule the route request retry. 
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint32_t m_maxRreqId
The max number of request ids for a single destination. 
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Ptr< dsr::DsrRouteCache > m_routeCache
A "drop-front" queue used by the routing layer to cache routes found. 
Ipv4Address GetOurAdd() const
Get local address of entry. 
uint32_t m_maxCacheLen
Max # of cache entries for route cache. 
void SetSource(Ipv4Address s)
Set surce address function. 
bool IsRunning(void) const
void PassiveScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using passive acknowledgment. 
bool Dequeue(Ipv4Address dst, DsrMaintainBuffEntry &entry)
Return first found (the earliest) entry for given destination. 
void SetPacket(Ptr< const Packet > p)
Set packet. 
void CheckSendBuffer()
Check the send buffer of packets with route when send buffer timer expire. 
std::map< uint32_t, Ptr< dsr::DsrNetworkQueue > > m_priorityQueue
priority queues 
Describes an IPv6 address. 
std::map< PassiveKey, uint32_t > m_passiveCnt
Map packet key + passive forward counts. 
Ipv4 addresses are stored in host order in this class. 
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated. 
TracedCallback< Ptr< const Packet > > m_dropTrace
The trace for drop, receive and send data packets. 
void SetMaxQueueLen(uint32_t len)
Set the maximum queue length. 
std::map< PassiveKey, Timer > m_passiveAckTimer
The timer for passive acknowledgment. 
Ipv4Address GetNextHop() const
Get next hop of entry. 
void AddPacketTag(const Tag &tag) const
Add a packet tag. 
Ptr< Node > GetNode() const
Get the node. 
void AddDsrOption(DsrOptionHeader const &option)
Serialize the option, prepending pad1 or padn option as necessary. 
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry. 
void CancelPacketTimerNextHop(Ipv4Address nextHop, uint8_t protocol)
Cancel the packet retransmission timer for a all maintenance entries with nextHop address...
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer. 
Ptr< Ipv4Route > m_ipv4Route
Ipv4 Route. 
void SendAck(uint16_t ackId, Ipv4Address destination, Ipv4Address realSrc, Ipv4Address realDst, uint8_t protocol, Ptr< Ipv4Route > route)
Send network layer acknowledgment back to the earlier hop to notify the receipt of data packet...
Time m_nodeTraversalTime
Time estimated for packet to travel between two nodes. 
void SetPacket(Ptr< const Packet > p)
Set packet function. 
void SetRouteCache(Ptr< dsr::DsrRouteCache > r)
Set the route cache. 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
bool m_subRoute
Whether to save sub route or not. 
Time Seconds(double value)
Construct a Time in the indicated unit. 
void Cancel(void)
Cancel the currently-running event if there is one. 
void ScheduleNetworkPacketRetry(DsrMaintainBuffEntry &mb, bool isFirst, uint8_t protocol)
Schedule the packet retransmission based on network layer acknowledgment. 
bool CancelPassiveTimer(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft)
Cancel the passive timer. 
void Insert(Ptr< dsr::DsrOptions > option)
Insert a new Dsr Option. 
Ipv4Address GetIPfromMAC(Mac48Address address)
Get the Ip address from mac address. 
bool SendRealDown(DsrNetworkQueueEntry &newEntry)
This function is called to send packets down stack. 
void RouteRequestTimerExpire(Ptr< Packet > packet, std::vector< Ipv4Address > address, uint32_t requestId, uint8_t protocol)
Handle route discovery timer. 
bool Enqueue(DsrMaintainBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
void CancelNetworkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the network packet retransmission timer for a specific maintenance entry. 
uint32_t m_rreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route. 
void Suspend(void)
Cancel the timer and save the amount of time left until it was set to expire. 
void SetGraTableSize(uint32_t g)
Set the gratuitous reply table size. 
Ptr< Ipv4Route > GetIpv4Route() const
Get IP route function. 
uint16_t m_ackId
acknowledge ID 
void PriorityScheduler(uint32_t priority, bool continueWithFirst)
This function is called to schedule sending packets from the network queue by priority. 
Timer m_sendBuffTimer
The send buffer timer. 
bool LinkEqual(DsrMaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for link ack. 
bool FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
functions used to direct to route cache 
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables. 
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit. 
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR. 
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node with give ip address. 
DsrOptionList_t m_options
List of DSR Options supported. 
Ptr< const Packet > GetPacket() const
Get packet from entry. 
void SendGratuitousReply(Ipv4Address replyTo, Ipv4Address replyFrom, std::vector< Ipv4Address > &nodeList, uint8_t protocol)
Send the gratuitous reply. 
void SendErrorRequest(DsrOptionRerrUnreachHeader &rerr, uint8_t protocol)
Send the error request packet. 
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated. 
PacketType
Packet types are used as they are in Linux. 
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
std::map< LinkKey, uint32_t > m_linkCnt
Map packet key + link forward counts. 
bool IsNull(void) const
Check for null implementation. 
void SetIdentification(uint16_t i)
Set identification function. 
Ptr< const Packet > GetPacket() const
Get packet function. 
std::map< NetworkKey, uint32_t > m_addressForwardCnt
Map network key + forward counts. 
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ipv4Address m_ourAdd
local address 
a unique identifier for an interface. 
Time m_nonpropRequestTimeout
The non-propagation request timeout. 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
std::map< Ipv4Address, Timer > m_nonPropReqTimer
Map IP address + RREQ timer. 
bool Dequeue(Ipv4Address dst, DsrSendBuffEntry &entry)
Return first found (the earliest) entry for the given destination. 
bool m_linkAck
define if we use link acknowledgement or not 
std::vector< std::string > GetElementsFromContext(std::string context)
Get the elements from the tracing context. 
void AddHeader(const Header &header)
Add header to this packet. 
Ptr< dsr::DsrRreqTable > m_rreqTable
A "drop-front" queue used by the routing layer to cache route request sent. 
Ptr< dsr::DsrPassiveBuffer > m_passiveBuffer
A "drop-front" queue used by the routing layer to cache route request sent. 
static const uint16_t PROT_NUMBER
Protocol number (0x0800) 
void SetDestination(Ipv4Address dest)
IpL4Protocol::DownTargetCallback m_downTarget
The callback for down layer. 
DsrSendBuffer m_sendBuffer
The send buffer. 
Ipv4Address GetSourceAddress() const
Get source address function. 
void SetSrc(Ipv4Address s)
Set source address. 
uint16_t GetAckId() const
Get acknowledge ID. 
Time m_maxMaintainTime
Time out for maintenance buffer. 
void CancelRreqTimer(Ipv4Address dst, bool isRemove)
Cancel the route request timer. 
virtual ~DsrRouting()
Destructor.