A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dsr-option-header.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Yufei Cheng
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
19  *
20  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22  * Information and Telecommunication Technology Center (ITTC)
23  * and Department of Electrical Engineering and Computer Science
24  * The University of Kansas Lawrence, KS USA.
25  *
26  * Work supported in part by NSF FIND (Future Internet Design) Program
27  * under grant CNS-0626918 (Postmodern Internet Architecture),
28  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29  * US Department of Defense (DoD), and ITTC at The University of Kansas.
30  */
31 
32 #include "ns3/assert.h"
33 #include "ns3/log.h"
34 #include "ns3/header.h"
35 #include "dsr-option-header.h"
36 #include "ns3/ipv4-address.h"
37 #include "ns3/address-utils.h"
38 #include "ns3/packet.h"
39 #include "ns3/enum.h"
40 
41 namespace ns3 {
42 namespace dsr {
43 NS_LOG_COMPONENT_DEFINE ("DsrOptionHeader");
44 
45 NS_OBJECT_ENSURE_REGISTERED (DsrOptionHeader);
46 
48 {
49  static TypeId tid = TypeId ("ns3::dsr::DsrOptionHeader")
51  .SetParent<Header> ()
52  ;
53  return tid;
54 }
55 
57 {
58  return GetTypeId ();
59 }
60 
62  : m_type (0),
63  m_length (0)
64 {
65 }
66 
68 {
69 }
70 
71 void DsrOptionHeader::SetType (uint8_t type)
72 {
73  m_type = type;
74 }
75 
76 uint8_t DsrOptionHeader::GetType () const
77 {
78  return m_type;
79 }
80 
81 void DsrOptionHeader::SetLength (uint8_t length)
82 {
83  m_length = length;
84 }
85 
87 {
88  return m_length;
89 }
90 
91 void DsrOptionHeader::Print (std::ostream &os) const
92 {
93  os << "( type = " << (uint32_t)m_type << " length = " << (uint32_t)m_length << " )";
94 }
95 
97 {
98  return m_length + 2;
99 }
100 
102 {
104 
105  i.WriteU8 (m_type);
106  i.WriteU8 (m_length);
107  i.Write (m_data.Begin (), m_data.End ());
108 }
109 
111 {
113 
114  m_type = i.ReadU8 ();
115  m_length = i.ReadU8 ();
116 
117  m_data = Buffer ();
119  Buffer::Iterator dataStart = i;
120  i.Next (m_length);
121  Buffer::Iterator dataEnd = i;
122  m_data.Begin ().Write (dataStart, dataEnd);
123 
124  return GetSerializedSize ();
125 }
126 
128 {
129  Alignment retVal = { 1, 0 };
130  return retVal;
131 }
132 
134 
136 {
137  static TypeId tid = TypeId ("ns3::dsr::DsrOptionPad1Header")
139  .SetParent<DsrOptionHeader> ()
140  ;
141  return tid;
142 }
143 
145 {
146  return GetTypeId ();
147 }
148 
150 {
151  SetType (224);
152 }
153 
155 {
156 }
157 
158 void DsrOptionPad1Header::Print (std::ostream &os) const
159 {
160  os << "( type = " << (uint32_t)GetType () << " )";
161 }
162 
164 {
165  return 1;
166 }
167 
169 {
171 
172  i.WriteU8 (GetType ());
173 }
174 
176 {
178 
179  SetType (i.ReadU8 ());
180 
181  return GetSerializedSize ();
182 }
183 
185 
187 {
188  static TypeId tid = TypeId ("ns3::dsr::DsrOptionPadnHeader")
190  .SetParent<DsrOptionHeader> ()
191  ;
192  return tid;
193 }
194 
196 {
197  return GetTypeId ();
198 }
199 
201 {
202  SetType (0);
203  NS_ASSERT_MSG (pad >= 2, "PadN must be at least 2 bytes long");
204  SetLength (pad - 2);
205 }
206 
208 {
209 }
210 
211 void DsrOptionPadnHeader::Print (std::ostream &os) const
212 {
213  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << " )";
214 }
215 
217 {
218  return GetLength () + 2;
219 }
220 
222 {
224 
225  i.WriteU8 (GetType ());
226  i.WriteU8 (GetLength ());
227 
228  for (int padding = 0; padding < GetLength (); padding++)
229  {
230  i.WriteU8 (0);
231  }
232 }
233 
235 {
237 
238  SetType (i.ReadU8 ());
239  SetLength (i.ReadU8 ());
240 
241  return GetSerializedSize ();
242 }
243 
245 
247 {
248  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRreqHeader")
250  .SetParent<DsrOptionHeader> ()
251  ;
252  return tid;
253 }
254 
256 {
257  return GetTypeId ();
258 }
259 
261  : m_ipv4Address (0)
262 {
263  SetType (1);
264  SetLength (6 + m_ipv4Address.size () * 4);
265 }
266 
268 {
269 }
270 
272 {
273  m_ipv4Address.clear ();
274  m_ipv4Address.assign (n, Ipv4Address (""));
275 }
276 
278 {
279  return m_target;
280 }
281 
283 {
284  m_target = target;
285 }
286 
288 {
289  m_ipv4Address.push_back (ipv4);
290  SetLength (6 + m_ipv4Address.size () * 4);
291 }
292 
293 void DsrOptionRreqHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
294 {
295  m_ipv4Address = ipv4Address;
296  SetLength (6 + m_ipv4Address.size () * 4);
297 }
298 
299 std::vector<Ipv4Address> DsrOptionRreqHeader::GetNodesAddresses () const
300 {
301  return m_ipv4Address;
302 }
303 
305 {
306  return m_ipv4Address.size ();
307 }
308 
310 {
311  m_ipv4Address.at (index) = addr;
312 }
313 
315 {
316  return m_ipv4Address.at (index);
317 }
318 
319 void DsrOptionRreqHeader::SetId (uint16_t identification)
320 {
321  m_identification = identification;
322 }
323 
324 uint16_t DsrOptionRreqHeader::GetId () const
325 {
326  return m_identification;
327 }
328 
329 void DsrOptionRreqHeader::Print (std::ostream &os) const
330 {
331  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
332 
333  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
334  {
335  os << *it << " ";
336  }
337 
338  os << ")";
339 }
340 
342 {
343  return 8 + m_ipv4Address.size () * 4;
344 }
345 
347 {
349  uint8_t buff[4];
350 
351  i.WriteU8 (GetType ());
352  i.WriteU8 (GetLength ());
354  WriteTo (i, m_target);
355 
356  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
357  {
358  it->Serialize (buff);
359  i.Write (buff, 4);
360  }
361 }
362 
364 {
366  uint8_t buff[4];
367 
368  SetType (i.ReadU8 ());
369  SetLength (i.ReadU8 ());
371  ReadFrom (i, m_target);
372 
373  uint8_t index = 0;
374  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
375  {
376  i.Read (buff, 4);
377  m_address = it->Deserialize (buff);
378  SetNodeAddress (index, m_address);
379  ++index;
380  }
381 
382  return GetSerializedSize ();
383 }
384 
386 {
387  Alignment retVal = { 4, 0 };
388  return retVal;
389 }
390 
392 
394 {
395  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRrepHeader")
397  .SetParent<DsrOptionHeader> ()
398  ;
399  return tid;
400 }
401 
403 {
404  return GetTypeId ();
405 }
406 
408  : m_ipv4Address (0)
409 {
410  SetType (2);
411  SetLength (2 + m_ipv4Address.size () * 4);
412 }
413 
415 {
416 }
417 
419 {
420  m_ipv4Address.clear ();
421  m_ipv4Address.assign (n, Ipv4Address (""));
422 }
423 
424 void DsrOptionRrepHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
425 {
426  m_ipv4Address = ipv4Address;
427  SetLength (2 + m_ipv4Address.size () * 4);
428 }
429 
430 std::vector<Ipv4Address> DsrOptionRrepHeader::GetNodesAddress () const
431 {
432  return m_ipv4Address;
433 }
434 
436 {
437  m_ipv4Address.at (index) = addr;
438 }
439 
441 {
442  return m_ipv4Address.at (index);
443 }
444 
445 Ipv4Address DsrOptionRrepHeader::GetTargetAddress (std::vector<Ipv4Address> ipv4Address) const
446 {
447  return m_ipv4Address.at (ipv4Address.size () - 1);
448 }
449 
450 void DsrOptionRrepHeader::Print (std::ostream &os) const
451 {
452  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
453 
454  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
455  {
456  os << *it << " ";
457  }
458 
459  os << ")";
460 }
461 
463 {
464  return 4 + m_ipv4Address.size () * 4;
465 }
466 
468 {
470  uint8_t buff[4];
471 
472  i.WriteU8 (GetType ());
473  i.WriteU8 (GetLength ());
474  i.WriteU8 (0);
475  i.WriteU8 (0);
476 
477  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
478  {
479  it->Serialize (buff);
480  i.Write (buff, 4);
481  }
482 }
483 
485 {
487  uint8_t buff[4];
488 
489  SetType (i.ReadU8 ());
490  SetLength (i.ReadU8 ());
491  i.ReadU8 ();
492  i.ReadU8 ();
493 
494  uint8_t index = 0;
495  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
496  {
497  i.Read (buff, 4);
498  m_address = it->Deserialize (buff);
499  SetNodeAddress (index, m_address);
500  ++index;
501  }
502 
503  return GetSerializedSize ();
504 }
505 
507 {
508  Alignment retVal = { 4, 0 };
509  return retVal;
510 }
511 
513 
515 {
516  static TypeId tid = TypeId ("ns3::dsr::DsrOptionSRHeader")
518  .SetParent<DsrOptionHeader> ()
519  ;
520  return tid;
521 }
522 
524 {
525  return GetTypeId ();
526 }
527 
529  : m_segmentsLeft (0),
530  m_ipv4Address (0)
531 {
532  SetType (96);
533  SetLength (2 + m_ipv4Address.size () * 4);
534 }
535 
537 {
538 }
539 
540 void DsrOptionSRHeader::SetSegmentsLeft (uint8_t segmentsLeft)
541 {
542  m_segmentsLeft = segmentsLeft;
543 }
544 
546 {
547  return m_segmentsLeft;
548 }
549 
550 void DsrOptionSRHeader::SetSalvage (uint8_t salvage)
551 {
552  m_salvage = salvage;
553 }
554 
556 {
557  return m_salvage;
558 }
559 
561 {
562  m_ipv4Address.clear ();
563  m_ipv4Address.assign (n, Ipv4Address (""));
564 }
565 
566 void DsrOptionSRHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
567 {
568  m_ipv4Address = ipv4Address;
569  SetLength (2 + m_ipv4Address.size () * 4);
570 }
571 
572 std::vector<Ipv4Address> DsrOptionSRHeader::GetNodesAddress () const
573 {
574  return m_ipv4Address;
575 }
576 
578 {
579  m_ipv4Address.at (index) = addr;
580 }
581 
583 {
584  return m_ipv4Address.at (index);
585 }
586 
588 {
589  return m_ipv4Address.size ();
590 }
591 
592 void DsrOptionSRHeader::Print (std::ostream &os) const
593 {
594  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
595 
596  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
597  {
598  os << *it << " ";
599  }
600 
601  os << ")";
602 }
603 
605 {
606  return 4 + m_ipv4Address.size () * 4;
607 }
608 
610 {
612  uint8_t buff[4];
613 
614  i.WriteU8 (GetType ());
615  i.WriteU8 (GetLength ());
616  i.WriteU8 (m_salvage);
618 
619  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
620  {
621  it->Serialize (buff);
622  i.Write (buff, 4);
623  }
624 }
625 
627 {
629  uint8_t buff[4];
630 
631  SetType (i.ReadU8 ());
632  SetLength (i.ReadU8 ());
633  m_salvage = i.ReadU8 ();
634  m_segmentsLeft = i.ReadU8 ();
635 
636  uint8_t index = 0;
637  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
638  {
639  i.Read (buff, 4);
640  m_address = it->Deserialize (buff);
641  SetNodeAddress (index, m_address);
642  ++index;
643  }
644 
645  return GetSerializedSize ();
646 }
647 
649 {
650  Alignment retVal = { 4, 0 };
651  return retVal;
652 }
653 
655 
657 {
658  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrHeader")
660  .SetParent<DsrOptionHeader> ()
661  ;
662  return tid;
663 }
664 
666 {
667  return GetTypeId ();
668 }
669 
671  : m_errorType (0),
672  m_salvage (0),
673  m_errorLength (4)
674 {
675  SetType (3);
676  SetLength (18);
677 }
678 
680 {
681 }
682 
683 void DsrOptionRerrHeader::SetErrorType (uint8_t errorType)
684 {
685  m_errorType = errorType;
686 }
687 
689 {
690  return m_errorType;
691 }
692 
693 void DsrOptionRerrHeader::SetSalvage (uint8_t salvage)
694 {
695  m_salvage = salvage;
696 }
697 
699 {
700  return m_salvage;
701 }
702 
704 {
705  m_errorSrcAddress = errorSrcAddress;
706 }
707 
709 {
710  return m_errorSrcAddress;
711 }
712 
714 {
715  m_errorDstAddress = errorDstAddress;
716 }
717 
719 {
720  return m_errorDstAddress;
721 }
722 
723 void DsrOptionRerrHeader::Print (std::ostream &os) const
724 {
725  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
726  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
727  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
728 
729 }
730 
732 {
733  return 20;
734 }
735 
737 {
739 
740  i.WriteU8 (GetType ());
741  i.WriteU8 (GetLength ());
742  i.WriteU8 (m_errorType);
743  i.WriteU8 (m_salvage);
747 }
748 
750 {
752 
753  SetType (i.ReadU8 ());
754  SetLength (i.ReadU8 ());
755  m_errorType = i.ReadU8 ();
756  m_salvage = i.ReadU8 ();
759 
760  m_errorData = Buffer ();
762  Buffer::Iterator dataStart = i;
763  i.Next (m_errorLength);
764  Buffer::Iterator dataEnd = i;
765  m_errorData.Begin ().Write (dataStart, dataEnd);
766 
767  return GetSerializedSize ();
768 }
769 
771 {
772  Alignment retVal = { 4, 0 };
773  return retVal;
774 }
775 
777 
779 {
780  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnreachHeader")
782  .SetParent<DsrOptionRerrHeader> ()
783  ;
784  return tid;
785 }
786 
788 {
789  return GetTypeId ();
790 }
791 
793  :
794  m_salvage (0)
795 {
796  SetType (3);
797  SetLength (18);
798  SetErrorType (1);
799 }
800 
802 {
803 }
804 
806 {
807  m_salvage = salvage;
808 }
809 
811 {
812  return m_salvage;
813 }
814 
816 {
817  m_errorSrcAddress = errorSrcAddress;
818 }
819 
821 {
822  return m_errorSrcAddress;
823 }
824 
826 {
827  m_errorDstAddress = errorDstAddress;
828 }
829 
831 {
832  return m_errorDstAddress;
833 }
834 
836 {
837  m_unreachNode = unreachNode;
838 }
839 
841 {
842  return m_unreachNode;
843 }
844 
846 {
847  m_originalDst = originalDst;
848 }
849 
851 {
852  return m_originalDst;
853 }
854 
855 void DsrOptionRerrUnreachHeader::Print (std::ostream &os) const
856 {
857  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
858  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
859  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
860  << " unreach node = " << m_unreachNode << " )";
861 }
862 
864 {
865  return 20;
866 }
867 
869 {
871 
872  i.WriteU8 (GetType ());
873  i.WriteU8 (GetLength ());
874  i.WriteU8 (GetErrorType ());
875  i.WriteU8 (m_salvage);
878  WriteTo (i, m_unreachNode);
879  WriteTo (i, m_originalDst);
880 }
881 
883 {
885 
886  SetType (i.ReadU8 ());
887  SetLength (i.ReadU8 ());
888  SetErrorType (i.ReadU8 ());
889  m_salvage = i.ReadU8 ();
892  ReadFrom (i, m_unreachNode);
893  ReadFrom (i, m_originalDst);
894 
895  return GetSerializedSize ();
896 }
897 
899 {
900  Alignment retVal = { 4, 0 };
901  return retVal;
902 }
903 
905 
907 {
908  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnsupportHeader")
910  .SetParent<DsrOptionRerrHeader> ()
911  ;
912  return tid;
913 }
914 
916 {
917  return GetTypeId ();
918 }
919 
921  :
922  m_salvage (0)
923 {
924  SetType (3);
925  SetLength (14);
926  SetErrorType (3);
927 }
928 
930 {
931 }
932 
934 {
935  m_salvage = salvage;
936 }
937 
939 {
940  return m_salvage;
941 }
942 
944 {
945  m_errorSrcAddress = errorSrcAddress;
946 }
947 
949 {
950  return m_errorSrcAddress;
951 }
952 
954 {
955  m_errorDstAddress = errorDstAddress;
956 }
957 
959 {
960  return m_errorDstAddress;
961 }
962 
964 {
965  m_unsupport = unsupport;
966 }
967 
969 {
970  return m_unsupport;
971 }
972 
973 void DsrOptionRerrUnsupportHeader::Print (std::ostream &os) const
974 {
975  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
976  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
977  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
978  << " unsupported option = " << m_unsupport << " )";
979 
980 }
981 
983 {
984  return 16;
985 }
986 
988 {
990 
991  i.WriteU8 (GetType ());
992  i.WriteU8 (GetLength ());
993  i.WriteU8 (GetErrorType ());
994  i.WriteU8 (m_salvage);
997  i.WriteU16 (m_unsupport);
998 
999 }
1000 
1002 {
1003  Buffer::Iterator i = start;
1004 
1005  SetType (i.ReadU8 ());
1006  SetLength (i.ReadU8 ());
1007  SetErrorType (i.ReadU8 ());
1008  m_salvage = i.ReadU8 ();
1011  m_unsupport = i.ReadU16 ();
1012 
1013  return GetSerializedSize ();
1014 }
1015 
1017 {
1018  Alignment retVal = { 4, 0 };
1019  return retVal;
1020 }
1021 
1023 
1025 {
1026  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReqHeader")
1028  .SetParent<DsrOptionHeader> ()
1029  ;
1030  return tid;
1031 }
1032 
1034 {
1035  return GetTypeId ();
1036 }
1037 
1039  : m_identification (0)
1040 
1041 {
1042  SetType (160);
1043  SetLength (2);
1044 }
1045 
1047 {
1048 }
1049 
1050 void DsrOptionAckReqHeader::SetAckId (uint16_t identification)
1051 {
1052  m_identification = identification;
1053 }
1054 
1056 {
1057  return m_identification;
1058 }
1059 
1060 void DsrOptionAckReqHeader::Print (std::ostream &os) const
1061 {
1062  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1063  << " id = " << m_identification << " )";
1064 }
1065 
1067 {
1068  return 4;
1069 }
1070 
1072 {
1073  Buffer::Iterator i = start;
1074 
1075  i.WriteU8 (GetType ());
1076  i.WriteU8 (GetLength ());
1078 }
1079 
1081 {
1082  Buffer::Iterator i = start;
1083 
1084  SetType (i.ReadU8 ());
1085  SetLength (i.ReadU8 ());
1086  m_identification = i.ReadU16 ();
1087 
1088  return GetSerializedSize ();
1089 }
1090 
1092 {
1093  Alignment retVal = { 4, 0 };
1094  return retVal;
1095 }
1096 
1098 
1100 {
1101  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckHeader")
1103  .SetParent<DsrOptionHeader> ()
1104  ;
1105  return tid;
1106 }
1107 
1109 {
1110  return GetTypeId ();
1111 }
1112 
1114  : m_identification (0)
1115 {
1116  SetType (32);
1117  SetLength (10);
1118 }
1119 
1121 {
1122 }
1123 
1124 void DsrOptionAckHeader::SetAckId (uint16_t identification)
1125 {
1126  m_identification = identification;
1127 }
1128 
1130 {
1131  return m_identification;
1132 }
1133 
1135 {
1136  m_realSrcAddress = realSrcAddress;
1137 }
1138 
1140 {
1141  return m_realSrcAddress;
1142 }
1143 
1145 {
1146  m_realDstAddress = realDstAddress;
1147 }
1148 
1150 {
1151  return m_realDstAddress;
1152 }
1153 
1154 void DsrOptionAckHeader::Print (std::ostream &os) const
1155 {
1156  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1157  << " id = " << m_identification << " real src = " << m_realSrcAddress
1158  << " real dst = " << m_realDstAddress << " )";
1159 
1160 }
1161 
1163 {
1164  return 12;
1165 }
1166 
1168 {
1169  Buffer::Iterator i = start;
1170 
1171  i.WriteU8 (GetType ());
1172  i.WriteU8 (GetLength ());
1176 }
1177 
1179 {
1180  Buffer::Iterator i = start;
1181 
1182  SetType (i.ReadU8 ());
1183  SetLength (i.ReadU8 ());
1184  m_identification = i.ReadU16 ();
1187 
1188  return GetSerializedSize ();
1189 }
1190 
1192 {
1193  Alignment retVal = { 4, 0 };
1194  return retVal;
1195 }
1196 } /* namespace dsr */
1197 } /* namespace ns3 */
uint16_t ReadU16(void)
Definition: buffer.h:1036
virtual void Print(std::ostream &os) const
Print some informations about the packet.
uint8_t m_errorType
The error type or route error option.
static Ipv4Address Deserialize(const uint8_t buf[4])
void AddNodeAddress(Ipv4Address ipv4)
Add one node address.
uint16_t GetAckId() const
Set the Ack id number.
virtual void SetErrorSrc(Ipv4Address errorSrcAddress)
Set the route error source address.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
virtual Ipv4Address GetErrorDst() const
Get the error destination ip address.
uint16_t m_unsupport
The unsupported option.
void SetAckId(uint16_t identification)
Set the Ack request id number.
TypeId AddConstructor(void)
Definition: type-id.h:418
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Ipv4Address GetNodeAddress(uint8_t index) const
Get a Node IPv4 Address.
DsrOptionPadnHeader(uint32_t pad=2)
Constructor.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
Ipv4Address GetTarget()
Get the target ipv4 address.
Ipv4Address GetNodeAddress(uint8_t index) const
Get a Node IPv4 Address.
virtual Ipv4Address GetErrorSrc() const
Get the route error source address.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
static TypeId GetTypeId()
Get the type identificator.
uint16_t GetId() const
Set the request id number.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
automatically resized byte buffer
Definition: buffer.h:92
Doxygen introspection did not find any typical Config paths.
std::vector< Ipv4Address > GetNodesAddresses() const
Get the vector of ipv4 address.
Ipv4Address m_unreachNode
The unreachable node address.
virtual void SetErrorDst(Ipv4Address errorDstAddress)
Set the error destination ip address.
Ipv4Address m_errorDstAddress
The error destination address.
virtual void SetErrorSrc(Ipv4Address errorSrcAddress)
Set the route error source address.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetSegmentsLeft(uint8_t segmentsLeft)
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual ~DsrOptionAckReqHeader()
Destructor.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
std::vector< Ipv4Address > GetNodesAddress() const
Get the vector of ipv4 address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
void SetUnsupported(uint16_t optionType)
Set the unsupported option type value.
Source Route (SR) Message Format.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
virtual ~DsrOptionPadnHeader()
Destructor.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
uint8_t GetLength() const
Get the option length.
Acknowledgement Request (ACK_RREQ) Message Format.
represents the alignment requirements of an option header
void SetNodeAddress(uint8_t index, Ipv4Address addr)
Set a Node IPv4 Address.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
Ipv4Address GetUnreachNode() const
Get the unreachable node ip address.
iterator in a Buffer instance
Definition: buffer.h:98
virtual void Print(std::ostream &os) const
Print some informations about the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void SetSalvage(uint8_t salvage)
Set the salvage value of the packet.
uint16_t m_identification
identification field
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
std::vector< Ipv4Address > GetNodesAddress() const
Get the vector of ipv4 address.
Ipv4Address m_errorDstAddress
The error destination address.
Route Reply (RREP) Message Format.
uint16_t m_identification
Identifier of the packet.
Ipv4Address m_errorSrcAddress
The error source address.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
static TypeId GetTypeId()
Get the type identificator.
VectorIpv4Address_t m_ipv4Address
The vector of Nodes' IPv4 Address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual void SetErrorSrc(Ipv4Address errorSrcAddress)
Set the route error source address.
virtual void SetErrorDst(Ipv4Address errorDstAddress)
Set the error destination ip address.
virtual void SetErrorDst(Ipv4Address errorDstAddress)
Set the error destination ip address.
uint16_t GetAckId() const
Set the Ack request id number.
uint8_t m_salvage
The salavage field.
Buffer m_data
The anonymous data of this option.
virtual ~DsrOptionRerrUnsupportHeader()
Destructor.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual ~DsrOptionSRHeader()
Destructor.
uint32_t GetNodesNumber() const
Get the number of nodes.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void WriteU16(uint16_t data)
Definition: buffer.cc:899
uint8_t m_salvage
The salavage field.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
void WriteHtonU16(uint16_t data)
Definition: buffer.h:912
Ipv4Address GetOriginalDst() const
Get the unreachable node ip address.
Buffer::Iterator End(void) const
Definition: buffer.h:1082
uint16_t GetUnsupported() const
Get the unsupported option type value.
void Next(void)
go forward by one byte
Definition: buffer.h:852
static TypeId GetTypeId()
Get the type identificator.
void SetErrorType(uint8_t errorType)
Set the route error type.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
Ipv4Address GetNodeAddress(uint8_t index) const
Get a Node IPv4 Address.
uint8_t GetErrorType() const
Get the route error type.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Buffer::Iterator Begin(void) const
Definition: buffer.h:1076
virtual void Print(std::ostream &os) const
Print some informations about the packet.
Ipv4Address GetRealSrc() const
Get Error source ip address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual ~DsrOptionHeader()
Destructor.
Acknowledgement (ACK) Message Format.
void SetTarget(Ipv4Address target)
Set the target ipv4 address.
void SetRealDst(Ipv4Address realDstAddress)
Set Error source ip address.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
void SetNodeAddress(uint8_t index, Ipv4Address addr)
Set a Node IPv4 Address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
Route Error (RERR) Unsupported option Message Format.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
Ipv4Address m_realSrcAddress
ack source address
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual Ipv4Address GetErrorSrc() const
Get the route error source address.
uint8_t m_type
The type of the option.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void SetSalvage(uint8_t salvage)
Set the salvage value of the packet.
Ipv4Address m_address
The ip address header deserilize to.
VectorIpv4Address_t m_ipv4Address
The vector of Nodes' IPv4 Address.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Route Request (RREQ) Message Format.
void SetId(uint16_t identification)
Set the request id number.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint8_t m_length
The option length.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
void Read(uint8_t *buffer, uint32_t size)
Definition: buffer.cc:1152
virtual Ipv4Address GetErrorDst() const
Get the error destination ip address.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint16_t m_identification
The identification field.
virtual uint8_t GetSalvage() const
Get the salvage value of the packet.
Ipv4Address GetRealDst() const
Get Error source ip address.
static TypeId GetTypeId()
Get the type identificator.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
bool AddAtEnd(uint32_t end)
Definition: buffer.cc:360
void SetUnreachNode(Ipv4Address unreachNode)
Set the unreachable node ip address.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint8_t m_salvage
The salavage field.
virtual ~DsrOptionAckHeader()
Destructor.
Ipv4Address m_originalDst
The original destination address.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual Ipv4Address GetErrorDst() const
Get the error destination ip address.
virtual ~DsrOptionRerrUnreachHeader()
Destructor.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
static TypeId GetTypeId()
Get the type identificator.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
void WriteU8(uint8_t data)
Definition: buffer.h:876
virtual uint8_t GetSalvage() const
Get the salvage value of the packet.
uint8_t m_errorType
The error type or route error option.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Doxygen introspection did not find any typical Config paths.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Route Error (RERR) Unreachable node address option Message Format.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void SetRealSrc(Ipv4Address realSrcAddress)
Set Error source ip address.
void SetType(uint8_t type)
Set the type of the option.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Doxygen introspection did not find any typical Config paths.
virtual ~DsrOptionRerrHeader()
Destructor.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint8_t m_errorType
The error type or route error option.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
uint8_t ReadU8(void)
Definition: buffer.h:1028
Ipv4Address m_realDstAddress
ack destination address
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void Write(uint8_t const *buffer, uint32_t size)
Definition: buffer.cc:982
Ipv4Address GetTargetAddress(std::vector< Ipv4Address > ipv4Address) const
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
VectorIpv4Address_t m_ipv4Address
The vector of Nodes' IPv4 Address.
virtual ~DsrOptionRreqHeader()
Destructor.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
Ipv4Address m_errorDstAddress
The error destination address.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
virtual ~DsrOptionRrepHeader()
Destructor.
virtual Ipv4Address GetErrorSrc() const
Get the route error source address.
uint8_t m_segmentsLeft
Number of left segments.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual ~DsrOptionPad1Header()
Destructor.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
uint16_t ReadNtohU16(void)
Definition: buffer.h:953
void SetAckId(uint16_t identification)
Set the Ack id number.
void SetLength(uint8_t length)
Set the option length.
Ipv4Address m_errorSrcAddress
The error source address.
virtual uint8_t GetSalvage() const
Get the salvage value of the packet.
Buffer m_errorData
The anonymous data of this option.
void SetNodeAddress(uint8_t index, Ipv4Address addr)
Set a Node IPv4 Address.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint8_t GetType() const
Get the type of the option.
a unique identifier for an interface.
Definition: type-id.h:49
uint16_t m_errorLength
The specific error message length.
void SetSalvage(uint8_t salvage)
Ipv4Address m_errorSrcAddress
The error source address.
Doxygen introspection did not find any typical Config paths.
void SetOriginalDst(Ipv4Address originalDst)
Set the unreachable node ip address.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
virtual void SetSalvage(uint8_t salvage)
Set the salvage value of the packet.
static TypeId GetTypeId()
Get the type identificator.
uint8_t m_salvage
Number of savlage times for a packet.