31 #define NS_LOG_APPEND_CONTEXT \
32 if (GetObject<Node>()) \
34 std::clog << "[node " << GetObject<Node>()->GetId() << "] "; \
44 #include "ns3/adhoc-wifi-mac.h"
45 #include "ns3/arp-header.h"
46 #include "ns3/assert.h"
47 #include "ns3/boolean.h"
48 #include "ns3/config.h"
49 #include "ns3/double.h"
51 #include "ns3/icmpv4-l4-protocol.h"
52 #include "ns3/inet-socket-address.h"
53 #include "ns3/ipv4-address.h"
54 #include "ns3/ipv4-header.h"
55 #include "ns3/ipv4-l3-protocol.h"
56 #include "ns3/ipv4-route.h"
57 #include "ns3/ipv6-interface.h"
58 #include "ns3/llc-snap-header.h"
60 #include "ns3/net-device.h"
61 #include "ns3/node-list.h"
62 #include "ns3/object-vector.h"
63 #include "ns3/packet.h"
64 #include "ns3/pointer.h"
66 #include "ns3/string.h"
67 #include "ns3/tcp-socket-factory.h"
68 #include "ns3/timer.h"
69 #include "ns3/trace-source-accessor.h"
70 #include "ns3/udp-l4-protocol.h"
71 #include "ns3/udp-socket-factory.h"
72 #include "ns3/uinteger.h"
73 #include "ns3/wifi-net-device.h"
119 TypeId(
"ns3::dsr::DsrRouting")
125 "The route cache for saving routes from "
126 "route discovery process.",
129 MakePointerChecker<DsrRouteCache>())
132 "The request table to manage route requests.",
135 MakePointerChecker<DsrRreqTable>())
138 "The passive buffer to manage "
139 "promisucously received passive ack.",
142 MakePointerChecker<DsrPassiveBuffer>())
143 .AddAttribute(
"MaxSendBuffLen",
144 "Maximum number of packets that can be stored "
148 MakeUintegerChecker<uint32_t>())
149 .AddAttribute(
"MaxSendBuffTime",
150 "Maximum time packets can be queued in the send buffer .",
154 .AddAttribute(
"MaxMaintLen",
155 "Maximum number of packets that can be stored "
156 "in maintenance buffer.",
159 MakeUintegerChecker<uint32_t>())
160 .AddAttribute(
"MaxMaintTime",
161 "Maximum time packets can be queued in maintenance buffer.",
165 .AddAttribute(
"MaxCacheLen",
166 "Maximum number of route entries that can be stored "
170 MakeUintegerChecker<uint32_t>())
171 .AddAttribute(
"RouteCacheTimeout",
172 "Maximum time the route cache can be queued in "
177 .AddAttribute(
"MaxEntriesEachDst",
178 "Maximum number of route entries for a "
179 "single destination to respond.",
182 MakeUintegerChecker<uint32_t>())
183 .AddAttribute(
"SendBuffInterval",
184 "How often to check send buffer for packet with route.",
188 .AddAttribute(
"NodeTraversalTime",
189 "The time it takes to traverse two neighboring nodes.",
193 .AddAttribute(
"RreqRetries",
194 "Maximum number of retransmissions for "
195 "request discovery of a route.",
198 MakeUintegerChecker<uint32_t>())
199 .AddAttribute(
"MaintenanceRetries",
200 "Maximum number of retransmissions for "
201 "data packets from maintenance buffer.",
204 MakeUintegerChecker<uint32_t>())
205 .AddAttribute(
"RequestTableSize",
206 "Maximum number of request entries in the request table, "
207 "set this as the number of nodes in the simulation.",
210 MakeUintegerChecker<uint32_t>())
211 .AddAttribute(
"RequestIdSize",
212 "Maximum number of request source Ids in "
213 "the request table.",
216 MakeUintegerChecker<uint32_t>())
217 .AddAttribute(
"UniqueRequestIdSize",
218 "Maximum number of request Ids in "
219 "the request table for a single destination.",
222 MakeUintegerChecker<uint32_t>())
223 .AddAttribute(
"NonPropRequestTimeout",
224 "The timeout value for non-propagation request.",
228 .AddAttribute(
"DiscoveryHopLimit",
229 "The max discovery hop limit for route requests.",
232 MakeUintegerChecker<uint32_t>())
233 .AddAttribute(
"MaxSalvageCount",
234 "The max salvage count for a single data packet.",
237 MakeUintegerChecker<uint8_t>())
238 .AddAttribute(
"BlacklistTimeout",
239 "The time for a neighbor to stay in blacklist.",
243 .AddAttribute(
"GratReplyHoldoff",
244 "The time for gratuitous reply entry to expire.",
248 .AddAttribute(
"BroadcastJitter",
249 "The jitter time to avoid collision for broadcast packets.",
252 MakeUintegerChecker<uint32_t>())
253 .AddAttribute(
"LinkAckTimeout",
254 "The time a packet in maintenance buffer wait for "
255 "link acknowledgment.",
259 .AddAttribute(
"TryLinkAcks",
260 "The number of link acknowledgment to use.",
263 MakeUintegerChecker<uint32_t>())
264 .AddAttribute(
"PassiveAckTimeout",
265 "The time a packet in maintenance buffer wait for "
266 "passive acknowledgment.",
270 .AddAttribute(
"TryPassiveAcks",
271 "The number of passive acknowledgment to use.",
274 MakeUintegerChecker<uint32_t>())
275 .AddAttribute(
"RequestPeriod",
276 "The base time interval between route requests.",
280 .AddAttribute(
"MaxRequestPeriod",
281 "The max time interval between route requests.",
285 .AddAttribute(
"GraReplyTableSize",
286 "The gratuitous reply table size.",
289 MakeUintegerChecker<uint32_t>())
290 .AddAttribute(
"CacheType",
291 "Use Link Cache or use Path Cache",
295 .AddAttribute(
"StabilityDecrFactor",
296 "The stability decrease factor for link cache",
299 MakeUintegerChecker<uint32_t>())
300 .AddAttribute(
"StabilityIncrFactor",
301 "The stability increase factor for link cache",
304 MakeUintegerChecker<uint32_t>())
305 .AddAttribute(
"InitStability",
306 "The initial stability factor for link cache",
310 .AddAttribute(
"MinLifeTime",
311 "The minimal life time for link cache",
315 .AddAttribute(
"UseExtends",
316 "The extension time for link cache",
320 .AddAttribute(
"EnableSubRoute",
321 "Enables saving of sub route when receiving "
322 "route error messages, only available when "
323 "using path route cache",
327 .AddAttribute(
"RetransIncr",
328 "The increase time for retransmission timer "
329 "when facing network congestion",
333 .AddAttribute(
"MaxNetworkQueueSize",
334 "The max number of packet to save in the network queue.",
337 MakeUintegerChecker<uint32_t>())
338 .AddAttribute(
"MaxNetworkQueueDelay",
339 "The max time for a packet to stay in the network queue.",
343 .AddAttribute(
"NumPriorityQueues",
344 "The max number of packet to save in the network queue.",
347 MakeUintegerChecker<uint32_t>())
348 .AddAttribute(
"LinkAcknowledgment",
349 "Enable Link layer acknowledgment mechanism",
353 .AddTraceSource(
"Tx",
356 "ns3::dsr::DsrOptionSRHeader::TracedCallback")
357 .AddTraceSource(
"Drop",
360 "ns3::Packet::TracedCallback");
411 Ptr<Node> node = this->GetObject<Node>();
414 m_ipv4 = this->GetObject<Ipv4L3Protocol>();
446 std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator,
bool> result_i =
479 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces(); i++)
484 if (addr != loopback)
502 routeCache->ScheduleTimer();
511 m_ipv4->GetNetDevice(1)->SetPromiscReceiveCallback(
527 routeCache->AddArpCache(
m_ipv4->GetInterface(i)->GetArpCache());
545 return n->
GetDevice(std::stoi(elements[3]));
548 std::vector<std::string>
551 std::vector<std::string> elements;
554 while (pos1 != std::string::npos)
556 pos1 = context.find(
'/', pos1);
557 pos2 = context.find(
'/', pos1 + 1);
558 elements.push_back(context.substr(pos1 + 1, pos2 - (pos1 + 1)));
569 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces(); i++)
582 adhoc->TraceDisconnectWithoutContext(
"TxErrHeader",
652 for (int32_t i = 0; i < nNodes; ++i)
656 int32_t ifIndex = ipv4->GetInterfaceForAddress(ipv4Address);
694 std::vector<Ipv4Address> nodelist = rt.
GetVector();
705 m_routeCache->DeleteAllRoutesIncludeLink(errorSrc, unreachNode, node);
725 for (int32_t i = 0; i < nNodes; ++i)
731 if (netDevice->GetAddress() ==
address)
733 return ipv4->GetAddress(1, 0).GetLocal();
753 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
774 if (ipv4Address == vec.back())
776 NS_LOG_DEBUG(
"We have reached to the final destination " << ipv4Address <<
" "
780 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
782 if (ipv4Address == (*i))
816 for (int32_t i = 0; i < nNodes; ++i)
820 if (ipv4->GetAddress(1, 0).GetLocal() ==
address)
840 return ipv4->GetAddress(1, 0).GetLocal();
877 NS_LOG_DEBUG(
"Here we try to find the data packet in the send buffer");
880 bool findRoute =
m_routeCache->LookupRoute(destination, toDst);
883 NS_LOG_INFO(
"We have found a route for the packet");
886 uint8_t protocol = i->GetProtocol();
902 uint32_t size = copyP->
GetSize();
903 uint8_t*
data =
new uint8_t[size];
906 uint8_t optionType = 0;
907 optionType = *(
data);
913 uint8_t errorType = *(
data + 2);
930 std::vector<Ipv4Address> errorRoute = toDst.
GetVector();
943 if (nextHop ==
"0.0.0.0")
967 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
970 NS_LOG_LOGIC(
"Will be inserting into priority queue number: " << priority);
982 if (dsrNetworkQueue->Enqueue(newEntry))
988 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
1000 std::vector<Ipv4Address> nodeList =
1005 if (nextHop ==
"0.0.0.0")
1010 uint8_t salvage = 0;
1014 (nodeList.size() - 2));
1021 uint8_t length = sourceRoute.
GetLength();
1033 nodeList.size() - 2,
1069 if (nextHop != destination)
1151 newEntry.
SetSrc(sourceIp);
1152 newEntry.
SetDst(destinationIp);
1161 dsr->CancelLinkPacketTimer(newEntry);
1168 NS_LOG_INFO(
this << from << to << packetType << *pktMinusIpHdr);
1182 uint32_t size = pktMinusIpHdr->
GetSize();
1183 uint8_t*
data =
new uint8_t[size];
1185 uint8_t optionType = 0;
1186 optionType = *(
data);
1190 if (optionType == 96)
1197 <<
" overhearing packet PID: " << pktMinusIpHdr->
GetUid() <<
" from "
1199 <<
" with source IP " << ipv4Header.
GetSource() <<
" and destination IP "
1200 << ipv4Header.
GetDestination() <<
" and packet : " << *pktMinusDsrHdr);
1202 bool isPromisc =
true;
1203 dsrOption->Process(pktMinusIpHdr,
1223 NS_LOG_FUNCTION(
this << packet << source << destination << (uint32_t)protocol);
1226 bool findRoute =
m_routeCache->LookupRoute(destination, toDst);
1232 <<
" there is no route for this packet, queue the packet");
1243 <<
" to queue. Packet: " << *packet);
1267 std::vector<Ipv4Address> nodeList =
1271 if (nextHop ==
"0.0.0.0")
1276 uint8_t salvage = 0;
1285 (nodeList.size() - 2));
1288 uint8_t length = sourceRoute.
GetLength();
1301 nodeList.size() - 2,
1338 if (nextHop != destination)
1359 NS_LOG_FUNCTION(
this << unreachNode << destination << originalDst << (uint32_t)salvage
1360 << (uint32_t)protocol);
1374 uint8_t rerrLength = rerrUnreachHeader.
GetLength();
1377 bool findRoute =
m_routeCache->LookupRoute(destination, toDst);
1384 NS_LOG_INFO(
"We are the error source, send request to original dst " << originalDst);
1392 <<
" there is no route for this packet, queue the packet");
1409 <<
" Add packet PID: " << p->
GetUid() <<
" to queue. Packet: " << *p);
1414 NS_LOG_DEBUG(
"When there is no existing route request for "
1415 << destination <<
", initialize one");
1427 std::vector<Ipv4Address> nodeList = toDst.
GetVector();
1429 if (nextHop ==
"0.0.0.0")
1443 uint8_t srLength = sourceRoute.
GetLength();
1444 uint8_t length = (srLength + rerrLength);
1454 NS_LOG_INFO(
"Send the packet to the next hop address " << nextHop <<
" from "
1459 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
1461 NS_LOG_DEBUG(
"Will be inserting into priority queue " << dsrNetworkQueue
1462 <<
" number: " << priority);
1473 if (dsrNetworkQueue->Enqueue(newEntry))
1479 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
1491 NS_LOG_FUNCTION(
this << rerr << sourceRoute << nextHop << (uint32_t)protocol << route);
1506 route->SetOutputDevice(dev);
1509 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
1511 NS_LOG_DEBUG(
"Will be inserting into priority queue " << dsrNetworkQueue
1512 <<
" number: " << priority);
1519 if (dsrNetworkQueue->Enqueue(newEntry))
1525 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
1536 NS_LOG_FUNCTION(
this << packet << source << destination << (uint32_t)protocol << route);
1541 NS_LOG_INFO(
"Drop packet. Not handling ICMP packet for now");
1547 bool findRoute =
m_routeCache->LookupRoute(destination, toDst);
1553 <<
" there is no route for this packet, queue the packet");
1564 <<
" to send buffer. Packet: " << *packet);
1579 NS_LOG_LOGIC(
"There is existing route request timer with request count "
1594 std::vector<Ipv4Address> nodeList =
1598 if (nextHop ==
"0.0.0.0")
1603 uint8_t salvage = 0;
1612 (nodeList.size() - 2));
1615 uint8_t length = sourceRoute.
GetLength();
1630 nodeList.size() - 2,
1666 if (nextHop != destination)
1703 uint32_t sourceId = dsrRoutingHeader.
GetSourceId();
1704 uint32_t destinationId = dsrRoutingHeader.
GetDestId();
1712 uint8_t numberAddress = (buf[1] - 2) / 4;
1725 newDsrRoutingHeader.
SetDestId(destinationId);
1741 NS_LOG_FUNCTION(
this << packet << source << nextHop << (uint32_t)protocol);
1748 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
1750 NS_LOG_INFO(
"Will be inserting into priority queue number: " << priority);
1757 if (dsrNetworkQueue->Enqueue(newEntry))
1763 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
1778 uint32_t numPriorities;
1779 if (continueWithFirst)
1785 numPriorities = priority;
1790 std::map<uint32_t, Ptr<DsrNetworkQueue>>::iterator q =
m_priorityQueue.find(i);
1792 uint32_t queueSize = dsrNetworkQueue->GetSize();
1806 uint32_t totalQueueSize = 0;
1812 NS_LOG_INFO(
"The size of the network queue for " << j->first <<
" is "
1813 << j->second->GetSize());
1814 totalQueueSize += j->second->GetSize();
1815 NS_LOG_INFO(
"The total network queue size is " << totalQueueSize);
1817 if (totalQueueSize > 5)
1824 dsrNetworkQueue->Dequeue(newEntry);
1827 NS_LOG_LOGIC(
"Packet sent by Dsr. Calling PriorityScheduler after some time");
1839 NS_LOG_LOGIC(
"Packet dropped by Dsr. Calling PriorityScheduler immediately");
1862 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
1865 std::vector<DsrNetworkQueueEntry> newNetworkQueue = dsrNetworkQueue->GetQueue();
1866 for (std::vector<DsrNetworkQueueEntry>::iterator i = newNetworkQueue.begin();
1867 i != newNetworkQueue.end();
1875 if (nextHop == j->first.m_nextHop)
1877 NS_LOG_DEBUG(
"The network delay left is " << j->second.GetDelayLeft());
1878 j->second.SetDelay(j->second.GetDelayLeft() +
m_retransIncr);
1908 NS_LOG_INFO(
"The nexthop address " << nextHop <<
" the source " << source <<
" the destination "
1935 uint8_t length = sourceRoute.
GetLength();
1949 nodeList.size() - 2,
1986 if (nextHop != destination)
1999 <<
" " << destination);
2002 NS_LOG_LOGIC(
"Schedule sending the next packet in send buffer");
2013 NS_LOG_LOGIC(
"All queued packets are out-dated for the destination in send buffer");
2038 uint32_t size = copyP->
GetSize();
2039 uint8_t*
data =
new uint8_t[size];
2042 uint8_t optionType = 0;
2043 optionType = *(
data);
2044 NS_LOG_DEBUG(
"The option type value in send packet " << (uint32_t)optionType);
2045 if (optionType == 3)
2051 uint8_t errorType = *(
data + 2);
2055 NS_LOG_DEBUG(
"The packet is route error unreach packet");
2093 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
2097 << dsrNetworkQueue <<
" number: " << priority);
2109 if (dsrNetworkQueue->Enqueue(newEntry))
2115 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
2122 NS_LOG_LOGIC(
"Schedule sending the next packet in error buffer");
2134 NS_LOG_DEBUG(
"Packet not found in either the send or error buffer");
2143 uint16_t fragmentOffset,
2144 uint16_t identification,
2165 NS_LOG_DEBUG(
"We get the all equal for passive buffer here");
2170 mbEntry.
SetDst(destination);
2200 newEntry.
SetDst(destination);
2220 NS_LOG_FUNCTION(
this << (uint32_t)ackId << ipv4Header << realSrc << realDst);
2267 std::map<LinkKey, Timer>::const_iterator i =
m_linkAckTimer.find(linkKey);
2292 NS_LOG_INFO(
"Link acknowledgment received, remove same maintenance buffer entry");
2339 NS_LOG_INFO(
"Remove same maintenance buffer entry based on network acknowledgment");
2357 std::map<PassiveKey, Timer>::const_iterator j =
m_passiveAckTimer.find(passiveKey);
2383 std::vector<Ipv4Address> previousErrorDst;
2400 uint8_t numberAddress = (buf[1] - 2) / 4;
2401 NS_LOG_DEBUG(
"The number of addresses " << (uint32_t)numberAddress);
2417 errorDst = address1;
2424 if (std::find(previousErrorDst.begin(), previousErrorDst.end(), destination) ==
2425 previousErrorDst.end())
2427 NS_LOG_DEBUG(
"have not seen this dst before " << errorDst <<
" in "
2428 << previousErrorDst.size());
2430 previousErrorDst.push_back(errorDst);
2442 NS_LOG_INFO(
"Cancel the packet timer for next maintenance entry");
2452 NS_LOG_INFO(
"Maintenance buffer entry not found");
2463 NS_LOG_FUNCTION(
this << packet << source << dst << (uint32_t)protocol);
2476 newPacket->
CopyData(buf,
sizeof(buf));
2477 uint8_t numberAddress = (buf[1] - 2) / 4;
2487 bool findRoute =
m_routeCache->LookupRoute(dst, toDst);
2497 std::vector<Ipv4Address> nodeList =
2501 if (nextHop ==
"0.0.0.0")
2513 (nodeList.size() - 2));
2519 uint8_t length = sourceRoute.
GetLength();
2531 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
2533 NS_LOG_DEBUG(
"Will be inserting into priority queue " << dsrNetworkQueue
2534 <<
" number: " << priority);
2541 if (dsrNetworkQueue->Enqueue(newEntry))
2547 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
2558 NS_LOG_DEBUG(
"Will not salvage this packet, silently drop");
2614 NS_LOG_DEBUG(
"The passive acknowledgment option for data packet");
2765 NS_LOG_INFO(
"We need to send error messages now");
2871 NS_LOG_FUNCTION(
this << packet << sourceRoute << source << nextHop << targetAddress
2872 << (uint32_t)protocol << route);
2884 uint8_t length = sourceRoute.
GetLength();
2933 if (nextHop != targetAddress)
2971 uint8_t length = rreqHeader.
GetLength();
2976 bool nonProp =
true;
2977 std::vector<Ipv4Address>
address;
2979 address.push_back(destination);
3012 std::vector<Ipv4Address> ip = toDst.
GetVector();
3024 if (nextHop ==
"0.0.0.0")
3042 NS_LOG_INFO(
"No route found, initiate route error request");
3071 bool nonProp =
false;
3072 std::vector<Ipv4Address>
address;
3074 address.push_back(originalDst);
3086 NS_LOG_INFO(
"Only when there is no existing route request time when the initial route "
3087 "request is scheduled");
3093 NS_LOG_INFO(
"There is existing route request, find the existing route request entry");
3112 NS_LOG_DEBUG(
"Did not find the non-propagation timer");
3154 std::vector<Ipv4Address>
address,
3159 NS_LOG_FUNCTION(
this << packet << nonProp << requestId << (uint32_t)protocol);
3170 std::vector<Ipv4Address>
address;
3193 std::vector<Ipv4Address>
address;
3205 rreqDelay =
Time(std::pow(
static_cast<double>(
m_rreqTable->GetRreqCnt(dst)), 2.0) *
3214 <<
" with delay time " << rreqDelay.
As(
Time::S));
3231 std::vector<Ipv4Address>
address,
3250 std::vector<Ipv4Address> ip = toDst.
GetVector();
3261 NS_LOG_INFO(
"The nextHop address is " << nextHop);
3262 if (nextHop ==
"0.0.0.0")
3291 NS_LOG_DEBUG(
"Route not found. Drop packet with dst " << dst);
3303 NS_LOG_DEBUG(
"Check the route request entry " << source <<
" " << dst);
3318 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
3320 NS_LOG_LOGIC(
"Inserting into priority queue number: " << priority);
3326 if (dsrNetworkQueue->Enqueue(newEntry))
3332 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
3354 std::vector<Ipv4Address>& nodeList,
3372 std::vector<Ipv4Address>::iterator before =
3373 find(nodeList.begin(), nodeList.end(), srcAddress);
3374 for (std::vector<Ipv4Address>::iterator i = nodeList.begin(); i != before; ++i)
3379 std::vector<Ipv4Address>::iterator after =
3381 for (std::vector<Ipv4Address>::iterator j = after; j != nodeList.end(); ++j)
3417 NS_LOG_INFO(
"The same gratuitous route reply has already sent");
3431 route->SetOutputDevice(dev);
3432 NS_LOG_INFO(
"The output device " << dev <<
" packet is: " << *packet);
3435 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
3437 NS_LOG_INFO(
"Inserting into priority queue number: " << priority);
3443 if (dsrNetworkQueue->Enqueue(newEntry))
3449 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
3489 NS_LOG_FUNCTION(
this << ackId << destination << realSrc << realDst << (uint32_t)protocol
3515 route->SetOutputDevice(dev);
3518 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue>>::iterator i =
m_priorityQueue.find(priority);
3521 NS_LOG_LOGIC(
"Will be inserting into priority queue " << dsrNetworkQueue
3522 <<
" number: " << priority);
3528 if (dsrNetworkQueue->Enqueue(newEntry))
3534 NS_LOG_INFO(
"Packet dropped as dsr network queue is full");
3544 << incomingInterface);
3555 uint32_t sourceId = dsrRoutingHeader.
GetSourceId();
3557 NS_LOG_INFO(
"The source address " << source <<
" with source id " << sourceId);
3563 bool isPromisc =
false;
3577 uint8_t*
data =
new uint8_t[size];
3580 uint8_t optionType = 0;
3581 uint8_t optionLength = 0;
3582 uint8_t segmentsLeft = 0;
3584 optionType = *(
data);
3585 NS_LOG_LOGIC(
"The option type value " << (uint32_t)optionType <<
" with packet id "
3590 if (optionType == 1)
3595 NS_LOG_INFO(
"Discard this packet due to unidirectional link");
3602 ->Process(p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3604 if (optionLength == 0)
3610 else if (optionType == 2)
3615 ->Process(p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3617 if (optionLength == 0)
3624 else if (optionType == 32)
3630 ->Process(p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3632 if (optionLength == 0)
3639 else if (optionType == 3)
3642 NS_LOG_INFO(
"The option type value " << (uint32_t)optionType);
3647 ->Process(p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3649 if (optionLength == 0)
3654 NS_LOG_INFO(
"The option Length " << (uint32_t)optionLength);
3657 else if (optionType == 96)
3662 ->Process(p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3663 segmentsLeft = *(
data + 3);
3664 if (optionLength == 0)
3671 if (segmentsLeft == 0)
3676 Ptr<IpL4Protocol> nextProto = l3proto->GetProtocol(nextHeader);
3683 nextProto->Receive(copy, ip, incomingInterface);
3710 NS_LOG_INFO(
"This is not the final destination, the packet has already been "
3711 "forward to next hop");
3721 uint8_t salvage = 0;
3723 DsrOptionRerrUnsupportHeader rerrUnsupportHeader;
3724 rerrUnsupportHeader.SetErrorType(3);
3725 rerrUnsupportHeader.SetErrorSrc(
3727 rerrUnsupportHeader.SetUnsupported(optionType);
3728 rerrUnsupportHeader.SetErrorDst(
3730 rerrUnsupportHeader.SetSalvage(
3743 DsrRouting::Receive(Ptr<Packet> p,
const Ipv6Header& ip, Ptr<Ipv6Interface> incomingInterface)
3745 NS_LOG_FUNCTION(
this << p << ip.GetSource() << ip.GetDestination() << incomingInterface);
3785 if ((*i)->GetOptionNumber() == optionNumber)
a polymophic address class
Wifi MAC high model for an ad-hoc Wifi MAC.
AttributeValue implementation for Boolean.
bool IsNull() const
Check for null implementation.
L4 Protocol abstract base class.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route) override
Describes an IPv6 address.
static Mac48Address ConvertFrom(const Address &address)
PacketType
Packet types are used as they are in Linux.
@ PACKET_OTHERHOST
Packet addressed to someone else.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static uint32_t GetNNodes()
static Ptr< Node > GetNode(uint32_t n)
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
virtual void DoDispose()
Destructor implementation.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
uint64_t GetUid() const
Returns the packet's Uid.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
A simple virtual Timer class.
@ CANCEL_ON_DESTROY
This policy cancels the event from the destructor of the Timer or from Suspend().
void Cancel()
Cancel the currently-running event if there is one.
void Schedule()
Schedule a new event using the currently-configured delay, function, and arguments.
void Resume()
Restart the timer to expire within the amount of time left saved during Suspend.
void Suspend()
Pause the timer and save the amount of time left until it was set to expire.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
Hold together all Wifi-related objects.
Ptr< const Packet > GetPacket() const
Get packet from entry.
void SetMaxQueueLen(uint32_t len)
Set maximum queue length.
bool Enqueue(DsrErrorBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue.
bool Dequeue(Ipv4Address dst, DsrErrorBuffEntry &entry)
Return first found (the earliest) entry for given destination.
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue.
void DropPacketForErrLink(Ipv4Address source, Ipv4Address nextHop)
Remove all packets with the error link.
void SetErrorBufferTimeout(Time t)
Set error buffer timeout.
uint32_t GetSize()
Returns the number of entries in the queue.
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
void SetGraTableSize(uint32_t g)
Set the gratuitous reply table size.
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found.
DSR Maintain Buffer Entry.
uint8_t GetSegsLeft() const
Get segments left.
void SetDst(Ipv4Address n)
Set destination address.
void SetExpireTime(Time exp)
Set expiration time.
Ptr< const Packet > GetPacket() const
Get packet.
void SetNextHop(Ipv4Address n)
Set next hop of entry.
Ipv4Address GetSrc() const
Get source address.
void SetSegsLeft(uint8_t segs)
Set segments left.
void SetPacket(Ptr< const Packet > p)
Set packet.
void SetOurAdd(Ipv4Address us)
Set local address of entry.
void SetSrc(Ipv4Address s)
Set source address.
uint16_t GetAckId() const
Get acknowledge ID.
Ipv4Address GetOurAdd() const
Get local address of entry.
void SetAckId(uint16_t ackId)
Set acknowledge ID.
Ipv4Address GetNextHop() const
Get next hop of entry.
Ipv4Address GetDst() const
Get destination address.
bool Dequeue(Ipv4Address dst, DsrMaintainBuffEntry &entry)
Return first found (the earliest) entry for given destination.
void SetMaxQueueLen(uint32_t len)
Set maximum queue length.
bool AllEqual(DsrMaintainBuffEntry &entry)
Verify if all the elements in the maintenance buffer entry is the same.
bool LinkEqual(DsrMaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for link ack.
bool Find(Ipv4Address nextHop)
Finds whether a packet with next hop dst exists in the queue.
void SetMaintainBufferTimeout(Time t)
Set maintain buffer timeout.
uint32_t GetSize()
Number of entries.
bool PromiscEqual(DsrMaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for promiscuous ack.
bool NetworkEqual(DsrMaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for network ack.
bool Enqueue(DsrMaintainBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue.
Ipv4Address GetSourceAddress() const
Get source address function.
Ptr< const Packet > GetPacket() const
Get packet function.
Ptr< Ipv4Route > GetIpv4Route() const
Get IP route function.
Ipv4Address GetNextHopAddress() const
Get next hop address function.
void AddDsrOption(const DsrOptionHeader &option)
Serialize the option, prepending pad1 or padn option as necessary.
uint32_t GetDsrOptionsOffset() const
Get the offset where the options begin, measured from the start of the extension header.
DSR Passive Buffer Entry.
void SetIdentification(uint16_t i)
Set identification function.
void SetDestination(Ipv4Address d)
Set destination address function.
void SetSegsLeft(uint8_t seg)
Set segments left.
void SetSource(Ipv4Address s)
Set surce address function.
void SetPacket(Ptr< const Packet > p)
Set packet function.
void SetFragmentOffset(uint16_t f)
Set fragment offset function.
DsrRouteCacheEntry class for entries in the route cache.
IP_VECTOR GetVector() const
Get the IP vector.
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Ptr< dsr::DsrRreqTable > GetRequestTable() const
Get the request table.
void ScheduleInterRequest(Ptr< Packet > packet)
Schedule the intermediate route request.
void CheckSendBuffer()
Check the send buffer of packets with route when send buffer timer expire.
Ptr< Ipv4 > m_ip
The ip ptr.
void ScheduleRreqRetry(Ptr< Packet > packet, std::vector< Ipv4Address > address, bool nonProp, uint32_t requestId, uint8_t protocol)
Schedule the route request retry.
void NotifyNewAggregate() override
Notify all Objects aggregated to this one of a new Object being aggregated.
Time m_blacklistTimeout
The black list time out.
std::string m_cacheType
The type of route cache.
std::map< Ipv4Address, Timer > m_nonPropReqTimer
Map IP address + RREQ timer.
IpL4Protocol::DownTargetCallback GetDownTarget() const override
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
void SetNode(Ptr< Node > node)
Set the node.
void SendBuffTimerExpire()
The send buffer timer expire.
void SetPassiveBuffer(Ptr< dsr::DsrPassiveBuffer > r)
Set the node.
std::vector< std::string > GetElementsFromContext(std::string context)
Get the elements from the tracing context.
void UseExtends(DsrRouteCacheEntry::IP_VECTOR rt)
Extends the lifetime of a route cache entry.
uint32_t m_maxRreqId
The max number of request ids for a single destination.
bool SendRealDown(DsrNetworkQueueEntry &newEntry)
This function is called to send packets down stack.
Time m_sendBufferTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for.
uint8_t segsLeft
The segment left value from SR header.
void SendRequest(Ptr< Packet > packet, Ipv4Address source)
Forward the route request if the node is not the destination.
void CancelPacketTimerNextHop(Ipv4Address nextHop, uint8_t protocol)
Cancel the packet retransmission timer for a all maintenance entries with nextHop address.
bool m_linkAck
define if we use link acknowledgement or not
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
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.
bool CancelPassiveTimer(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft)
Cancel the passive timer.
void PassiveScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using passive acknowledgment.
bool AddRoute_Link(DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
dd route link to cache See also DsrRouteCache::AddRoute_Link
uint16_t m_ackId
The ack id assigned to each acknowledge.
void CancelLinkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the link packet retransmission timer for a specific maintenance entry.
Time m_nonpropRequestTimeout
The non-propagation request timeout.
Time m_gratReplyHoldoff
The max gratuitous reply hold off time.
uint16_t GetIDfromIP(Ipv4Address address)
Get the node id from ip address.
std::map< uint32_t, Ptr< dsr::DsrNetworkQueue > > m_priorityQueue
priority queues
uint32_t m_maxEntriesEachDst
Max number of route entries to save for each destination.
std::map< Ipv4Address, Timer > m_addressReqTimer
Map IP address + RREQ timer.
Time m_retransIncr
the increase time for retransmission timer when face network congestion
std::map< NetworkKey, Timer > m_addressForwardTimer
Map network key + forward timer.
uint32_t m_stabilityDecrFactor
The initial decrease factor for link cache.
Time m_nodeTraversalTime
Time estimated for packet to travel between two nodes.
uint32_t m_requestId
The id assigned to each route request.
std::map< NetworkKey, uint32_t > m_addressForwardCnt
Map network key + forward counts.
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get the netdevice from the context.
bool FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
Find the source request entry in the route request queue, return false if not found.
Ipv4Address m_broadcast
The broadcast IP address.
Ptr< dsr::DsrPassiveBuffer > GetPassiveBuffer() const
Get the passive buffer.
Ipv4Address GetIPfromMAC(Mac48Address address)
Get the Ip address from mac address.
Ptr< dsr::DsrRouteCache > GetRouteCache() const
Get the route cache.
Time m_maxNetworkDelay
Maximum network delay.
Ptr< dsr::DsrOptions > GetOption(int optionNumber)
Get the option corresponding to optionNumber.
uint32_t m_maxSendBuffLen
The maximum number of packets that we allow a routing protocol to buffer.
Time m_passiveAckTimeout
The timeout value for passive acknowledge.
void SetRequestTable(Ptr< dsr::DsrRreqTable > r)
Set the node.
uint32_t m_maxMaintainLen
Max # of entries for maintenance buffer.
static const uint8_t PROT_NUMBER
Define the dsr protocol number.
uint32_t GetPriority(DsrMessageType messageType)
Set the priority of the packet in network queue.
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.
void ScheduleNetworkPacketRetry(DsrMaintainBuffEntry &mb, bool isFirst, uint8_t protocol)
Schedule the packet retransmission based on network layer acknowledgment.
Ipv4Address m_mainAddress
Our own Ip address.
void SendInitialRequest(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Broadcast the route request packet in subnet.
Timer m_sendBuffTimer
The send buffer timer.
Time m_maxCacheTime
Max time for caching the route cache entry.
void SendGratuitousReply(Ipv4Address replyTo, Ipv4Address replyFrom, std::vector< Ipv4Address > &nodeList, uint8_t protocol)
Send the gratuitous reply.
void DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
Delete all the routes which includes the link from next hop address that has just been notified as un...
DsrOptionList_t m_options
List of DSR Options supported.
std::map< PassiveKey, uint32_t > m_passiveCnt
Map packet key + passive forward counts.
DsrErrorBuffer m_errorBuffer
The error buffer to save the error messages.
void SalvagePacket(Ptr< const Packet > packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol)
Salvage the packet which has been transmitted for 3 times.
bool m_subRoute
Whether to save sub route or not.
enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, const Ipv4Header &header, Ptr< Ipv4Interface > incomingInterface) override
void SendPacket(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol)
This function is called by when really sending out the packet.
void SetDownTarget(IpL4Protocol::DownTargetCallback callback) override
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
bool IsLinkCache()
Checks if the link is cached in the route cache See also DsrRouteCache::IsLinkCache.
std::map< LinkKey, uint32_t > m_linkCnt
Map packet key + link forward counts.
~DsrRouting() override
Destructor.
DsrSendBuffer m_sendBuffer
The send buffer.
uint32_t m_passiveRetries
uint32_t m_rreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route.
uint8_t m_maxSalvageCount
Maximum # times to salvage a packet.
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.
uint16_t AddAckReqHeader(Ptr< Packet > &packet, Ipv4Address nextHop)
This function is called to add ack request header for network acknowledgement.
uint32_t m_requestTableSize
The max size of the request table size.
DsrGraReply m_graReply
The gratuitous route reply.
void ScheduleLinkPacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on link-layer acknowledgment.
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.
Time m_sendBuffInterval
how often to check send buffer
TracedCallback< const DsrOptionSRHeader & > m_txPacketTrace
packet trace callback
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,...
bool LookupRoute(Ipv4Address id, DsrRouteCacheEntry &rt)
Lookup route cache entry with destination address dst See also DsrRouteCache::LookupRoute.
Time m_initStability
The initial stability value for link cache.
uint32_t m_stabilityIncrFactor
The initial increase factor for link cache.
void SetDownTarget6(IpL4Protocol::DownTargetCallback6 callback) override
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
Time m_useExtends
The use extension of the life time for link cache.
uint32_t m_numPriorityQueues
The number of priority queues used.
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Get the next hop of the route.
IpL4Protocol::DownTargetCallback m_downTarget
The callback for down layer.
uint32_t m_graReplyTableSize
Set the gratuitous reply table size.
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.
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node with give ip address.
Ptr< Ipv4L3Protocol > m_ipv4
Ipv4l3Protocol.
void Scheduler(uint32_t priority)
This function is called to schedule sending packets from the network queue.
void RouteRequestTimerExpire(Ptr< Packet > packet, std::vector< Ipv4Address > address, uint32_t requestId, uint8_t protocol)
Handle route discovery timer.
void NetworkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using network acknowledgment.
uint32_t m_requestTableIds
The request table identifiers.
TracedCallback< Ptr< const Packet > > m_dropTrace
The trace for drop, receive and send data packets.
void SendPacketFromBuffer(const DsrOptionSRHeader &sourceRoute, Ipv4Address nextHop, uint8_t protocol)
This function is responsible for sending out data packets when have route, if no route found,...
uint32_t m_tryPassiveAcks
Maximum number of packet transmission using passive acknowledgment.
void LinkScheduleTimerExpire(DsrMaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using link acknowledgment.
bool UpdateRouteEntry(Ipv4Address dst)
Update route cache entry if it has been recently used and successfully delivered the data packet.
uint32_t m_maxNetworkSize
Maximum network queue size.
Ptr< Ipv4Route > m_ipv4Route
Ipv4 Route.
Ptr< Node > GetNode() const
Get the node.
Ipv4Address GetIPfromID(uint16_t id)
Get the ip address from id.
Time m_maxRequestPeriod
The max request period.
void SchedulePassivePacketRetry(DsrMaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on passive acknowledgment.
Ptr< dsr::DsrPassiveBuffer > m_passiveBuffer
A "drop-front" queue used by the routing layer to cache route request sent.
Ptr< Node > m_node
The node ptr.
Ptr< dsr::DsrRouteCache > m_routeCache
A "drop-front" queue used by the routing layer to cache routes found.
std::map< PassiveKey, Timer > m_passiveAckTimer
The timer for passive acknowledgment.
bool AddRoute(DsrRouteCacheEntry &rt)
Add route cache entry if it doesn't yet exist in route cache See also DsrRouteCache::AddRoute.
Time m_maxMaintainTime
Time out for maintenance buffer.
DsrMaintainBuffer m_maintainBuffer
The declaration of maintain buffer.
uint32_t m_maxMaintRexmt
Maximum number of retransmissions of data packets.
void CallCancelPacketTimer(uint16_t ackId, const Ipv4Header &ipv4Header, Ipv4Address realSrc, Ipv4Address realDst)
Call the cancel packet retransmission timer function.
Time m_requestPeriod
The base time interval between route requests.
Time m_linkAckTimeout
The timeout value for link acknowledge.
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.
uint32_t m_tryLinkAcks
Maximum number of packet transmission using link acknowledgment.
uint32_t m_discoveryHopLimit
Maximum hops to go for route request.
void CancelRreqTimer(Ipv4Address dst, bool isRemove)
Cancel the route request timer.
std::map< LinkKey, Timer > m_linkAckTimer
The timer for link acknowledgment.
IpL4Protocol::DownTargetCallback6 GetDownTarget6() const override
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
Time m_minLifeTime
The min life time.
void ForwardPacket(Ptr< const Packet > packet, DsrOptionSRHeader &sourceRoute, const Ipv4Header &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.
static TypeId GetTypeId()
Get the type identificator.
void SendErrorRequest(DsrOptionRerrUnreachHeader &rerr, uint8_t protocol)
Send the error request packet.
void DoDispose() override
Drop trace callback.
int GetProtocolNumber() const override
Get the dsr protocol number.
void PacketNewRoute(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol)
When route vector corrupted, originate a new packet, normally not happening.
Ptr< dsr::DsrRreqTable > m_rreqTable
A "drop-front" queue used by the routing layer to cache route request sent.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void IncreaseRetransTimer()
This function is called to increase the retransmission timer for data packet in the network queue.
void CancelPassivePacketTimer(DsrMaintainBuffEntry &mb)
Cancel the passive packet retransmission timer for a specific maintenance entry.
void CancelNetworkPacketTimer(DsrMaintainBuffEntry &mb)
Cancel the network packet retransmission timer for a specific maintenance entry.
void PriorityScheduler(uint32_t priority, bool continueWithFirst)
This function is called to schedule sending packets from the network queue by priority.
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.
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.
void SetRouteCache(Ptr< dsr::DsrRouteCache > r)
Set the route cache.
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.
void Insert(Ptr< dsr::DsrOptions > option)
Insert a new Dsr Option.
std::vector< Ipv4Address > m_finalRoute
The route cache.
void CancelPacketAllTimer(DsrMaintainBuffEntry &mb)
Cancel all the packet timers.
uint32_t m_broadcastJitter
The max time to delay route request broadcast.
uint32_t m_maxCacheLen
Max # of cache entries for route cache.
Ptr< const Packet > GetPacket() const
Get pointer to entry's packet.
void SetMaxQueueLen(uint32_t len)
Set the maximum queue length.
uint32_t GetSize()
Number of entries.
bool Dequeue(Ipv4Address dst, DsrSendBuffEntry &entry)
Return first found (the earliest) entry for the given destination.
void SetSendBufferTimeout(Time t)
Set the entry lifetime in the queue.
bool Enqueue(DsrSendBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue.
bool Find(Ipv4Address dst)
Check if a packet with destination dst exists in the queue.
std::vector< DsrSendBuffEntry > & GetBuffer()
Return a pointer to the internal queue.
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
The maintenance buffer is responsible for maintaining packet next hop delivery The data packet is sav...
Ipv4Address m_source
source address
Ipv4Address m_ourAdd
local address
Ipv4Address m_destination
destination address
Ipv4Address m_nextHop
next hop address
Ipv4Address m_ourAdd
local address
Ipv4Address m_destination
destination address
uint16_t m_ackId
acknowledge ID
Ipv4Address m_source
source address
Ipv4Address m_nextHop
next hop
Ipv4Address m_destination
destination address
Ipv4Address m_source
source address
uint8_t m_segsLeft
segments left
uint16_t m_ackId
acknowledge ID