A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dsr-options.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Yufei Cheng
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
18 *
19 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20 * ResiliNets Research Group https://resilinets.org/
21 * Information and Telecommunication Technology Center (ITTC)
22 * and Department of Electrical Engineering and Computer Science
23 * The University of Kansas Lawrence, KS USA.
24 *
25 * Work supported in part by NSF FIND (Future Internet Design) Program
26 * under grant CNS-0626918 (Postmodern Internet Architecture),
27 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
28 * US Department of Defense (DoD), and ITTC at The University of Kansas.
29 */
30
31#define NS_LOG_APPEND_CONTEXT \
32 if (GetObject<Node>()) \
33 { \
34 std::clog << "[node " << GetObject<Node>()->GetId() << "] "; \
35 }
36
37#include "dsr-options.h"
38
39#include "dsr-option-header.h"
40#include "dsr-rcache.h"
41
42#include "ns3/assert.h"
43#include "ns3/fatal-error.h"
44#include "ns3/icmpv4-l4-protocol.h"
45#include "ns3/ip-l4-protocol.h"
46#include "ns3/ipv4-address.h"
47#include "ns3/ipv4-header.h"
48#include "ns3/ipv4-interface.h"
49#include "ns3/ipv4-l3-protocol.h"
50#include "ns3/ipv4-route.h"
51#include "ns3/log.h"
52#include "ns3/node-list.h"
53#include "ns3/node.h"
54#include "ns3/object-vector.h"
55#include "ns3/pointer.h"
56#include "ns3/ptr.h"
57#include "ns3/trace-source-accessor.h"
58#include "ns3/udp-header.h"
59#include "ns3/uinteger.h"
60
61#include <algorithm>
62#include <ctime>
63#include <list>
64#include <map>
65
66namespace ns3
67{
68
69NS_LOG_COMPONENT_DEFINE("DsrOptions");
70
71namespace dsr
72{
73
75
76TypeId
78{
79 static TypeId tid = TypeId("ns3::dsr::DsrOptions")
81 .SetGroupName("Dsr")
82 .AddAttribute("OptionNumber",
83 "The Dsr option number.",
86 MakeUintegerChecker<uint8_t>())
87 .AddTraceSource("Drop",
88 "Packet dropped.",
90 "ns3::Packet::TracedCallback")
91 .AddTraceSource("Rx",
92 "Receive DSR packet.",
94 "ns3::dsr::DsrOptionSRHeader::TracedCallback");
95 return tid;
96}
97
99{
101}
102
104{
106}
107
108void
110{
111 NS_LOG_FUNCTION(this << node);
112 m_node = node;
113}
114
117{
119 return m_node;
120}
121
122bool
124 Ipv4Address destAddress,
125 std::vector<Ipv4Address>& nodeList)
126{
127 NS_LOG_FUNCTION(this << ipv4Address << destAddress);
128 std::vector<Ipv4Address>::iterator it = find(nodeList.begin(), nodeList.end(), destAddress);
129
130 for (std::vector<Ipv4Address>::iterator i = it; i != nodeList.end(); ++i)
131 {
132 if ((ipv4Address == (*i)) && ((*i) != nodeList.back()))
133 {
134 return true;
135 }
136 }
137 return false;
138}
139
140std::vector<Ipv4Address>
141DsrOptions::CutRoute(Ipv4Address ipv4Address, std::vector<Ipv4Address>& nodeList)
142{
143 NS_LOG_FUNCTION(this << ipv4Address);
144 std::vector<Ipv4Address>::iterator it = find(nodeList.begin(), nodeList.end(), ipv4Address);
145 std::vector<Ipv4Address> cutRoute;
146 for (std::vector<Ipv4Address>::iterator i = it; i != nodeList.end(); ++i)
147 {
148 cutRoute.push_back(*i);
149 }
150 return cutRoute;
151}
152
155{
156 NS_LOG_FUNCTION(this << nextHop << srcAddress);
157 m_ipv4Route = Create<Ipv4Route>();
158 m_ipv4Route->SetDestination(nextHop);
159 m_ipv4Route->SetGateway(nextHop);
160 m_ipv4Route->SetSource(srcAddress);
161 return m_ipv4Route;
162}
163
164bool
165DsrOptions::ReverseRoutes(std::vector<Ipv4Address>& vec)
166{
167 NS_LOG_FUNCTION(this);
168
169 std::reverse(vec.begin(), vec.end());
170
171 return true;
172}
173
175DsrOptions::SearchNextHop(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec)
176{
177 NS_LOG_FUNCTION(this << ipv4Address);
178 Ipv4Address nextHop;
179 NS_LOG_DEBUG("the vector size " << vec.size());
180 if (vec.size() == 2)
181 {
182 NS_LOG_DEBUG("The two nodes are neighbors");
183 nextHop = vec[1];
184 return nextHop;
185 }
186
187 if (ipv4Address == vec.back())
188 {
189 NS_LOG_DEBUG("We have reached to the final destination " << ipv4Address << " "
190 << vec.back());
191 return ipv4Address;
192 }
193 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
194 {
195 if (ipv4Address == (*i))
196 {
197 nextHop = *(++i);
198 return nextHop;
199 }
200 }
201
202 NS_LOG_DEBUG("next hop address not found, route corrupted");
203 Ipv4Address none = "0.0.0.0";
204 return none;
205}
206
208DsrOptions::ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec)
209{
210 NS_LOG_FUNCTION(this << ipv4Address);
211 Ipv4Address nextHop;
212 if (vec.size() == 2)
213 {
214 NS_LOG_DEBUG("The two nodes are neighbors");
215 nextHop = vec[0];
216 return nextHop;
217 }
218
219 for (std::vector<Ipv4Address>::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri)
220 {
221 if (ipv4Address == (*ri))
222 {
223 nextHop = *(++ri);
224 return nextHop;
225 }
226 }
227
228 NS_LOG_DEBUG("next hop address not found, route corrupted");
229 Ipv4Address none = "0.0.0.0";
230 return none;
231}
232
234DsrOptions::ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec)
235{
236 NS_LOG_FUNCTION(this << ipv4Address);
237 Ipv4Address nextTwoHop;
238 NS_LOG_DEBUG("The vector size " << vec.size());
239 NS_ASSERT(vec.size() > 2);
240 for (std::vector<Ipv4Address>::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri)
241 {
242 if (ipv4Address == (*ri))
243 {
244 nextTwoHop = *(ri + 2);
245 return nextTwoHop;
246 }
247 }
248 NS_FATAL_ERROR("next hop address not found, route corrupted");
249 Ipv4Address none = "0.0.0.0";
250 return none;
251}
252
253void
254DsrOptions::PrintVector(std::vector<Ipv4Address>& vec)
255{
256 NS_LOG_FUNCTION(this);
257 /*
258 * Check elements in a route vector
259 */
260 if (vec.empty())
261 {
262 NS_LOG_DEBUG("The vector is empty");
263 }
264 else
265 {
266 NS_LOG_DEBUG("Print all the elements in a vector");
267 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
268 {
269 NS_LOG_DEBUG("The ip address " << *i);
270 }
271 }
272}
273
274bool
275DsrOptions::IfDuplicates(std::vector<Ipv4Address>& vec, std::vector<Ipv4Address>& vec2)
276{
277 NS_LOG_FUNCTION(this);
278 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
279 {
280 for (std::vector<Ipv4Address>::const_iterator j = vec2.begin(); j != vec2.end(); ++j)
281 {
282 if ((*i) == (*j))
283 {
284 return true;
285 }
286 }
287 }
288 return false;
289}
290
291bool
292DsrOptions::CheckDuplicates(Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec)
293{
294 NS_LOG_FUNCTION(this << ipv4Address);
295 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
296 {
297 if ((*i) == ipv4Address)
298 {
299 return true;
300 }
301 }
302 return false;
303}
304
305void
306DsrOptions::RemoveDuplicates(std::vector<Ipv4Address>& vec)
307{
308 NS_LOG_FUNCTION(this);
309 // Remove duplicate ip address from the route if any, should not happen with normal behavior
310 // nodes
311 std::vector<Ipv4Address> vec2(vec); // declare vec2 as a copy of the vec
312 PrintVector(vec2); // Print all the ip address in the route
313 vec.clear(); // clear vec
314 for (std::vector<Ipv4Address>::const_iterator i = vec2.begin(); i != vec2.end(); ++i)
315 {
316 if (vec.empty())
317 {
318 vec.push_back(*i);
319 continue;
320 }
321
322 for (std::vector<Ipv4Address>::iterator j = vec.begin(); j != vec.end(); ++j)
323 {
324 if ((*i) == (*j))
325 {
326 if ((j + 1) != vec.end())
327 {
328 vec.erase(j + 1, vec.end()); // Automatic shorten the route
329 }
330
331 break;
332 }
333 else if (j == (vec.end() - 1))
334 {
335 vec.push_back(*i);
336 break;
337 }
338 }
339 }
340}
341
344{
345 NS_LOG_FUNCTION(this << address);
346 int32_t nNodes = NodeList::GetNNodes();
347 for (int32_t i = 0; i < nNodes; ++i)
348 {
350 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
351 if (ipv4->GetAddress(1, 0).GetLocal() == address)
352 {
353 return i;
354 }
355 }
356 return 255;
357}
358
361{
362 NS_LOG_FUNCTION(this << ipv4Address);
363 int32_t nNodes = NodeList::GetNNodes();
364 for (int32_t i = 0; i < nNodes; ++i)
365 {
367 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
368 int32_t ifIndex = ipv4->GetInterfaceForAddress(ipv4Address);
369 if (ifIndex != -1)
370 {
371 return node;
372 }
373 }
374 return nullptr;
375}
376
378
379TypeId
381{
382 static TypeId tid = TypeId("ns3::dsr::DsrOptionPad1")
384 .SetGroupName("Dsr")
385 .AddConstructor<DsrOptionPad1>();
386 return tid;
387}
388
390{
392}
393
395{
397}
398
399uint8_t
401{
403
404 return OPT_NUMBER;
405}
406
407uint8_t
409 Ptr<Packet> dsrP,
410 Ipv4Address ipv4Address,
411 Ipv4Address source,
412 const Ipv4Header& ipv4Header,
413 uint8_t protocol,
414 bool& isPromisc,
415 Ipv4Address promiscSource)
416{
417 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Header
418 << (uint32_t)protocol << isPromisc);
419 Ptr<Packet> p = packet->Copy();
420 DsrOptionPad1Header pad1Header;
421 p->RemoveHeader(pad1Header);
422
423 isPromisc = false;
424
425 return pad1Header.GetSerializedSize();
426}
427
429
430TypeId
432{
433 static TypeId tid = TypeId("ns3::dsr::DsrOptionPadn")
435 .SetGroupName("Dsr")
436 .AddConstructor<DsrOptionPadn>();
437 return tid;
438}
439
441{
443}
444
446{
448}
449
450uint8_t
452{
454 return OPT_NUMBER;
455}
456
457uint8_t
459 Ptr<Packet> dsrP,
460 Ipv4Address ipv4Address,
461 Ipv4Address source,
462 const Ipv4Header& ipv4Header,
463 uint8_t protocol,
464 bool& isPromisc,
465 Ipv4Address promiscSource)
466{
467 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Header
468 << (uint32_t)protocol << isPromisc);
469
470 Ptr<Packet> p = packet->Copy();
471 DsrOptionPadnHeader padnHeader;
472 p->RemoveHeader(padnHeader);
473
474 isPromisc = false;
475
476 return padnHeader.GetSerializedSize();
477}
478
480
481TypeId
483{
484 static TypeId tid = TypeId("ns3::dsr::DsrOptionRreq")
486 .SetGroupName("Dsr")
487 .AddConstructor<DsrOptionRreq>();
488 return tid;
489}
490
491TypeId
493{
494 return GetTypeId();
495}
496
498{
500}
501
503{
505}
506
507uint8_t
509{
511
512 return OPT_NUMBER;
513}
514
515uint8_t
517 Ptr<Packet> dsrP,
518 Ipv4Address ipv4Address,
519 Ipv4Address source,
520 const Ipv4Header& ipv4Header,
521 uint8_t protocol,
522 bool& isPromisc,
523 Ipv4Address promiscSource)
524{
525 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Header
526 << (uint32_t)protocol << isPromisc);
527 // Fields from IP header
528 Ipv4Address srcAddress = ipv4Header.GetSource();
529 /*
530 * \ when the ip source address is equal to the address of our own, this is request packet
531 * originated \ by the node itself, discard it
532 */
533 if (source == ipv4Address)
534 {
535 NS_LOG_DEBUG("Discard the packet since it was originated from same source address");
536 m_dropTrace(packet); // call the drop trace to show in the tracing
537 return 0;
538 }
539 /*
540 * Get the node associated with the ipv4 address and get several objects from the node and leave
541 * for further use
542 */
543 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
544 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting>();
545
546 Ptr<Packet> p =
547 packet->Copy(); // Note: The packet here doesn't contain the fixed size dsr header
548 /*
549 * \brief Get the number of routers' address field before removing the header
550 * \peek the packet and get the value
551 */
552 uint8_t buf[2];
553 p->CopyData(buf, sizeof(buf));
554 uint8_t numberAddress = (buf[1] - 6) / 4;
555 NS_LOG_DEBUG("The number of Ip addresses " << (uint32_t)numberAddress);
556 if (numberAddress >= 255)
557 {
558 NS_LOG_DEBUG("Discard the packet, malformed header since two many ip addresses in route");
559 m_dropTrace(packet); // call the drop trace to show in the tracing
560 return 0;
561 }
562
563 /*
564 * Create the dsr rreq header
565 */
567 /*
568 * Set the number of addresses with the value from peek data and remove the rreq header
569 */
570 rreq.SetNumberAddress(numberAddress);
571 // Remove the route request header
572 p->RemoveHeader(rreq);
573 // Verify the option length
574 uint8_t length = rreq.GetLength();
575 if (length % 2 != 0)
576 {
577 NS_LOG_LOGIC("Malformed header. Drop!");
578 m_dropTrace(packet); // call drop trace
579 return 0;
580 }
581 // Check the rreq id for verifying the request id
582 uint16_t requestId = rreq.GetId();
583 // The target address is where we want to send the data packets
584 Ipv4Address targetAddress = rreq.GetTarget();
585 // Get the node list and source address from the route request header
586 std::vector<Ipv4Address> mainVector = rreq.GetNodesAddresses();
587 std::vector<Ipv4Address> nodeList(mainVector);
588 // Get the real source address of this request, it will be used when checking if we have
589 // received the save route request before or not
590 Ipv4Address sourceAddress = nodeList.front();
591 PrintVector(nodeList);
592 /*
593 * Construct the dsr routing header for later use
594 */
595 DsrRoutingHeader dsrRoutingHeader;
596 dsrRoutingHeader.SetNextHeader(protocol);
597 dsrRoutingHeader.SetMessageType(1);
598 dsrRoutingHeader.SetSourceId(GetIDfromIP(source));
599 dsrRoutingHeader.SetDestId(255);
600
601 // check whether we have received this request or not, if not, it will save the request in the
602 // table for later use, if not found, return false, and push the newly received source request
603 // entry in the cache
604
605 // Get the TTL value, this is used to test if the packet will be forwarded or not
606 uint8_t ttl = ipv4Header.GetTtl();
607 bool dupRequest = false; // initialize the duplicate request check value
608 if (ttl)
609 {
610 // if the ttl value is not 0, then this request will be forwarded, then we need to
611 // save it in the source entry
612 dupRequest = dsr->FindSourceEntry(sourceAddress, targetAddress, requestId);
613 }
614 /*
615 * Before processing the route request, we need to check two things
616 * 1. if this is the exact same request we have just received, ignore it
617 * 2. if our address is already in the path list, ignore it
618 * 3. otherwise process further
619 */
620
621 if (dupRequest)
622 {
623 // We have received this same route request before, not forwarding it now
624 NS_LOG_LOGIC("Duplicate request. Drop!");
625 m_dropTrace(packet); // call drop trace
626 return 0;
627 }
628
629 else if (CheckDuplicates(ipv4Address, nodeList))
630 {
631 /*
632 * if the route contains the node address already, drop the request packet
633 */
634 m_dropTrace(packet); // call drop trace
635 NS_LOG_DEBUG("Our node address is already seen in the route, drop the request");
636 return 0;
637 }
638 else
639 {
640 // A node ignores all RREQs received from any node in its blacklist
641 DsrRouteCacheEntry toPrev;
642 bool isRouteInCache = dsr->LookupRoute(targetAddress, toPrev);
644 toPrev.GetVector(); // The route from our own route cache to dst
645 PrintVector(ip);
646 std::vector<Ipv4Address> saveRoute(nodeList);
647 PrintVector(saveRoute);
648 bool areThereDuplicates = IfDuplicates(ip, saveRoute);
649 /*
650 * When the reverse route is created or updated, the following actions on the route are
651 * also carried out:
652 * 3. the next hop in the routing table becomes the node from which the RREQ was received
653 * 4. the hop count is copied from the Hop Count in the RREQ message;
654 */
655
656 // A node generates a RREP if either:
657 // (i) it is itself the destination,
658 /*
659 * The target address equal to our own ip address
660 */
661 NS_LOG_DEBUG("The target address over here " << targetAddress << " and the ip address "
662 << ipv4Address << " and the source address "
663 << mainVector[0]);
664 if (targetAddress == ipv4Address)
665 {
666 Ipv4Address nextHop; // Declare the next hop address to use
667 if (nodeList.size() == 1)
668 {
669 NS_LOG_DEBUG("These two nodes are neighbors");
670 m_finalRoute.clear();
673 m_finalRoute.push_back(source); // push back the request originator's address
674 m_finalRoute.push_back(ipv4Address); // push back our own address
675 nextHop = srcAddress;
676 }
677 else
678 {
679 std::vector<Ipv4Address> changeRoute(nodeList);
680 changeRoute.push_back(ipv4Address); // push back our own address
681 m_finalRoute.clear(); // get a clear route vector
682 for (std::vector<Ipv4Address>::iterator i = changeRoute.begin();
683 i != changeRoute.end();
684 ++i)
685 {
686 m_finalRoute.push_back(*i); // Get the full route from source to destination
687 }
689 nextHop = ReverseSearchNextHop(ipv4Address, m_finalRoute); // get the next hop
690 }
691
693 rrep.SetNodesAddress(m_finalRoute); // Set the node addresses in the route reply header
694 NS_LOG_DEBUG("The nextHop address " << nextHop);
695 Ipv4Address replyDst = m_finalRoute.front();
696 /*
697 * This part add dsr header to the packet and send route reply packet
698 */
699 DsrRoutingHeader dsrRoutingHeader;
700 dsrRoutingHeader.SetNextHeader(protocol);
701 dsrRoutingHeader.SetMessageType(1);
702 dsrRoutingHeader.SetSourceId(GetIDfromIP(ipv4Address));
703 dsrRoutingHeader.SetDestId(GetIDfromIP(replyDst));
704 // Set the route for route reply
705 SetRoute(nextHop, ipv4Address);
706
707 uint8_t length =
708 rrep.GetLength(); // Get the length of the rrep header excluding the type header
709 dsrRoutingHeader.SetPayloadLength(length + 2);
710 dsrRoutingHeader.AddDsrOption(rrep);
711 Ptr<Packet> newPacket = Create<Packet>();
712 newPacket->AddHeader(dsrRoutingHeader);
713 dsr->ScheduleInitialReply(newPacket, ipv4Address, nextHop, m_ipv4Route);
714 /*
715 * Create the route entry to the rreq originator and save it to route cache, also need
716 * to reverse the route
717 */
720 {
722 Ipv4Address dst = m_finalRoute.back();
723 bool addRoute = false;
724 if (numberAddress > 0)
725 {
726 DsrRouteCacheEntry toSource(/*ip=*/m_finalRoute,
727 /*dst=*/dst,
728 /*exp=*/ActiveRouteTimeout);
729 if (dsr->IsLinkCache())
730 {
731 addRoute = dsr->AddRoute_Link(m_finalRoute, ipv4Address);
732 }
733 else
734 {
735 addRoute = dsr->AddRoute(toSource);
736 }
737 }
738 else
739 {
740 NS_LOG_DEBUG("Abnormal RouteRequest");
741 return 0;
742 }
743
744 if (addRoute)
745 {
746 /*
747 * Found a route to the dst, construct the source route option header
748 */
749 DsrOptionSRHeader sourceRoute;
750 NS_LOG_DEBUG("The route length " << m_finalRoute.size());
751 sourceRoute.SetNodesAddress(m_finalRoute);
752
756 // if (dsr->IsLinkCache ())
757 // {
758 // dsr->UseExtends (m_finalRoute);
759 // }
760 sourceRoute.SetSegmentsLeft((m_finalRoute.size() - 2));
761 // The salvage value here is 0
762 sourceRoute.SetSalvage(0);
763 Ipv4Address nextHop =
764 SearchNextHop(ipv4Address, m_finalRoute); // Get the next hop address
765 NS_LOG_DEBUG("The nextHop address " << nextHop);
766
767 if (nextHop == "0.0.0.0")
768 {
769 dsr->PacketNewRoute(dsrP, ipv4Address, dst, protocol);
770 return 0;
771 }
772 SetRoute(nextHop, ipv4Address);
773 /*
774 * Send the data packet from the send buffer
775 */
776 dsr->SendPacketFromBuffer(sourceRoute, nextHop, protocol);
777 // Cancel the route request timer for destination after sending the data packet
778 dsr->CancelRreqTimer(dst, true);
779 }
780 else
781 {
782 NS_LOG_DEBUG("The route is failed to add in cache");
783 return 0;
784 }
785 }
786 else
787 {
788 NS_LOG_DEBUG("Unable to reverse route");
789 return 0;
790 }
791 isPromisc = false;
792 return rreq.GetSerializedSize();
793 }
794
795 /*
796 * (ii) or it has an active route to the destination, send reply based on request header and
797 * route cache, need to delay based on a random value from d = H * (h - 1 + r), which can
798 * avoid possible route reply storm. Also, verify if two vectors do not contain duplicates
799 * (part of the route to the destination from route cache and route collected so far). If
800 * so, do not use the route found and forward the route request.
801 */
802 else if (isRouteInCache && !areThereDuplicates)
803 {
804 m_finalRoute.clear(); // Clear the final route vector
808 for (std::vector<Ipv4Address>::iterator i = saveRoute.begin(); i != saveRoute.end();
809 ++i)
810 {
811 m_finalRoute.push_back(*i);
812 }
817 for (std::vector<Ipv4Address>::iterator j = ip.begin(); j != ip.end(); ++j)
818 {
819 m_finalRoute.push_back(*j);
820 }
821 /*
822 * Create the route entry to the rreq originator and save it to route cache, also need
823 * to reverse the route
824 */
825 bool addRoute = false;
826 std::vector<Ipv4Address> reverseRoute(m_finalRoute);
827
828 if (ReverseRoutes(reverseRoute))
829 {
830 saveRoute.push_back(ipv4Address);
831 ReverseRoutes(saveRoute);
832 Ipv4Address dst = saveRoute.back();
833 NS_LOG_DEBUG("This is the route save in route cache");
834 PrintVector(saveRoute);
835
836 DsrRouteCacheEntry toSource(/*ip=*/saveRoute,
837 /*dst=*/dst,
838 /*exp=*/ActiveRouteTimeout);
839 NS_ASSERT(saveRoute.front() == ipv4Address);
840 // Add the route entry in the route cache
841 if (dsr->IsLinkCache())
842 {
843 addRoute = dsr->AddRoute_Link(saveRoute, ipv4Address);
844 }
845 else
846 {
847 addRoute = dsr->AddRoute(toSource);
848 }
849
850 if (addRoute)
851 {
852 NS_LOG_LOGIC("We have added the route and search send buffer for packet with "
853 "destination "
854 << dst);
855 /*
856 * Found a route the dst, construct the source route option header
857 */
858 DsrOptionSRHeader sourceRoute;
859 PrintVector(saveRoute);
860
861 sourceRoute.SetNodesAddress(saveRoute);
862 // if (dsr->IsLinkCache ())
863 // {
864 // dsr->UseExtends (saveRoute);
865 // }
866 sourceRoute.SetSegmentsLeft((saveRoute.size() - 2));
867 uint8_t salvage = 0;
868 sourceRoute.SetSalvage(salvage);
869 Ipv4Address nextHop =
870 SearchNextHop(ipv4Address, saveRoute); // Get the next hop address
871 NS_LOG_DEBUG("The nextHop address " << nextHop);
872
873 if (nextHop == "0.0.0.0")
874 {
875 dsr->PacketNewRoute(dsrP, ipv4Address, dst, protocol);
876 return 0;
877 }
878 SetRoute(nextHop, ipv4Address);
879 /*
880 * Schedule the packet retry
881 */
882 dsr->SendPacketFromBuffer(sourceRoute, nextHop, protocol);
883 // Cancel the route request timer for destination
884 dsr->CancelRreqTimer(dst, true);
885 }
886 else
887 {
888 NS_LOG_DEBUG("The route is failed to add in cache");
889 return 0;
890 }
891 }
892 else
893 {
894 NS_LOG_DEBUG("Unable to reverse the route");
895 return 0;
896 }
897
898 /*
899 * Need to first pin down the next hop address before removing duplicates
900 */
901 Ipv4Address nextHop = ReverseSearchNextHop(ipv4Address, m_finalRoute);
902 /*
903 * First remove the duplicate ip address to automatically shorten the route, and then
904 * reversely search the next hop address
905 */
906 // Set the route
907 SetRoute(nextHop, ipv4Address);
908
909 uint16_t hops = m_finalRoute.size();
911 rrep.SetNodesAddress(m_finalRoute); // Set the node addresses in the route reply header
912 // Get the real source of the reply
913 Ipv4Address realSource = m_finalRoute.back();
915 NS_LOG_DEBUG("This is the full route from " << realSource << " to "
916 << m_finalRoute.front());
917 /*
918 * This part add dsr header to the packet and send route reply packet
919 */
920 DsrRoutingHeader dsrRoutingHeader;
921 dsrRoutingHeader.SetNextHeader(protocol);
922 dsrRoutingHeader.SetMessageType(1);
923 dsrRoutingHeader.SetSourceId(GetIDfromIP(realSource));
924 dsrRoutingHeader.SetDestId(255);
925
926 uint8_t length =
927 rrep.GetLength(); // Get the length of the rrep header excluding the type header
928 dsrRoutingHeader.SetPayloadLength(length + 2);
929 dsrRoutingHeader.AddDsrOption(rrep);
930 Ptr<Packet> newPacket = Create<Packet>();
931 newPacket->AddHeader(dsrRoutingHeader);
932 dsr->ScheduleCachedReply(newPacket, ipv4Address, nextHop, m_ipv4Route, hops);
933 isPromisc = false;
934 return rreq.GetSerializedSize();
935 }
936 /*
937 * (iii) no route in any type has been found
938 */
939 else
940 {
941 mainVector.push_back(ipv4Address);
942 NS_ASSERT(mainVector.front() == source);
943 NS_LOG_DEBUG("Print out the main vector");
944 PrintVector(mainVector);
945 rreq.SetNodesAddress(mainVector);
946
947 Ptr<Packet> errP = p->Copy();
948 if (errP->GetSize())
949 {
950 NS_LOG_DEBUG("Error header included");
952 p->RemoveHeader(rerr);
953 Ipv4Address errorSrc = rerr.GetErrorSrc();
954 Ipv4Address unreachNode = rerr.GetUnreachNode();
955 Ipv4Address errorDst = rerr.GetErrorDst();
956
957 if ((errorSrc == srcAddress) && (unreachNode == ipv4Address))
958 {
959 NS_LOG_DEBUG("The error link back to work again");
960 uint16_t length = rreq.GetLength();
961 NS_LOG_DEBUG("The RREQ header length " << length);
962 dsrRoutingHeader.AddDsrOption(rreq);
963 dsrRoutingHeader.SetPayloadLength(length + 2);
964 }
965 else
966 {
967 dsr->DeleteAllRoutesIncludeLink(errorSrc, unreachNode, ipv4Address);
968
970 newUnreach.SetErrorType(1);
971 newUnreach.SetErrorSrc(errorSrc);
972 newUnreach.SetUnreachNode(unreachNode);
973 newUnreach.SetErrorDst(errorDst);
974 newUnreach.SetSalvage(rerr.GetSalvage()); // Set the value about whether to
975 // salvage a packet or not
976 uint16_t length = rreq.GetLength() + newUnreach.GetLength();
977 NS_LOG_DEBUG("The RREQ and newUnreach header length " << length);
978 dsrRoutingHeader.SetPayloadLength(length + 4);
979 dsrRoutingHeader.AddDsrOption(rreq);
980 dsrRoutingHeader.AddDsrOption(newUnreach);
981 }
982 }
983 else
984 {
985 uint16_t length = rreq.GetLength();
986 NS_LOG_DEBUG("The RREQ header length " << length);
987 dsrRoutingHeader.AddDsrOption(rreq);
988 dsrRoutingHeader.SetPayloadLength(length + 2);
989 }
990 // Get the TTL value
991 uint8_t ttl = ipv4Header.GetTtl();
992 /*
993 * Decrease the TTL value in the packet tag by one, this tag will go to ip layer 3 send
994 * function and drop packet when TTL value equals to 0
995 */
996 NS_LOG_DEBUG("The ttl value here " << (uint32_t)ttl);
997 if (ttl)
998 {
999 Ptr<Packet> interP = Create<Packet>();
1000 SocketIpTtlTag tag;
1001 tag.SetTtl(ttl - 1);
1002 interP->AddPacketTag(tag);
1003 interP->AddHeader(dsrRoutingHeader);
1004 dsr->ScheduleInterRequest(interP);
1005 isPromisc = false;
1006 }
1007 return rreq.GetSerializedSize();
1008 }
1009 }
1010 // unreachable: return rreq.GetSerializedSize ();
1011}
1012
1014
1015TypeId
1017{
1018 static TypeId tid = TypeId("ns3::dsr::DsrOptionRrep")
1020 .SetGroupName("Dsr")
1021 .AddConstructor<DsrOptionRrep>();
1022 return tid;
1023}
1024
1026{
1028}
1029
1031{
1033}
1034
1035TypeId
1037{
1038 return GetTypeId();
1039}
1040
1041uint8_t
1043{
1045
1046 return OPT_NUMBER;
1047}
1048
1049uint8_t
1051 Ptr<Packet> dsrP,
1052 Ipv4Address ipv4Address,
1053 Ipv4Address source,
1054 const Ipv4Header& ipv4Header,
1055 uint8_t protocol,
1056 bool& isPromisc,
1057 Ipv4Address promiscSource)
1058{
1059 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Header
1060 << (uint32_t)protocol << isPromisc);
1061
1062 Ptr<Packet> p = packet->Copy();
1063
1064 // Get the number of routers' address field
1065 uint8_t buf[2];
1066 p->CopyData(buf, sizeof(buf));
1067 uint8_t numberAddress = (buf[1] - 2) / 4;
1068
1070 rrep.SetNumberAddress(numberAddress); // Set the number of ip address in the header to reserver
1071 // space for deserialize header
1072 p->RemoveHeader(rrep);
1073
1074 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
1075 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting>();
1076
1077 NS_LOG_DEBUG("The next header value " << (uint32_t)protocol);
1078
1079 std::vector<Ipv4Address> nodeList = rrep.GetNodesAddress();
1083 Ipv4Address targetAddress = nodeList.front();
1084 // If the RREP option has reached to the destination
1085 if (targetAddress == ipv4Address)
1086 {
1087 RemoveDuplicates(nodeList); // This is for the route reply from intermediate node since we
1088 // didn't remove duplicate there
1089 if (nodeList.empty())
1090 {
1091 NS_LOG_DEBUG("The route we have contains 0 entries");
1092 return 0;
1093 }
1098 Ipv4Address dst = nodeList.back();
1104 DsrRouteCacheEntry toDestination(/*ip=*/nodeList,
1105 /*dst=*/dst,
1106 /*exp=*/ActiveRouteTimeout);
1107 NS_ASSERT(nodeList.front() == ipv4Address);
1108 bool addRoute = false;
1109 if (dsr->IsLinkCache())
1110 {
1111 addRoute = dsr->AddRoute_Link(nodeList, ipv4Address);
1112 }
1113 else
1114 {
1115 addRoute = dsr->AddRoute(toDestination);
1116 }
1117
1118 if (addRoute)
1119 {
1121 "We have added the route and search send buffer for packet with destination "
1122 << dst);
1126 DsrOptionSRHeader sourceRoute;
1127 NS_LOG_DEBUG("The route length " << nodeList.size());
1128 sourceRoute.SetNodesAddress(nodeList);
1129 sourceRoute.SetSegmentsLeft((nodeList.size() - 2));
1130 sourceRoute.SetSalvage(0);
1131 Ipv4Address nextHop = SearchNextHop(ipv4Address, nodeList); // Get the next hop address
1132 NS_LOG_DEBUG("The nextHop address " << nextHop);
1133 if (nextHop == "0.0.0.0")
1134 {
1135 dsr->PacketNewRoute(dsrP, ipv4Address, dst, protocol);
1136 return 0;
1137 }
1138 PrintVector(nodeList);
1139 SetRoute(nextHop, ipv4Address);
1140 // Cancel the route request timer for destination
1141 dsr->CancelRreqTimer(dst, true);
1145 dsr->SendPacketFromBuffer(sourceRoute, nextHop, protocol);
1146 }
1147 else
1148 {
1149 NS_LOG_DEBUG("Failed to add the route");
1150 return 0;
1151 }
1152 }
1153 else
1154 {
1155 uint8_t length = rrep.GetLength() -
1156 2; // The get length - 2 is to get aligned for the malformed header check
1157 NS_LOG_DEBUG("The length of rrep option " << (uint32_t)length);
1158
1159 if (length % 2 != 0)
1160 {
1161 NS_LOG_LOGIC("Malformed header. Drop!");
1162 m_dropTrace(packet);
1163 return 0;
1164 }
1165 PrintVector(nodeList);
1166 /*
1167 * This node is only an intermediate node, but it needs to save the possible route to the
1168 * destination when cutting the route
1169 */
1170 std::vector<Ipv4Address> routeCopy = nodeList;
1171 std::vector<Ipv4Address> cutRoute = CutRoute(ipv4Address, nodeList);
1172 PrintVector(cutRoute);
1173 if (cutRoute.size() >= 2)
1174 {
1175 Ipv4Address dst = cutRoute.back();
1176 NS_LOG_DEBUG("The route destination after cut " << dst);
1177 DsrRouteCacheEntry toDestination(/*ip=*/cutRoute,
1178 /*dst=*/dst,
1179 /*exp=*/ActiveRouteTimeout);
1180 NS_ASSERT(cutRoute.front() == ipv4Address);
1181 bool addRoute = false;
1182 if (dsr->IsLinkCache())
1183 {
1184 addRoute = dsr->AddRoute_Link(nodeList, ipv4Address);
1185 }
1186 else
1187 {
1188 addRoute = dsr->AddRoute(toDestination);
1189 }
1190 if (addRoute)
1191 {
1192 dsr->CancelRreqTimer(dst, true);
1193 }
1194 else
1195 {
1196 NS_LOG_DEBUG("The route not added");
1197 }
1198 }
1199 else
1200 {
1201 NS_LOG_DEBUG("The route is corrupted");
1202 }
1203 /*
1204 * Reverse search the vector for next hop address
1205 */
1206 Ipv4Address nextHop = ReverseSearchNextHop(ipv4Address, routeCopy);
1207 NS_ASSERT(routeCopy.back() == source);
1208 PrintVector(routeCopy);
1209 NS_LOG_DEBUG("The nextHop address " << nextHop << " and the source in the route reply "
1210 << source);
1211 /*
1212 * Set the route entry we will use to send reply
1213 */
1214 SetRoute(nextHop, ipv4Address);
1215 /*
1216 * This part add dsr routing header to the packet and send reply
1217 */
1218 DsrRoutingHeader dsrRoutingHeader;
1219 dsrRoutingHeader.SetNextHeader(protocol);
1220
1221 length = rrep.GetLength(); // Get the length of the rrep header excluding the type header
1222 NS_LOG_DEBUG("The reply header length " << (uint32_t)length);
1223 dsrRoutingHeader.SetPayloadLength(length + 2);
1224 dsrRoutingHeader.SetMessageType(1);
1225 dsrRoutingHeader.SetSourceId(GetIDfromIP(source));
1226 dsrRoutingHeader.SetDestId(GetIDfromIP(targetAddress));
1227 dsrRoutingHeader.AddDsrOption(rrep);
1228 Ptr<Packet> newPacket = Create<Packet>();
1229 newPacket->AddHeader(dsrRoutingHeader);
1230 dsr->SendReply(newPacket, ipv4Address, nextHop, m_ipv4Route);
1231 isPromisc = false;
1232 }
1233 return rrep.GetSerializedSize();
1234}
1235
1237
1238TypeId
1240{
1241 static TypeId tid = TypeId("ns3::dsr::DsrOptionSR")
1243 .SetGroupName("Dsr")
1244 .AddConstructor<DsrOptionSR>();
1245 return tid;
1246}
1247
1249{
1251}
1252
1254{
1256}
1257
1258TypeId
1260{
1261 return GetTypeId();
1262}
1263
1264uint8_t
1266{
1268 return OPT_NUMBER;
1269}
1270
1271uint8_t
1273 Ptr<Packet> dsrP,
1274 Ipv4Address ipv4Address,
1275 Ipv4Address source,
1276 const Ipv4Header& ipv4Header,
1277 uint8_t protocol,
1278 bool& isPromisc,
1279 Ipv4Address promiscSource)
1280{
1281 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Address << ipv4Header
1282 << (uint32_t)protocol << isPromisc);
1283 Ptr<Packet> p = packet->Copy();
1284 // Get the number of routers' address field
1285 uint8_t buf[2];
1286 p->CopyData(buf, sizeof(buf));
1287 uint8_t numberAddress = (buf[1] - 2) / 4;
1288 DsrOptionSRHeader sourceRoute;
1289 sourceRoute.SetNumberAddress(numberAddress);
1290 p->RemoveHeader(sourceRoute);
1291
1292 // The route size saved in the source route
1293 std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress();
1294 uint8_t segsLeft = sourceRoute.GetSegmentsLeft();
1295 uint8_t salvage = sourceRoute.GetSalvage();
1296 /*
1297 * Get the node from IP address and get the DSR extension object
1298 */
1299 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
1300 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting>();
1301 /*
1302 * Get the source and destination address from ipv4 header
1303 */
1304 Ipv4Address srcAddress = ipv4Header.GetSource();
1305 Ipv4Address destAddress = ipv4Header.GetDestination();
1306
1307 // Get the node list destination
1308 Ipv4Address destination = nodeList.back();
1309 /*
1310 * If it's a promiscuous receive data packet,
1311 * 1. see if automatic route shortening possible or not
1312 * 2. see if it is a passive acknowledgment
1313 */
1314 if (isPromisc)
1315 {
1316 NS_LOG_LOGIC("We process promiscuous receipt data packet");
1317 if (ContainAddressAfter(ipv4Address, destAddress, nodeList))
1318 {
1319 NS_LOG_LOGIC("Send back the gratuitous reply");
1320 dsr->SendGratuitousReply(source, srcAddress, nodeList, protocol);
1321 }
1322
1323 uint16_t fragmentOffset = ipv4Header.GetFragmentOffset();
1324 uint16_t identification = ipv4Header.GetIdentification();
1325
1326 if (destAddress != destination)
1327 {
1328 NS_LOG_DEBUG("Process the promiscuously received packet");
1329 bool findPassive = false;
1330 int32_t nNodes = NodeList::GetNNodes();
1331 for (int32_t i = 0; i < nNodes; ++i)
1332 {
1333 NS_LOG_DEBUG("Working with node " << i);
1334
1335 Ptr<Node> node = NodeList::GetNode(i);
1336 Ptr<dsr::DsrRouting> dsrNode = node->GetObject<dsr::DsrRouting>();
1337 // The source and destination addresses here are the real source and destination for
1338 // the packet
1339 findPassive = dsrNode->PassiveEntryCheck(packet,
1340 source,
1341 destination,
1342 segsLeft,
1343 fragmentOffset,
1344 identification,
1345 false);
1346 if (findPassive)
1347 {
1348 break;
1349 }
1350 }
1351
1352 if (findPassive)
1353 {
1354 NS_LOG_DEBUG("We find one previously received passive entry");
1355 /*
1356 * Get the node from IP address and get the DSR extension object
1357 * the srcAddress would be the source address from ip header
1358 */
1359 PrintVector(nodeList);
1360
1361 NS_LOG_DEBUG("promisc source " << promiscSource);
1362 Ptr<Node> node = GetNodeWithAddress(promiscSource);
1363 Ptr<dsr::DsrRouting> dsrSrc = node->GetObject<dsr::DsrRouting>();
1364 dsrSrc->CancelPassiveTimer(packet, source, destination, segsLeft);
1365 }
1366 else
1367 {
1368 NS_LOG_DEBUG("Saved the entry for further use");
1369 dsr->PassiveEntryCheck(packet,
1370 source,
1371 destination,
1372 segsLeft,
1373 fragmentOffset,
1374 identification,
1375 true);
1376 }
1377 }
1379 return 0;
1380 }
1381 else
1382 {
1383 /*
1384 * Get the number of address from the source route header
1385 */
1386 uint8_t length = sourceRoute.GetLength();
1387 uint8_t nextAddressIndex;
1388 Ipv4Address nextAddress;
1389
1390 // Get the option type value
1391 uint32_t size = p->GetSize();
1392 uint8_t* data = new uint8_t[size];
1393 p->CopyData(data, size);
1394 uint8_t optionType = 0;
1395 optionType = *(data);
1398 if (optionType == 160)
1399 {
1400 NS_LOG_LOGIC("Remove the ack request header and add ack header to the packet");
1401 // Here we remove the ack packet to the previous hop
1402 DsrOptionAckReqHeader ackReq;
1403 p->RemoveHeader(ackReq);
1404 uint16_t ackId = ackReq.GetAckId();
1405 /*
1406 * Send back acknowledgment packet to the earlier hop
1407 * If the node list is not empty, find the previous hop from the node list,
1408 * otherwise, use srcAddress
1409 */
1410 Ipv4Address ackAddress = srcAddress;
1411 if (!nodeList.empty())
1412 {
1413 if (segsLeft > numberAddress) // The segmentsLeft field should not be larger than
1414 // the total number of ip addresses
1415 {
1416 NS_LOG_LOGIC("Malformed header. Drop!");
1417 m_dropTrace(packet);
1418 return 0;
1419 }
1420 // -fstrict-overflow sensitive, see bug 1868
1421 if (numberAddress - segsLeft < 2) // The index is invalid
1422 {
1423 NS_LOG_LOGIC("Malformed header. Drop!");
1424 m_dropTrace(packet);
1425 return 0;
1426 }
1427 ackAddress = nodeList[numberAddress - segsLeft - 2];
1428 }
1429 m_ipv4Route = SetRoute(ackAddress, ipv4Address);
1430 NS_LOG_DEBUG("Send back ACK to the earlier hop " << ackAddress << " from us "
1431 << ipv4Address);
1432 dsr->SendAck(ackId, ackAddress, source, destination, protocol, m_ipv4Route);
1433 }
1434 /*
1435 * After send back ACK, check if the segments left value has turned to 0 or not, if yes,
1436 * update the route entry and return header length
1437 */
1438 if (segsLeft == 0)
1439 {
1440 NS_LOG_DEBUG("This is the final destination");
1441 isPromisc = false;
1442 return sourceRoute.GetSerializedSize();
1443 }
1444
1445 if (length % 2 != 0)
1446 {
1447 NS_LOG_LOGIC("Malformed header. Drop!");
1448 m_dropTrace(packet);
1449 return 0;
1450 }
1451
1452 if (segsLeft > numberAddress) // The segmentsLeft field should not be larger than the total
1453 // number of ip addresses
1454 {
1455 NS_LOG_LOGIC("Malformed header. Drop!");
1456 m_dropTrace(packet);
1457 return 0;
1458 }
1459
1460 DsrOptionSRHeader newSourceRoute;
1461 newSourceRoute.SetSegmentsLeft(segsLeft - 1);
1462 newSourceRoute.SetSalvage(salvage);
1463 newSourceRoute.SetNodesAddress(nodeList);
1464 nextAddressIndex = numberAddress - segsLeft;
1465 nextAddress = newSourceRoute.GetNodeAddress(nextAddressIndex);
1466 NS_LOG_DEBUG("The next address of source route option "
1467 << nextAddress << " and the nextAddressIndex: " << (uint32_t)nextAddressIndex
1468 << " and the segments left : " << (uint32_t)segsLeft);
1469 /*
1470 * Get the target Address in the node list
1471 */
1472 Ipv4Address targetAddress = nodeList.back();
1473 Ipv4Address realSource = nodeList.front();
1474 /*
1475 * Search the vector for next hop address
1476 */
1477 Ipv4Address nextHop = SearchNextHop(ipv4Address, nodeList);
1478 PrintVector(nodeList);
1479
1480 if (nextHop == "0.0.0.0")
1481 {
1482 NS_LOG_DEBUG("Before new packet " << *dsrP);
1483 dsr->PacketNewRoute(dsrP, realSource, targetAddress, protocol);
1484 return 0;
1485 }
1486
1487 if (ipv4Address == nextHop)
1488 {
1489 NS_LOG_DEBUG("We have reached the destination");
1490 newSourceRoute.SetSegmentsLeft(0);
1491 return newSourceRoute.GetSerializedSize();
1492 }
1493 // Verify the multicast address, leave it here for now
1494 if (nextAddress.IsMulticast() || destAddress.IsMulticast())
1495 {
1496 m_dropTrace(packet);
1497 return 0;
1498 }
1499 // Set the route and forward the data packet
1500 SetRoute(nextAddress, ipv4Address);
1501 NS_LOG_DEBUG("dsr packet size " << dsrP->GetSize());
1502 dsr->ForwardPacket(dsrP,
1503 newSourceRoute,
1504 ipv4Header,
1505 realSource,
1506 nextAddress,
1507 targetAddress,
1508 protocol,
1509 m_ipv4Route);
1510 }
1511 return sourceRoute.GetSerializedSize();
1512}
1513
1515
1516TypeId
1518{
1519 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerr")
1521 .SetGroupName("Dsr")
1522 .AddConstructor<DsrOptionRerr>();
1523 return tid;
1524}
1525
1527{
1529}
1530
1532{
1534}
1535
1536TypeId
1538{
1539 return GetTypeId();
1540}
1541
1542uint8_t
1544{
1546 return OPT_NUMBER;
1547}
1548
1549uint8_t
1551 Ptr<Packet> dsrP,
1552 Ipv4Address ipv4Address,
1553 Ipv4Address source,
1554 const Ipv4Header& ipv4Header,
1555 uint8_t protocol,
1556 bool& isPromisc,
1557 Ipv4Address promiscSource)
1558{
1559 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Header
1560 << (uint32_t)protocol << isPromisc);
1561 Ptr<Packet> p = packet->Copy();
1562 uint32_t size = p->GetSize();
1563 uint8_t* data = new uint8_t[size];
1564 p->CopyData(data, size);
1565 uint8_t errorType = *(data + 2);
1566 /*
1567 * Get the node from Ip address and get the dsr extension object
1568 */
1569 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
1570 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting>();
1571 NS_LOG_DEBUG("The error type value here " << (uint32_t)errorType);
1572 if (errorType == 1) // unreachable ip address
1573 {
1574 /*
1575 * Remove the route error header from the packet, and get the error type
1576 */
1577 DsrOptionRerrUnreachHeader rerrUnreach;
1578 p->RemoveHeader(rerrUnreach);
1579 /*
1580 * Get the error destination address
1581 */
1582 Ipv4Address unreachAddress = rerrUnreach.GetUnreachNode();
1583 Ipv4Address errorSource = rerrUnreach.GetErrorSrc();
1584
1585 NS_LOG_DEBUG("The error source is " << rerrUnreach.GetErrorDst()
1586 << "and the unreachable node is " << unreachAddress);
1587 /*
1588 * Get the serialized size of the rerr header
1589 */
1590 uint32_t rerrSize = rerrUnreach.GetSerializedSize();
1591 /*
1592 * Delete all the routes including the unreachable node address from the route cache
1593 */
1594 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
1595 dsr->DeleteAllRoutesIncludeLink(errorSource, unreachAddress, ipv4Address);
1596
1597 Ptr<Packet> newP = p->Copy();
1598 uint32_t serialized = DoSendError(newP, rerrUnreach, rerrSize, ipv4Address, protocol);
1599 return serialized;
1600 }
1601 else
1602 {
1603 /*
1604 * Two other type of error headers:
1605 * 1. flow state not supported type-specific information
1606 * 2. unsupported option with option number
1607 */
1608 /*
1609 * Remove the route error header from the packet, and get the error type
1610 */
1611 DsrOptionRerrUnsupportedHeader rerrUnsupported;
1612 p->RemoveHeader(rerrUnsupported);
1613
1615 // uint32_t rerrSize = rerrUnsupported.GetSerializedSize();
1616 // uint32_t serialized = DoSendError (p, rerrUnsupported, rerrSize, ipv4Address, protocol);
1617 uint32_t serialized = 0;
1618 return serialized;
1619 }
1620}
1621
1622uint8_t
1625 uint32_t rerrSize,
1626 Ipv4Address ipv4Address,
1627 uint8_t protocol)
1628{
1629 // Get the number of routers' address field
1630 uint8_t buf[2];
1631 p->CopyData(buf, sizeof(buf));
1632 uint8_t numberAddress = (buf[1] - 2) / 4;
1633
1634 // Here remove the source route header and schedule next hop error transmission
1635 NS_LOG_DEBUG("The number of addresses " << (uint32_t)numberAddress);
1636 DsrOptionSRHeader sourceRoute;
1637 sourceRoute.SetNumberAddress(numberAddress);
1638 p->RemoveHeader(sourceRoute);
1639 NS_ASSERT(p->GetSize() == 0);
1640 /*
1641 * Get the node from ip address and the dsr extension object
1642 */
1643 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
1644 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting>();
1645 /*
1646 * Get the segments left field and the next address
1647 */
1648 uint8_t segmentsLeft = sourceRoute.GetSegmentsLeft();
1649 uint8_t length = sourceRoute.GetLength();
1650 uint8_t nextAddressIndex;
1651 Ipv4Address nextAddress;
1652 /*
1653 * Get the route size and the error target address
1654 */
1655 std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress();
1656 Ipv4Address targetAddress = nodeList.back();
1657 /*
1658 * The total serialized size for both the rerr and source route headers
1659 */
1660 uint32_t serializedSize = rerrSize + sourceRoute.GetSerializedSize();
1661
1662 if (length % 2 != 0)
1663 {
1664 NS_LOG_LOGIC("Malformed header. Drop!");
1665 m_dropTrace(p);
1666 return 0;
1667 }
1668
1669 if (segmentsLeft > numberAddress)
1670 {
1671 NS_LOG_LOGIC("Malformed header. Drop!");
1672 m_dropTrace(p);
1673 return 0;
1674 }
1675 /*
1676 * When the error packet has reached to the destination
1677 */
1678 if (segmentsLeft == 0 && targetAddress == ipv4Address)
1679 {
1680 NS_LOG_INFO("This is the destination of the error, send error request");
1681 dsr->SendErrorRequest(rerr, protocol);
1682 return serializedSize;
1683 }
1684
1685 // Get the next Router Address
1686 DsrOptionSRHeader newSourceRoute;
1687 newSourceRoute.SetSegmentsLeft(segmentsLeft - 1);
1688 nextAddressIndex = numberAddress - segmentsLeft;
1689 nextAddress = sourceRoute.GetNodeAddress(nextAddressIndex);
1690 newSourceRoute.SetSalvage(sourceRoute.GetSalvage());
1691 newSourceRoute.SetNodesAddress(nodeList);
1692 nextAddress = newSourceRoute.GetNodeAddress(nextAddressIndex);
1693
1695 if (nextAddress.IsMulticast() || targetAddress.IsMulticast())
1696 {
1697 m_dropTrace(p);
1698 return serializedSize;
1699 }
1700
1701 // Set the route entry
1702 SetRoute(nextAddress, ipv4Address);
1703 dsr->ForwardErrPacket(rerr, newSourceRoute, nextAddress, protocol, m_ipv4Route);
1704 return serializedSize;
1705}
1706
1708
1709TypeId
1711{
1712 static TypeId tid = TypeId("ns3::dsr::DsrOptionAckReq")
1714 .SetGroupName("Dsr")
1715 .AddConstructor<DsrOptionAckReq>();
1716 return tid;
1717}
1718
1720{
1722}
1723
1725{
1727}
1728
1729TypeId
1731{
1732 return GetTypeId();
1733}
1734
1735uint8_t
1737{
1739 return OPT_NUMBER;
1740}
1741
1742uint8_t
1744 Ptr<Packet> dsrP,
1745 Ipv4Address ipv4Address,
1746 Ipv4Address source,
1747 const Ipv4Header& ipv4Header,
1748 uint8_t protocol,
1749 bool& isPromisc,
1750 Ipv4Address promiscSource)
1751{
1752 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Header
1753 << (uint32_t)protocol << isPromisc);
1754 /*
1755 * Current implementation of the ack request header processing is coded in source route header
1756 * processing
1757 */
1758 /*
1759 * Remove the ack request header
1760 */
1761 Ptr<Packet> p = packet->Copy();
1762 DsrOptionAckReqHeader ackReq;
1763 p->RemoveHeader(ackReq);
1764 /*
1765 * Get the node with ip address and get the dsr extension and reoute cache objects
1766 */
1767 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
1768 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting>();
1769
1770 NS_LOG_DEBUG("The next header value " << (uint32_t)protocol);
1771
1772 return ackReq.GetSerializedSize();
1773}
1774
1776
1777TypeId
1779{
1780 static TypeId tid = TypeId("ns3::dsr::DsrOptionAck")
1782 .SetGroupName("Dsr")
1783 .AddConstructor<DsrOptionAck>();
1784 return tid;
1785}
1786
1788{
1790}
1791
1793{
1795}
1796
1797TypeId
1799{
1800 return GetTypeId();
1801}
1802
1803uint8_t
1805{
1807 return OPT_NUMBER;
1808}
1809
1810uint8_t
1812 Ptr<Packet> dsrP,
1813 Ipv4Address ipv4Address,
1814 Ipv4Address source,
1815 const Ipv4Header& ipv4Header,
1816 uint8_t protocol,
1817 bool& isPromisc,
1818 Ipv4Address promiscSource)
1819{
1820 NS_LOG_FUNCTION(this << packet << dsrP << ipv4Address << source << ipv4Header
1821 << (uint32_t)protocol << isPromisc);
1822 /*
1823 * Remove the ACK header
1824 */
1825 Ptr<Packet> p = packet->Copy();
1827 p->RemoveHeader(ack);
1828 /*
1829 * Get the ACK source and destination address
1830 */
1831 Ipv4Address realSrc = ack.GetRealSrc();
1832 Ipv4Address realDst = ack.GetRealDst();
1833 uint16_t ackId = ack.GetAckId();
1834 /*
1835 * Get the node with ip address and get the dsr extension and route cache objects
1836 */
1837 Ptr<Node> node = GetNodeWithAddress(ipv4Address);
1838 Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting>();
1839 dsr->UpdateRouteEntry(realDst);
1840 /*
1841 * Cancel the packet retransmit timer when receiving the ack packet
1842 */
1843 dsr->CallCancelPacketTimer(ackId, ipv4Header, realSrc, realDst);
1844 return ack.GetSerializedSize();
1845}
1846
1847} // namespace dsr
1848} // namespace ns3
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
bool IsMulticast() const
Packet header for IPv4.
Definition: ipv4-header.h:34
Ipv4Address GetSource() const
Definition: ipv4-header.cc:302
uint16_t GetIdentification() const
Definition: ipv4-header.cc:71
Ipv4Address GetDestination() const
Definition: ipv4-header.cc:316
uint16_t GetFragmentOffset() const
Definition: ipv4-header.cc:254
uint8_t GetTtl() const
Definition: ipv4-header.cc:274
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
static uint32_t GetNNodes()
Definition: node-list.cc:258
static Ptr< Node > GetNode(uint32_t n)
Definition: node-list.cc:251
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
Definition: socket.h:1122
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:602
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
Hold an unsigned integer type.
Definition: uinteger.h:45
void SetSourceId(uint16_t sourceId)
brief Set the source ID of the header.
void SetNextHeader(uint8_t protocol)
Set the "Next header" field.
void SetDestId(uint16_t destId)
brief Set the dest ID of the header.
void SetMessageType(uint8_t messageType)
brief Set the message type of the header.
void SetPayloadLength(uint16_t length)
brief Set the payload length of the header.
Acknowledgement (ACK) Message Format.
uint16_t GetAckId() const
Set the Ack id number.
Ipv4Address GetRealDst() const
Get Error source ip address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Ipv4Address GetRealSrc() const
Get Error source ip address.
Dsr Option Ack.
Definition: dsr-options.h:606
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
The Dsr Ack option number.
Definition: dsr-options.h:611
static TypeId GetTypeId()
Get the type ID.
uint8_t GetOptionNumber() const override
Get the option number.
Acknowledgement Request (ACK_RREQ) Message Format.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint16_t GetAckId() const
Set the Ack request id number.
static TypeId GetTypeId()
Get the type ID.
uint8_t GetOptionNumber() const override
Get the option number.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
static const uint8_t OPT_NUMBER
Dsr ack request option number.
Definition: dsr-options.h:564
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void AddDsrOption(const DsrOptionHeader &option)
Serialize the option, prepending pad1 or padn option as necessary.
uint8_t GetLength() const
Get the option length.
Header of Dsr Option Pad1.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Dsr Option Pad1.
Definition: dsr-options.h:291
uint8_t GetOptionNumber() const override
Get the option number.
Definition: dsr-options.cc:400
static TypeId GetTypeId()
Get the type ID.
Definition: dsr-options.cc:380
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Definition: dsr-options.cc:408
static const uint8_t OPT_NUMBER
Pad1 option number.
Definition: dsr-options.h:296
Header of Dsr Option Padn.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
IPv4 Option Padn.
Definition: dsr-options.h:323
static const uint8_t OPT_NUMBER
PadN option number.
Definition: dsr-options.h:328
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Definition: dsr-options.cc:458
static TypeId GetTypeId()
Get the type ID.
Definition: dsr-options.cc:431
uint8_t GetOptionNumber() const override
Get the option number.
Definition: dsr-options.cc:451
void SetErrorType(uint8_t errorType)
Set the route error type.
Dsr Option Route Error.
Definition: dsr-options.h:497
uint8_t DoSendError(Ptr< Packet > p, DsrOptionRerrUnreachHeader &rerr, uint32_t rerrSize, Ipv4Address ipv4Address, uint8_t protocol)
Do Send error message.
static const uint8_t OPT_NUMBER
Dsr Route Error option number.
Definition: dsr-options.h:502
static TypeId GetTypeId()
Get the type ID.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
uint8_t GetOptionNumber() const override
Get the option number.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Route Error (RERR) Unreachable node address option Message Format.
Ipv4Address GetErrorSrc() const override
Get the route error source address.
void SetErrorDst(Ipv4Address errorDstAddress) override
Set the error destination ip address.
void SetErrorSrc(Ipv4Address errorSrcAddress) override
Set the route error source address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint8_t GetSalvage() const override
Get the salvage value of the packet.
void SetUnreachNode(Ipv4Address unreachNode)
Set the unreachable node ip address.
void SetSalvage(uint8_t salvage) override
Set the salvage value of the packet.
Ipv4Address GetUnreachNode() const
Get the unreachable node ip address.
Ipv4Address GetErrorDst() const override
Get the error destination ip address.
Route Error (RERR) Unsupported option Message Format.
Route Reply (RREP) Message Format.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
std::vector< Ipv4Address > GetNodesAddress() const
Get the vector of ipv4 address.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Dsr Option Route Reply.
Definition: dsr-options.h:407
static const uint8_t OPT_NUMBER
Router alert option number.
Definition: dsr-options.h:412
static TypeId GetTypeId()
Get the type ID.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint8_t GetOptionNumber() const override
Get the option number.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Route Request (RREQ) Message Format.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
Ipv4Address GetTarget()
Get the target ipv4 address.
std::vector< Ipv4Address > GetNodesAddresses() const
Get the vector of ipv4 address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint16_t GetId() const
Set the request id number.
Dsr Option Rreq.
Definition: dsr-options.h:355
static TypeId GetTypeId()
Get the type ID.
Definition: dsr-options.cc:482
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Definition: dsr-options.cc:492
static const uint8_t OPT_NUMBER
Rreq option number.
Definition: dsr-options.h:360
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
Definition: dsr-options.cc:516
uint8_t GetOptionNumber() const override
Get the option number.
Definition: dsr-options.cc:508
~DsrOptionRreq() override
Destructor.
Definition: dsr-options.cc:502
DsrOptionRreq()
Constructor.
Definition: dsr-options.cc:497
Source Route (SR) Message Format.
Ipv4Address GetNodeAddress(uint8_t index) const
Get a Node IPv4 Address.
std::vector< Ipv4Address > GetNodesAddress() const
Get the vector of ipv4 address.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
void SetSalvage(uint8_t salvage)
Set the salvage value for a packet.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetSegmentsLeft(uint8_t segmentsLeft)
Set the number of segments left to send.
uint8_t GetSalvage() const
Get the salvage value for a packet.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
uint8_t GetSegmentsLeft() const
Get the number of segments left to send.
Dsr Option Source Route.
Definition: dsr-options.h:454
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
Source Route option number.
Definition: dsr-options.h:459
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
uint8_t GetOptionNumber() const override
Get the option number.
static TypeId GetTypeId()
Get the type ID.
Introspection did not find any typical Config paths.
Definition: dsr-options.h:76
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Search for the next hop in the route.
Definition: dsr-options.cc:175
Ipv4Address ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next two hop in the route.
Definition: dsr-options.cc:234
TracedCallback< Ptr< const Packet > > m_dropTrace
Drop trace callback.
Definition: dsr-options.h:244
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node object with Ipv4Address.
Definition: dsr-options.cc:360
DsrOptions()
Constructor.
Definition: dsr-options.cc:98
Ptr< Node > GetNode() const
Get the node.
Definition: dsr-options.cc:116
Time ActiveRouteTimeout
The active route timeout value.
Definition: dsr-options.h:276
bool CheckDuplicates(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Check if the route already contains the node ip address.
Definition: dsr-options.cc:292
void SetNode(Ptr< Node > node)
Set the node.
Definition: dsr-options.cc:109
virtual uint8_t GetOptionNumber() const =0
Get the option number.
~DsrOptions() override
Destructor.
Definition: dsr-options.cc:103
std::vector< Ipv4Address > m_finalRoute
The vector of final Ipv4 address.
Definition: dsr-options.h:272
void PrintVector(std::vector< Ipv4Address > &vec)
Print out the elements in the route vector.
Definition: dsr-options.cc:254
bool IfDuplicates(std::vector< Ipv4Address > &vec, std::vector< Ipv4Address > &vec2)
Check if the two vectors contain duplicate or not.
Definition: dsr-options.cc:275
bool ReverseRoutes(std::vector< Ipv4Address > &vec)
Reverse the routes.
Definition: dsr-options.cc:165
void RemoveDuplicates(std::vector< Ipv4Address > &vec)
Remove the duplicates from the route.
Definition: dsr-options.cc:306
uint32_t GetIDfromIP(Ipv4Address address)
Get the node id with Ipv4Address.
Definition: dsr-options.cc:343
static TypeId GetTypeId()
Get the type identificator.
Definition: dsr-options.cc:77
std::vector< Ipv4Address > CutRoute(Ipv4Address ipv4Address, std::vector< Ipv4Address > &nodeList)
Cut the route from ipv4Address to the end of the route vector.
Definition: dsr-options.cc:141
bool ContainAddressAfter(Ipv4Address ipv4Address, Ipv4Address destAddress, std::vector< Ipv4Address > &nodeList)
Search for the ipv4 address in the node list.
Definition: dsr-options.cc:123
TracedCallback< const DsrOptionSRHeader & > m_rxPacketTrace
The receive trace back, only triggered when final destination receive data packet.
Definition: dsr-options.h:280
Ipv4Address ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next hop in the route.
Definition: dsr-options.cc:208
Ptr< Ipv4Route > m_ipv4Route
The ipv4 route.
Definition: dsr-options.h:260
virtual 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.
Definition: dsr-options.cc:154
Ptr< Node > m_node
the node
Definition: dsr-options.h:283
DsrRouteCacheEntry class for entries in the route cache.
Definition: dsr-rcache.h:229
IP_VECTOR GetVector() const
Get the IP vector.
Definition: dsr-rcache.h:309
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Definition: dsr-rcache.h:231
Header of Dsr Routing.
Dsr Routing base.
Definition: dsr-routing.h:98
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#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.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t data[writeSize]