32 #define NS_LOG_APPEND_CONTEXT \
33 if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId () << "] "; }
43 #include "ns3/string.h"
46 #include "ns3/assert.h"
47 #include "ns3/uinteger.h"
48 #include "ns3/packet.h"
49 #include "ns3/boolean.h"
50 #include "ns3/node-list.h"
51 #include "ns3/double.h"
52 #include "ns3/pointer.h"
53 #include "ns3/object-vector.h"
54 #include "ns3/ipv4-address.h"
55 #include "ns3/ipv4-header.h"
56 #include "ns3/ipv4-l3-protocol.h"
57 #include "ns3/ipv4-route.h"
58 #include "ns3/trace-source-accessor.h"
59 #include "ns3/icmpv4-l4-protocol.h"
60 #include "ns3/adhoc-wifi-mac.h"
61 #include "ns3/wifi-net-device.h"
62 #include "ns3/inet-socket-address.h"
63 #include "ns3/udp-l4-protocol.h"
64 #include "ns3/udp-socket-factory.h"
65 #include "ns3/tcp-socket-factory.h"
105 .AddConstructor<DsrRouting> ()
106 .AddAttribute (
"RouteCache",
"The route cache for saving routes from route discovery process.",
110 MakePointerChecker<RouteCache> ())
111 .AddAttribute (
"RreqTable",
"The request table to manage route requests.",
115 MakePointerChecker<RreqTable> ())
116 .AddAttribute (
"MaxSendBuffLen",
"Maximum number of packets that can be stored in send buffer.",
119 MakeUintegerChecker<uint32_t> ())
120 .AddAttribute (
"MaxSendBuffTime",
"Maximum time packets can be queued in the send buffer .",
124 .AddAttribute (
"MaxMaintLen",
"Maximum number of packets that can be stored in maintenance buffer.",
127 MakeUintegerChecker<uint32_t> ())
128 .AddAttribute (
"MaxMaintTime",
"Maximum time packets can be queued in maintenance buffer.",
132 .AddAttribute (
"MaxCacheLen",
"Maximum number of route entries that can be stored in route cache.",
135 MakeUintegerChecker<uint32_t> ())
136 .AddAttribute (
"RouteCacheTimeout",
"Maximum time the route cache can be queued in route cache.",
140 .AddAttribute (
"MaxEntriesEachDst",
"Maximum number of route entries for a single destination to respond.",
143 MakeUintegerChecker<uint32_t> ())
144 .AddAttribute (
"SendBuffInterval",
"How often to check send buffer for packet with route.",
148 .AddAttribute (
"NodeTraversalTime",
"The time it takes to traverse two neighboring nodes.",
152 .AddAttribute (
"RreqRetries",
"Maximum number of retransmissions for request discovery of a route.",
155 MakeUintegerChecker<uint32_t> ())
156 .AddAttribute (
"MaintenanceRetries",
"Maximum number of retransmissions for data packets from maintenance buffer.",
159 MakeDoubleChecker<uint32_t> ())
160 .AddAttribute (
"RequestTableSize",
"Maximum number of request entries in the request table.",
163 MakeUintegerChecker<uint32_t> ())
164 .AddAttribute (
"RequestIdSize",
"Maximum number of request source Ids in the request table.",
167 MakeUintegerChecker<uint32_t> ())
168 .AddAttribute (
"UniqueRequestIdSize",
"Maximum number of request Ids in the request table for a single destination.",
171 MakeUintegerChecker<uint16_t> ())
172 .AddAttribute (
"NonPropRequestTimeout",
"The timeout value for non-propagation request.",
176 .AddAttribute (
"DiscoveryHopLimit",
"The max discovery hop limit for route requests.",
179 MakeDoubleChecker<uint32_t> ())
180 .AddAttribute (
"MaxSalvageCount",
"The max salvage count for a single data packet.",
183 MakeUintegerChecker<uint8_t> ())
184 .AddAttribute (
"BlacklistTimeout",
"The time for a neighbor to stay in blacklist.",
188 .AddAttribute (
"GratReplyHoldoff",
"The time for gratuitous reply entry to expire.",
192 .AddAttribute (
"BroadcastJitter",
"The jitter time to avoid collision for broadcast packets.",
195 MakeUintegerChecker<uint16_t> ())
196 .AddAttribute (
"PassiveAckTimeout",
"The time a packet in maintenance buffer wait for passive acknowledgment.",
200 .AddAttribute (
"TryPassiveAcks",
"The number of passive acknowledgment to use.",
203 MakeUintegerChecker<uint32_t> ())
204 .AddAttribute (
"RequestPeriod",
"The base time interval between route requests.",
208 .AddAttribute (
"MaxRequestPeriod",
"The max time interval between route requests.",
212 .AddAttribute (
"GraReplyTableSize",
"The gratuitous reply table size.",
215 MakeUintegerChecker<uint32_t> ())
216 .AddAttribute (
"CacheType",
"Use Link Cache or use Path Cache",
219 MakeStringChecker ())
220 .AddAttribute (
"StabilityDecrFactor",
"The stability decrease factor for link cache",
223 MakeUintegerChecker<uint64_t> ())
224 .AddAttribute (
"StabilityIncrFactor",
"The stability increase factor for link cache",
227 MakeUintegerChecker<uint64_t> ())
228 .AddAttribute (
"InitStability",
"The initial stability factor for link cache",
232 .AddAttribute (
"MinLifeTime",
"The minimal life time for link cache",
236 .AddAttribute (
"UseExtends",
"The extension time for link cache",
240 .AddAttribute (
"EnableSubRoute",
"Enables saving of sub route when receiving route error messages, only available when using path route cache",
243 MakeBooleanChecker ())
244 .AddAttribute (
"RetransIncr",
"The increase time for retransmission timer when facing network congestion",
248 .AddAttribute (
"MaxNetworkQueueSize",
"The max number of packet to save in the network queue.",
251 MakeUintegerChecker<uint32_t> ())
252 .AddAttribute (
"MaxNetworkQueueDelay",
"The max time for a packet to stay in the network queue.",
256 .AddAttribute (
"NumPriorityQueues",
"The max number of packet to save in the network queue.",
259 MakeUintegerChecker<uint32_t> ())
260 .AddTraceSource (
"Tx",
"Send DSR packet.",
262 .AddTraceSource (
"Drop",
"Drop DSR packet",
314 Ptr<Node> node = this->GetObject<Node> ();
317 m_ipv4 = this->GetObject<Ipv4L3Protocol> ();
366 if (addr != loopback)
401 std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator,
bool> result_i =
m_priorityQueue.insert (std::make_pair (i, queue_i));
513 std::vector<Ipv4Address> nodelist = rt.
GetVector ();
534 for (int32_t i = 0; i < nNodes; ++i)
540 if (netDevice->GetAddress () == address)
561 for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i)
573 if (vec.size () == 2)
581 if (ipv4Address == vec.back ())
583 NS_LOG_DEBUG (
"We have reached to the final destination " << ipv4Address <<
" " << vec.back ());
586 for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i)
588 if (ipv4Address == (*i))
623 for (int32_t i = 0; i < nNodes; ++i)
689 SendPacket (dequeP, source, nextHop, protocol);
695 newPacket->RemoveAtStart (offset);
699 newPacket->CopyData (buf,
sizeof(buf));
700 uint8_t numberAddress = (buf[1] - 2) / 4;
704 newPacket->RemoveHeader (sourceRoute);
709 newPacket->RemoveHeader (ackReq);
717 if (nextHop ==
"0.0.0.0")
728 std::vector<Ipv4Address> nodeList = salvageRoute.
GetVector ();
754 if (nextHop != destination)
815 NS_LOG_DEBUG (
"Here we try to find the data packet in the send buffer");
821 NS_LOG_INFO (
"We have found a route for the packet");
824 uint8_t protocol = i->GetProtocol ();
839 uint32_t size = copyP->
GetSize ();
840 uint8_t *
data =
new uint8_t[size];
843 uint8_t optionType = 0;
844 optionType = *(
data);
850 uint8_t errorType = *(data + 2);
866 std::vector<Ipv4Address> errorRoute = toDst.
GetVector ();
877 if (nextHop ==
"0.0.0.0")
884 uint8_t length = (sourceRoute.
GetLength () + newUnreach.GetLength ());
899 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
901 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
905 if (dsrNetworkQueue->
Enqueue (newEntry))
911 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
923 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
925 if (nextHop ==
"0.0.0.0")
935 uint8_t length = sourceRoute.
GetLength ();
950 networkKey.
m_ackId = newEntry.GetAckId ();
951 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
952 networkKey.
m_nextHop = newEntry.GetNextHop ();
953 networkKey.
m_source = newEntry.GetSrc ();
958 passiveKey.
m_source = newEntry.GetSrc ();
960 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
964 if (nextHop != destination)
1013 NS_LOG_INFO (
this << from << to << packetType << *p);
1020 uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
1028 uint32_t size = p->
GetSize ();
1029 uint8_t *
data =
new uint8_t[size];
1031 uint8_t optionType = 0;
1032 optionType = *(
data);
1036 if (optionType == 96)
1041 " overhearing packet PID: " << p->
GetUid () <<
1044 " with source IP " << ipv4Header.
GetSource () <<
1046 " and packet : " << *dsrPacket);
1047 bool isPromisc =
true;
1048 dsrOption->Process (p, dsrPacket,
m_mainAddress, source, ipv4Header, nextHeader, isPromisc);
1062 NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)protocol);
1070 <<
"s " <<
m_mainAddress <<
" there is no route for this packet, queue the packet");
1078 <<
"s Add packet PID: " << packet->
GetUid () <<
" to queue. Packet: " << *packet);
1100 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
1102 if (nextHop ==
"0.0.0.0")
1107 uint8_t salvage = 0;
1116 uint8_t length = sourceRoute.
GetLength ();
1121 SendPacket (cleanP, source, nextHop, protocol);
1126 source, destination, 0,
1133 networkKey.
m_ackId = newEntry.GetAckId ();
1134 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
1135 networkKey.
m_nextHop = newEntry.GetNextHop ();
1136 networkKey.
m_source = newEntry.GetSrc ();
1141 passiveKey.
m_source = newEntry.GetSrc ();
1143 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
1147 if (nextHop != destination)
1163 NS_LOG_FUNCTION (
this << errorHop << destination << originalDst << (uint32_t)salvage << (uint32_t)protocol);
1177 uint8_t rerrLength = rerrUnreachHeader.
GetLength ();
1186 <<
"s " <<
m_mainAddress <<
" there is no route for this packet, queue the packet");
1190 newPacket->
AddHeader (dsrRoutingHeader);
1198 <<
"s Add packet PID: " << p->
GetUid () <<
" to queue. Packet: " << *p);
1202 NS_LOG_DEBUG (
"When there is no existing route request for " << destination <<
", initialize one");
1212 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
1214 if (nextHop ==
"0.0.0.0")
1227 uint8_t srLength = sourceRoute.
GetLength ();
1228 uint8_t length = (srLength + rerrLength);
1233 newPacket->
AddHeader (dsrRoutingHeader);
1241 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1243 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
1247 if (dsrNetworkQueue->
Enqueue (newEntry))
1253 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1265 NS_LOG_FUNCTION (
this << rerr << sourceRoute << nextHop << (uint32_t)protocol << route);
1269 dsrRoutingHeader.SetMessageType (1);
1274 dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 4);
1275 dsrRoutingHeader.AddDsrOption (rerr);
1276 dsrRoutingHeader.AddDsrOption (sourceRoute);
1283 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1285 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
1289 if (dsrNetworkQueue->
Enqueue (newEntry))
1295 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1306 NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)protocol << route);
1311 NS_LOG_INFO (
"Drop packet. Not handling ICMP packet for now");
1322 <<
"s " <<
m_mainAddress <<
" there is no route for this packet, queue the packet");
1330 <<
"s Add packet PID: " << packet->
GetUid () <<
" to queue. Packet: " << *packet);
1335 NS_LOG_DEBUG (
"When there is no existing route request for " << destination <<
", initialize one");
1357 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
1359 if (nextHop ==
"0.0.0.0")
1364 uint8_t salvage = 0;
1373 uint8_t length = sourceRoute.
GetLength ();
1379 SendPacket (cleanP, source, nextHop, protocol);
1385 source, destination, 0,
1391 networkKey.
m_ackId = newEntry.GetAckId ();
1392 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
1393 networkKey.
m_nextHop = newEntry.GetNextHop ();
1394 networkKey.
m_source = newEntry.GetSrc ();
1399 passiveKey.
m_source = newEntry.GetSrc ();
1401 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
1405 if (nextHop != destination)
1433 uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
1434 uint32_t destinationId = dsrRoutingHeader.
GetDestId ();
1441 uint8_t numberAddress = (buf[1] - 2) / 4;
1455 newDsrRoutingHeader.
SetDestId (destinationId);
1468 NS_LOG_FUNCTION (
this << packet << source << nextHop << (uint32_t)protocol);
1475 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1477 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
1481 if (dsrNetworkQueue->
Enqueue (newEntry))
1487 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1502 NS_LOG_DEBUG (
"Scheduler looking for packets in network queue");
1503 uint32_t numPriorities;
1504 if (continueWithFirst)
1510 numPriorities = priority;
1515 std::map<uint32_t, Ptr<DsrNetworkQueue> >::iterator q =
m_priorityQueue.find (i);
1517 uint32_t queueSize = dsrNetworkQueue->
GetSize ();
1520 if ((i == (m_numPriorityQueues - 1)) && continueWithFirst)
1531 uint32_t totalQueueSize = 0;
1534 NS_LOG_DEBUG (
"The size of the network queue for " << j->first <<
" is " << j->second->GetSize ());
1535 totalQueueSize += j->second->GetSize ();
1536 NS_LOG_DEBUG (
"And the total size is " << totalQueueSize);
1538 if (totalQueueSize > 5)
1544 dsrNetworkQueue->
Dequeue (newEntry);
1547 NS_LOG_DEBUG (
"Packet sent by Dsr. Calling PriorityScheduler after some time");
1556 NS_LOG_DEBUG (
"Packet dropped by Dsr. Calling PriorityScheduler immediately");
1559 if ((i == (m_numPriorityQueues - 1)) && continueWithFirst)
1577 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1580 std::vector<DsrNetworkQueueEntry> newNetworkQueue = dsrNetworkQueue->
GetQueue ();
1581 for (std::vector<DsrNetworkQueueEntry>::iterator i = newNetworkQueue.begin (); i != newNetworkQueue.end (); i++)
1586 if (nextHop == j->first.m_nextHop)
1588 NS_LOG_DEBUG (
"The network delay left is " << j->second.GetDelayLeft ());
1589 j->second.SetDelay (j->second.GetDelayLeft () +
m_retransIncr);
1590 NS_LOG_DEBUG (
"The new network delay time is " << j->second.GetDelayLeft ());
1619 NS_LOG_INFO (
"The nexthop address " << nextHop <<
" the source " << source <<
" the destination " << destination);
1641 uint8_t length = sourceRoute.
GetLength ();
1653 source, destination, 0,
1660 networkKey.
m_ackId = newEntry.GetAckId ();
1661 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
1662 networkKey.
m_nextHop = newEntry.GetNextHop ();
1663 networkKey.
m_source = newEntry.GetSrc ();
1668 passiveKey.
m_source = newEntry.GetSrc ();
1670 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
1674 if (nextHop != destination)
1687 NS_LOG_DEBUG (
"Schedule sending the next packet in send buffer");
1694 NS_LOG_DEBUG (
"All queued packets are out-dated for the destination in send buffer");
1712 uint32_t offset = dsrRoutingHeader.GetDsrOptionsOffset ();
1717 uint32_t size = copyP->
GetSize ();
1718 uint8_t *
data =
new uint8_t[size];
1721 uint8_t optionType = 0;
1722 optionType = *(
data);
1723 NS_LOG_DEBUG (
"The option type value in send packet " << (uint32_t)optionType);
1724 if (optionType == 3)
1730 uint8_t errorType = *(data + 2);
1734 NS_LOG_DEBUG (
"The packet is route error unreach packet");
1763 newPacket->
AddHeader (newRoutingHeader);
1768 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1770 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
1774 if (dsrNetworkQueue->
Enqueue (newEntry))
1780 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1787 NS_LOG_DEBUG (
"Schedule sending the next packet in send buffer");
1795 NS_LOG_DEBUG (
"Packet not found in either the send or error buffer");
1803 NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)segsLeft);
1809 newEntry.
SetSrc (source);
1810 newEntry.
SetDst (destination);
1827 NS_LOG_FUNCTION (
this << (uint32_t)ackId << ipv4Header << realSrc << realDst);
1836 realSrc, realDst, ackId,
1858 <<
" source " << mb.
GetSrc () <<
" destination " << mb.
GetDst ()
1862 std::map<NetworkKey, Timer>::const_iterator i =
1887 NS_LOG_INFO (
"Remove same maintenance buffer entry based on network acknowledgment");
1905 std::map<PassiveKey, Timer>::const_iterator j =
1945 NS_LOG_INFO (
"Cancel the packet timer for next maintenance entry");
1952 NS_LOG_INFO (
"Maintenance buffer entry not found");
1959 NS_LOG_FUNCTION (
this << packet << source << dst << (uint32_t)protocol);
1972 newPacket->
CopyData (buf,
sizeof(buf));
1973 uint8_t numberAddress = (buf[1] - 2) / 4;
1993 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
1995 if (nextHop ==
"0.0.0.0")
2016 <<
" length of ack request header " << (uint32_t)(ackReq.
GetLength ()));
2028 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
2030 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
2034 if (dsrNetworkQueue->
Enqueue (newEntry))
2040 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
2050 NS_LOG_DEBUG (
"Will not salvage this packet, silently drop");
2072 NS_LOG_DEBUG (
"The passive acknowledgment option for data packet");
2089 NS_LOG_DEBUG (
"is the first retry or not " << isFirst);
2104 networkKey.m_ackId = newEntry.
GetAckId ();
2105 networkKey.m_ourAdd = newEntry.
GetOurAdd ();
2106 networkKey.m_nextHop = newEntry.
GetNextHop ();
2107 networkKey.m_source = newEntry.
GetSrc ();
2108 networkKey.m_destination = newEntry.
GetDst ();
2130 networkKey.m_ackId = mb.
GetAckId ();
2133 networkKey.m_source = mb.
GetSrc ();
2134 networkKey.m_destination = mb.
GetDst ();
2144 NS_LOG_DEBUG (
"The packet with dsr header " << dsrP->GetSize ());
2145 networkKey.m_ackId = mb.
GetAckId ();
2148 networkKey.m_source = mb.
GetSrc ();
2149 networkKey.m_destination = mb.
GetDst ();
2208 else if (!onlyPassive)
2257 NS_LOG_LOGIC (
"Packet transmissions to " << nextHop <<
" has been attempted SendRetries times for " << networkKey.
m_ackId);
2266 uint8_t numberAddress = (buf[1] - 2) / 4;
2267 NS_LOG_DEBUG (
"The number of addresses " << (uint32_t)numberAddress);
2286 errorDst = address1;
2316 NS_LOG_FUNCTION (
this << packet << sourceRoute << source << nextHop << targetAddress << (uint32_t)protocol << route);
2321 dsrRoutingHeader.SetMessageType (2);
2322 dsrRoutingHeader.SetSourceId (
GetIDfromIP (source));
2323 dsrRoutingHeader.SetDestId (
GetIDfromIP (targetAddress));
2327 uint8_t length = sourceRoute.
GetLength ();
2328 dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
2329 dsrRoutingHeader.AddDsrOption (sourceRoute);
2338 source, targetAddress,
2345 networkKey.
m_ackId = newEntry.GetAckId ();
2346 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
2347 networkKey.
m_nextHop = newEntry.GetNextHop ();
2348 networkKey.
m_source = newEntry.GetSrc ();
2353 passiveKey.
m_source = newEntry.GetSrc ();
2355 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
2359 if (nextHop != targetAddress)
2376 NS_LOG_FUNCTION (
this << source << destination << (uint32_t)protocol);
2397 uint8_t length = rreqHeader.
GetLength ();
2399 packet->AddHeader (dsrRoutingHeader);
2402 bool nonProp =
true;
2403 std::vector<Ipv4Address> address;
2404 address.push_back (source);
2405 address.push_back (destination);
2435 std::vector<Ipv4Address> ip = toDst.GetVector ();
2446 if (nextHop ==
"0.0.0.0")
2460 NS_LOG_INFO (
"No route found, initiate route error request");
2477 rreqHeader.SetTarget (originalDst);
2483 uint8_t length = rreqHeader.GetLength () + rerr.
GetLength ();
2487 bool nonProp =
false;
2488 std::vector<Ipv4Address> address;
2490 address.push_back (originalDst);
2501 NS_LOG_INFO (
"Only when there is no existing route request time when the initial route request is scheduled");
2507 NS_LOG_INFO (
"There is existing route request, find the existing route request entry");
2525 NS_LOG_DEBUG (
"Did not find the non-propagation timer");
2570 NS_LOG_FUNCTION (
this << packet << nonProp << requestId << (uint32_t)protocol);
2581 std::vector<Ipv4Address> address;
2582 address.push_back (source);
2583 address.push_back (dst);
2605 std::vector<Ipv4Address> address;
2606 address.push_back (source);
2607 address.push_back (dst);
2657 std::vector<Ipv4Address> ip = toDst.
GetVector ();
2664 uint8_t salvage = 0;
2668 if (nextHop ==
"0.0.0.0")
2690 NS_LOG_DEBUG (
"Route not found. Drop packet with dst " << dst);
2702 NS_LOG_DEBUG (
"Check the route request entry " << source <<
" " << dst);
2718 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
2720 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
2724 if (dsrNetworkQueue->
Enqueue (newEntry))
2730 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
2762 std::vector<Ipv4Address>::iterator before = find (nodeList.begin (), nodeList.end (), srcAddress);
2763 for (std::vector<Ipv4Address>::iterator i = nodeList.begin (); i != before; ++i)
2768 std::vector<Ipv4Address>::iterator after = find (nodeList.begin (), nodeList.end (),
m_mainAddress);
2769 for (std::vector<Ipv4Address>::iterator j = after; j != nodeList.end (); ++j)
2795 newPacket->
AddHeader (dsrRoutingHeader);
2804 NS_LOG_INFO (
"The same gratuitous route reply has already sent");
2818 NS_LOG_INFO (
"The output device " << dev <<
" packet is: " << *packet);
2821 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
2823 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
2827 if (dsrNetworkQueue->
Enqueue (newEntry))
2833 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
2845 packet, source, nextHop, route);
2867 NS_LOG_FUNCTION (
this << ackId << destination << realSrc << realDst << (uint32_t)protocol << route);
2873 dsrRoutingHeader.SetMessageType (1);
2875 dsrRoutingHeader.SetDestId (
GetIDfromIP (destination));
2886 dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
2887 dsrRoutingHeader.AddDsrOption (ack);
2896 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
2898 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
2902 if (dsrNetworkQueue->
Enqueue (newEntry))
2908 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
2929 uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
2931 NS_LOG_DEBUG (
"The source address " << source <<
" with source id " << sourceId);
2937 bool isPromisc =
false;
2948 uint32_t size = p->
GetSize ();
2949 uint8_t *
data =
new uint8_t[size];
2952 uint8_t optionType = 0;
2953 uint8_t optionLength = 0;
2954 uint8_t segmentsLeft = 0;
2956 optionType = *(
data);
2957 NS_LOG_LOGIC (
"The option type value " << (uint32_t)optionType <<
" with packet size " << p->
GetSize ());
2960 if (optionType == 1)
2965 NS_LOG_DEBUG (
"Discard this packet due to unidirectional link");
2970 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc);
2972 if (optionLength == 0)
2978 else if (optionType == 2)
2981 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc);
2983 if (optionLength == 0)
2990 else if (optionType == 32)
2994 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc);
2996 if (optionLength == 0)
3003 else if (optionType == 3)
3006 NS_LOG_DEBUG (
"The option type value " << (uint32_t)optionType);
3009 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc);
3011 if (optionLength == 0)
3016 NS_LOG_DEBUG (
"The option Length " << (uint32_t)optionLength);
3019 else if (optionType == 96)
3021 NS_LOG_DEBUG (
"This is the source route option " << (uint32_t)optionType);
3023 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc);
3025 segmentsLeft = *(data + 3);
3026 NS_LOG_DEBUG (
"The segments left in source route header " << (uint32_t)segmentsLeft);
3027 if (optionLength == 0)
3034 if (segmentsLeft == 0)
3048 nextProto->Receive (copy, ip, incomingInterface);
3071 NS_LOG_INFO (
"This is not the final destination, the packet has already been forward to next hop");
3081 uint8_t salvage = 0;
3144 if ((*i)->GetOptionNumber () == optionNumber)