A Discrete-Event Network Simulator
API
dsr-option-header.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Yufei Cheng
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
18  *
19  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20  * ResiliNets Research Group https://resilinets.org/
21  * Information and Telecommunication Technology Center (ITTC)
22  * and Department of Electrical Engineering and Computer Science
23  * The University of Kansas Lawrence, KS USA.
24  *
25  * Work supported in part by NSF FIND (Future Internet Design) Program
26  * under grant CNS-0626918 (Postmodern Internet Architecture),
27  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
28  * US Department of Defense (DoD), and ITTC at The University of Kansas.
29  */
30 
31 #include "dsr-option-header.h"
32 
33 #include "ns3/address-utils.h"
34 #include "ns3/assert.h"
35 #include "ns3/enum.h"
36 #include "ns3/header.h"
37 #include "ns3/ipv4-address.h"
38 #include "ns3/log.h"
39 #include "ns3/packet.h"
40 
41 namespace ns3
42 {
43 
44 NS_LOG_COMPONENT_DEFINE("DsrOptionHeader");
45 
46 namespace dsr
47 {
48 
49 NS_OBJECT_ENSURE_REGISTERED(DsrOptionHeader);
50 
51 TypeId
53 {
54  static TypeId tid = TypeId("ns3::dsr::DsrOptionHeader")
56  .SetParent<Header>()
57  .SetGroupName("Dsr");
58  return tid;
59 }
60 
61 TypeId
63 {
64  return GetTypeId();
65 }
66 
68  : m_type(0),
69  m_length(0)
70 {
71 }
72 
74 {
75 }
76 
77 void
79 {
80  m_type = type;
81 }
82 
83 uint8_t
85 {
86  return m_type;
87 }
88 
89 void
91 {
92  m_length = length;
93 }
94 
95 uint8_t
97 {
98  return m_length;
99 }
100 
101 void
102 DsrOptionHeader::Print(std::ostream& os) const
103 {
104  os << "( type = " << (uint32_t)m_type << " length = " << (uint32_t)m_length << " )";
105 }
106 
107 uint32_t
109 {
110  return m_length + 2;
111 }
112 
113 void
115 {
117 
118  i.WriteU8(m_type);
119  i.WriteU8(m_length);
120  i.Write(m_data.Begin(), m_data.End());
121 }
122 
123 uint32_t
125 {
127 
128  m_type = i.ReadU8();
129  m_length = i.ReadU8();
130 
131  m_data = Buffer();
133  Buffer::Iterator dataStart = i;
134  i.Next(m_length);
135  Buffer::Iterator dataEnd = i;
136  m_data.Begin().Write(dataStart, dataEnd);
137 
138  return GetSerializedSize();
139 }
140 
143 {
144  Alignment retVal = {1, 0};
145  return retVal;
146 }
147 
149 
150 TypeId
152 {
153  static TypeId tid = TypeId("ns3::dsr::DsrOptionPad1Header")
155  .SetParent<DsrOptionHeader>()
156  .SetGroupName("Dsr");
157  return tid;
158 }
159 
160 TypeId
162 {
163  return GetTypeId();
164 }
165 
167 {
168  SetType(224);
169 }
170 
172 {
173 }
174 
175 void
176 DsrOptionPad1Header::Print(std::ostream& os) const
177 {
178  os << "( type = " << (uint32_t)GetType() << " )";
179 }
180 
181 uint32_t
183 {
184  return 1;
185 }
186 
187 void
189 {
191 
192  i.WriteU8(GetType());
193 }
194 
195 uint32_t
197 {
199 
200  SetType(i.ReadU8());
201 
202  return GetSerializedSize();
203 }
204 
206 
207 TypeId
209 {
210  static TypeId tid = TypeId("ns3::dsr::DsrOptionPadnHeader")
212  .SetParent<DsrOptionHeader>()
213  .SetGroupName("Dsr");
214  return tid;
215 }
216 
217 TypeId
219 {
220  return GetTypeId();
221 }
222 
224 {
225  SetType(0);
226  NS_ASSERT_MSG(pad >= 2, "PadN must be at least 2 bytes long");
227  SetLength(pad - 2);
228 }
229 
231 {
232 }
233 
234 void
235 DsrOptionPadnHeader::Print(std::ostream& os) const
236 {
237  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << " )";
238 }
239 
240 uint32_t
242 {
243  return GetLength() + 2;
244 }
245 
246 void
248 {
250 
251  i.WriteU8(GetType());
252  i.WriteU8(GetLength());
253 
254  for (int padding = 0; padding < GetLength(); padding++)
255  {
256  i.WriteU8(0);
257  }
258 }
259 
260 uint32_t
262 {
264 
265  SetType(i.ReadU8());
266  SetLength(i.ReadU8());
267 
268  return GetSerializedSize();
269 }
270 
272 
273 TypeId
275 {
276  static TypeId tid = TypeId("ns3::dsr::DsrOptionRreqHeader")
278  .SetParent<DsrOptionHeader>()
279  .SetGroupName("Dsr");
280  return tid;
281 }
282 
283 TypeId
285 {
286  return GetTypeId();
287 }
288 
290  : m_ipv4Address(0)
291 {
292  SetType(1);
293  SetLength(6 + m_ipv4Address.size() * 4);
294 }
295 
297 {
298 }
299 
300 void
302 {
303  m_ipv4Address.clear();
304  m_ipv4Address.assign(n, Ipv4Address());
305 }
306 
309 {
310  return m_target;
311 }
312 
313 void
315 {
316  m_target = target;
317 }
318 
319 void
321 {
322  m_ipv4Address.push_back(ipv4);
323  SetLength(6 + m_ipv4Address.size() * 4);
324 }
325 
326 void
327 DsrOptionRreqHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
328 {
329  m_ipv4Address = ipv4Address;
330  SetLength(6 + m_ipv4Address.size() * 4);
331 }
332 
333 std::vector<Ipv4Address>
335 {
336  return m_ipv4Address;
337 }
338 
339 uint32_t
341 {
342  return m_ipv4Address.size();
343 }
344 
345 void
347 {
348  m_ipv4Address.at(index) = addr;
349 }
350 
353 {
354  return m_ipv4Address.at(index);
355 }
356 
357 void
358 DsrOptionRreqHeader::SetId(uint16_t identification)
359 {
360  m_identification = identification;
361 }
362 
363 uint16_t
365 {
366  return m_identification;
367 }
368 
369 void
370 DsrOptionRreqHeader::Print(std::ostream& os) const
371 {
372  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
373 
374  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin();
375  it != m_ipv4Address.end();
376  it++)
377  {
378  os << *it << " ";
379  }
380 
381  os << ")";
382 }
383 
384 uint32_t
386 {
387  return 8 + m_ipv4Address.size() * 4;
388 }
389 
390 void
392 {
394  uint8_t buff[4];
395 
396  i.WriteU8(GetType());
397  i.WriteU8(GetLength());
399  WriteTo(i, m_target);
400 
401  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
402  it++)
403  {
404  it->Serialize(buff);
405  i.Write(buff, 4);
406  }
407 }
408 
409 uint32_t
411 {
413  uint8_t buff[4];
414 
415  SetType(i.ReadU8());
416  SetLength(i.ReadU8());
418  ReadFrom(i, m_target);
419 
420  uint8_t index = 0;
421  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
422  it++)
423  {
424  i.Read(buff, 4);
425  m_address = it->Deserialize(buff);
426  SetNodeAddress(index, m_address);
427  ++index;
428  }
429 
430  return GetSerializedSize();
431 }
432 
435 {
436  Alignment retVal = {4, 0};
437  return retVal;
438 }
439 
441 
442 TypeId
444 {
445  static TypeId tid = TypeId("ns3::dsr::DsrOptionRrepHeader")
447  .SetParent<DsrOptionHeader>()
448  .SetGroupName("Dsr");
449  return tid;
450 }
451 
452 TypeId
454 {
455  return GetTypeId();
456 }
457 
459  : m_ipv4Address(0)
460 {
461  SetType(2);
462  SetLength(2 + m_ipv4Address.size() * 4);
463 }
464 
466 {
467 }
468 
469 void
471 {
472  m_ipv4Address.clear();
473  m_ipv4Address.assign(n, Ipv4Address());
474 }
475 
476 void
477 DsrOptionRrepHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
478 {
479  m_ipv4Address = ipv4Address;
480  SetLength(2 + m_ipv4Address.size() * 4);
481 }
482 
483 std::vector<Ipv4Address>
485 {
486  return m_ipv4Address;
487 }
488 
489 void
491 {
492  m_ipv4Address.at(index) = addr;
493 }
494 
497 {
498  return m_ipv4Address.at(index);
499 }
500 
502 DsrOptionRrepHeader::GetTargetAddress(std::vector<Ipv4Address> ipv4Address) const
503 {
504  return m_ipv4Address.at(ipv4Address.size() - 1);
505 }
506 
507 void
508 DsrOptionRrepHeader::Print(std::ostream& os) const
509 {
510  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
511 
512  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin();
513  it != m_ipv4Address.end();
514  it++)
515  {
516  os << *it << " ";
517  }
518 
519  os << ")";
520 }
521 
522 uint32_t
524 {
525  return 4 + m_ipv4Address.size() * 4;
526 }
527 
528 void
530 {
532  uint8_t buff[4];
533 
534  i.WriteU8(GetType());
535  i.WriteU8(GetLength());
536  i.WriteU8(0);
537  i.WriteU8(0);
538 
539  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
540  it++)
541  {
542  it->Serialize(buff);
543  i.Write(buff, 4);
544  }
545 }
546 
547 uint32_t
549 {
551  uint8_t buff[4];
552 
553  SetType(i.ReadU8());
554  SetLength(i.ReadU8());
555  i.ReadU8();
556  i.ReadU8();
557 
558  uint8_t index = 0;
559  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
560  it++)
561  {
562  i.Read(buff, 4);
563  m_address = it->Deserialize(buff);
564  SetNodeAddress(index, m_address);
565  ++index;
566  }
567 
568  return GetSerializedSize();
569 }
570 
573 {
574  Alignment retVal = {4, 0};
575  return retVal;
576 }
577 
579 
580 TypeId
582 {
583  static TypeId tid = TypeId("ns3::dsr::DsrOptionSRHeader")
585  .SetParent<DsrOptionHeader>()
586  .SetGroupName("Dsr");
587  return tid;
588 }
589 
590 TypeId
592 {
593  return GetTypeId();
594 }
595 
597  : m_segmentsLeft(0),
598  m_ipv4Address(0)
599 {
600  SetType(96);
601  SetLength(2 + m_ipv4Address.size() * 4);
602 }
603 
605 {
606 }
607 
608 void
610 {
611  m_segmentsLeft = segmentsLeft;
612 }
613 
614 uint8_t
616 {
617  return m_segmentsLeft;
618 }
619 
620 void
622 {
623  m_salvage = salvage;
624 }
625 
626 uint8_t
628 {
629  return m_salvage;
630 }
631 
632 void
634 {
635  m_ipv4Address.clear();
636  m_ipv4Address.assign(n, Ipv4Address());
637 }
638 
639 void
640 DsrOptionSRHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
641 {
642  m_ipv4Address = ipv4Address;
643  SetLength(2 + m_ipv4Address.size() * 4);
644 }
645 
646 std::vector<Ipv4Address>
648 {
649  return m_ipv4Address;
650 }
651 
652 void
654 {
655  m_ipv4Address.at(index) = addr;
656 }
657 
660 {
661  return m_ipv4Address.at(index);
662 }
663 
664 uint8_t
666 {
667  return m_ipv4Address.size();
668 }
669 
670 void
671 DsrOptionSRHeader::Print(std::ostream& os) const
672 {
673  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
674 
675  for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin();
676  it != m_ipv4Address.end();
677  it++)
678  {
679  os << *it << " ";
680  }
681 
682  os << ")";
683 }
684 
685 uint32_t
687 {
688  return 4 + m_ipv4Address.size() * 4;
689 }
690 
691 void
693 {
695  uint8_t buff[4];
696 
697  i.WriteU8(GetType());
698  i.WriteU8(GetLength());
699  i.WriteU8(m_salvage);
701 
702  for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
703  it++)
704  {
705  it->Serialize(buff);
706  i.Write(buff, 4);
707  }
708 }
709 
710 uint32_t
712 {
714  uint8_t buff[4];
715 
716  SetType(i.ReadU8());
717  SetLength(i.ReadU8());
718  m_salvage = i.ReadU8();
719  m_segmentsLeft = i.ReadU8();
720 
721  uint8_t index = 0;
722  for (std::vector<Ipv4Address>::iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
723  it++)
724  {
725  i.Read(buff, 4);
726  m_address = it->Deserialize(buff);
727  SetNodeAddress(index, m_address);
728  ++index;
729  }
730 
731  return GetSerializedSize();
732 }
733 
736 {
737  Alignment retVal = {4, 0};
738  return retVal;
739 }
740 
742 
743 TypeId
745 {
746  static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrHeader")
748  .SetParent<DsrOptionHeader>()
749  .SetGroupName("Dsr");
750  return tid;
751 }
752 
753 TypeId
755 {
756  return GetTypeId();
757 }
758 
760  : m_errorType(0),
761  m_salvage(0),
762  m_errorLength(4)
763 {
764  SetType(3);
765  SetLength(18);
766 }
767 
769 {
770 }
771 
772 void
774 {
775  m_errorType = errorType;
776 }
777 
778 uint8_t
780 {
781  return m_errorType;
782 }
783 
784 void
786 {
787  m_salvage = salvage;
788 }
789 
790 uint8_t
792 {
793  return m_salvage;
794 }
795 
796 void
798 {
799  m_errorSrcAddress = errorSrcAddress;
800 }
801 
804 {
805  return m_errorSrcAddress;
806 }
807 
808 void
810 {
811  m_errorDstAddress = errorDstAddress;
812 }
813 
816 {
817  return m_errorDstAddress;
818 }
819 
820 void
821 DsrOptionRerrHeader::Print(std::ostream& os) const
822 {
823  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
824  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
825  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
826 }
827 
828 uint32_t
830 {
831  return 20;
832 }
833 
834 void
836 {
838 
839  i.WriteU8(GetType());
840  i.WriteU8(GetLength());
841  i.WriteU8(m_errorType);
842  i.WriteU8(m_salvage);
846 }
847 
848 uint32_t
850 {
852 
853  SetType(i.ReadU8());
854  SetLength(i.ReadU8());
855  m_errorType = i.ReadU8();
856  m_salvage = i.ReadU8();
859 
860  m_errorData = Buffer();
862  Buffer::Iterator dataStart = i;
863  i.Next(m_errorLength);
864  Buffer::Iterator dataEnd = i;
865  m_errorData.Begin().Write(dataStart, dataEnd);
866 
867  return GetSerializedSize();
868 }
869 
872 {
873  Alignment retVal = {4, 0};
874  return retVal;
875 }
876 
878 
879 TypeId
881 {
882  static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnreachHeader")
884  .SetParent<DsrOptionRerrHeader>()
885  .SetGroupName("Dsr");
886  return tid;
887 }
888 
889 TypeId
891 {
892  return GetTypeId();
893 }
894 
896  : m_salvage(0)
897 {
898  SetType(3);
899  SetLength(18);
900  SetErrorType(1);
901 }
902 
904 {
905 }
906 
907 void
909 {
910  m_salvage = salvage;
911 }
912 
913 uint8_t
915 {
916  return m_salvage;
917 }
918 
919 void
921 {
922  m_errorSrcAddress = errorSrcAddress;
923 }
924 
927 {
928  return m_errorSrcAddress;
929 }
930 
931 void
933 {
934  m_errorDstAddress = errorDstAddress;
935 }
936 
939 {
940  return m_errorDstAddress;
941 }
942 
943 void
945 {
946  m_unreachNode = unreachNode;
947 }
948 
951 {
952  return m_unreachNode;
953 }
954 
955 void
957 {
958  m_originalDst = originalDst;
959 }
960 
963 {
964  return m_originalDst;
965 }
966 
967 void
968 DsrOptionRerrUnreachHeader::Print(std::ostream& os) const
969 {
970  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
971  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
972  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
973  << " unreach node = " << m_unreachNode << " )";
974 }
975 
976 uint32_t
978 {
979  return 20;
980 }
981 
982 void
984 {
986 
987  i.WriteU8(GetType());
988  i.WriteU8(GetLength());
989  i.WriteU8(GetErrorType());
990  i.WriteU8(m_salvage);
995 }
996 
997 uint32_t
999 {
1000  Buffer::Iterator i = start;
1001 
1002  SetType(i.ReadU8());
1003  SetLength(i.ReadU8());
1004  SetErrorType(i.ReadU8());
1005  m_salvage = i.ReadU8();
1008  ReadFrom(i, m_unreachNode);
1009  ReadFrom(i, m_originalDst);
1010 
1011  return GetSerializedSize();
1012 }
1013 
1016 {
1017  Alignment retVal = {4, 0};
1018  return retVal;
1019 }
1020 
1022 
1023 TypeId
1025 {
1026  static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnsupportHeader")
1028  .SetParent<DsrOptionRerrHeader>()
1029  .SetGroupName("Dsr");
1030  return tid;
1031 }
1032 
1033 TypeId
1035 {
1036  return GetTypeId();
1037 }
1038 
1040  : m_salvage(0)
1041 {
1042  SetType(3);
1043  SetLength(14);
1044  SetErrorType(3);
1045 }
1046 
1048 {
1049 }
1050 
1051 void
1053 {
1054  m_salvage = salvage;
1055 }
1056 
1057 uint8_t
1059 {
1060  return m_salvage;
1061 }
1062 
1063 void
1065 {
1066  m_errorSrcAddress = errorSrcAddress;
1067 }
1068 
1071 {
1072  return m_errorSrcAddress;
1073 }
1074 
1075 void
1077 {
1078  m_errorDstAddress = errorDstAddress;
1079 }
1080 
1083 {
1084  return m_errorDstAddress;
1085 }
1086 
1087 void
1089 {
1090  m_unsupported = unsupported;
1091 }
1092 
1093 uint16_t
1095 {
1096  return m_unsupported;
1097 }
1098 
1099 void
1101 {
1102  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1103  << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
1104  << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
1105  << " unsupported option = " << m_unsupported << " )";
1106 }
1107 
1108 uint32_t
1110 {
1111  return 16;
1112 }
1113 
1114 void
1116 {
1117  Buffer::Iterator i = start;
1118 
1119  i.WriteU8(GetType());
1120  i.WriteU8(GetLength());
1121  i.WriteU8(GetErrorType());
1122  i.WriteU8(m_salvage);
1126 }
1127 
1128 uint32_t
1130 {
1131  Buffer::Iterator i = start;
1132 
1133  SetType(i.ReadU8());
1134  SetLength(i.ReadU8());
1135  SetErrorType(i.ReadU8());
1136  m_salvage = i.ReadU8();
1139  m_unsupported = i.ReadU16();
1140 
1141  return GetSerializedSize();
1142 }
1143 
1146 {
1147  Alignment retVal = {4, 0};
1148  return retVal;
1149 }
1150 
1152 
1153 TypeId
1155 {
1156  static TypeId tid = TypeId("ns3::dsr::DsrOptionAckReqHeader")
1158  .SetParent<DsrOptionHeader>()
1159  .SetGroupName("Dsr");
1160  return tid;
1161 }
1162 
1163 TypeId
1165 {
1166  return GetTypeId();
1167 }
1168 
1170  : m_identification(0)
1171 
1172 {
1173  SetType(160);
1174  SetLength(2);
1175 }
1176 
1178 {
1179 }
1180 
1181 void
1182 DsrOptionAckReqHeader::SetAckId(uint16_t identification)
1183 {
1184  m_identification = identification;
1185 }
1186 
1187 uint16_t
1189 {
1190  return m_identification;
1191 }
1192 
1193 void
1194 DsrOptionAckReqHeader::Print(std::ostream& os) const
1195 {
1196  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1197  << " id = " << m_identification << " )";
1198 }
1199 
1200 uint32_t
1202 {
1203  return 4;
1204 }
1205 
1206 void
1208 {
1209  Buffer::Iterator i = start;
1210 
1211  i.WriteU8(GetType());
1212  i.WriteU8(GetLength());
1214 }
1215 
1216 uint32_t
1218 {
1219  Buffer::Iterator i = start;
1220 
1221  SetType(i.ReadU8());
1222  SetLength(i.ReadU8());
1223  m_identification = i.ReadU16();
1224 
1225  return GetSerializedSize();
1226 }
1227 
1230 {
1231  Alignment retVal = {4, 0};
1232  return retVal;
1233 }
1234 
1236 
1237 TypeId
1239 {
1240  static TypeId tid = TypeId("ns3::dsr::DsrOptionAckHeader")
1242  .SetParent<DsrOptionHeader>()
1243  .SetGroupName("Dsr");
1244  return tid;
1245 }
1246 
1247 TypeId
1249 {
1250  return GetTypeId();
1251 }
1252 
1254  : m_identification(0)
1255 {
1256  SetType(32);
1257  SetLength(10);
1258 }
1259 
1261 {
1262 }
1263 
1264 void
1265 DsrOptionAckHeader::SetAckId(uint16_t identification)
1266 {
1267  m_identification = identification;
1268 }
1269 
1270 uint16_t
1272 {
1273  return m_identification;
1274 }
1275 
1276 void
1278 {
1279  m_realSrcAddress = realSrcAddress;
1280 }
1281 
1284 {
1285  return m_realSrcAddress;
1286 }
1287 
1288 void
1290 {
1291  m_realDstAddress = realDstAddress;
1292 }
1293 
1296 {
1297  return m_realDstAddress;
1298 }
1299 
1300 void
1301 DsrOptionAckHeader::Print(std::ostream& os) const
1302 {
1303  os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1304  << " id = " << m_identification << " real src = " << m_realSrcAddress
1305  << " real dst = " << m_realDstAddress << " )";
1306 }
1307 
1308 uint32_t
1310 {
1311  return 12;
1312 }
1313 
1314 void
1316 {
1317  Buffer::Iterator i = start;
1318 
1319  i.WriteU8(GetType());
1320  i.WriteU8(GetLength());
1324 }
1325 
1326 uint32_t
1328 {
1329  Buffer::Iterator i = start;
1330 
1331  SetType(i.ReadU8());
1332  SetLength(i.ReadU8());
1333  m_identification = i.ReadU16();
1336 
1337  return GetSerializedSize();
1338 }
1339 
1342 {
1343  Alignment retVal = {4, 0};
1344  return retVal;
1345 }
1346 } /* namespace dsr */
1347 } /* namespace ns3 */
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void Write(const uint8_t *buffer, uint32_t size)
Definition: buffer.cc:951
void WriteU16(uint16_t data)
Definition: buffer.cc:862
void Read(uint8_t *buffer, uint32_t size)
Definition: buffer.cc:1128
void WriteHtonU16(uint16_t data)
Definition: buffer.h:915
uint16_t ReadNtohU16()
Definition: buffer.h:954
uint16_t ReadU16()
Definition: buffer.h:1035
void Next()
go forward by one byte
Definition: buffer.h:853
automatically resized byte buffer
Definition: buffer.h:94
Buffer::Iterator Begin() const
Definition: buffer.h:1074
void AddAtEnd(uint32_t end)
Definition: buffer.cc:357
Buffer::Iterator End() const
Definition: buffer.h:1081
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
static Ipv4Address Deserialize(const uint8_t buf[4])
a unique identifier for an interface.
Definition: type-id.h:60
TypeId AddConstructor()
Record in this TypeId the fact that the default constructor is accessible.
Definition: type-id.h:653
Acknowledgement (ACK) Message Format.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetAckId(uint16_t identification)
Set the Ack id number.
uint16_t GetAckId() const
Set the Ack id number.
uint16_t m_identification
identification field
static TypeId GetTypeId()
Get the type identificator.
void SetRealSrc(Ipv4Address realSrcAddress)
Set Error source ip address.
void SetRealDst(Ipv4Address realDstAddress)
Set Error source ip address.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Ipv4Address m_realDstAddress
ack destination address
Ipv4Address GetRealDst() const
Get Error source ip address.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
Ipv4Address m_realSrcAddress
ack source address
Ipv4Address GetRealSrc() const
Get Error source ip address.
~DsrOptionAckHeader() override
Destructor.
Acknowledgement Request (ACK_RREQ) Message Format.
~DsrOptionAckReqHeader() override
Destructor.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
void SetAckId(uint16_t identification)
Set the Ack request id number.
uint16_t m_identification
The identification field.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint16_t GetAckId() const
Set the Ack request id number.
static TypeId GetTypeId()
Get the type identificator.
Header for Dsr Options.
virtual Alignment GetAlignment() const
Get the Alignment requirement of this option header.
static TypeId GetTypeId()
Get the type identificator.
Buffer m_data
The anonymous data of this option.
uint8_t GetType() const
Get the type of the option.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
~DsrOptionHeader() override
Destructor.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Print(std::ostream &os) const override
Print some information about the packet.
void SetType(uint8_t type)
Set the type of the option.
uint8_t m_length
The option length.
uint8_t m_type
The type of the option.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetLength(uint8_t length)
Set the option length.
uint8_t GetLength() const
Get the option length.
Header of Dsr Option Pad1.
~DsrOptionPad1Header() override
Destructor.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
Header of Dsr Option Padn.
DsrOptionPadnHeader(uint32_t pad=2)
Constructor.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Print(std::ostream &os) const override
Print some information about the packet.
static TypeId GetTypeId()
Get the type identificator.
~DsrOptionPadnHeader() override
Destructor.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Header of Dsr Option Route Error.
uint8_t GetErrorType() const
Get the route error type.
Buffer m_errorData
The anonymous data of this option.
virtual void SetSalvage(uint8_t salvage)
Set the salvage value of the packet.
virtual Ipv4Address GetErrorSrc() const
Get the route error source address.
void SetErrorType(uint8_t errorType)
Set the route error type.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Ipv4Address m_errorSrcAddress
The error source address.
static TypeId GetTypeId()
Get the type identificator.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint8_t m_salvage
The salavage field.
~DsrOptionRerrHeader() override
Destructor.
virtual void SetErrorDst(Ipv4Address errorDstAddress)
Set the error destination ip address.
virtual Ipv4Address GetErrorDst() const
Get the error destination ip address.
Ipv4Address m_errorDstAddress
The error destination address.
uint16_t m_errorLength
The specific error message length.
uint8_t m_errorType
The error type or route error option.
virtual uint8_t GetSalvage() const
Get the salvage value of the packet.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
void Print(std::ostream &os) const override
Print some information about the packet.
virtual void SetErrorSrc(Ipv4Address errorSrcAddress)
Set the route error source address.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Route Error (RERR) Unreachable node address option Message Format.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetOriginalDst(Ipv4Address originalDst)
Set the unreachable node ip address.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Ipv4Address GetErrorSrc() const override
Get the route error source address.
static TypeId GetTypeId()
Get the type identificator.
void SetErrorDst(Ipv4Address errorDstAddress) override
Set the error destination ip address.
void SetErrorSrc(Ipv4Address errorSrcAddress) override
Set the route error source address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint8_t GetSalvage() const override
Get the salvage value of the packet.
Ipv4Address m_unreachNode
The unreachable node address.
Ipv4Address GetOriginalDst() const
Get the unreachable node ip address.
~DsrOptionRerrUnreachHeader() override
Destructor.
void SetUnreachNode(Ipv4Address unreachNode)
Set the unreachable node ip address.
void SetSalvage(uint8_t salvage) override
Set the salvage value of the packet.
uint8_t m_errorType
The error type or route error option.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
void Print(std::ostream &os) const override
Print some information about the packet.
Ipv4Address m_errorSrcAddress
The error source address.
uint8_t m_salvage
The salavage field.
Ipv4Address m_originalDst
The original destination address.
Ipv4Address m_errorDstAddress
The error destination address.
Ipv4Address GetUnreachNode() const
Get the unreachable node ip address.
Ipv4Address GetErrorDst() const override
Get the error destination ip address.
Route Error (RERR) Unsupported option Message Format.
~DsrOptionRerrUnsupportHeader() override
Destructor.
static TypeId GetTypeId()
Get the type identificator.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetErrorSrc(Ipv4Address errorSrcAddress) override
Set the route error source address.
void SetUnsupported(uint16_t optionType)
Set the unsupported option type value.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
Ipv4Address GetErrorSrc() const override
Get the route error source address.
Ipv4Address m_errorDstAddress
The error destination address.
uint8_t m_errorType
The error type or route error option.
uint16_t GetUnsupported() const
Get the unsupported option type value.
uint16_t m_unsupported
The unsupported option.
void SetSalvage(uint8_t salvage) override
Set the salvage value of the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
uint8_t GetSalvage() const override
Get the salvage value of the packet.
Ipv4Address GetErrorDst() const override
Get the error destination ip address.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetErrorDst(Ipv4Address errorDstAddress) override
Set the error destination ip address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Ipv4Address m_errorSrcAddress
The error source address.
Route Reply (RREP) Message Format.
Ipv4Address GetTargetAddress(std::vector< Ipv4Address > ipv4Address) const
Get the target node Ip address.
Ipv4Address m_address
The Ip address to write to when deserialize the packet.
void SetNodeAddress(uint8_t index, Ipv4Address addr)
Set a Node IPv4 Address.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
std::vector< Ipv4Address > GetNodesAddress() const
Get the vector of ipv4 address.
~DsrOptionRrepHeader() override
Destructor.
VectorIpv4Address_t m_ipv4Address
The vector of Nodes' IPv4 Address.
Ipv4Address GetNodeAddress(uint8_t index) const
Get a Node IPv4 Address.
static TypeId GetTypeId()
Get the type identificator.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
Route Request (RREQ) Message Format.
static TypeId GetTypeId()
Get the type identificator.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
Ipv4Address m_target
Ipv4 address of target node.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
Ipv4Address m_address
Ipv4 address to write when desearizing the packet.
void SetNodeAddress(uint8_t index, Ipv4Address addr)
Set a Node IPv4 Address.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
~DsrOptionRreqHeader() override
Destructor.
Ipv4Address GetNodeAddress(uint8_t index) const
Get a Node IPv4 Address.
uint16_t m_identification
Identifier of the packet.
void SetTarget(Ipv4Address target)
Set the target ipv4 address.
Ipv4Address GetTarget()
Get the target ipv4 address.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
std::vector< Ipv4Address > GetNodesAddresses() const
Get the vector of ipv4 address.
VectorIpv4Address_t m_ipv4Address
The vector of Nodes' IPv4 Address.
void Print(std::ostream &os) const override
Print some information about the packet.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint32_t GetNodesNumber() const
Get the number of nodes.
void AddNodeAddress(Ipv4Address ipv4)
Add one node address.
uint16_t GetId() const
Set the request id number.
void SetId(uint16_t identification)
Set the request id number.
Source Route (SR) Message Format.
Ipv4Address GetNodeAddress(uint8_t index) const
Get a Node IPv4 Address.
uint8_t m_segmentsLeft
Number of left segments.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
std::vector< Ipv4Address > GetNodesAddress() const
Get the vector of ipv4 address.
Ipv4Address m_address
The ip address header deserilize to.
void SetNumberAddress(uint8_t n)
Set the number of ipv4 address.
static TypeId GetTypeId()
Get the type identificator.
void SetSalvage(uint8_t salvage)
Set the salvage value for a packet.
void Print(std::ostream &os) const override
Print some information about the packet.
VectorIpv4Address_t m_ipv4Address
The vector of Nodes' IPv4 Address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetNodeAddress(uint8_t index, Ipv4Address addr)
Set a Node IPv4 Address.
void SetSegmentsLeft(uint8_t segmentsLeft)
Set the number of segments left to send.
uint8_t GetSalvage() const
Get the salvage value for a packet.
uint8_t GetNodeListSize() const
Get the node list size which is the number of ip address of the route.
uint8_t m_salvage
Number of savlage times for a packet.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
void SetNodesAddress(std::vector< Ipv4Address > ipv4Address)
Set the vector of ipv4 address.
uint8_t GetSegmentsLeft() const
Get the number of segments left to send.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
~DsrOptionSRHeader() override
Destructor.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
represents the alignment requirements of an option header