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  .AddAttribute ("ErrorType","Type of route errors",
664  MakeEnumChecker (NODE_UNREACHABLE, "Node unreachable",
665  FLOW_STATE_NOT_SUPPORTED, "Flow state not supported",
666  OPTION_NOT_SUPPORTED, "Option not supported"))
667  ;
668  return tid;
669 }
670 
672 {
673  return GetTypeId ();
674 }
675 
677  : m_errorType (0),
678  m_salvage (0),
679  m_errorLength (4)
680 {
681  SetType (3);
682  SetLength (18);
683 }
684 
686 {
687 }
688 
689 void DsrOptionRerrHeader::SetErrorType (uint8_t errorType)
690 {
691  m_errorType = errorType;
692 }
693 
695 {
696  return m_errorType;
697 }
698 
699 void DsrOptionRerrHeader::SetSalvage (uint8_t salvage)
700 {
701  m_salvage = salvage;
702 }
703 
705 {
706  return m_salvage;
707 }
708 
710 {
711  m_errorSrcAddress = errorSrcAddress;
712 }
713 
715 {
716  return m_errorSrcAddress;
717 }
718 
720 {
721  m_errorDstAddress = errorDstAddress;
722 }
723 
725 {
726  return m_errorDstAddress;
727 }
728 
729 void DsrOptionRerrHeader::Print (std::ostream &os) const
730 {
731  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
732  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
733  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
734 
735 }
736 
738 {
739  return 20;
740 }
741 
743 {
745 
746  i.WriteU8 (GetType ());
747  i.WriteU8 (GetLength ());
748  i.WriteU8 (m_errorType);
749  i.WriteU8 (m_salvage);
753 }
754 
756 {
758 
759  SetType (i.ReadU8 ());
760  SetLength (i.ReadU8 ());
761  m_errorType = i.ReadU8 ();
762  m_salvage = i.ReadU8 ();
765 
766  m_errorData = Buffer ();
768  Buffer::Iterator dataStart = i;
769  i.Next (m_errorLength);
770  Buffer::Iterator dataEnd = i;
771  m_errorData.Begin ().Write (dataStart, dataEnd);
772 
773  return GetSerializedSize ();
774 }
775 
777 {
778  Alignment retVal = { 4, 0 };
779  return retVal;
780 }
781 
783 
785 {
786  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnreachHeader")
788  .SetParent<DsrOptionRerrHeader> ()
789  ;
790  return tid;
791 }
792 
794 {
795  return GetTypeId ();
796 }
797 
799  :
800  m_salvage (0)
801 {
802  SetType (3);
803  SetLength (18);
804  SetErrorType (1);
805 }
806 
808 {
809 }
810 
812 {
813  m_salvage = salvage;
814 }
815 
817 {
818  return m_salvage;
819 }
820 
822 {
823  m_errorSrcAddress = errorSrcAddress;
824 }
825 
827 {
828  return m_errorSrcAddress;
829 }
830 
832 {
833  m_errorDstAddress = errorDstAddress;
834 }
835 
837 {
838  return m_errorDstAddress;
839 }
840 
842 {
843  m_unreachNode = unreachNode;
844 }
845 
847 {
848  return m_unreachNode;
849 }
850 
852 {
853  m_originalDst = originalDst;
854 }
855 
857 {
858  return m_originalDst;
859 }
860 
861 void DsrOptionRerrUnreachHeader::Print (std::ostream &os) const
862 {
863  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
864  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
865  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
866  << " unreach node = " << m_unreachNode << " )";
867 }
868 
870 {
871  return 20;
872 }
873 
875 {
877 
878  i.WriteU8 (GetType ());
879  i.WriteU8 (GetLength ());
880  i.WriteU8 (GetErrorType ());
881  i.WriteU8 (m_salvage);
884  WriteTo (i, m_unreachNode);
885  WriteTo (i, m_originalDst);
886 }
887 
889 {
891 
892  SetType (i.ReadU8 ());
893  SetLength (i.ReadU8 ());
894  SetErrorType (i.ReadU8 ());
895  m_salvage = i.ReadU8 ();
898  ReadFrom (i, m_unreachNode);
899  ReadFrom (i, m_originalDst);
900 
901  return GetSerializedSize ();
902 }
903 
905 {
906  Alignment retVal = { 4, 0 };
907  return retVal;
908 }
909 
911 
913 {
914  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnsupportHeader")
916  .SetParent<DsrOptionRerrHeader> ()
917  ;
918  return tid;
919 }
920 
922 {
923  return GetTypeId ();
924 }
925 
927  :
928  m_salvage (0)
929 {
930  SetType (3);
931  SetLength (14);
932  SetErrorType (3);
933 }
934 
936 {
937 }
938 
940 {
941  m_salvage = salvage;
942 }
943 
945 {
946  return m_salvage;
947 }
948 
950 {
951  m_errorSrcAddress = errorSrcAddress;
952 }
953 
955 {
956  return m_errorSrcAddress;
957 }
958 
960 {
961  m_errorDstAddress = errorDstAddress;
962 }
963 
965 {
966  return m_errorDstAddress;
967 }
968 
970 {
971  m_unsupport = unsupport;
972 }
973 
975 {
976  return m_unsupport;
977 }
978 
979 void DsrOptionRerrUnsupportHeader::Print (std::ostream &os) const
980 {
981  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
982  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
983  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
984  << " unsupported option = " << m_unsupport << " )";
985 
986 }
987 
989 {
990  return 16;
991 }
992 
994 {
996 
997  i.WriteU8 (GetType ());
998  i.WriteU8 (GetLength ());
999  i.WriteU8 (GetErrorType ());
1000  i.WriteU8 (m_salvage);
1003  i.WriteU16 (m_unsupport);
1004 
1005 }
1006 
1008 {
1009  Buffer::Iterator i = start;
1010 
1011  SetType (i.ReadU8 ());
1012  SetLength (i.ReadU8 ());
1013  SetErrorType (i.ReadU8 ());
1014  m_salvage = i.ReadU8 ();
1017  m_unsupport = i.ReadU16 ();
1018 
1019  return GetSerializedSize ();
1020 }
1021 
1023 {
1024  Alignment retVal = { 4, 0 };
1025  return retVal;
1026 }
1027 
1029 
1031 {
1032  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReqHeader")
1034  .SetParent<DsrOptionHeader> ()
1035  ;
1036  return tid;
1037 }
1038 
1040 {
1041  return GetTypeId ();
1042 }
1043 
1045  : m_identification (0)
1046 
1047 {
1048  SetType (160);
1049  SetLength (2);
1050 }
1051 
1053 {
1054 }
1055 
1056 void DsrOptionAckReqHeader::SetAckId (uint16_t identification)
1057 {
1058  m_identification = identification;
1059 }
1060 
1062 {
1063  return m_identification;
1064 }
1065 
1066 void DsrOptionAckReqHeader::Print (std::ostream &os) const
1067 {
1068  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1069  << " id = " << m_identification << " )";
1070 }
1071 
1073 {
1074  return 4;
1075 }
1076 
1078 {
1079  Buffer::Iterator i = start;
1080 
1081  i.WriteU8 (GetType ());
1082  i.WriteU8 (GetLength ());
1084 }
1085 
1087 {
1088  Buffer::Iterator i = start;
1089 
1090  SetType (i.ReadU8 ());
1091  SetLength (i.ReadU8 ());
1092  m_identification = i.ReadU16 ();
1093 
1094  return GetSerializedSize ();
1095 }
1096 
1098 {
1099  Alignment retVal = { 4, 0 };
1100  return retVal;
1101 }
1102 
1104 
1106 {
1107  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckHeader")
1109  .SetParent<DsrOptionHeader> ()
1110  ;
1111  return tid;
1112 }
1113 
1115 {
1116  return GetTypeId ();
1117 }
1118 
1120  : m_identification (0)
1121 {
1122  SetType (32);
1123  SetLength (10);
1124 }
1125 
1127 {
1128 }
1129 
1130 void DsrOptionAckHeader::SetAckId (uint16_t identification)
1131 {
1132  m_identification = identification;
1133 }
1134 
1136 {
1137  return m_identification;
1138 }
1139 
1141 {
1142  m_realSrcAddress = realSrcAddress;
1143 }
1144 
1146 {
1147  return m_realSrcAddress;
1148 }
1149 
1151 {
1152  m_realDstAddress = realDstAddress;
1153 }
1154 
1156 {
1157  return m_realDstAddress;
1158 }
1159 
1160 void DsrOptionAckHeader::Print (std::ostream &os) const
1161 {
1162  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1163  << " id = " << m_identification << " real src = " << m_realSrcAddress
1164  << " real dst = " << m_realDstAddress << " )";
1165 
1166 }
1167 
1169 {
1170  return 12;
1171 }
1172 
1174 {
1175  Buffer::Iterator i = start;
1176 
1177  i.WriteU8 (GetType ());
1178  i.WriteU8 (GetLength ());
1182 }
1183 
1185 {
1186  Buffer::Iterator i = start;
1187 
1188  SetType (i.ReadU8 ());
1189  SetLength (i.ReadU8 ());
1190  m_identification = i.ReadU16 ();
1193 
1194  return GetSerializedSize ();
1195 }
1196 
1198 {
1199  Alignment retVal = { 4, 0 };
1200  return retVal;
1201 }
1202 } /* namespace dsr */
1203 } /* namespace ns3 */
uint16_t ReadU16(void)
Definition: buffer.h:845
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.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Definition: enum.cc:178
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.
NS_OBJECT_ENSURE_REGISTERED(DsrFsHeader)
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.
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)
automatically resized byte buffer
Definition: buffer.h:92
Header of Dsr Option Pad1.
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)
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.
hold variables of type 'enum'
Definition: enum.h:37
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:895
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:726
Ipv4Address GetOriginalDst() const
Get the unreachable node ip address.
Buffer::Iterator End(void) const
Definition: buffer.h:881
uint16_t GetUnsupported() const
Get the unsupported option type value.
void Next(void)
Definition: buffer.h:666
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:875
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:1148
virtual Ipv4Address GetErrorDst() const
Get the error destination ip address.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
NS_LOG_COMPONENT_DEFINE("DsrFsHeader")
virtual uint8_t GetSalvage() const
Get the salvage value of the packet.
Ipv4Address GetRealDst() const
Get Error source ip address.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
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:356
void SetUnreachNode(Ipv4Address unreachNode)
Set the unreachable node ip address.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
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:690
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.
Header for Dsr Options.
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.
Header of Dsr Option Padn.
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:819
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:978
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:767
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.
Header of Dsr Option Route Error.
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.