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  ;
47 
49 {
50  static TypeId tid = TypeId ("ns3::dsr::DsrOptionHeader")
52  .SetParent<Header> ()
53  ;
54  return tid;
55 }
56 
58 {
59  return GetTypeId ();
60 }
61 
63  : m_type (0),
64  m_length (0)
65 {
66 }
67 
69 {
70 }
71 
72 void DsrOptionHeader::SetType (uint8_t type)
73 {
74  m_type = type;
75 }
76 
77 uint8_t DsrOptionHeader::GetType () const
78 {
79  return m_type;
80 }
81 
82 void DsrOptionHeader::SetLength (uint8_t length)
83 {
84  m_length = length;
85 }
86 
88 {
89  return m_length;
90 }
91 
92 void DsrOptionHeader::Print (std::ostream &os) const
93 {
94  os << "( type = " << (uint32_t)m_type << " length = " << (uint32_t)m_length << " )";
95 }
96 
98 {
99  return m_length + 2;
100 }
101 
103 {
105 
106  i.WriteU8 (m_type);
107  i.WriteU8 (m_length);
108  i.Write (m_data.Begin (), m_data.End ());
109 }
110 
112 {
114 
115  m_type = i.ReadU8 ();
116  m_length = i.ReadU8 ();
117 
118  m_data = Buffer ();
120  Buffer::Iterator dataStart = i;
121  i.Next (m_length);
122  Buffer::Iterator dataEnd = i;
123  m_data.Begin ().Write (dataStart, dataEnd);
124 
125  return GetSerializedSize ();
126 }
127 
129 {
130  Alignment retVal = { 1, 0 };
131  return retVal;
132 }
133 
135  ;
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  ;
188 
190 {
191  static TypeId tid = TypeId ("ns3::dsr::DsrOptionPadnHeader")
193  .SetParent<DsrOptionHeader> ()
194  ;
195  return tid;
196 }
197 
199 {
200  return GetTypeId ();
201 }
202 
204 {
205  SetType (0);
206  NS_ASSERT_MSG (pad >= 2, "PadN must be at least 2 bytes long");
207  SetLength (pad - 2);
208 }
209 
211 {
212 }
213 
214 void DsrOptionPadnHeader::Print (std::ostream &os) const
215 {
216  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << " )";
217 }
218 
220 {
221  return GetLength () + 2;
222 }
223 
225 {
227 
228  i.WriteU8 (GetType ());
229  i.WriteU8 (GetLength ());
230 
231  for (int padding = 0; padding < GetLength (); padding++)
232  {
233  i.WriteU8 (0);
234  }
235 }
236 
238 {
240 
241  SetType (i.ReadU8 ());
242  SetLength (i.ReadU8 ());
243 
244  return GetSerializedSize ();
245 }
246 
248  ;
249 
251 {
252  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRreqHeader")
254  .SetParent<DsrOptionHeader> ()
255  ;
256  return tid;
257 }
258 
260 {
261  return GetTypeId ();
262 }
263 
265  : m_ipv4Address (0)
266 {
267  SetType (1);
268  SetLength (6 + m_ipv4Address.size () * 4);
269 }
270 
272 {
273 }
274 
276 {
277  m_ipv4Address.clear ();
278  m_ipv4Address.assign (n, Ipv4Address (""));
279 }
280 
282 {
283  return m_target;
284 }
285 
287 {
288  m_target = target;
289 }
290 
292 {
293  m_ipv4Address.push_back (ipv4);
294  SetLength (6 + m_ipv4Address.size () * 4);
295 }
296 
297 void DsrOptionRreqHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
298 {
299  m_ipv4Address = ipv4Address;
300  SetLength (6 + m_ipv4Address.size () * 4);
301 }
302 
303 std::vector<Ipv4Address> DsrOptionRreqHeader::GetNodesAddresses () const
304 {
305  return m_ipv4Address;
306 }
307 
309 {
310  return m_ipv4Address.size ();
311 }
312 
314 {
315  m_ipv4Address.at (index) = addr;
316 }
317 
319 {
320  return m_ipv4Address.at (index);
321 }
322 
323 void DsrOptionRreqHeader::SetId (uint16_t identification)
324 {
325  m_identification = identification;
326 }
327 
328 uint16_t DsrOptionRreqHeader::GetId () const
329 {
330  return m_identification;
331 }
332 
333 void DsrOptionRreqHeader::Print (std::ostream &os) const
334 {
335  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
336 
337  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
338  {
339  os << *it << " ";
340  }
341 
342  os << ")";
343 }
344 
346 {
347  return 8 + m_ipv4Address.size () * 4;
348 }
349 
351 {
353  uint8_t buff[4];
354 
355  i.WriteU8 (GetType ());
356  i.WriteU8 (GetLength ());
358  WriteTo (i, m_target);
359 
360  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
361  {
362  it->Serialize (buff);
363  i.Write (buff, 4);
364  }
365 }
366 
368 {
370  uint8_t buff[4];
371 
372  SetType (i.ReadU8 ());
373  SetLength (i.ReadU8 ());
375  ReadFrom (i, m_target);
376 
377  uint8_t index = 0;
378  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
379  {
380  i.Read (buff, 4);
381  m_address = it->Deserialize (buff);
382  SetNodeAddress (index, m_address);
383  ++index;
384  }
385 
386  return GetSerializedSize ();
387 }
388 
390 {
391  Alignment retVal = { 4, 0 };
392  return retVal;
393 }
394 
396  ;
397 
399 {
400  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRrepHeader")
402  .SetParent<DsrOptionHeader> ()
403  ;
404  return tid;
405 }
406 
408 {
409  return GetTypeId ();
410 }
411 
413  : m_ipv4Address (0)
414 {
415  SetType (2);
416  SetLength (2 + m_ipv4Address.size () * 4);
417 }
418 
420 {
421 }
422 
424 {
425  m_ipv4Address.clear ();
426  m_ipv4Address.assign (n, Ipv4Address (""));
427 }
428 
429 void DsrOptionRrepHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
430 {
431  m_ipv4Address = ipv4Address;
432  SetLength (2 + m_ipv4Address.size () * 4);
433 }
434 
435 std::vector<Ipv4Address> DsrOptionRrepHeader::GetNodesAddress () const
436 {
437  return m_ipv4Address;
438 }
439 
441 {
442  m_ipv4Address.at (index) = addr;
443 }
444 
446 {
447  return m_ipv4Address.at (index);
448 }
449 
450 Ipv4Address DsrOptionRrepHeader::GetTargetAddress (std::vector<Ipv4Address> ipv4Address) const
451 {
452  return m_ipv4Address.at (ipv4Address.size () - 1);
453 }
454 
455 void DsrOptionRrepHeader::Print (std::ostream &os) const
456 {
457  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
458 
459  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
460  {
461  os << *it << " ";
462  }
463 
464  os << ")";
465 }
466 
468 {
469  return 4 + m_ipv4Address.size () * 4;
470 }
471 
473 {
475  uint8_t buff[4];
476 
477  i.WriteU8 (GetType ());
478  i.WriteU8 (GetLength ());
479  i.WriteU8 (0);
480  i.WriteU8 (0);
481 
482  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
483  {
484  it->Serialize (buff);
485  i.Write (buff, 4);
486  }
487 }
488 
490 {
492  uint8_t buff[4];
493 
494  SetType (i.ReadU8 ());
495  SetLength (i.ReadU8 ());
496  i.ReadU8 ();
497  i.ReadU8 ();
498 
499  uint8_t index = 0;
500  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
501  {
502  i.Read (buff, 4);
503  m_address = it->Deserialize (buff);
504  SetNodeAddress (index, m_address);
505  ++index;
506  }
507 
508  return GetSerializedSize ();
509 }
510 
512 {
513  Alignment retVal = { 4, 0 };
514  return retVal;
515 }
516 
518  ;
519 
521 {
522  static TypeId tid = TypeId ("ns3::dsr::DsrOptionSRHeader")
524  .SetParent<DsrOptionHeader> ()
525  ;
526  return tid;
527 }
528 
530 {
531  return GetTypeId ();
532 }
533 
535  : m_segmentsLeft (0),
536  m_ipv4Address (0)
537 {
538  SetType (96);
539  SetLength (2 + m_ipv4Address.size () * 4);
540 }
541 
543 {
544 }
545 
546 void DsrOptionSRHeader::SetSegmentsLeft (uint8_t segmentsLeft)
547 {
548  m_segmentsLeft = segmentsLeft;
549 }
550 
552 {
553  return m_segmentsLeft;
554 }
555 
556 void DsrOptionSRHeader::SetSalvage (uint8_t salvage)
557 {
558  m_salvage = salvage;
559 }
560 
562 {
563  return m_salvage;
564 }
565 
567 {
568  m_ipv4Address.clear ();
569  m_ipv4Address.assign (n, Ipv4Address (""));
570 }
571 
572 void DsrOptionSRHeader::SetNodesAddress (std::vector<Ipv4Address> ipv4Address)
573 {
574  m_ipv4Address = ipv4Address;
575  SetLength (2 + m_ipv4Address.size () * 4);
576 }
577 
578 std::vector<Ipv4Address> DsrOptionSRHeader::GetNodesAddress () const
579 {
580  return m_ipv4Address;
581 }
582 
584 {
585  m_ipv4Address.at (index) = addr;
586 }
587 
589 {
590  return m_ipv4Address.at (index);
591 }
592 
594 {
595  return m_ipv4Address.size ();
596 }
597 
598 void DsrOptionSRHeader::Print (std::ostream &os) const
599 {
600  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength () << "";
601 
602  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
603  {
604  os << *it << " ";
605  }
606 
607  os << ")";
608 }
609 
611 {
612  return 4 + m_ipv4Address.size () * 4;
613 }
614 
616 {
618  uint8_t buff[4];
619 
620  i.WriteU8 (GetType ());
621  i.WriteU8 (GetLength ());
622  i.WriteU8 (m_salvage);
624 
625  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
626  {
627  it->Serialize (buff);
628  i.Write (buff, 4);
629  }
630 }
631 
633 {
635  uint8_t buff[4];
636 
637  SetType (i.ReadU8 ());
638  SetLength (i.ReadU8 ());
639  m_salvage = i.ReadU8 ();
640  m_segmentsLeft = i.ReadU8 ();
641 
642  uint8_t index = 0;
643  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin (); it != m_ipv4Address.end (); it++)
644  {
645  i.Read (buff, 4);
646  m_address = it->Deserialize (buff);
647  SetNodeAddress (index, m_address);
648  ++index;
649  }
650 
651  return GetSerializedSize ();
652 }
653 
655 {
656  Alignment retVal = { 4, 0 };
657  return retVal;
658 }
659 
661  ;
662 
664 {
665  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrHeader")
667  .SetParent<DsrOptionHeader> ()
668  .AddAttribute ("ErrorType","Type of route errors",
671  MakeEnumChecker (NODE_UNREACHABLE, "Node unreachable",
672  FLOW_STATE_NOT_SUPPORTED, "Flow state not supported",
673  OPTION_NOT_SUPPORTED, "Option not supported"))
674  ;
675  return tid;
676 }
677 
679 {
680  return GetTypeId ();
681 }
682 
684  : m_errorType (0),
685  m_salvage (0),
686  m_errorLength (4)
687 {
688  SetType (3);
689  SetLength (18);
690 }
691 
693 {
694 }
695 
696 void DsrOptionRerrHeader::SetErrorType (uint8_t errorType)
697 {
698  m_errorType = errorType;
699 }
700 
702 {
703  return m_errorType;
704 }
705 
706 void DsrOptionRerrHeader::SetSalvage (uint8_t salvage)
707 {
708  m_salvage = salvage;
709 }
710 
712 {
713  return m_salvage;
714 }
715 
717 {
718  m_errorSrcAddress = errorSrcAddress;
719 }
720 
722 {
723  return m_errorSrcAddress;
724 }
725 
727 {
728  m_errorDstAddress = errorDstAddress;
729 }
730 
732 {
733  return m_errorDstAddress;
734 }
735 
736 void DsrOptionRerrHeader::Print (std::ostream &os) const
737 {
738  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
739  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
740  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
741 
742 }
743 
745 {
746  return 20;
747 }
748 
750 {
752 
753  i.WriteU8 (GetType ());
754  i.WriteU8 (GetLength ());
755  i.WriteU8 (m_errorType);
756  i.WriteU8 (m_salvage);
760 }
761 
763 {
765 
766  SetType (i.ReadU8 ());
767  SetLength (i.ReadU8 ());
768  m_errorType = i.ReadU8 ();
769  m_salvage = i.ReadU8 ();
772 
773  m_errorData = Buffer ();
775  Buffer::Iterator dataStart = i;
776  i.Next (m_errorLength);
777  Buffer::Iterator dataEnd = i;
778  m_errorData.Begin ().Write (dataStart, dataEnd);
779 
780  return GetSerializedSize ();
781 }
782 
784 {
785  Alignment retVal = { 4, 0 };
786  return retVal;
787 }
788 
790  ;
791 
793 {
794  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnreachHeader")
796  .SetParent<DsrOptionRerrHeader> ()
797  ;
798  return tid;
799 }
800 
802 {
803  return GetTypeId ();
804 }
805 
807  :
808  m_salvage (0)
809 {
810  SetType (3);
811  SetLength (18);
812  SetErrorType (1);
813 }
814 
816 {
817 }
818 
820 {
821  m_salvage = salvage;
822 }
823 
825 {
826  return m_salvage;
827 }
828 
830 {
831  m_errorSrcAddress = errorSrcAddress;
832 }
833 
835 {
836  return m_errorSrcAddress;
837 }
838 
840 {
841  m_errorDstAddress = errorDstAddress;
842 }
843 
845 {
846  return m_errorDstAddress;
847 }
848 
850 {
851  m_unreachNode = unreachNode;
852 }
853 
855 {
856  return m_unreachNode;
857 }
858 
860 {
861  m_originalDst = originalDst;
862 }
863 
865 {
866  return m_originalDst;
867 }
868 
869 void DsrOptionRerrUnreachHeader::Print (std::ostream &os) const
870 {
871  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
872  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
873  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
874  << " unreach node = " << m_unreachNode << " )";
875 }
876 
878 {
879  return 20;
880 }
881 
883 {
885 
886  i.WriteU8 (GetType ());
887  i.WriteU8 (GetLength ());
888  i.WriteU8 (GetErrorType ());
889  i.WriteU8 (m_salvage);
892  WriteTo (i, m_unreachNode);
893  WriteTo (i, m_originalDst);
894 }
895 
897 {
899 
900  SetType (i.ReadU8 ());
901  SetLength (i.ReadU8 ());
902  SetErrorType (i.ReadU8 ());
903  m_salvage = i.ReadU8 ();
906  ReadFrom (i, m_unreachNode);
907  ReadFrom (i, m_originalDst);
908 
909  return GetSerializedSize ();
910 }
911 
913 {
914  Alignment retVal = { 4, 0 };
915  return retVal;
916 }
917 
919  ;
920 
922 {
923  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnsupportHeader")
925  .SetParent<DsrOptionRerrHeader> ()
926  ;
927  return tid;
928 }
929 
931 {
932  return GetTypeId ();
933 }
934 
936  :
937  m_salvage (0)
938 {
939  SetType (3);
940  SetLength (14);
941  SetErrorType (3);
942 }
943 
945 {
946 }
947 
949 {
950  m_salvage = salvage;
951 }
952 
954 {
955  return m_salvage;
956 }
957 
959 {
960  m_errorSrcAddress = errorSrcAddress;
961 }
962 
964 {
965  return m_errorSrcAddress;
966 }
967 
969 {
970  m_errorDstAddress = errorDstAddress;
971 }
972 
974 {
975  return m_errorDstAddress;
976 }
977 
979 {
980  m_unsupport = unsupport;
981 }
982 
984 {
985  return m_unsupport;
986 }
987 
988 void DsrOptionRerrUnsupportHeader::Print (std::ostream &os) const
989 {
990  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
991  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
992  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
993  << " unsupported option = " << m_unsupport << " )";
994 
995 }
996 
998 {
999  return 16;
1000 }
1001 
1003 {
1004  Buffer::Iterator i = start;
1005 
1006  i.WriteU8 (GetType ());
1007  i.WriteU8 (GetLength ());
1008  i.WriteU8 (GetErrorType ());
1009  i.WriteU8 (m_salvage);
1012  i.WriteU16 (m_unsupport);
1013 
1014 }
1015 
1017 {
1018  Buffer::Iterator i = start;
1019 
1020  SetType (i.ReadU8 ());
1021  SetLength (i.ReadU8 ());
1022  SetErrorType (i.ReadU8 ());
1023  m_salvage = i.ReadU8 ();
1026  m_unsupport = i.ReadU16 ();
1027 
1028  return GetSerializedSize ();
1029 }
1030 
1032 {
1033  Alignment retVal = { 4, 0 };
1034  return retVal;
1035 }
1036 
1038  ;
1039 
1041 {
1042  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReqHeader")
1044  .SetParent<DsrOptionHeader> ()
1045  ;
1046  return tid;
1047 }
1048 
1050 {
1051  return GetTypeId ();
1052 }
1053 
1055  : m_identification (0)
1056 
1057 {
1058  SetType (160);
1059  SetLength (2);
1060 }
1061 
1063 {
1064 }
1065 
1066 void DsrOptionAckReqHeader::SetAckId (uint16_t identification)
1067 {
1068  m_identification = identification;
1069 }
1070 
1072 {
1073  return m_identification;
1074 }
1075 
1076 void DsrOptionAckReqHeader::Print (std::ostream &os) const
1077 {
1078  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1079  << " id = " << m_identification << " )";
1080 }
1081 
1083 {
1084  return 4;
1085 }
1086 
1088 {
1089  Buffer::Iterator i = start;
1090 
1091  i.WriteU8 (GetType ());
1092  i.WriteU8 (GetLength ());
1094 }
1095 
1097 {
1098  Buffer::Iterator i = start;
1099 
1100  SetType (i.ReadU8 ());
1101  SetLength (i.ReadU8 ());
1102  m_identification = i.ReadU16 ();
1103 
1104  return GetSerializedSize ();
1105 }
1106 
1108 {
1109  Alignment retVal = { 4, 0 };
1110  return retVal;
1111 }
1112 
1114  ;
1115 
1117 {
1118  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckHeader")
1120  .SetParent<DsrOptionHeader> ()
1121  ;
1122  return tid;
1123 }
1124 
1126 {
1127  return GetTypeId ();
1128 }
1129 
1131  : m_identification (0)
1132 {
1133  SetType (32);
1134  SetLength (10);
1135 }
1136 
1138 {
1139 }
1140 
1141 void DsrOptionAckHeader::SetAckId (uint16_t identification)
1142 {
1143  m_identification = identification;
1144 }
1145 
1147 {
1148  return m_identification;
1149 }
1150 
1152 {
1153  m_realSrcAddress = realSrcAddress;
1154 }
1155 
1157 {
1158  return m_realSrcAddress;
1159 }
1160 
1162 {
1163  m_realDstAddress = realDstAddress;
1164 }
1165 
1167 {
1168  return m_realDstAddress;
1169 }
1170 
1171 void DsrOptionAckHeader::Print (std::ostream &os) const
1172 {
1173  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1174  << " id = " << m_identification << " real src = " << m_realSrcAddress
1175  << " real dst = " << m_realDstAddress << " )";
1176 
1177 }
1178 
1180 {
1181  return 12;
1182 }
1183 
1185 {
1186  Buffer::Iterator i = start;
1187 
1188  i.WriteU8 (GetType ());
1189  i.WriteU8 (GetLength ());
1193 }
1194 
1196 {
1197  Buffer::Iterator i = start;
1198 
1199  SetType (i.ReadU8 ());
1200  SetLength (i.ReadU8 ());
1201  m_identification = i.ReadU16 ();
1204 
1205  return GetSerializedSize ();
1206 }
1207 
1209 {
1210  Alignment retVal = { 4, 0 };
1211  return retVal;
1212 }
1213 } /* namespace dsr */
1214 } /* 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.
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)
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.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
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)
go forward by one byte
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.
uint16_t m_identification
The identification field.
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.
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: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.
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.