A Discrete-Event Network Simulator
API
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 
43 NS_LOG_COMPONENT_DEFINE ("DsrOptionHeader");
44 
45 namespace dsr {
46 
47 NS_OBJECT_ENSURE_REGISTERED (DsrOptionHeader);
48 
50 {
51  static TypeId tid = TypeId ("ns3::dsr::DsrOptionHeader")
53  .SetParent<Header> ()
54  ;
55  return tid;
56 }
57 
59 {
60  return GetTypeId ();
61 }
62 
64  : m_type (0),
65  m_length (0)
66 {
67 }
68 
70 {
71 }
72 
73 void DsrOptionHeader::SetType (uint8_t type)
74 {
75  m_type = type;
76 }
77 
78 uint8_t DsrOptionHeader::GetType () const
79 {
80  return m_type;
81 }
82 
83 void DsrOptionHeader::SetLength (uint8_t length)
84 {
85  m_length = length;
86 }
87 
89 {
90  return m_length;
91 }
92 
93 void DsrOptionHeader::Print (std::ostream &os) const
94 {
95  os << "( type = " << (uint32_t)m_type << " length = " << (uint32_t)m_length << " )";
96 }
97 
99 {
100  return m_length + 2;
101 }
102 
104 {
106 
107  i.WriteU8 (m_type);
108  i.WriteU8 (m_length);
109  i.Write (m_data.Begin (), m_data.End ());
110 }
111 
113 {
115 
116  m_type = i.ReadU8 ();
117  m_length = i.ReadU8 ();
118 
119  m_data = Buffer ();
121  Buffer::Iterator dataStart = i;
122  i.Next (m_length);
123  Buffer::Iterator dataEnd = i;
124  m_data.Begin ().Write (dataStart, dataEnd);
125 
126  return GetSerializedSize ();
127 }
128 
130 {
131  Alignment retVal = { 1, 0 };
132  return retVal;
133 }
134 
136 
138 {
139  static TypeId tid = TypeId ("ns3::dsr::DsrOptionPad1Header")
141  .SetParent<DsrOptionHeader> ()
142  ;
143  return tid;
144 }
145 
147 {
148  return GetTypeId ();
149 }
150 
152 {
153  SetType (224);
154 }
155 
157 {
158 }
159 
160 void DsrOptionPad1Header::Print (std::ostream &os) const
161 {
162  os << "( type = " << (uint32_t)GetType () << " )";
163 }
164 
166 {
167  return 1;
168 }
169 
171 {
173 
174  i.WriteU8 (GetType ());
175 }
176 
178 {
180 
181  SetType (i.ReadU8 ());
182 
183  return GetSerializedSize ();
184 }
185 
187 
189 {
190  static TypeId tid = TypeId ("ns3::dsr::DsrOptionPadnHeader")
192  .SetParent<DsrOptionHeader> ()
193  ;
194  return tid;
195 }
196 
198 {
199  return GetTypeId ();
200 }
201 
203 {
204  SetType (0);
205  NS_ASSERT_MSG (pad >= 2, "PadN must be at least 2 bytes long");
206  SetLength (pad - 2);
207 }
208 
210 {
211 }
212 
213 void DsrOptionPadnHeader::Print (std::ostream &os) const
214 {
215  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << " )";
216 }
217 
219 {
220  return GetLength () + 2;
221 }
222 
224 {
226 
227  i.WriteU8 (GetType ());
228  i.WriteU8 (GetLength ());
229 
230  for (int padding = 0; padding < GetLength (); padding++)
231  {
232  i.WriteU8 (0);
233  }
234 }
235 
237 {
239 
240  SetType (i.ReadU8 ());
241  SetLength (i.ReadU8 ());
242 
243  return GetSerializedSize ();
244 }
245 
247 
249 {
250  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRreqHeader")
252  .SetParent<DsrOptionHeader> ()
253  ;
254  return tid;
255 }
256 
258 {
259  return GetTypeId ();
260 }
261 
263  : m_ipv4Address (0)
264 {
265  SetType (1);
266  SetLength (6 + m_ipv4Address.size () * 4);
267 }
268 
270 {
271 }
272 
274 {
275  m_ipv4Address.clear ();
276  m_ipv4Address.assign (n, Ipv4Address (""));
277 }
278 
280 {
281  return m_target;
282 }
283 
285 {
286  m_target = target;
287 }
288 
290 {
291  m_ipv4Address.push_back (ipv4);
292  SetLength (6 + m_ipv4Address.size () * 4);
293 }
294 
295 void DsrOptionRreqHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
296 {
297  m_ipv4Address = ipv4Address;
298  SetLength (6 + m_ipv4Address.size () * 4);
299 }
300 
301 std::vector<Ipv4Address> DsrOptionRreqHeader::GetNodesAddresses () const
302 {
303  return m_ipv4Address;
304 }
305 
307 {
308  return m_ipv4Address.size ();
309 }
310 
312 {
313  m_ipv4Address.at (index) = addr;
314 }
315 
317 {
318  return m_ipv4Address.at (index);
319 }
320 
321 void DsrOptionRreqHeader::SetId (uint16_t identification)
322 {
323  m_identification = identification;
324 }
325 
326 uint16_t DsrOptionRreqHeader::GetId () const
327 {
328  return m_identification;
329 }
330 
331 void DsrOptionRreqHeader::Print (std::ostream &os) const
332 {
333  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
334 
335  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
336  {
337  os << *it << " ";
338  }
339 
340  os << ")";
341 }
342 
344 {
345  return 8 + m_ipv4Address.size () * 4;
346 }
347 
349 {
351  uint8_t buff[4];
352 
353  i.WriteU8 (GetType ());
354  i.WriteU8 (GetLength ());
356  WriteTo (i, m_target);
357 
358  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
359  {
360  it->Serialize (buff);
361  i.Write (buff, 4);
362  }
363 }
364 
366 {
368  uint8_t buff[4];
369 
370  SetType (i.ReadU8 ());
371  SetLength (i.ReadU8 ());
373  ReadFrom (i, m_target);
374 
375  uint8_t index = 0;
376  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
377  {
378  i.Read (buff, 4);
379  m_address = it->Deserialize (buff);
380  SetNodeAddress (index, m_address);
381  ++index;
382  }
383 
384  return GetSerializedSize ();
385 }
386 
388 {
389  Alignment retVal = { 4, 0 };
390  return retVal;
391 }
392 
394 
396 {
397  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRrepHeader")
399  .SetParent<DsrOptionHeader> ()
400  ;
401  return tid;
402 }
403 
405 {
406  return GetTypeId ();
407 }
408 
410  : m_ipv4Address (0)
411 {
412  SetType (2);
413  SetLength (2 + m_ipv4Address.size () * 4);
414 }
415 
417 {
418 }
419 
421 {
422  m_ipv4Address.clear ();
423  m_ipv4Address.assign (n, Ipv4Address (""));
424 }
425 
426 void DsrOptionRrepHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
427 {
428  m_ipv4Address = ipv4Address;
429  SetLength (2 + m_ipv4Address.size () * 4);
430 }
431 
432 std::vector<Ipv4Address> DsrOptionRrepHeader::GetNodesAddress () const
433 {
434  return m_ipv4Address;
435 }
436 
438 {
439  m_ipv4Address.at (index) = addr;
440 }
441 
443 {
444  return m_ipv4Address.at (index);
445 }
446 
447 Ipv4Address DsrOptionRrepHeader::GetTargetAddress (std::vector<Ipv4Address> ipv4Address) const
448 {
449  return m_ipv4Address.at (ipv4Address.size () - 1);
450 }
451 
452 void DsrOptionRrepHeader::Print (std::ostream &os) const
453 {
454  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
455 
456  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
457  {
458  os << *it << " ";
459  }
460 
461  os << ")";
462 }
463 
465 {
466  return 4 + m_ipv4Address.size () * 4;
467 }
468 
470 {
472  uint8_t buff[4];
473 
474  i.WriteU8 (GetType ());
475  i.WriteU8 (GetLength ());
476  i.WriteU8 (0);
477  i.WriteU8 (0);
478 
479  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
480  {
481  it->Serialize (buff);
482  i.Write (buff, 4);
483  }
484 }
485 
487 {
489  uint8_t buff[4];
490 
491  SetType (i.ReadU8 ());
492  SetLength (i.ReadU8 ());
493  i.ReadU8 ();
494  i.ReadU8 ();
495 
496  uint8_t index = 0;
497  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
498  {
499  i.Read (buff, 4);
500  m_address = it->Deserialize (buff);
501  SetNodeAddress (index, m_address);
502  ++index;
503  }
504 
505  return GetSerializedSize ();
506 }
507 
509 {
510  Alignment retVal = { 4, 0 };
511  return retVal;
512 }
513 
515 
517 {
518  static TypeId tid = TypeId ("ns3::dsr::DsrOptionSRHeader")
520  .SetParent<DsrOptionHeader> ()
521  ;
522  return tid;
523 }
524 
526 {
527  return GetTypeId ();
528 }
529 
531  : m_segmentsLeft (0),
532  m_ipv4Address (0)
533 {
534  SetType (96);
535  SetLength (2 + m_ipv4Address.size () * 4);
536 }
537 
539 {
540 }
541 
542 void DsrOptionSRHeader::SetSegmentsLeft (uint8_t segmentsLeft)
543 {
544  m_segmentsLeft = segmentsLeft;
545 }
546 
548 {
549  return m_segmentsLeft;
550 }
551 
552 void DsrOptionSRHeader::SetSalvage (uint8_t salvage)
553 {
554  m_salvage = salvage;
555 }
556 
558 {
559  return m_salvage;
560 }
561 
563 {
564  m_ipv4Address.clear ();
565  m_ipv4Address.assign (n, Ipv4Address (""));
566 }
567 
568 void DsrOptionSRHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
569 {
570  m_ipv4Address = ipv4Address;
571  SetLength (2 + m_ipv4Address.size () * 4);
572 }
573 
574 std::vector<Ipv4Address> DsrOptionSRHeader::GetNodesAddress () const
575 {
576  return m_ipv4Address;
577 }
578 
580 {
581  m_ipv4Address.at (index) = addr;
582 }
583 
585 {
586  return m_ipv4Address.at (index);
587 }
588 
590 {
591  return m_ipv4Address.size ();
592 }
593 
594 void DsrOptionSRHeader::Print (std::ostream &os) const
595 {
596  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
597 
598  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
599  {
600  os << *it << " ";
601  }
602 
603  os << ")";
604 }
605 
607 {
608  return 4 + m_ipv4Address.size () * 4;
609 }
610 
612 {
614  uint8_t buff[4];
615 
616  i.WriteU8 (GetType ());
617  i.WriteU8 (GetLength ());
618  i.WriteU8 (m_salvage);
620 
621  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
622  {
623  it->Serialize (buff);
624  i.Write (buff, 4);
625  }
626 }
627 
629 {
631  uint8_t buff[4];
632 
633  SetType (i.ReadU8 ());
634  SetLength (i.ReadU8 ());
635  m_salvage = i.ReadU8 ();
636  m_segmentsLeft = i.ReadU8 ();
637 
638  uint8_t index = 0;
639  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
640  {
641  i.Read (buff, 4);
642  m_address = it->Deserialize (buff);
643  SetNodeAddress (index, m_address);
644  ++index;
645  }
646 
647  return GetSerializedSize ();
648 }
649 
651 {
652  Alignment retVal = { 4, 0 };
653  return retVal;
654 }
655 
657 
659 {
660  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrHeader")
662  .SetParent<DsrOptionHeader> ()
663  ;
664  return tid;
665 }
666 
668 {
669  return GetTypeId ();
670 }
671 
673  : m_errorType (0),
674  m_salvage (0),
675  m_errorLength (4)
676 {
677  SetType (3);
678  SetLength (18);
679 }
680 
682 {
683 }
684 
685 void DsrOptionRerrHeader::SetErrorType (uint8_t errorType)
686 {
687  m_errorType = errorType;
688 }
689 
691 {
692  return m_errorType;
693 }
694 
695 void DsrOptionRerrHeader::SetSalvage (uint8_t salvage)
696 {
697  m_salvage = salvage;
698 }
699 
701 {
702  return m_salvage;
703 }
704 
706 {
707  m_errorSrcAddress = errorSrcAddress;
708 }
709 
711 {
712  return m_errorSrcAddress;
713 }
714 
716 {
717  m_errorDstAddress = errorDstAddress;
718 }
719 
721 {
722  return m_errorDstAddress;
723 }
724 
725 void DsrOptionRerrHeader::Print (std::ostream &os) const
726 {
727  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
728  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
729  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
730 
731 }
732 
734 {
735  return 20;
736 }
737 
739 {
741 
742  i.WriteU8 (GetType ());
743  i.WriteU8 (GetLength ());
744  i.WriteU8 (m_errorType);
745  i.WriteU8 (m_salvage);
749 }
750 
752 {
754 
755  SetType (i.ReadU8 ());
756  SetLength (i.ReadU8 ());
757  m_errorType = i.ReadU8 ();
758  m_salvage = i.ReadU8 ();
761 
762  m_errorData = Buffer ();
764  Buffer::Iterator dataStart = i;
765  i.Next (m_errorLength);
766  Buffer::Iterator dataEnd = i;
767  m_errorData.Begin ().Write (dataStart, dataEnd);
768 
769  return GetSerializedSize ();
770 }
771 
773 {
774  Alignment retVal = { 4, 0 };
775  return retVal;
776 }
777 
779 
781 {
782  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnreachHeader")
784  .SetParent<DsrOptionRerrHeader> ()
785  ;
786  return tid;
787 }
788 
790 {
791  return GetTypeId ();
792 }
793 
795  :
796  m_salvage (0)
797 {
798  SetType (3);
799  SetLength (18);
800  SetErrorType (1);
801 }
802 
804 {
805 }
806 
808 {
809  m_salvage = salvage;
810 }
811 
813 {
814  return m_salvage;
815 }
816 
818 {
819  m_errorSrcAddress = errorSrcAddress;
820 }
821 
823 {
824  return m_errorSrcAddress;
825 }
826 
828 {
829  m_errorDstAddress = errorDstAddress;
830 }
831 
833 {
834  return m_errorDstAddress;
835 }
836 
838 {
839  m_unreachNode = unreachNode;
840 }
841 
843 {
844  return m_unreachNode;
845 }
846 
848 {
849  m_originalDst = originalDst;
850 }
851 
853 {
854  return m_originalDst;
855 }
856 
857 void DsrOptionRerrUnreachHeader::Print (std::ostream &os) const
858 {
859  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
860  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
861  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
862  << " unreach node = " << m_unreachNode << " )";
863 }
864 
866 {
867  return 20;
868 }
869 
871 {
873 
874  i.WriteU8 (GetType ());
875  i.WriteU8 (GetLength ());
876  i.WriteU8 (GetErrorType ());
877  i.WriteU8 (m_salvage);
880  WriteTo (i, m_unreachNode);
881  WriteTo (i, m_originalDst);
882 }
883 
885 {
887 
888  SetType (i.ReadU8 ());
889  SetLength (i.ReadU8 ());
890  SetErrorType (i.ReadU8 ());
891  m_salvage = i.ReadU8 ();
894  ReadFrom (i, m_unreachNode);
895  ReadFrom (i, m_originalDst);
896 
897  return GetSerializedSize ();
898 }
899 
901 {
902  Alignment retVal = { 4, 0 };
903  return retVal;
904 }
905 
907 
909 {
910  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnsupportHeader")
912  .SetParent<DsrOptionRerrHeader> ()
913  ;
914  return tid;
915 }
916 
918 {
919  return GetTypeId ();
920 }
921 
923  :
924  m_salvage (0)
925 {
926  SetType (3);
927  SetLength (14);
928  SetErrorType (3);
929 }
930 
932 {
933 }
934 
936 {
937  m_salvage = salvage;
938 }
939 
941 {
942  return m_salvage;
943 }
944 
946 {
947  m_errorSrcAddress = errorSrcAddress;
948 }
949 
951 {
952  return m_errorSrcAddress;
953 }
954 
956 {
957  m_errorDstAddress = errorDstAddress;
958 }
959 
961 {
962  return m_errorDstAddress;
963 }
964 
966 {
967  m_unsupport = unsupport;
968 }
969 
971 {
972  return m_unsupport;
973 }
974 
975 void DsrOptionRerrUnsupportHeader::Print (std::ostream &os) const
976 {
977  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
978  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
979  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
980  << " unsupported option = " << m_unsupport << " )";
981 
982 }
983 
985 {
986  return 16;
987 }
988 
990 {
992 
993  i.WriteU8 (GetType ());
994  i.WriteU8 (GetLength ());
995  i.WriteU8 (GetErrorType ());
996  i.WriteU8 (m_salvage);
999  i.WriteU16 (m_unsupport);
1000 
1001 }
1002 
1004 {
1005  Buffer::Iterator i = start;
1006 
1007  SetType (i.ReadU8 ());
1008  SetLength (i.ReadU8 ());
1009  SetErrorType (i.ReadU8 ());
1010  m_salvage = i.ReadU8 ();
1013  m_unsupport = i.ReadU16 ();
1014 
1015  return GetSerializedSize ();
1016 }
1017 
1019 {
1020  Alignment retVal = { 4, 0 };
1021  return retVal;
1022 }
1023 
1025 
1027 {
1028  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReqHeader")
1030  .SetParent<DsrOptionHeader> ()
1031  ;
1032  return tid;
1033 }
1034 
1036 {
1037  return GetTypeId ();
1038 }
1039 
1041  : m_identification (0)
1042 
1043 {
1044  SetType (160);
1045  SetLength (2);
1046 }
1047 
1049 {
1050 }
1051 
1052 void DsrOptionAckReqHeader::SetAckId (uint16_t identification)
1053 {
1054  m_identification = identification;
1055 }
1056 
1058 {
1059  return m_identification;
1060 }
1061 
1062 void DsrOptionAckReqHeader::Print (std::ostream &os) const
1063 {
1064  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1065  << " id = " << m_identification << " )";
1066 }
1067 
1069 {
1070  return 4;
1071 }
1072 
1074 {
1075  Buffer::Iterator i = start;
1076 
1077  i.WriteU8 (GetType ());
1078  i.WriteU8 (GetLength ());
1080 }
1081 
1083 {
1084  Buffer::Iterator i = start;
1085 
1086  SetType (i.ReadU8 ());
1087  SetLength (i.ReadU8 ());
1088  m_identification = i.ReadU16 ();
1089 
1090  return GetSerializedSize ();
1091 }
1092 
1094 {
1095  Alignment retVal = { 4, 0 };
1096  return retVal;
1097 }
1098 
1100 
1102 {
1103  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckHeader")
1105  .SetParent<DsrOptionHeader> ()
1106  ;
1107  return tid;
1108 }
1109 
1111 {
1112  return GetTypeId ();
1113 }
1114 
1116  : m_identification (0)
1117 {
1118  SetType (32);
1119  SetLength (10);
1120 }
1121 
1123 {
1124 }
1125 
1126 void DsrOptionAckHeader::SetAckId (uint16_t identification)
1127 {
1128  m_identification = identification;
1129 }
1130 
1132 {
1133  return m_identification;
1134 }
1135 
1137 {
1138  m_realSrcAddress = realSrcAddress;
1139 }
1140 
1142 {
1143  return m_realSrcAddress;
1144 }
1145 
1147 {
1148  m_realDstAddress = realDstAddress;
1149 }
1150 
1152 {
1153  return m_realDstAddress;
1154 }
1155 
1156 void DsrOptionAckHeader::Print (std::ostream &os) const
1157 {
1158  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1159  << " id = " << m_identification << " real src = " << m_realSrcAddress
1160  << " real dst = " << m_realDstAddress << " )";
1161 
1162 }
1163 
1165 {
1166  return 12;
1167 }
1168 
1170 {
1171  Buffer::Iterator i = start;
1172 
1173  i.WriteU8 (GetType ());
1174  i.WriteU8 (GetLength ());
1178 }
1179 
1181 {
1182  Buffer::Iterator i = start;
1183 
1184  SetType (i.ReadU8 ());
1185  SetLength (i.ReadU8 ());
1186  m_identification = i.ReadU16 ();
1189 
1190  return GetSerializedSize ();
1191 }
1192 
1194 {
1195  Alignment retVal = { 4, 0 };
1196  return retVal;
1197 }
1198 } /* namespace dsr */
1199 } /* 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:454
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 an Object subclass with the TypeId system.
Definition: object-base.h:44
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
def start()
Definition: core.py:1482
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:201
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:40
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.
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.
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:51
uint16_t m_errorLength
The specific error message length.
void SetSalvage(uint8_t salvage)
Ipv4Address m_errorSrcAddress
The error source address.
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.