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"
110 .AddConstructor<DsrRouting> ()
111 .AddAttribute (
"RouteCache",
"The route cache for saving routes from route discovery process.",
115 MakePointerChecker<RouteCache> ())
116 .AddAttribute (
"RreqTable",
"The request table to manage route requests.",
120 MakePointerChecker<RreqTable> ())
121 .AddAttribute (
"PassiveBuffer",
"The passive buffer to manage promisucously received passive ack.",
125 MakePointerChecker<PassiveBuffer> ())
126 .AddAttribute (
"MaxSendBuffLen",
"Maximum number of packets that can be stored in send buffer.",
129 MakeUintegerChecker<uint32_t> ())
130 .AddAttribute (
"MaxSendBuffTime",
"Maximum time packets can be queued in the send buffer .",
134 .AddAttribute (
"MaxMaintLen",
"Maximum number of packets that can be stored in maintenance buffer.",
137 MakeUintegerChecker<uint32_t> ())
138 .AddAttribute (
"MaxMaintTime",
"Maximum time packets can be queued in maintenance buffer.",
142 .AddAttribute (
"MaxCacheLen",
"Maximum number of route entries that can be stored in route cache.",
145 MakeUintegerChecker<uint32_t> ())
146 .AddAttribute (
"RouteCacheTimeout",
"Maximum time the route cache can be queued in route cache.",
150 .AddAttribute (
"MaxEntriesEachDst",
"Maximum number of route entries for a single destination to respond.",
153 MakeUintegerChecker<uint32_t> ())
154 .AddAttribute (
"SendBuffInterval",
"How often to check send buffer for packet with route.",
158 .AddAttribute (
"NodeTraversalTime",
"The time it takes to traverse two neighboring nodes.",
162 .AddAttribute (
"RreqRetries",
"Maximum number of retransmissions for request discovery of a route.",
165 MakeUintegerChecker<uint32_t> ())
166 .AddAttribute (
"MaintenanceRetries",
"Maximum number of retransmissions for data packets from maintenance buffer.",
169 MakeUintegerChecker<uint32_t> ())
170 .AddAttribute (
"RequestTableSize",
"Maximum number of request entries in the request table, set this as the number of nodes in the simulation.",
173 MakeUintegerChecker<uint32_t> ())
174 .AddAttribute (
"RequestIdSize",
"Maximum number of request source Ids in the request table.",
177 MakeUintegerChecker<uint32_t> ())
178 .AddAttribute (
"UniqueRequestIdSize",
"Maximum number of request Ids in the request table for a single destination.",
181 MakeUintegerChecker<uint32_t> ())
182 .AddAttribute (
"NonPropRequestTimeout",
"The timeout value for non-propagation request.",
186 .AddAttribute (
"DiscoveryHopLimit",
"The max discovery hop limit for route requests.",
189 MakeUintegerChecker<uint32_t> ())
190 .AddAttribute (
"MaxSalvageCount",
"The max salvage count for a single data packet.",
193 MakeUintegerChecker<uint8_t> ())
194 .AddAttribute (
"BlacklistTimeout",
"The time for a neighbor to stay in blacklist.",
198 .AddAttribute (
"GratReplyHoldoff",
"The time for gratuitous reply entry to expire.",
202 .AddAttribute (
"BroadcastJitter",
"The jitter time to avoid collision for broadcast packets.",
205 MakeUintegerChecker<uint32_t> ())
206 .AddAttribute (
"LinkAckTimeout",
"The time a packet in maintenance buffer wait for link acknowledgment.",
210 .AddAttribute (
"TryLinkAcks",
"The number of link acknowledgment to use.",
213 MakeUintegerChecker<uint32_t> ())
214 .AddAttribute (
"PassiveAckTimeout",
"The time a packet in maintenance buffer wait for passive acknowledgment.",
218 .AddAttribute (
"TryPassiveAcks",
"The number of passive acknowledgment to use.",
221 MakeUintegerChecker<uint32_t> ())
222 .AddAttribute (
"RequestPeriod",
"The base time interval between route requests.",
226 .AddAttribute (
"MaxRequestPeriod",
"The max time interval between route requests.",
230 .AddAttribute (
"GraReplyTableSize",
"The gratuitous reply table size.",
233 MakeUintegerChecker<uint32_t> ())
234 .AddAttribute (
"CacheType",
"Use Link Cache or use Path Cache",
237 MakeStringChecker ())
238 .AddAttribute (
"StabilityDecrFactor",
"The stability decrease factor for link cache",
241 MakeUintegerChecker<uint32_t> ())
242 .AddAttribute (
"StabilityIncrFactor",
"The stability increase factor for link cache",
245 MakeUintegerChecker<uint32_t> ())
246 .AddAttribute (
"InitStability",
"The initial stability factor for link cache",
250 .AddAttribute (
"MinLifeTime",
"The minimal life time for link cache",
254 .AddAttribute (
"UseExtends",
"The extension time for link cache",
258 .AddAttribute (
"EnableSubRoute",
"Enables saving of sub route when receiving route error messages, only available when using path route cache",
261 MakeBooleanChecker ())
262 .AddAttribute (
"RetransIncr",
"The increase time for retransmission timer when facing network congestion",
266 .AddAttribute (
"MaxNetworkQueueSize",
"The max number of packet to save in the network queue.",
269 MakeUintegerChecker<uint32_t> ())
270 .AddAttribute (
"MaxNetworkQueueDelay",
"The max time for a packet to stay in the network queue.",
274 .AddAttribute (
"NumPriorityQueues",
"The max number of packet to save in the network queue.",
277 MakeUintegerChecker<uint32_t> ())
278 .AddAttribute (
"LinkAcknowledgment",
"Enable Link layer acknowledgment mechanism",
281 MakeBooleanChecker ())
282 .AddTraceSource (
"Tx",
"Send DSR packet.",
284 .AddTraceSource (
"Drop",
"Drop DSR packet",
336 Ptr<Node> node = this->GetObject<Node> ();
339 m_ipv4 = this->GetObject<Ipv4L3Protocol> ();
368 std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator,
bool> result_i =
m_priorityQueue.insert (std::make_pair (i, queue_i));
400 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
405 if (addr != loopback)
423 routeCache->ScheduleTimer ();
446 routeCache->AddArpCache (
m_ipv4->GetInterface (i)->GetArpCache ());
459 Config::Connect (
"NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",
472 Mac48Address nodeAddr = netDevice->GetMac()->GetAddress();
473 std::ostringstream oss;
519 Ipv4Address ourAddress = ipv4->GetAddress (1, 0).GetLocal ();
533 newEntry.SetSrc (sourceIp);
534 newEntry.SetDst (destinationIp);
536 newEntry.SetOurAdd (previousHop);
537 newEntry.SetNextHop (ourAddress);
543 dsr->CancelLinkPacketTimer (newEntry);
556 return n->
GetDevice (atoi (elements[3].c_str ()));
559 std::vector<std::string>
562 std::vector <std::string> elements;
564 while (pos1 != context.npos)
566 pos1 = context.find (
"/",pos1);
567 pos2 = context.find (
"/",pos1+1);
568 elements.push_back (context.substr (pos1+1,pos2-(pos1+1)));
580 for (uint32_t i = 0; i <
m_ipv4->GetNInterfaces (); i++)
590 mac->TraceDisconnectWithoutContext (
"TxErrHeader",
656 for (int32_t i = 0; i < nNodes; ++i)
660 int32_t ifIndex = ipv4->GetInterfaceForAddress (ipv4Address);
693 std::vector<Ipv4Address> nodelist = rt.
GetVector ();
701 m_routeCache->DeleteAllRoutesIncludeLink (errorSrc, unreachNode, node);
711 return m_rreqTable->FindSourceEntry (src, dst,
id);
719 for (int32_t i = 0; i < nNodes; ++i)
725 if (netDevice->GetAddress () ==
address)
727 return ipv4->GetAddress (1, 0).GetLocal ();
746 for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i)
758 if (vec.size () == 2)
766 if (ipv4Address == vec.back ())
768 NS_LOG_DEBUG (
"We have reached to the final destination " << ipv4Address <<
" " << vec.back ());
771 for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i)
773 if (ipv4Address == (*i))
807 for (int32_t i = 0; i < nNodes; ++i)
811 if (ipv4->GetAddress (1, 0).GetLocal () ==
address)
831 return ipv4->GetAddress (1, 0).GetLocal ();
865 NS_LOG_DEBUG (
"Here we try to find the data packet in the send buffer");
868 bool findRoute =
m_routeCache->LookupRoute (destination, toDst);
871 NS_LOG_INFO (
"We have found a route for the packet");
874 uint8_t protocol = i->GetProtocol ();
889 uint32_t size = copyP->
GetSize ();
890 uint8_t *
data =
new uint8_t[size];
893 uint8_t optionType = 0;
894 optionType = *(
data);
900 uint8_t errorType = *(data + 2);
916 std::vector<Ipv4Address> errorRoute = toDst.
GetVector ();
928 if (nextHop ==
"0.0.0.0")
935 uint8_t length = (sourceRoute.
GetLength () + newUnreach.GetLength ());
950 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
952 NS_LOG_LOGIC (
"Will be inserting into priority queue number: " << priority);
959 if (dsrNetworkQueue->Enqueue (newEntry))
965 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
977 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
979 if (nextHop ==
"0.0.0.0")
993 uint8_t length = sourceRoute.
GetLength ();
1006 networkKey.
m_ackId = newEntry.GetAckId ();
1007 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
1008 networkKey.
m_nextHop = newEntry.GetNextHop ();
1009 networkKey.
m_source = newEntry.GetSrc ();
1014 passiveKey.
m_source = newEntry.GetSrc ();
1016 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
1019 linkKey.
m_source = newEntry.GetSrc ();
1021 linkKey.
m_ourAdd = newEntry.GetOurAdd ();
1022 linkKey.
m_nextHop = newEntry.GetNextHop ();
1035 if (nextHop != destination)
1085 NS_LOG_INFO (
this << from << to << packetType << *p);
1092 uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
1100 uint32_t size = p->
GetSize ();
1101 uint8_t *
data =
new uint8_t[size];
1103 uint8_t optionType = 0;
1104 optionType = *(
data);
1108 if (optionType == 96)
1114 " overhearing packet PID: " << p->
GetUid () <<
1115 " from " << promiscSource <<
1117 " with source IP " << ipv4Header.
GetSource () <<
1119 " and packet : " << *dsrPacket);
1121 bool isPromisc =
true;
1122 dsrOption->Process (p, dsrPacket,
m_mainAddress, source, ipv4Header, nextHeader, isPromisc, promiscSource);
1136 NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)protocol);
1139 bool findRoute =
m_routeCache->LookupRoute (destination, toDst);
1144 <<
"s " <<
m_mainAddress <<
" there is no route for this packet, queue the packet");
1152 <<
"s Add packet PID: " << packet->
GetUid () <<
" to queue. Packet: " << *packet);
1174 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
1176 if (nextHop ==
"0.0.0.0")
1181 uint8_t salvage = 0;
1191 uint8_t length = sourceRoute.
GetLength ();
1199 source, destination, 0,
1206 networkKey.
m_ackId = newEntry.GetAckId ();
1207 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
1208 networkKey.
m_nextHop = newEntry.GetNextHop ();
1209 networkKey.
m_source = newEntry.GetSrc ();
1214 passiveKey.
m_source = newEntry.GetSrc ();
1216 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
1219 linkKey.
m_source = newEntry.GetSrc ();
1221 linkKey.
m_ourAdd = newEntry.GetOurAdd ();
1222 linkKey.
m_nextHop = newEntry.GetNextHop ();
1235 if (nextHop != destination)
1252 NS_LOG_FUNCTION (
this << unreachNode << destination << originalDst << (uint32_t)salvage << (uint32_t)protocol);
1266 uint8_t rerrLength = rerrUnreachHeader.
GetLength ();
1270 bool findRoute =
m_routeCache->LookupRoute (destination, toDst);
1277 NS_LOG_INFO (
"We are the error source, send request to original dst " << originalDst);
1284 <<
"s " <<
m_mainAddress <<
" there is no route for this packet, queue the packet");
1288 newPacket->
AddHeader (dsrRoutingHeader);
1296 <<
"s Add packet PID: " << p->
GetUid () <<
" to queue. Packet: " << *p);
1300 NS_LOG_DEBUG (
"When there is no existing route request for " << destination <<
", initialize one");
1311 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
1313 if (nextHop ==
"0.0.0.0")
1327 uint8_t srLength = sourceRoute.
GetLength ();
1328 uint8_t length = (srLength + rerrLength);
1333 newPacket->
AddHeader (dsrRoutingHeader);
1341 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1343 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
1350 if (dsrNetworkQueue->Enqueue (newEntry))
1356 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1368 NS_LOG_FUNCTION (
this << rerr << sourceRoute << nextHop << (uint32_t)protocol << route);
1372 dsrRoutingHeader.SetMessageType (1);
1377 dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 4);
1378 dsrRoutingHeader.AddDsrOption (rerr);
1379 dsrRoutingHeader.AddDsrOption (sourceRoute);
1386 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1388 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
1395 if (dsrNetworkQueue->Enqueue (newEntry))
1401 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1412 NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)protocol << route);
1417 NS_LOG_INFO (
"Drop packet. Not handling ICMP packet for now");
1423 bool findRoute =
m_routeCache->LookupRoute (destination, toDst);
1428 <<
"s " <<
m_mainAddress <<
" there is no route for this packet, queue the packet");
1436 <<
"s Add packet PID: " << packet->
GetUid () <<
" to send buffer. Packet: " << *packet);
1448 NS_LOG_LOGIC (
"There is existing route request timer with request count " <<
m_rreqTable->GetRreqCnt (destination));
1462 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
1464 if (nextHop ==
"0.0.0.0")
1469 uint8_t salvage = 0;
1479 uint8_t length = sourceRoute.
GetLength ();
1489 source, destination, 0,
1495 networkKey.
m_ackId = newEntry.GetAckId ();
1496 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
1497 networkKey.
m_nextHop = newEntry.GetNextHop ();
1498 networkKey.
m_source = newEntry.GetSrc ();
1503 passiveKey.
m_source = newEntry.GetSrc ();
1505 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
1508 linkKey.
m_source = newEntry.GetSrc ();
1510 linkKey.
m_ourAdd = newEntry.GetOurAdd ();
1511 linkKey.
m_nextHop = newEntry.GetNextHop ();
1524 if (nextHop != destination)
1557 uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
1558 uint32_t destinationId = dsrRoutingHeader.
GetDestId ();
1565 uint8_t numberAddress = (buf[1] - 2) / 4;
1578 newDsrRoutingHeader.
SetDestId (destinationId);
1591 NS_LOG_FUNCTION (
this << packet << source << nextHop << (uint32_t)protocol);
1598 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1600 NS_LOG_INFO (
"Will be inserting into priority queue number: " << priority);
1607 if (dsrNetworkQueue->Enqueue (newEntry))
1613 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1628 uint32_t numPriorities;
1629 if (continueWithFirst)
1635 numPriorities = priority;
1640 std::map<uint32_t, Ptr<DsrNetworkQueue> >::iterator q =
m_priorityQueue.find (i);
1642 uint32_t queueSize = dsrNetworkQueue->GetSize ();
1645 if ((i == (m_numPriorityQueues - 1)) && continueWithFirst)
1656 uint32_t totalQueueSize = 0;
1659 NS_LOG_INFO (
"The size of the network queue for " << j->first <<
" is " << j->second->GetSize ());
1660 totalQueueSize += j->second->GetSize ();
1661 NS_LOG_INFO (
"The total network queue size is " << totalQueueSize);
1663 if (totalQueueSize > 5)
1669 dsrNetworkQueue->Dequeue (newEntry);
1672 NS_LOG_LOGIC (
"Packet sent by Dsr. Calling PriorityScheduler after some time");
1681 NS_LOG_LOGIC (
"Packet dropped by Dsr. Calling PriorityScheduler immediately");
1685 if ((i == (m_numPriorityQueues - 1)) && continueWithFirst)
1703 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1706 std::vector<DsrNetworkQueueEntry> newNetworkQueue = dsrNetworkQueue->GetQueue ();
1707 for (std::vector<DsrNetworkQueueEntry>::iterator i = newNetworkQueue.begin (); i != newNetworkQueue.end (); i++)
1712 if (nextHop == j->first.m_nextHop)
1714 NS_LOG_DEBUG (
"The network delay left is " << j->second.GetDelayLeft ());
1715 j->second.SetDelay (j->second.GetDelayLeft () +
m_retransIncr);
1743 NS_LOG_INFO (
"The nexthop address " << nextHop <<
" the source " << source <<
" the destination " << destination);
1749 NS_LOG_DEBUG (
"destination over here " << destination);
1768 uint8_t length = sourceRoute.
GetLength ();
1777 source, destination, 0,
1784 networkKey.
m_ackId = newEntry.GetAckId ();
1785 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
1786 networkKey.
m_nextHop = newEntry.GetNextHop ();
1787 networkKey.
m_source = newEntry.GetSrc ();
1792 passiveKey.
m_source = newEntry.GetSrc ();
1794 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
1797 linkKey.
m_source = newEntry.GetSrc ();
1799 linkKey.
m_ourAdd = newEntry.GetOurAdd ();
1800 linkKey.
m_nextHop = newEntry.GetNextHop ();
1813 if (nextHop != destination)
1828 NS_LOG_LOGIC (
"Schedule sending the next packet in send buffer");
1835 NS_LOG_LOGIC (
"All queued packets are out-dated for the destination in send buffer");
1853 uint32_t offset = dsrRoutingHeader.GetDsrOptionsOffset ();
1858 uint32_t size = copyP->
GetSize ();
1859 uint8_t *
data =
new uint8_t[size];
1862 uint8_t optionType = 0;
1863 optionType = *(
data);
1864 NS_LOG_DEBUG (
"The option type value in send packet " << (uint32_t)optionType);
1865 if (optionType == 3)
1871 uint8_t errorType = *(data + 2);
1875 NS_LOG_DEBUG (
"The packet is route error unreach packet");
1905 newPacket->
AddHeader (newRoutingHeader);
1910 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
1912 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
1919 if (dsrNetworkQueue->Enqueue (newEntry))
1925 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
1932 NS_LOG_LOGIC (
"Schedule sending the next packet in error buffer");
1940 NS_LOG_DEBUG (
"Packet not found in either the send or error buffer");
1946 uint16_t fragmentOffset, uint16_t identification,
bool saveEntry)
1948 NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)segsLeft);
1967 NS_LOG_DEBUG (
"We get the all equal for passive buffer here");
1972 mbEntry.
SetDst (destination);
1991 NS_LOG_FUNCTION (
this << packet << source << destination << (uint32_t)segsLeft);
1999 newEntry.
SetSrc (source);
2000 newEntry.
SetDst (destination);
2017 NS_LOG_FUNCTION (
this << (uint32_t)ackId << ipv4Header << realSrc << realDst);
2026 realSrc, realDst, ackId,
2059 std::map<LinkKey, Timer>::const_iterator i =
2086 NS_LOG_INFO (
"Link acknowledgment received, remove same maintenance buffer entry");
2107 <<
" source " << mb.
GetSrc () <<
" destination " << mb.
GetDst ()
2111 std::map<NetworkKey, Timer>::const_iterator i =
2136 NS_LOG_INFO (
"Remove same maintenance buffer entry based on network acknowledgment");
2154 std::map<PassiveKey, Timer>::const_iterator j =
2182 std::vector<Ipv4Address> previousErrorDst;
2199 uint8_t numberAddress = (buf[1] - 2) / 4;
2200 NS_LOG_DEBUG (
"The number of addresses " << (uint32_t)numberAddress);
2216 errorDst = address1;
2223 if (std::find(previousErrorDst.begin(), previousErrorDst.end(), destination)==previousErrorDst.end())
2225 NS_LOG_DEBUG (
"have not seen this dst before " << errorDst <<
" in " << previousErrorDst.size());
2227 previousErrorDst.push_back(errorDst);
2239 NS_LOG_INFO (
"Cancel the packet timer for next maintenance entry");
2246 NS_LOG_INFO (
"Maintenance buffer entry not found");
2254 NS_LOG_FUNCTION (
this << packet << source << dst << (uint32_t)protocol);
2267 newPacket->
CopyData (buf,
sizeof(buf));
2268 uint8_t numberAddress = (buf[1] - 2) / 4;
2278 bool findRoute =
m_routeCache->LookupRoute (dst, toDst);
2288 std::vector<Ipv4Address> nodeList = toDst.
GetVector ();
2290 if (nextHop ==
"0.0.0.0")
2306 uint8_t length = sourceRoute.
GetLength ();
2318 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
2320 NS_LOG_DEBUG (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
2327 if (dsrNetworkQueue->Enqueue (newEntry))
2333 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
2344 NS_LOG_DEBUG (
"Will not salvage this packet, silently drop");
2402 NS_LOG_DEBUG (
"The passive acknowledgment option for data packet");
2419 NS_LOG_DEBUG (
"is the first retry or not " << isFirst);
2440 networkKey.m_ackId = newEntry.
GetAckId ();
2441 networkKey.m_ourAdd = newEntry.
GetOurAdd ();
2442 networkKey.m_nextHop = newEntry.
GetNextHop ();
2443 networkKey.m_source = newEntry.
GetSrc ();
2444 networkKey.m_destination = newEntry.
GetDst ();
2469 networkKey.m_ackId = mb.
GetAckId ();
2472 networkKey.m_source = mb.
GetSrc ();
2473 networkKey.m_destination = mb.
GetDst ();
2488 NS_LOG_DEBUG (
"The packet with dsr header " << dsrP->GetSize ());
2489 networkKey.m_ackId = mb.
GetAckId ();
2492 networkKey.m_source = mb.
GetSrc ();
2493 networkKey.m_destination = mb.
GetDst ();
2551 NS_LOG_INFO (
"We need to send error messages now");
2659 NS_LOG_FUNCTION (
this << packet << sourceRoute << source << nextHop << targetAddress << (uint32_t)protocol << route);
2664 dsrRoutingHeader.SetMessageType (2);
2665 dsrRoutingHeader.SetSourceId (
GetIDfromIP (source));
2666 dsrRoutingHeader.SetDestId (
GetIDfromIP (targetAddress));
2670 uint8_t length = sourceRoute.
GetLength ();
2671 dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
2672 dsrRoutingHeader.AddDsrOption (sourceRoute);
2678 source, targetAddress,
m_ackId,
2685 networkKey.
m_ackId = newEntry.GetAckId ();
2686 networkKey.
m_ourAdd = newEntry.GetOurAdd ();
2687 networkKey.
m_nextHop = newEntry.GetNextHop ();
2688 networkKey.
m_source = newEntry.GetSrc ();
2693 passiveKey.
m_source = newEntry.GetSrc ();
2695 passiveKey.
m_segsLeft = newEntry.GetSegsLeft ();
2698 linkKey.
m_source = newEntry.GetSrc ();
2700 linkKey.
m_ourAdd = newEntry.GetOurAdd ();
2701 linkKey.
m_nextHop = newEntry.GetNextHop ();
2714 if (nextHop != targetAddress)
2732 NS_LOG_FUNCTION (
this << source << destination << (uint32_t)protocol);
2753 uint8_t length = rreqHeader.
GetLength ();
2755 packet->AddHeader (dsrRoutingHeader);
2758 bool nonProp =
true;
2759 std::vector<Ipv4Address>
address;
2760 address.push_back (source);
2761 address.push_back (destination);
2793 std::vector<Ipv4Address> ip = toDst.GetVector ();
2805 if (nextHop ==
"0.0.0.0")
2823 NS_LOG_INFO (
"No route found, initiate route error request");
2840 rreqHeader.SetTarget (originalDst);
2846 uint8_t length = rreqHeader.GetLength () + rerr.
GetLength ();
2850 bool nonProp =
false;
2851 std::vector<Ipv4Address>
address;
2853 address.push_back (originalDst);
2864 NS_LOG_INFO (
"Only when there is no existing route request time when the initial route request is scheduled");
2870 NS_LOG_INFO (
"There is existing route request, find the existing route request entry");
2888 NS_LOG_DEBUG (
"Did not find the non-propagation timer");
2933 NS_LOG_FUNCTION (
this << packet << nonProp << requestId << (uint32_t)protocol);
2944 std::vector<Ipv4Address>
address;
2945 address.push_back (source);
2946 address.push_back (dst);
2968 std::vector<Ipv4Address>
address;
2969 address.push_back (source);
2970 address.push_back (dst);
3020 std::vector<Ipv4Address> ip = toDst.
GetVector ();
3031 NS_LOG_INFO (
"The nextHop address is " << nextHop);
3032 if (nextHop ==
"0.0.0.0")
3058 NS_LOG_DEBUG (
"Route not found. Drop packet with dst " << dst);
3070 NS_LOG_DEBUG (
"Check the route request entry " << source <<
" " << dst);
3087 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
3089 NS_LOG_LOGIC (
"Inserting into priority queue number: " << priority);
3095 if (dsrNetworkQueue->Enqueue (newEntry))
3101 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
3133 std::vector<Ipv4Address>::iterator before = find (nodeList.begin (), nodeList.end (), srcAddress);
3134 for (std::vector<Ipv4Address>::iterator i = nodeList.begin (); i != before; ++i)
3139 std::vector<Ipv4Address>::iterator after = find (nodeList.begin (), nodeList.end (),
m_mainAddress);
3140 for (std::vector<Ipv4Address>::iterator j = after; j != nodeList.end (); ++j)
3166 newPacket->
AddHeader (dsrRoutingHeader);
3175 NS_LOG_INFO (
"The same gratuitous route reply has already sent");
3190 NS_LOG_INFO (
"The output device " << dev <<
" packet is: " << *packet);
3193 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
3195 NS_LOG_INFO (
"Inserting into priority queue number: " << priority);
3201 if (dsrNetworkQueue->Enqueue (newEntry))
3207 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
3219 packet, source, nextHop, route);
3241 NS_LOG_FUNCTION (
this << ackId << destination << realSrc << realDst << (uint32_t)protocol << route);
3247 dsrRoutingHeader.SetMessageType (1);
3249 dsrRoutingHeader.SetDestId (
GetIDfromIP (destination));
3260 dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
3261 dsrRoutingHeader.AddDsrOption (ack);
3269 std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i =
m_priorityQueue.find (priority);
3272 NS_LOG_LOGIC (
"Will be inserting into priority queue " << dsrNetworkQueue <<
" number: " << priority);
3278 if (dsrNetworkQueue->Enqueue (newEntry))
3284 NS_LOG_INFO (
"Packet dropped as dsr network queue is full");
3306 uint32_t sourceId = dsrRoutingHeader.
GetSourceId ();
3308 NS_LOG_INFO (
"The source address " << source <<
" with source id " << sourceId);
3314 bool isPromisc =
false;
3325 uint32_t size = p->
GetSize ();
3326 uint8_t *
data =
new uint8_t[size];
3329 uint8_t optionType = 0;
3330 uint8_t optionLength = 0;
3331 uint8_t segmentsLeft = 0;
3333 optionType = *(
data);
3334 NS_LOG_LOGIC (
"The option type value " << (uint32_t)optionType <<
" with packet id " << p->
GetUid());
3337 if (optionType == 1)
3342 NS_LOG_INFO (
"Discard this packet due to unidirectional link");
3347 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3349 if (optionLength == 0)
3355 else if (optionType == 2)
3358 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3360 if (optionLength == 0)
3367 else if (optionType == 32)
3371 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3373 if (optionLength == 0)
3380 else if (optionType == 3)
3383 NS_LOG_INFO (
"The option type value " << (uint32_t)optionType);
3386 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3388 if (optionLength == 0)
3393 NS_LOG_INFO (
"The option Length " << (uint32_t)optionLength);
3396 else if (optionType == 96)
3399 optionLength = dsrOption->Process (p, packet,
m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
3400 segmentsLeft = *(data + 3);
3401 if (optionLength == 0)
3408 if (segmentsLeft == 0)
3420 nextProto->Receive (copy, ip, incomingInterface);
3447 NS_LOG_INFO (
"This is not the final destination, the packet has already been forward to next hop");
3457 uint8_t salvage = 0;
3519 if ((*i)->GetOptionNumber () == optionNumber)
bool Dequeue(Ipv4Address dst, ErrorBuffEntry &entry)
Return first found (the earliest) entry for given destination.
uint32_t m_sendRetries
of retries have been sent for network acknowledgment
uint32_t m_stabilityDecrFactor
The initial decrease factor for link cache.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void SetExpireTime(Time exp)
bool NetworkEqual(MaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for network ack.
void SetDownTarget(IpL4Protocol::DownTargetCallback callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
bool Find(Ipv4Address dst)
Check if a packet with destination dst exists in the queue.
std::string m_cacheType
The type of route cache.
Simulation virtual time values and global simulation resolution.
void SetDst(Ipv4Address n)
uint32_t GetSize()
Number of entries.
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 this RNG stream.
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.
void SetDestination(Ipv4Address d)
static uint32_t GetNNodes(void)
void CancelLinkPacketTimer(MaintainBuffEntry &mb)
Cancel the link packet retransmission timer for a specific maintenance entry.
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.
void ScheduleInterRequest(Ptr< Packet > packet)
Schedule the intermediate route request.
uint32_t m_stabilityIncrFactor
The initial increase factor for link cache.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
void SendInitialRequest(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Broadcast the route request packet in subnet.
bool AddRoute(RouteCacheEntry &rt)
functions used to direct to route cache
hold variables of type string
void SendBuffTimerExpire()
The send buffer timer expire.
static Ptr< Node > GetNode(uint32_t n)
void Scheduler(uint32_t priority)
This function is called to schedule sending packets from the network queue.
DSR Passive Buffer Entry.
Ipv4Address m_destination
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.
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.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
uint32_t m_linkRetries
of retries have been sent for link acknowledgment
TracedCallback< const DsrOptionSRHeader & > m_txPacketTrace
uint64_t GetUid(void) const
Returns the packet's Uid.
void SetErrorBufferTimeout(Time t)
bool Enqueue(ErrorBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
void NetworkScheduleTimerExpire(MaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using network acknowledgment.
bool IsNull(void) const
Check for null implementation.
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.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void DropPacketForErrLink(Ipv4Address source, Ipv4Address nextHop)
Remove all packets with the error link.
#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.
Ptr< dsr::RouteCache > m_routeCache
A "drop-front" queue used by the routing layer to cache routes found.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void IncreaseRetransTimer()
This function is called to increase the retransmission timer for data packet in the network queue...
bool IsMulticast(void) const
Ipv4Address m_mainAddress
Our own Ip address.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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)
fatal error handling
bool IsLinkCache()
functions used to direct to route cache
Time m_linkAckTimeout
The timeout value for link acknowledge.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
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.
void Connect(std::string path, const CallbackBase &cb)
void SetPacket(Ptr< const Packet > p)
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
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.
uint32_t m_tryLinkAcks
Maximum number of packet transmission using link acknowledgment.
bool AddRoute_Link(RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
functions used to direct to route cache
Ipv4Address m_destination
void SetSrc(Ipv4Address s)
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.
Time m_maxCacheTime
Max time for caching the route cache entry.
std::vector< SendBuffEntry > & GetBuffer()
Return a pointer to the internal queue.
Time m_gratReplyHoldoff
The max gratuitous reply hold off time.
a polymophic address class
Ptr< const Packet > GetPacket() const
uint32_t m_maxMaintainLen
Max # of entries for maintainance 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.
bool IsRunning(void) const
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...
uint32_t m_graReplyTableSize
Set the gratuitous reply table size.
bool AllEqual(MaintainBuffEntry &entry)
Verify if all the elements in the maintainence buffer entry is the same.
void SetSource(Ipv4Address s)
Ipv4Address m_destination
void ConnectCallbacks()
Connect the callback for the tracing event.
Time m_maxNetworkDelay
Maximum network delay.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
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.
Ptr< dsr::RreqTable > GetRequestTable() const
Get the request table.
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
void LinkScheduleTimerExpire(MaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using link acknowledgment.
Ipv4Address GetOurAdd() const
bool LinkEqual(MaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for link ack.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Attribute for objects of type ns3::Time.
void Schedule(void)
Schedule a new event using the currently-configured delay, function, and arguments.
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...
Hold an unsigned integer type.
Time m_sendBufferTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for.
int GetProtocolNumber(void) const
Get the dsr protocol number.
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Ipv4Address m_broadcast
The broadcast IP address.
bool IsBroadcast(void) const
uint32_t m_numPriorityQueues
The number of priority queues used.
uint32_t m_broadcastJitter
The max time to delay route request broadcast.
void SetNode(Ptr< Node > node)
Set the node.
bool Find(Ipv4Address nextHop)
Finds whether a packet with destination dst exists in the queue.
static const uint8_t PROT_NUMBER
Define the dsr protocol number.
uint32_t m_requestId
The id assigned to each route request.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Ptr< dsr::RouteCache > GetRouteCache() const
Get the route cache.
Hold together all Wifi-related objects.
bool PromiscEqual(MaintainBuffEntry &entry)
Verify if the maintain buffer entry is the same in every field for promiscuous ack.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Ptr< const Packet > GetPacket() const
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.
void CancelNetworkPacketTimer(MaintainBuffEntry &mb)
Cancel the network packet retransmission timer for a specific maintenance entry.
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 SetGraTableSize(uint32_t g)
Set the gratuitous reply table size.
bool UpdateRouteEntry(Ipv4Address dst)
functions used to direct to route cache
bool Dequeue(Ipv4Address dst, SendBuffEntry &entry)
Return first found (the earliest) entry for the given destination.
Time m_minLifeTime
The min life time.
Time m_useExtends
The use extension of the life time for link cache.
void SetPacket(Ptr< const Packet > p)
GraReply m_graReply
The gratuitous route reply.
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...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Time m_blacklistTimeout
The black list time out.
Ipv4Address GetSrc() const
uint16_t GetAckId() const
void SetPassiveBuffer(Ptr< dsr::PassiveBuffer > r)
Set the node.
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.
virtual void NotifyNewAggregate(void)
This method is invoked whenever two sets of objects are aggregated together.
Access to the Ipv4 forwarding table, interfaces, and configuration.
uint32_t GetSize()
Number of entries.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
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.
Ipv4Address GetNextHopAddress() const
Time m_initStability
The initial stability value for link cache.
The maintenance buffer is responsible for maintaining packet next hop delivery The data packet is sav...
Time m_requestPeriod
The base time interval between route requests.
Implement the Ipv4 layer.
Ptr< dsr::DsrOptions > GetOption(int optionNumber)
Get the option corresponding to optionNumber.
uint16_t GetIDfromIP(Ipv4Address address)
Get the node id from ip address.
Ptr< Node > m_node
The node ptr.
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue.
void CallCancelPacketTimer(uint16_t ackId, Ipv4Header const &ipv4Header, Ipv4Address realSrc, Ipv4Address realDst)
Call the cancel packet retransmission timer function.
void ScheduleNetworkPacketRetry(MaintainBuffEntry &mb, bool isFirst, uint8_t protocol)
Schedule the packet retransmission based on network layer acknowledgment.
uint32_t m_passiveRetries
of retries have been sent for passive acknowledgment
uint32_t m_maxNetworkSize
Maximum network queue size.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
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.
ErrorBuffer m_errorBuffer
The error buffer to save the error messages.
uint32_t m_maxMaintRexmt
Maximum number of retransmissions of data packets.
Ipv4Address GetDst() const
void Resume(void)
Restart the timer to expire within the amount of time left saved during Suspend.
Ptr< const Packet > GetPacket() const
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.
void SetMaxQueueLen(uint32_t len)
Time m_retransIncr
the increase time for retransmission timer when face network congestion
void ScheduleLinkPacketRetry(MaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on link-layer acknowledgment.
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.
Ptr< dsr::PassiveBuffer > m_passiveBuffer
A "drop-front" queue used by the routing layer to cache route request sent.
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.
MaintainBuffer m_maintainBuffer
The declaration of maintain buffer.
L4 Protocol abstract base class.
static Time Now(void)
Return the "current simulation time".
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
void NotifyDataReceipt(std::string context, Ptr< const Packet > p)
Notify the data receipt.
DSR Maintain Buffer Entry.
void SendPacket(Ptr< Packet > packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol)
This function is called by when really sending out the packet.
void ScheduleRreqRetry(Ptr< Packet > packet, std::vector< Ipv4Address > address, bool nonProp, uint32_t requestId, uint8_t protocol)
Schedule the route request retry.
IP_VECTOR GetVector() const
void SetMaintainBufferTimeout(Time t)
Verify if all the elements in the maintainence buffer entry is the same.
IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
uint32_t m_maxRreqId
The max number of request ids for a single destination.
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found, create a new one if not.
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Ptr< dsr::PassiveBuffer > GetPassiveBuffer() const
Get the passive buffer.
uint32_t m_maxCacheLen
Max # of cache entries for route cache.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
uint32_t GetSize()
Number of entries.
bool Enqueue(MaintainBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
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
Ipv4Address GetSourceAddress() const
Describes an IPv6 address.
std::map< PassiveKey, uint32_t > m_passiveCnt
Map packet key + passive forward counts.
Ptr< Ipv4Route > GetIpv4Route() const
Ipv4 addresses are stored in host order in this class.
virtual void NotifyNewAggregate()
This method is invoked whenever two sets of objects are aggregated together.
TracedCallback< Ptr< const Packet > > m_dropTrace
The trace for drop, receive and send data packets.
Ptr< dsr::RreqTable > m_rreqTable
A "drop-front" queue used by the routing layer to cache route request sent.
std::map< PassiveKey, Timer > m_passiveAckTimer
The timer for passive acknowledgment.
void AddDsrOption(DsrOptionHeader const &option)
Serialize the option, prepending pad1 or padn option as necessary.
void CancelPacketTimerNextHop(Ipv4Address nextHop, uint8_t protocol)
Cancel the packet retransmission timer for a all maintenance entries with nextHop address...
void SetSegsLeft(uint8_t segs)
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 SetRequestTable(Ptr< dsr::RreqTable > r)
Set the node.
#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.
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.
uint32_t m_rreqRetries
Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route.
void SetSegsLeft(uint8_t seg)
void Suspend(void)
Cancel the timer and save the amount of time left until it was set to expire.
Ptr< const Packet > GetPacket() const
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 FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
functions used to direct to route cache
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
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.
void SetRouteCache(Ptr< dsr::RouteCache > r)
Set the route cache.
DsrOptionList_t m_options
List of DSR Options supported.
bool Dequeue(Ipv4Address dst, MaintainBuffEntry &entry)
Return first found (the earliest) entry for given destination.
void SendGratuitousReply(Ipv4Address replyTo, Ipv4Address replyFrom, std::vector< Ipv4Address > &nodeList, uint8_t protocol)
Send the gratuitous reply.
void SetIdentification(uint16_t i)
void SendErrorRequest(DsrOptionRerrUnreachHeader &rerr, uint8_t protocol)
Send the error request packet.
void SetSendBufferTimeout(Time t)
Set the entry lifetime in the queue.
void CancelPacketAllTimer(MaintainBuffEntry &mb)
Cancel all the packet timers.
PacketType
Packet types are used as they are in Linux.
Ptr< Node > GetNode() const
Get the node.
SendBuffer m_sendBuffer
The send buffer.
std::map< LinkKey, uint32_t > m_linkCnt
Map packet key + link forward counts.
bool LookupRoute(Ipv4Address id, RouteCacheEntry &rt)
functions used to direct to route cache
bool IsSuspended(void) const
void SetMaxQueueLen(uint32_t len)
Set the maximum queue length.
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
std::map< NetworkKey, uint32_t > m_addressForwardCnt
Map network key + forward counts.
void SetFragmentOffset(uint16_t f)
Ptr< T > GetObject(void) const
Doxygen introspection did not find any typical Config paths.
a unique identifier for an interface.
bool Enqueue(SendBuffEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...
Time m_nonpropRequestTimeout
The non-propagation request timeout.
TypeId SetParent(TypeId tid)
std::map< Ipv4Address, Timer > m_nonPropReqTimer
Map IP address + RREQ timer.
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 PassiveScheduleTimerExpire(MaintainBuffEntry &mb, uint8_t protocol)
This function deals with packet retransmission timer expire using passive acknowledgment.
void AddHeader(const Header &header)
Add header to this packet.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
void CancelPassivePacketTimer(MaintainBuffEntry &mb)
Cancel the passive packet retransmission timer for a specific maintenance entry.
void SetDestination(Ipv4Address dest)
void SetMaxQueueLen(uint32_t len)
Verify if all the elements in the maintainence buffer entry is the same.
IpL4Protocol::DownTargetCallback m_downTarget
The callback for down layer.
uint8_t GetSegsLeft() const
void SetAckId(uint16_t ackId)
void UseExtends(RouteCacheEntry::IP_VECTOR rt)
functions used to direct to route cache
Ipv4Address GetNextHop() const
Time m_maxMaintainTime
Time out for maintainance buffer.
void CancelRreqTimer(Ipv4Address dst, bool isRemove)
Cancel the route request timer.
virtual ~DsrRouting()
Destructor.
void SchedulePassivePacketRetry(MaintainBuffEntry &mb, uint8_t protocol)
Schedule the packet retransmission based on passive acknowledgment.