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 (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
386{
387 return 8 + m_ipv4Address.size() * 4;
388}
389
390void
392{
393 Buffer::Iterator i = start;
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
411{
412 Buffer::Iterator i = start;
413 uint8_t buff[4];
414
415 SetType(i.ReadU8());
416 SetLength(i.ReadU8());
418 ReadFrom(i, m_target);
419
420 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
421 {
422 i.Read(buff, 4);
424 SetNodeAddress(static_cast<uint8_t>(index), m_address);
425 }
426
427 return GetSerializedSize();
428}
429
432{
433 Alignment retVal = {4, 0};
434 return retVal;
435}
436
438
439TypeId
441{
442 static TypeId tid = TypeId("ns3::dsr::DsrOptionRrepHeader")
444 .SetParent<DsrOptionHeader>()
445 .SetGroupName("Dsr");
446 return tid;
447}
448
449TypeId
451{
452 return GetTypeId();
453}
454
456 : m_ipv4Address(0)
457{
458 SetType(2);
459 SetLength(2 + m_ipv4Address.size() * 4);
460}
461
463{
464}
465
466void
468{
469 m_ipv4Address.clear();
470 m_ipv4Address.assign(n, Ipv4Address());
471}
472
473void
474DsrOptionRrepHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
475{
476 m_ipv4Address = ipv4Address;
477 SetLength(2 + m_ipv4Address.size() * 4);
478}
479
480std::vector<Ipv4Address>
482{
483 return m_ipv4Address;
484}
485
486void
488{
489 m_ipv4Address.at(index) = addr;
490}
491
494{
495 return m_ipv4Address.at(index);
496}
497
499DsrOptionRrepHeader::GetTargetAddress(std::vector<Ipv4Address> ipv4Address) const
500{
501 return m_ipv4Address.at(ipv4Address.size() - 1);
502}
503
504void
505DsrOptionRrepHeader::Print(std::ostream& os) const
506{
507 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
508
509 for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin();
510 it != m_ipv4Address.end();
511 it++)
512 {
513 os << *it << " ";
514 }
515
516 os << ")";
517}
518
521{
522 return 4 + m_ipv4Address.size() * 4;
523}
524
525void
527{
528 Buffer::Iterator i = start;
529 uint8_t buff[4];
530
531 i.WriteU8(GetType());
532 i.WriteU8(GetLength());
533 i.WriteU8(0);
534 i.WriteU8(0);
535
536 for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
537 it++)
538 {
539 it->Serialize(buff);
540 i.Write(buff, 4);
541 }
542}
543
546{
547 Buffer::Iterator i = start;
548 uint8_t buff[4];
549
550 SetType(i.ReadU8());
551 SetLength(i.ReadU8());
552 i.ReadU8();
553 i.ReadU8();
554
555 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
556 {
557 i.Read(buff, 4);
559 SetNodeAddress(static_cast<uint8_t>(index), m_address);
560 }
561
562 return GetSerializedSize();
563}
564
567{
568 Alignment retVal = {4, 0};
569 return retVal;
570}
571
573
574TypeId
576{
577 static TypeId tid = TypeId("ns3::dsr::DsrOptionSRHeader")
579 .SetParent<DsrOptionHeader>()
580 .SetGroupName("Dsr");
581 return tid;
582}
583
584TypeId
586{
587 return GetTypeId();
588}
589
591 : m_segmentsLeft(0),
592 m_ipv4Address(0)
593{
594 SetType(96);
595 SetLength(2 + m_ipv4Address.size() * 4);
596}
597
599{
600}
601
602void
604{
605 m_segmentsLeft = segmentsLeft;
606}
607
608uint8_t
610{
611 return m_segmentsLeft;
612}
613
614void
616{
617 m_salvage = salvage;
618}
619
620uint8_t
622{
623 return m_salvage;
624}
625
626void
628{
629 m_ipv4Address.clear();
630 m_ipv4Address.assign(n, Ipv4Address());
631}
632
633void
634DsrOptionSRHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
635{
636 m_ipv4Address = ipv4Address;
637 SetLength(2 + m_ipv4Address.size() * 4);
638}
639
640std::vector<Ipv4Address>
642{
643 return m_ipv4Address;
644}
645
646void
648{
649 m_ipv4Address.at(index) = addr;
650}
651
654{
655 return m_ipv4Address.at(index);
656}
657
658uint8_t
660{
661 return m_ipv4Address.size();
662}
663
664void
665DsrOptionSRHeader::Print(std::ostream& os) const
666{
667 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
668
669 for (std::vector<Ipv4Address>::const_iterator it = m_ipv4Address.begin();
670 it != m_ipv4Address.end();
671 it++)
672 {
673 os << *it << " ";
674 }
675
676 os << ")";
677}
678
681{
682 return 4 + m_ipv4Address.size() * 4;
683}
684
685void
687{
688 Buffer::Iterator i = start;
689 uint8_t buff[4];
690
691 i.WriteU8(GetType());
692 i.WriteU8(GetLength());
695
696 for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end();
697 it++)
698 {
699 it->Serialize(buff);
700 i.Write(buff, 4);
701 }
702}
703
706{
707 Buffer::Iterator i = start;
708 uint8_t buff[4];
709
710 SetType(i.ReadU8());
711 SetLength(i.ReadU8());
712 m_salvage = i.ReadU8();
714
715 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
716 {
717 i.Read(buff, 4);
719 SetNodeAddress(static_cast<uint8_t>(index), m_address);
720 }
721
722 return GetSerializedSize();
723}
724
727{
728 Alignment retVal = {4, 0};
729 return retVal;
730}
731
733
734TypeId
736{
737 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrHeader")
739 .SetParent<DsrOptionHeader>()
740 .SetGroupName("Dsr");
741 return tid;
742}
743
744TypeId
746{
747 return GetTypeId();
748}
749
751 : m_errorType(0),
752 m_salvage(0),
753 m_errorLength(4)
754{
755 SetType(3);
756 SetLength(18);
757}
758
760{
761}
762
763void
765{
766 m_errorType = errorType;
767}
768
769uint8_t
771{
772 return m_errorType;
773}
774
775void
777{
778 m_salvage = salvage;
779}
780
781uint8_t
783{
784 return m_salvage;
785}
786
787void
789{
790 m_errorSrcAddress = errorSrcAddress;
791}
792
795{
796 return m_errorSrcAddress;
797}
798
799void
801{
802 m_errorDstAddress = errorDstAddress;
803}
804
807{
808 return m_errorDstAddress;
809}
810
811void
812DsrOptionRerrHeader::Print(std::ostream& os) const
813{
814 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
815 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
816 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
817}
818
821{
822 return 20;
823}
824
825void
827{
828 Buffer::Iterator i = start;
829
830 i.WriteU8(GetType());
831 i.WriteU8(GetLength());
837}
838
841{
842 Buffer::Iterator i = start;
843
844 SetType(i.ReadU8());
845 SetLength(i.ReadU8());
846 m_errorType = i.ReadU8();
847 m_salvage = i.ReadU8();
850
853 Buffer::Iterator dataStart = i;
855 Buffer::Iterator dataEnd = i;
856 m_errorData.Begin().Write(dataStart, dataEnd);
857
858 return GetSerializedSize();
859}
860
863{
864 Alignment retVal = {4, 0};
865 return retVal;
866}
867
869
870TypeId
872{
873 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnreachHeader")
875 .SetParent<DsrOptionRerrHeader>()
876 .SetGroupName("Dsr");
877 return tid;
878}
879
880TypeId
882{
883 return GetTypeId();
884}
885
887 : m_salvage(0)
888{
889 SetType(3);
890 SetLength(18);
891 SetErrorType(1);
892}
893
895{
896}
897
898void
900{
901 m_salvage = salvage;
902}
903
904uint8_t
906{
907 return m_salvage;
908}
909
910void
912{
913 m_errorSrcAddress = errorSrcAddress;
914}
915
918{
919 return m_errorSrcAddress;
920}
921
922void
924{
925 m_errorDstAddress = errorDstAddress;
926}
927
930{
931 return m_errorDstAddress;
932}
933
934void
936{
937 m_unreachNode = unreachNode;
938}
939
942{
943 return m_unreachNode;
944}
945
946void
948{
949 m_originalDst = originalDst;
950}
951
954{
955 return m_originalDst;
956}
957
958void
960{
961 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
962 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
963 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
964 << " unreach node = " << m_unreachNode << " )";
965}
966
969{
970 return 20;
971}
972
973void
975{
976 Buffer::Iterator i = start;
977
978 i.WriteU8(GetType());
979 i.WriteU8(GetLength());
986}
987
990{
991 Buffer::Iterator i = start;
992
993 SetType(i.ReadU8());
994 SetLength(i.ReadU8());
995 SetErrorType(i.ReadU8());
996 m_salvage = i.ReadU8();
1001
1002 return GetSerializedSize();
1003}
1004
1007{
1008 Alignment retVal = {4, 0};
1009 return retVal;
1010}
1011
1013
1014TypeId
1016{
1017 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnsupportedHeader")
1019 .SetParent<DsrOptionRerrHeader>()
1020 .SetGroupName("Dsr");
1021 return tid;
1022}
1023
1024TypeId
1026{
1027 return GetTypeId();
1028}
1029
1031 : m_salvage(0)
1032{
1033 SetType(3);
1034 SetLength(14);
1035 SetErrorType(3);
1036}
1037
1039{
1040}
1041
1042void
1044{
1045 m_salvage = salvage;
1046}
1047
1048uint8_t
1050{
1051 return m_salvage;
1052}
1053
1054void
1056{
1057 m_errorSrcAddress = errorSrcAddress;
1058}
1059
1062{
1063 return m_errorSrcAddress;
1064}
1065
1066void
1068{
1069 m_errorDstAddress = errorDstAddress;
1070}
1071
1074{
1075 return m_errorDstAddress;
1076}
1077
1078void
1080{
1082}
1083
1084uint16_t
1086{
1087 return m_unsupported;
1088}
1089
1090void
1092{
1093 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1094 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
1095 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
1096 << " unsupported option = " << m_unsupported << " )";
1097}
1098
1101{
1102 return 16;
1103}
1104
1105void
1107{
1108 Buffer::Iterator i = start;
1109
1110 i.WriteU8(GetType());
1111 i.WriteU8(GetLength());
1112 i.WriteU8(GetErrorType());
1113 i.WriteU8(m_salvage);
1117}
1118
1121{
1122 Buffer::Iterator i = start;
1123
1124 SetType(i.ReadU8());
1125 SetLength(i.ReadU8());
1126 SetErrorType(i.ReadU8());
1127 m_salvage = i.ReadU8();
1130 m_unsupported = i.ReadU16();
1131
1132 return GetSerializedSize();
1133}
1134
1137{
1138 Alignment retVal = {4, 0};
1139 return retVal;
1140}
1141
1143
1144TypeId
1146{
1147 static TypeId tid = TypeId("ns3::dsr::DsrOptionAckReqHeader")
1149 .SetParent<DsrOptionHeader>()
1150 .SetGroupName("Dsr");
1151 return tid;
1152}
1153
1154TypeId
1156{
1157 return GetTypeId();
1158}
1159
1161 : m_identification(0)
1162
1163{
1164 SetType(160);
1165 SetLength(2);
1166}
1167
1169{
1170}
1171
1172void
1173DsrOptionAckReqHeader::SetAckId(uint16_t identification)
1174{
1175 m_identification = identification;
1176}
1177
1178uint16_t
1180{
1181 return m_identification;
1182}
1183
1184void
1185DsrOptionAckReqHeader::Print(std::ostream& os) const
1186{
1187 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1188 << " id = " << m_identification << " )";
1189}
1190
1193{
1194 return 4;
1195}
1196
1197void
1199{
1200 Buffer::Iterator i = start;
1201
1202 i.WriteU8(GetType());
1203 i.WriteU8(GetLength());
1205}
1206
1209{
1210 Buffer::Iterator i = start;
1211
1212 SetType(i.ReadU8());
1213 SetLength(i.ReadU8());
1215
1216 return GetSerializedSize();
1217}
1218
1221{
1222 Alignment retVal = {4, 0};
1223 return retVal;
1224}
1225
1227
1228TypeId
1230{
1231 static TypeId tid = TypeId("ns3::dsr::DsrOptionAckHeader")
1233 .SetParent<DsrOptionHeader>()
1234 .SetGroupName("Dsr");
1235 return tid;
1236}
1237
1238TypeId
1240{
1241 return GetTypeId();
1242}
1243
1245 : m_identification(0)
1246{
1247 SetType(32);
1248 SetLength(10);
1249}
1250
1252{
1253}
1254
1255void
1256DsrOptionAckHeader::SetAckId(uint16_t identification)
1257{
1258 m_identification = identification;
1259}
1260
1261uint16_t
1263{
1264 return m_identification;
1265}
1266
1267void
1269{
1270 m_realSrcAddress = realSrcAddress;
1271}
1272
1275{
1276 return m_realSrcAddress;
1277}
1278
1279void
1281{
1282 m_realDstAddress = realDstAddress;
1283}
1284
1287{
1288 return m_realDstAddress;
1289}
1290
1291void
1292DsrOptionAckHeader::Print(std::ostream& os) const
1293{
1294 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1295 << " id = " << m_identification << " real src = " << m_realSrcAddress
1296 << " real dst = " << m_realDstAddress << " )";
1297}
1298
1301{
1302 return 12;
1303}
1304
1305void
1307{
1308 Buffer::Iterator i = start;
1309
1310 i.WriteU8(GetType());
1311 i.WriteU8(GetLength());
1315}
1316
1319{
1320 Buffer::Iterator i = start;
1321
1322 SetType(i.ReadU8());
1323 SetLength(i.ReadU8());
1327
1328 return GetSerializedSize();
1329}
1330
1333{
1334 Alignment retVal = {4, 0};
1335 return retVal;
1336}
1337} /* namespace dsr */
1338} /* 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:954
void WriteU16(uint16_t data)
Definition: buffer.cc:865
void Read(uint8_t *buffer, uint32_t size)
Definition: buffer.cc:1131
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
@ unsupported
Definition: lr-wpan-mac.h:350
#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