A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
41namespace ns3
42{
43
44NS_LOG_COMPONENT_DEFINE("DsrOptionHeader");
45
46namespace dsr
47{
48
49NS_OBJECT_ENSURE_REGISTERED(DsrOptionHeader);
50
51TypeId
53{
54 static TypeId tid = TypeId("ns3::dsr::DsrOptionHeader")
56 .SetParent<Header>()
57 .SetGroupName("Dsr");
58 return tid;
59}
60
63{
64 return GetTypeId();
65}
66
68 : m_type(0),
69 m_length(0)
70{
71}
72
74{
75}
76
77void
79{
80 m_type = type;
81}
82
83uint8_t
85{
86 return m_type;
87}
88
89void
91{
92 m_length = length;
93}
94
95uint8_t
97{
98 return m_length;
99}
100
101void
102DsrOptionHeader::Print(std::ostream& os) const
103{
104 os << "( type = " << (uint32_t)m_type << " length = " << (uint32_t)m_length << " )";
105}
106
109{
110 return m_length + 2;
111}
112
113void
115{
116 Buffer::Iterator i = start;
117
118 i.WriteU8(m_type);
119 i.WriteU8(m_length);
120 i.Write(m_data.Begin(), m_data.End());
121}
122
125{
126 Buffer::Iterator i = start;
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
150TypeId
152{
153 static TypeId tid = TypeId("ns3::dsr::DsrOptionPad1Header")
155 .SetParent<DsrOptionHeader>()
156 .SetGroupName("Dsr");
157 return tid;
158}
159
160TypeId
162{
163 return GetTypeId();
164}
165
167{
168 SetType(224);
169}
170
172{
173}
174
175void
176DsrOptionPad1Header::Print(std::ostream& os) const
177{
178 os << "( type = " << (uint32_t)GetType() << " )";
179}
180
183{
184 return 1;
185}
186
187void
189{
190 Buffer::Iterator i = start;
191
192 i.WriteU8(GetType());
193}
194
197{
198 Buffer::Iterator i = start;
199
200 SetType(i.ReadU8());
201
202 return GetSerializedSize();
203}
204
206
207TypeId
209{
210 static TypeId tid = TypeId("ns3::dsr::DsrOptionPadnHeader")
212 .SetParent<DsrOptionHeader>()
213 .SetGroupName("Dsr");
214 return tid;
215}
216
217TypeId
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
234void
235DsrOptionPadnHeader::Print(std::ostream& os) const
236{
237 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << " )";
238}
239
242{
243 return GetLength() + 2;
244}
245
246void
248{
249 Buffer::Iterator i = start;
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
262{
263 Buffer::Iterator i = start;
264
265 SetType(i.ReadU8());
266 SetLength(i.ReadU8());
267
268 return GetSerializedSize();
269}
270
272
273TypeId
275{
276 static TypeId tid = TypeId("ns3::dsr::DsrOptionRreqHeader")
278 .SetParent<DsrOptionHeader>()
279 .SetGroupName("Dsr");
280 return tid;
281}
282
283TypeId
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
300void
302{
303 m_ipv4Address.clear();
304 m_ipv4Address.assign(n, Ipv4Address());
305}
306
309{
310 return m_target;
311}
312
313void
315{
316 m_target = target;
317}
318
319void
321{
322 m_ipv4Address.push_back(ipv4);
323 SetLength(6 + m_ipv4Address.size() * 4);
324}
325
326void
327DsrOptionRreqHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
328{
329 m_ipv4Address = ipv4Address;
330 SetLength(6 + m_ipv4Address.size() * 4);
331}
332
333std::vector<Ipv4Address>
335{
336 return m_ipv4Address;
337}
338
341{
342 return m_ipv4Address.size();
343}
344
345void
347{
348 m_ipv4Address.at(index) = addr;
349}
350
353{
354 return m_ipv4Address.at(index);
355}
356
357void
358DsrOptionRreqHeader::SetId(uint16_t identification)
359{
360 m_identification = identification;
361}
362
363uint16_t
365{
366 return m_identification;
367}
368
369void
370DsrOptionRreqHeader::Print(std::ostream& os) const
371{
372 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
373
374 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
375 {
376 os << *it << " ";
377 }
378
379 os << ")";
380}
381
384{
385 return 8 + m_ipv4Address.size() * 4;
386}
387
388void
390{
391 Buffer::Iterator i = start;
392 uint8_t buff[4];
393
394 i.WriteU8(GetType());
395 i.WriteU8(GetLength());
397 WriteTo(i, m_target);
398
399 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
400 {
401 it->Serialize(buff);
402 i.Write(buff, 4);
403 }
404}
405
408{
409 Buffer::Iterator i = start;
410 uint8_t buff[4];
411
412 SetType(i.ReadU8());
413 SetLength(i.ReadU8());
415 ReadFrom(i, m_target);
416
417 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
418 {
419 i.Read(buff, 4);
421 SetNodeAddress(static_cast<uint8_t>(index), m_address);
422 }
423
424 return GetSerializedSize();
425}
426
429{
430 Alignment retVal = {4, 0};
431 return retVal;
432}
433
435
436TypeId
438{
439 static TypeId tid = TypeId("ns3::dsr::DsrOptionRrepHeader")
441 .SetParent<DsrOptionHeader>()
442 .SetGroupName("Dsr");
443 return tid;
444}
445
446TypeId
448{
449 return GetTypeId();
450}
451
453 : m_ipv4Address(0)
454{
455 SetType(2);
456 SetLength(2 + m_ipv4Address.size() * 4);
457}
458
460{
461}
462
463void
465{
466 m_ipv4Address.clear();
467 m_ipv4Address.assign(n, Ipv4Address());
468}
469
470void
471DsrOptionRrepHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
472{
473 m_ipv4Address = ipv4Address;
474 SetLength(2 + m_ipv4Address.size() * 4);
475}
476
477std::vector<Ipv4Address>
479{
480 return m_ipv4Address;
481}
482
483void
485{
486 m_ipv4Address.at(index) = addr;
487}
488
491{
492 return m_ipv4Address.at(index);
493}
494
496DsrOptionRrepHeader::GetTargetAddress(std::vector<Ipv4Address> ipv4Address) const
497{
498 return m_ipv4Address.at(ipv4Address.size() - 1);
499}
500
501void
502DsrOptionRrepHeader::Print(std::ostream& os) const
503{
504 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
505
506 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
507 {
508 os << *it << " ";
509 }
510
511 os << ")";
512}
513
516{
517 return 4 + m_ipv4Address.size() * 4;
518}
519
520void
522{
523 Buffer::Iterator i = start;
524 uint8_t buff[4];
525
526 i.WriteU8(GetType());
527 i.WriteU8(GetLength());
528 i.WriteU8(0);
529 i.WriteU8(0);
530
531 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
532 {
533 it->Serialize(buff);
534 i.Write(buff, 4);
535 }
536}
537
540{
541 Buffer::Iterator i = start;
542 uint8_t buff[4];
543
544 SetType(i.ReadU8());
545 SetLength(i.ReadU8());
546 i.ReadU8();
547 i.ReadU8();
548
549 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
550 {
551 i.Read(buff, 4);
553 SetNodeAddress(static_cast<uint8_t>(index), m_address);
554 }
555
556 return GetSerializedSize();
557}
558
561{
562 Alignment retVal = {4, 0};
563 return retVal;
564}
565
567
568TypeId
570{
571 static TypeId tid = TypeId("ns3::dsr::DsrOptionSRHeader")
573 .SetParent<DsrOptionHeader>()
574 .SetGroupName("Dsr");
575 return tid;
576}
577
578TypeId
580{
581 return GetTypeId();
582}
583
585 : m_segmentsLeft(0),
586 m_ipv4Address(0)
587{
588 SetType(96);
589 SetLength(2 + m_ipv4Address.size() * 4);
590}
591
593{
594}
595
596void
598{
599 m_segmentsLeft = segmentsLeft;
600}
601
602uint8_t
604{
605 return m_segmentsLeft;
606}
607
608void
610{
611 m_salvage = salvage;
612}
613
614uint8_t
616{
617 return m_salvage;
618}
619
620void
622{
623 m_ipv4Address.clear();
624 m_ipv4Address.assign(n, Ipv4Address());
625}
626
627void
628DsrOptionSRHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
629{
630 m_ipv4Address = ipv4Address;
631 SetLength(2 + m_ipv4Address.size() * 4);
632}
633
634std::vector<Ipv4Address>
636{
637 return m_ipv4Address;
638}
639
640void
642{
643 m_ipv4Address.at(index) = addr;
644}
645
648{
649 return m_ipv4Address.at(index);
650}
651
652uint8_t
654{
655 return m_ipv4Address.size();
656}
657
658void
659DsrOptionSRHeader::Print(std::ostream& os) const
660{
661 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
662
663 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
664 {
665 os << *it << " ";
666 }
667
668 os << ")";
669}
670
673{
674 return 4 + m_ipv4Address.size() * 4;
675}
676
677void
679{
680 Buffer::Iterator i = start;
681 uint8_t buff[4];
682
683 i.WriteU8(GetType());
684 i.WriteU8(GetLength());
687
688 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
689 {
690 it->Serialize(buff);
691 i.Write(buff, 4);
692 }
693}
694
697{
698 Buffer::Iterator i = start;
699 uint8_t buff[4];
700
701 SetType(i.ReadU8());
702 SetLength(i.ReadU8());
703 m_salvage = i.ReadU8();
705
706 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
707 {
708 i.Read(buff, 4);
710 SetNodeAddress(static_cast<uint8_t>(index), m_address);
711 }
712
713 return GetSerializedSize();
714}
715
718{
719 Alignment retVal = {4, 0};
720 return retVal;
721}
722
724
725TypeId
727{
728 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrHeader")
730 .SetParent<DsrOptionHeader>()
731 .SetGroupName("Dsr");
732 return tid;
733}
734
735TypeId
737{
738 return GetTypeId();
739}
740
742 : m_errorType(0),
743 m_salvage(0),
744 m_errorLength(4)
745{
746 SetType(3);
747 SetLength(18);
748}
749
751{
752}
753
754void
756{
757 m_errorType = errorType;
758}
759
760uint8_t
762{
763 return m_errorType;
764}
765
766void
768{
769 m_salvage = salvage;
770}
771
772uint8_t
774{
775 return m_salvage;
776}
777
778void
780{
781 m_errorSrcAddress = errorSrcAddress;
782}
783
786{
787 return m_errorSrcAddress;
788}
789
790void
792{
793 m_errorDstAddress = errorDstAddress;
794}
795
798{
799 return m_errorDstAddress;
800}
801
802void
803DsrOptionRerrHeader::Print(std::ostream& os) const
804{
805 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
806 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
807 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
808}
809
812{
813 return 20;
814}
815
816void
818{
819 Buffer::Iterator i = start;
820
821 i.WriteU8(GetType());
822 i.WriteU8(GetLength());
828}
829
832{
833 Buffer::Iterator i = start;
834
835 SetType(i.ReadU8());
836 SetLength(i.ReadU8());
837 m_errorType = i.ReadU8();
838 m_salvage = i.ReadU8();
841
844 Buffer::Iterator dataStart = i;
846 Buffer::Iterator dataEnd = i;
847 m_errorData.Begin().Write(dataStart, dataEnd);
848
849 return GetSerializedSize();
850}
851
854{
855 Alignment retVal = {4, 0};
856 return retVal;
857}
858
860
861TypeId
863{
864 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnreachHeader")
866 .SetParent<DsrOptionRerrHeader>()
867 .SetGroupName("Dsr");
868 return tid;
869}
870
871TypeId
873{
874 return GetTypeId();
875}
876
878 : m_salvage(0)
879{
880 SetType(3);
881 SetLength(18);
882 SetErrorType(1);
883}
884
886{
887}
888
889void
891{
892 m_salvage = salvage;
893}
894
895uint8_t
897{
898 return m_salvage;
899}
900
901void
903{
904 m_errorSrcAddress = errorSrcAddress;
905}
906
909{
910 return m_errorSrcAddress;
911}
912
913void
915{
916 m_errorDstAddress = errorDstAddress;
917}
918
921{
922 return m_errorDstAddress;
923}
924
925void
927{
928 m_unreachNode = unreachNode;
929}
930
933{
934 return m_unreachNode;
935}
936
937void
939{
940 m_originalDst = originalDst;
941}
942
945{
946 return m_originalDst;
947}
948
949void
951{
952 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
953 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
954 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
955 << " unreach node = " << m_unreachNode << " )";
956}
957
960{
961 return 20;
962}
963
964void
966{
967 Buffer::Iterator i = start;
968
969 i.WriteU8(GetType());
970 i.WriteU8(GetLength());
977}
978
981{
982 Buffer::Iterator i = start;
983
984 SetType(i.ReadU8());
985 SetLength(i.ReadU8());
986 SetErrorType(i.ReadU8());
987 m_salvage = i.ReadU8();
992
993 return GetSerializedSize();
994}
995
998{
999 Alignment retVal = {4, 0};
1000 return retVal;
1001}
1002
1004
1005TypeId
1007{
1008 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnsupportedHeader")
1010 .SetParent<DsrOptionRerrHeader>()
1011 .SetGroupName("Dsr");
1012 return tid;
1013}
1014
1015TypeId
1017{
1018 return GetTypeId();
1019}
1020
1022 : m_salvage(0)
1023{
1024 SetType(3);
1025 SetLength(14);
1026 SetErrorType(3);
1027}
1028
1030{
1031}
1032
1033void
1035{
1036 m_salvage = salvage;
1037}
1038
1039uint8_t
1041{
1042 return m_salvage;
1043}
1044
1045void
1047{
1048 m_errorSrcAddress = errorSrcAddress;
1049}
1050
1053{
1054 return m_errorSrcAddress;
1055}
1056
1057void
1059{
1060 m_errorDstAddress = errorDstAddress;
1061}
1062
1065{
1066 return m_errorDstAddress;
1067}
1068
1069void
1071{
1073}
1074
1075uint16_t
1077{
1078 return m_unsupported;
1079}
1080
1081void
1083{
1084 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1085 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
1086 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
1087 << " unsupported option = " << m_unsupported << " )";
1088}
1089
1092{
1093 return 16;
1094}
1095
1096void
1098{
1099 Buffer::Iterator i = start;
1100
1101 i.WriteU8(GetType());
1102 i.WriteU8(GetLength());
1103 i.WriteU8(GetErrorType());
1104 i.WriteU8(m_salvage);
1108}
1109
1112{
1113 Buffer::Iterator i = start;
1114
1115 SetType(i.ReadU8());
1116 SetLength(i.ReadU8());
1117 SetErrorType(i.ReadU8());
1118 m_salvage = i.ReadU8();
1121 m_unsupported = i.ReadU16();
1122
1123 return GetSerializedSize();
1124}
1125
1128{
1129 Alignment retVal = {4, 0};
1130 return retVal;
1131}
1132
1134
1135TypeId
1137{
1138 static TypeId tid = TypeId("ns3::dsr::DsrOptionAckReqHeader")
1140 .SetParent<DsrOptionHeader>()
1141 .SetGroupName("Dsr");
1142 return tid;
1143}
1144
1145TypeId
1147{
1148 return GetTypeId();
1149}
1150
1152 : m_identification(0)
1153
1154{
1155 SetType(160);
1156 SetLength(2);
1157}
1158
1160{
1161}
1162
1163void
1164DsrOptionAckReqHeader::SetAckId(uint16_t identification)
1165{
1166 m_identification = identification;
1167}
1168
1169uint16_t
1171{
1172 return m_identification;
1173}
1174
1175void
1176DsrOptionAckReqHeader::Print(std::ostream& os) const
1177{
1178 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1179 << " id = " << m_identification << " )";
1180}
1181
1184{
1185 return 4;
1186}
1187
1188void
1190{
1191 Buffer::Iterator i = start;
1192
1193 i.WriteU8(GetType());
1194 i.WriteU8(GetLength());
1196}
1197
1200{
1201 Buffer::Iterator i = start;
1202
1203 SetType(i.ReadU8());
1204 SetLength(i.ReadU8());
1206
1207 return GetSerializedSize();
1208}
1209
1212{
1213 Alignment retVal = {4, 0};
1214 return retVal;
1215}
1216
1218
1219TypeId
1221{
1222 static TypeId tid = TypeId("ns3::dsr::DsrOptionAckHeader")
1224 .SetParent<DsrOptionHeader>()
1225 .SetGroupName("Dsr");
1226 return tid;
1227}
1228
1229TypeId
1231{
1232 return GetTypeId();
1233}
1234
1236 : m_identification(0)
1237{
1238 SetType(32);
1239 SetLength(10);
1240}
1241
1243{
1244}
1245
1246void
1247DsrOptionAckHeader::SetAckId(uint16_t identification)
1248{
1249 m_identification = identification;
1250}
1251
1252uint16_t
1254{
1255 return m_identification;
1256}
1257
1258void
1260{
1261 m_realSrcAddress = realSrcAddress;
1262}
1263
1266{
1267 return m_realSrcAddress;
1268}
1269
1270void
1272{
1273 m_realDstAddress = realDstAddress;
1274}
1275
1278{
1279 return m_realDstAddress;
1280}
1281
1282void
1283DsrOptionAckHeader::Print(std::ostream& os) const
1284{
1285 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1286 << " id = " << m_identification << " real src = " << m_realSrcAddress
1287 << " real dst = " << m_realDstAddress << " )";
1288}
1289
1292{
1293 return 12;
1294}
1295
1296void
1298{
1299 Buffer::Iterator i = start;
1300
1301 i.WriteU8(GetType());
1302 i.WriteU8(GetLength());
1306}
1307
1310{
1311 Buffer::Iterator i = start;
1312
1313 SetType(i.ReadU8());
1314 SetLength(i.ReadU8());
1318
1319 return GetSerializedSize();
1320}
1321
1324{
1325 Alignment retVal = {4, 0};
1326 return retVal;
1327}
1328} /* namespace dsr */
1329} /* 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:948
void WriteU16(uint16_t data)
Definition: buffer.cc:859
void Read(uint8_t *buffer, uint32_t size)
Definition: buffer.cc:1125
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:360
Buffer::Iterator End() const
Definition: buffer.h:1081
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
static Ipv4Address Deserialize(const uint8_t buf[4])
a unique identifier for an interface.
Definition: type-id.h:59
TypeId AddConstructor()
Record in this TypeId the fact that the default constructor is accessible.
Definition: type-id.h:651
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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize 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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
~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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Route Error (RERR) Unsupported option Message Format.
Ipv4Address GetErrorDst() const override
Get the error destination ip address.
void SetErrorSrc(Ipv4Address errorSrcAddress) override
Set the route error source address.
uint16_t GetUnsupported() const
Get the unsupported option type value.
static TypeId GetTypeId()
Get the type identificator.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint8_t m_errorType
The error type or route error option.
void SetSalvage(uint8_t salvage) override
Set the salvage value of the packet.
Ipv4Address m_errorDstAddress
The error destination address.
void SetUnsupported(uint16_t optionType)
Set the unsupported option type value.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Alignment GetAlignment() const override
Get the Alignment requirement of this option header.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void SetErrorDst(Ipv4Address errorDstAddress) override
Set the error destination ip address.
Ipv4Address m_errorSrcAddress
The error source address.
void Print(std::ostream &os) const override
Print some information about the packet.
uint16_t m_unsupported
The unsupported option.
Ipv4Address GetErrorSrc() const override
Get the route error source address.
uint8_t GetSalvage() const override
Get the salvage value of the packet.
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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
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 Deserialize(Buffer::Iterator start) override
Deserialize 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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the 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