A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dsr-option-header.cc
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 {
103  Buffer::Iterator i = start;
104 
105  i.WriteU8 (m_type);
106  i.WriteU8 (m_length);
107  i.Write (m_data.Begin (), m_data.End ());
108 }
109 
111 {
112  Buffer::Iterator i = start;
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 
133 NS_OBJECT_ENSURE_REGISTERED (DsrOptionPad1Header);
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 {
170  Buffer::Iterator i = start;
171 
172  i.WriteU8 (GetType ());
173 }
174 
176 {
177  Buffer::Iterator i = start;
178 
179  SetType (i.ReadU8 ());
180 
181  return GetSerializedSize ();
182 }
183 
184 NS_OBJECT_ENSURE_REGISTERED (DsrOptionPadnHeader);
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 {
223  Buffer::Iterator i = start;
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 {
236  Buffer::Iterator i = start;
237 
238  SetType (i.ReadU8 ());
239  SetLength (i.ReadU8 ());
240 
241  return GetSerializedSize ();
242 }
243 
244 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRreqHeader);
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 {
348  Buffer::Iterator i = start;
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 {
365  Buffer::Iterator i = start;
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 
391 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRrepHeader);
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 {
469  Buffer::Iterator i = start;
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 {
486  Buffer::Iterator i = start;
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 
512 NS_OBJECT_ENSURE_REGISTERED (DsrOptionSRHeader);
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 
545 uint8_t DsrOptionSRHeader::GetSegmentsLeft () const
546 {
547  return m_segmentsLeft;
548 }
549 
550 void DsrOptionSRHeader::SetSalvage (uint8_t salvage)
551 {
552  m_salvage = salvage;
553 }
554 
555 uint8_t DsrOptionSRHeader::GetSalvage () const
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 
587 uint8_t DsrOptionSRHeader::GetNodeListSize () const
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 {
611  Buffer::Iterator i = start;
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 {
628  Buffer::Iterator i = start;
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 
654 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRerrHeader);
655 
657 {
658  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrHeader")
660  .SetParent<DsrOptionHeader> ()
661  .AddAttribute ("ErrorType","Type of route errors",
662  EnumValue (NODE_UNREACHABLE),
663  MakeEnumAccessor (&DsrOptionRerrHeader::m_errorType),
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_reserved (0),
679  m_salvage (0),
680  m_errorLength (4)
681 {
682  SetType (3);
683  SetLength (18);
684 }
685 
687 {
688 }
689 
690 void DsrOptionRerrHeader::SetErrorType (uint8_t errorType)
691 {
692  m_errorType = errorType;
693 }
694 
696 {
697  return m_errorType;
698 }
699 
700 void DsrOptionRerrHeader::SetSalvage (uint8_t salvage)
701 {
702  m_salvage = salvage;
703 }
704 
706 {
707  return m_salvage;
708 }
709 
711 {
712  m_errorSrcAddress = errorSrcAddress;
713 }
714 
716 {
717  return m_errorSrcAddress;
718 }
719 
721 {
722  m_errorDstAddress = errorDstAddress;
723 }
724 
726 {
727  return m_errorDstAddress;
728 }
729 
730 void DsrOptionRerrHeader::Print (std::ostream &os) const
731 {
732  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
733  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
734  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
735 
736 }
737 
739 {
740  return 20;
741 }
742 
744 {
745  Buffer::Iterator i = start;
746 
747  i.WriteU8 (GetType ());
748  i.WriteU8 (GetLength ());
749  i.WriteU8 (m_errorType);
750  i.WriteU8 (m_salvage);
751  WriteTo (i, m_errorSrcAddress);
752  WriteTo (i, m_errorDstAddress);
754 }
755 
757 {
758  Buffer::Iterator i = start;
759 
760  SetType (i.ReadU8 ());
761  SetLength (i.ReadU8 ());
762  m_errorType = i.ReadU8 ();
763  m_salvage = i.ReadU8 ();
764  ReadFrom (i, m_errorSrcAddress);
765  ReadFrom (i, m_errorDstAddress);
766 
767  m_errorData = Buffer ();
769  Buffer::Iterator dataStart = i;
770  i.Next (m_errorLength);
771  Buffer::Iterator dataEnd = i;
772  m_errorData.Begin ().Write (dataStart, dataEnd);
773 
774  return GetSerializedSize ();
775 }
776 
778 {
779  Alignment retVal = { 4, 0 };
780  return retVal;
781 }
782 
783 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRerrUnreachHeader);
784 
786 {
787  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnreachHeader")
789  .SetParent<DsrOptionRerrHeader> ()
790  ;
791  return tid;
792 }
793 
795 {
796  return GetTypeId ();
797 }
798 
800  : m_reserved (0),
801  m_salvage (0)
802 {
803  SetType (3);
804  SetLength (18);
805  SetErrorType (1);
806 }
807 
809 {
810 }
811 
813 {
814  m_salvage = salvage;
815 }
816 
818 {
819  return m_salvage;
820 }
821 
823 {
824  m_errorSrcAddress = errorSrcAddress;
825 }
826 
828 {
829  return m_errorSrcAddress;
830 }
831 
833 {
834  m_errorDstAddress = errorDstAddress;
835 }
836 
838 {
839  return m_errorDstAddress;
840 }
841 
843 {
844  m_unreachNode = unreachNode;
845 }
846 
848 {
849  return m_unreachNode;
850 }
851 
853 {
854  m_originalDst = originalDst;
855 }
856 
858 {
859  return m_originalDst;
860 }
861 
862 void DsrOptionRerrUnreachHeader::Print (std::ostream &os) const
863 {
864  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
865  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
866  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
867  << " unreach node = " << m_unreachNode << " )";
868 }
869 
871 {
872  return 20;
873 }
874 
876 {
877  Buffer::Iterator i = start;
878 
879  i.WriteU8 (GetType ());
880  i.WriteU8 (GetLength ());
881  i.WriteU8 (GetErrorType ());
882  i.WriteU8 (m_salvage);
883  WriteTo (i, m_errorSrcAddress);
884  WriteTo (i, m_errorDstAddress);
885  WriteTo (i, m_unreachNode);
886  WriteTo (i, m_originalDst);
887 }
888 
890 {
891  Buffer::Iterator i = start;
892 
893  SetType (i.ReadU8 ());
894  SetLength (i.ReadU8 ());
895  SetErrorType (i.ReadU8 ());
896  m_salvage = i.ReadU8 ();
897  ReadFrom (i, m_errorSrcAddress);
898  ReadFrom (i, m_errorDstAddress);
899  ReadFrom (i, m_unreachNode);
900  ReadFrom (i, m_originalDst);
901 
902  return GetSerializedSize ();
903 }
904 
906 {
907  Alignment retVal = { 4, 0 };
908  return retVal;
909 }
910 
911 NS_OBJECT_ENSURE_REGISTERED (DsrOptionRerrUnsupportHeader);
912 
914 {
915  static TypeId tid = TypeId ("ns3::dsr::DsrOptionRerrUnsupportHeader")
917  .SetParent<DsrOptionRerrHeader> ()
918  ;
919  return tid;
920 }
921 
923 {
924  return GetTypeId ();
925 }
926 
928  : m_reserved (0),
929  m_salvage (0)
930 {
931  SetType (3);
932  SetLength (14);
933  SetErrorType (3);
934 }
935 
937 {
938 }
939 
941 {
942  m_salvage = salvage;
943 }
944 
946 {
947  return m_salvage;
948 }
949 
951 {
952  m_errorSrcAddress = errorSrcAddress;
953 }
954 
956 {
957  return m_errorSrcAddress;
958 }
959 
961 {
962  m_errorDstAddress = errorDstAddress;
963 }
964 
966 {
967  return m_errorDstAddress;
968 }
969 
971 {
972  m_unsupport = unsupport;
973 }
974 
976 {
977  return m_unsupport;
978 }
979 
980 void DsrOptionRerrUnsupportHeader::Print (std::ostream &os) const
981 {
982  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
983  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
984  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
985  << " unsupported option = " << m_unsupport << " )";
986 
987 }
988 
990 {
991  return 16;
992 }
993 
995 {
996  Buffer::Iterator i = start;
997 
998  i.WriteU8 (GetType ());
999  i.WriteU8 (GetLength ());
1000  i.WriteU8 (GetErrorType ());
1001  i.WriteU8 (m_salvage);
1002  WriteTo (i, m_errorSrcAddress);
1003  WriteTo (i, m_errorDstAddress);
1004  i.WriteU16 (m_unsupport);
1005 
1006 }
1007 
1009 {
1010  Buffer::Iterator i = start;
1011 
1012  SetType (i.ReadU8 ());
1013  SetLength (i.ReadU8 ());
1014  SetErrorType (i.ReadU8 ());
1015  m_salvage = i.ReadU8 ();
1016  ReadFrom (i, m_errorSrcAddress);
1017  ReadFrom (i, m_errorDstAddress);
1018  m_unsupport = i.ReadU16 ();
1019 
1020  return GetSerializedSize ();
1021 }
1022 
1024 {
1025  Alignment retVal = { 4, 0 };
1026  return retVal;
1027 }
1028 
1029 NS_OBJECT_ENSURE_REGISTERED (DsrOptionAckReqHeader);
1030 
1032 {
1033  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckReqHeader")
1035  .SetParent<DsrOptionHeader> ()
1036  ;
1037  return tid;
1038 }
1039 
1041 {
1042  return GetTypeId ();
1043 }
1044 
1046  : m_identification (0)
1047 
1048 {
1049  SetType (160);
1050  SetLength (2);
1051 }
1052 
1054 {
1055 }
1056 
1057 void DsrOptionAckReqHeader::SetAckId (uint16_t identification)
1058 {
1059  m_identification = identification;
1060 }
1061 
1063 {
1064  return m_identification;
1065 }
1066 
1067 void DsrOptionAckReqHeader::Print (std::ostream &os) const
1068 {
1069  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1070  << " id = " << m_identification << " )";
1071 }
1072 
1074 {
1075  return 4;
1076 }
1077 
1079 {
1080  Buffer::Iterator i = start;
1081 
1082  i.WriteU8 (GetType ());
1083  i.WriteU8 (GetLength ());
1084  i.WriteU16 (m_identification);
1085 }
1086 
1088 {
1089  Buffer::Iterator i = start;
1090 
1091  SetType (i.ReadU8 ());
1092  SetLength (i.ReadU8 ());
1093  m_identification = i.ReadU16 ();
1094 
1095  return GetSerializedSize ();
1096 }
1097 
1099 {
1100  Alignment retVal = { 4, 0 };
1101  return retVal;
1102 }
1103 
1104 NS_OBJECT_ENSURE_REGISTERED (DsrOptionAckHeader);
1105 
1107 {
1108  static TypeId tid = TypeId ("ns3::dsr::DsrOptionAckHeader")
1110  .SetParent<DsrOptionHeader> ()
1111  ;
1112  return tid;
1113 }
1114 
1116 {
1117  return GetTypeId ();
1118 }
1119 
1121  : m_identification (0)
1122 {
1123  SetType (32);
1124  SetLength (10);
1125 }
1126 
1128 {
1129 }
1130 
1131 void DsrOptionAckHeader::SetAckId (uint16_t identification)
1132 {
1133  m_identification = identification;
1134 }
1135 
1137 {
1138  return m_identification;
1139 }
1140 
1142 {
1143  m_realSrcAddress = realSrcAddress;
1144 }
1145 
1147 {
1148  return m_realSrcAddress;
1149 }
1150 
1152 {
1153  m_realDstAddress = realDstAddress;
1154 }
1155 
1157 {
1158  return m_realDstAddress;
1159 }
1160 
1161 void DsrOptionAckHeader::Print (std::ostream &os) const
1162 {
1163  os << "( type = " << (uint32_t)GetType () << " length = " << (uint32_t)GetLength ()
1164  << " id = " << m_identification << " real src = " << m_realSrcAddress
1165  << " real dst = " << m_realDstAddress << " )";
1166 
1167 }
1168 
1170 {
1171  return 12;
1172 }
1173 
1175 {
1176  Buffer::Iterator i = start;
1177 
1178  i.WriteU8 (GetType ());
1179  i.WriteU8 (GetLength ());
1181  WriteTo (i, m_realSrcAddress);
1182  WriteTo (i, m_realDstAddress);
1183 }
1184 
1186 {
1187  Buffer::Iterator i = start;
1188 
1189  SetType (i.ReadU8 ());
1190  SetLength (i.ReadU8 ());
1191  m_identification = i.ReadU16 ();
1192  ReadFrom (i, m_realSrcAddress);
1193  ReadFrom (i, m_realDstAddress);
1194 
1195  return GetSerializedSize ();
1196 }
1197 
1199 {
1200  Alignment retVal = { 4, 0 };
1201  return retVal;
1202 }
1203 } /* namespace dsr */
1204 } /* 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.
void SetAckId(uint16_t identification)
Set the Ack request id number.
TypeId AddConstructor(void)
Definition: type-id.h:388
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.
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.
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
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.
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: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
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:44
uint16_t m_errorLength
The specific error message length.
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.