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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
7 *
8 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
9 * ResiliNets Research Group https://resilinets.org/
10 * Information and Telecommunication Technology Center (ITTC)
11 * and Department of Electrical Engineering and Computer Science
12 * The University of Kansas Lawrence, KS USA.
13 *
14 * Work supported in part by NSF FIND (Future Internet Design) Program
15 * under grant CNS-0626918 (Postmodern Internet Architecture),
16 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
17 * US Department of Defense (DoD), and ITTC at The University of Kansas.
18 */
19
20#include "dsr-option-header.h"
21
22#include "ns3/address-utils.h"
23#include "ns3/assert.h"
24#include "ns3/enum.h"
25#include "ns3/header.h"
26#include "ns3/ipv4-address.h"
27#include "ns3/log.h"
28#include "ns3/packet.h"
29
30namespace ns3
31{
32
33NS_LOG_COMPONENT_DEFINE("DsrOptionHeader");
34
35namespace dsr
36{
37
38NS_OBJECT_ENSURE_REGISTERED(DsrOptionHeader);
39
40TypeId
42{
43 static TypeId tid = TypeId("ns3::dsr::DsrOptionHeader")
45 .SetParent<Header>()
46 .SetGroupName("Dsr");
47 return tid;
48}
49
52{
53 return GetTypeId();
54}
55
57 : m_type(0),
58 m_length(0)
59{
60}
61
65
66void
68{
69 m_type = type;
70}
71
72uint8_t
74{
75 return m_type;
76}
77
78void
80{
81 m_length = length;
82}
83
84uint8_t
86{
87 return m_length;
88}
89
90void
91DsrOptionHeader::Print(std::ostream& os) const
92{
93 os << "( type = " << (uint32_t)m_type << " length = " << (uint32_t)m_length << " )";
94}
95
98{
99 return m_length + 2;
100}
101
102void
104{
105 Buffer::Iterator i = start;
106
107 i.WriteU8(m_type);
108 i.WriteU8(m_length);
109 i.Write(m_data.Begin(), m_data.End());
110}
111
114{
115 Buffer::Iterator i = start;
116
117 m_type = i.ReadU8();
118 m_length = i.ReadU8();
119
120 m_data = Buffer();
122 Buffer::Iterator dataStart = i;
123 i.Next(m_length);
124 Buffer::Iterator dataEnd = i;
125 m_data.Begin().Write(dataStart, dataEnd);
126
127 return GetSerializedSize();
128}
129
132{
133 Alignment retVal = {1, 0};
134 return retVal;
135}
136
138
139TypeId
141{
142 static TypeId tid = TypeId("ns3::dsr::DsrOptionPad1Header")
144 .SetParent<DsrOptionHeader>()
145 .SetGroupName("Dsr");
146 return tid;
147}
148
149TypeId
151{
152 return GetTypeId();
153}
154
159
163
164void
165DsrOptionPad1Header::Print(std::ostream& os) const
166{
167 os << "( type = " << (uint32_t)GetType() << " )";
168}
169
172{
173 return 1;
174}
175
176void
178{
179 Buffer::Iterator i = start;
180
181 i.WriteU8(GetType());
182}
183
186{
187 Buffer::Iterator i = start;
188
189 SetType(i.ReadU8());
190
191 return GetSerializedSize();
192}
193
195
196TypeId
198{
199 static TypeId tid = TypeId("ns3::dsr::DsrOptionPadnHeader")
201 .SetParent<DsrOptionHeader>()
202 .SetGroupName("Dsr");
203 return tid;
204}
205
206TypeId
208{
209 return GetTypeId();
210}
211
213{
214 SetType(0);
215 NS_ASSERT_MSG(pad >= 2, "PadN must be at least 2 bytes long");
216 SetLength(pad - 2);
217}
218
222
223void
224DsrOptionPadnHeader::Print(std::ostream& os) const
225{
226 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << " )";
227}
228
231{
232 return GetLength() + 2;
233}
234
235void
237{
238 Buffer::Iterator i = start;
239
240 i.WriteU8(GetType());
241 i.WriteU8(GetLength());
242
243 for (int padding = 0; padding < GetLength(); padding++)
244 {
245 i.WriteU8(0);
246 }
247}
248
251{
252 Buffer::Iterator i = start;
253
254 SetType(i.ReadU8());
255 SetLength(i.ReadU8());
256
257 return GetSerializedSize();
258}
259
261
262TypeId
264{
265 static TypeId tid = TypeId("ns3::dsr::DsrOptionRreqHeader")
267 .SetParent<DsrOptionHeader>()
268 .SetGroupName("Dsr");
269 return tid;
270}
271
272TypeId
274{
275 return GetTypeId();
276}
277
279 : m_ipv4Address(0)
280{
281 SetType(1);
282 SetLength(6 + m_ipv4Address.size() * 4);
283}
284
288
289void
291{
292 m_ipv4Address.clear();
293 m_ipv4Address.assign(n, Ipv4Address());
294}
295
301
302void
307
308void
310{
311 m_ipv4Address.push_back(ipv4);
312 SetLength(6 + m_ipv4Address.size() * 4);
313}
314
315void
316DsrOptionRreqHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
317{
318 m_ipv4Address = ipv4Address;
319 SetLength(6 + m_ipv4Address.size() * 4);
320}
321
322std::vector<Ipv4Address>
327
330{
331 return m_ipv4Address.size();
332}
333
334void
336{
337 m_ipv4Address.at(index) = addr;
338}
339
342{
343 return m_ipv4Address.at(index);
344}
345
346void
347DsrOptionRreqHeader::SetId(uint16_t identification)
348{
349 m_identification = identification;
350}
351
352uint16_t
354{
355 return m_identification;
356}
357
358void
359DsrOptionRreqHeader::Print(std::ostream& os) const
360{
361 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
362
363 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
364 {
365 os << *it << " ";
366 }
367
368 os << ")";
369}
370
373{
374 return 8 + m_ipv4Address.size() * 4;
375}
376
377void
379{
380 Buffer::Iterator i = start;
381 uint8_t buff[4];
382
383 i.WriteU8(GetType());
384 i.WriteU8(GetLength());
386 WriteTo(i, m_target);
387
388 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
389 {
390 it->Serialize(buff);
391 i.Write(buff, 4);
392 }
393}
394
397{
398 Buffer::Iterator i = start;
399 uint8_t buff[4];
400
401 SetType(i.ReadU8());
402 SetLength(i.ReadU8());
404 ReadFrom(i, m_target);
405
406 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
407 {
408 i.Read(buff, 4);
410 SetNodeAddress(static_cast<uint8_t>(index), m_address);
411 }
412
413 return GetSerializedSize();
414}
415
418{
419 Alignment retVal = {4, 0};
420 return retVal;
421}
422
424
425TypeId
427{
428 static TypeId tid = TypeId("ns3::dsr::DsrOptionRrepHeader")
430 .SetParent<DsrOptionHeader>()
431 .SetGroupName("Dsr");
432 return tid;
433}
434
435TypeId
437{
438 return GetTypeId();
439}
440
442 : m_ipv4Address(0)
443{
444 SetType(2);
445 SetLength(2 + m_ipv4Address.size() * 4);
446}
447
451
452void
454{
455 m_ipv4Address.clear();
456 m_ipv4Address.assign(n, Ipv4Address());
457}
458
459void
460DsrOptionRrepHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
461{
462 m_ipv4Address = ipv4Address;
463 SetLength(2 + m_ipv4Address.size() * 4);
464}
465
466std::vector<Ipv4Address>
471
472void
474{
475 m_ipv4Address.at(index) = addr;
476}
477
480{
481 return m_ipv4Address.at(index);
482}
483
485DsrOptionRrepHeader::GetTargetAddress(std::vector<Ipv4Address> ipv4Address) const
486{
487 return m_ipv4Address.at(ipv4Address.size() - 1);
488}
489
490void
491DsrOptionRrepHeader::Print(std::ostream& os) const
492{
493 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
494
495 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
496 {
497 os << *it << " ";
498 }
499
500 os << ")";
501}
502
505{
506 return 4 + m_ipv4Address.size() * 4;
507}
508
509void
511{
512 Buffer::Iterator i = start;
513 uint8_t buff[4];
514
515 i.WriteU8(GetType());
516 i.WriteU8(GetLength());
517 i.WriteU8(0);
518 i.WriteU8(0);
519
520 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
521 {
522 it->Serialize(buff);
523 i.Write(buff, 4);
524 }
525}
526
529{
530 Buffer::Iterator i = start;
531 uint8_t buff[4];
532
533 SetType(i.ReadU8());
534 SetLength(i.ReadU8());
535 i.ReadU8();
536 i.ReadU8();
537
538 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
539 {
540 i.Read(buff, 4);
542 SetNodeAddress(static_cast<uint8_t>(index), m_address);
543 }
544
545 return GetSerializedSize();
546}
547
550{
551 Alignment retVal = {4, 0};
552 return retVal;
553}
554
556
557TypeId
559{
560 static TypeId tid = TypeId("ns3::dsr::DsrOptionSRHeader")
562 .SetParent<DsrOptionHeader>()
563 .SetGroupName("Dsr");
564 return tid;
565}
566
567TypeId
569{
570 return GetTypeId();
571}
572
574 : m_segmentsLeft(0),
575 m_ipv4Address(0)
576{
577 SetType(96);
578 SetLength(2 + m_ipv4Address.size() * 4);
579}
580
584
585void
587{
588 m_segmentsLeft = segmentsLeft;
589}
590
591uint8_t
596
597void
599{
600 m_salvage = salvage;
601}
602
603uint8_t
605{
606 return m_salvage;
607}
608
609void
611{
612 m_ipv4Address.clear();
613 m_ipv4Address.assign(n, Ipv4Address());
614}
615
616void
617DsrOptionSRHeader::SetNodesAddress(std::vector<Ipv4Address> ipv4Address)
618{
619 m_ipv4Address = ipv4Address;
620 SetLength(2 + m_ipv4Address.size() * 4);
621}
622
623std::vector<Ipv4Address>
628
629void
631{
632 m_ipv4Address.at(index) = addr;
633}
634
637{
638 return m_ipv4Address.at(index);
639}
640
641uint8_t
643{
644 return m_ipv4Address.size();
645}
646
647void
648DsrOptionSRHeader::Print(std::ostream& os) const
649{
650 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << "";
651
652 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
653 {
654 os << *it << " ";
655 }
656
657 os << ")";
658}
659
662{
663 return 4 + m_ipv4Address.size() * 4;
664}
665
666void
668{
669 Buffer::Iterator i = start;
670 uint8_t buff[4];
671
672 i.WriteU8(GetType());
673 i.WriteU8(GetLength());
676
677 for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++)
678 {
679 it->Serialize(buff);
680 i.Write(buff, 4);
681 }
682}
683
686{
687 Buffer::Iterator i = start;
688 uint8_t buff[4];
689
690 SetType(i.ReadU8());
691 SetLength(i.ReadU8());
692 m_salvage = i.ReadU8();
694
695 for (std::size_t index = 0; index < m_ipv4Address.size(); index++)
696 {
697 i.Read(buff, 4);
699 SetNodeAddress(static_cast<uint8_t>(index), m_address);
700 }
701
702 return GetSerializedSize();
703}
704
707{
708 Alignment retVal = {4, 0};
709 return retVal;
710}
711
713
714TypeId
716{
717 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrHeader")
719 .SetParent<DsrOptionHeader>()
720 .SetGroupName("Dsr");
721 return tid;
722}
723
724TypeId
726{
727 return GetTypeId();
728}
729
731 : m_errorType(0),
732 m_salvage(0),
733 m_errorLength(4)
734{
735 SetType(3);
736 SetLength(18);
737}
738
742
743void
745{
746 m_errorType = errorType;
747}
748
749uint8_t
751{
752 return m_errorType;
753}
754
755void
757{
758 m_salvage = salvage;
759}
760
761uint8_t
763{
764 return m_salvage;
765}
766
767void
769{
770 m_errorSrcAddress = errorSrcAddress;
771}
772
778
779void
781{
782 m_errorDstAddress = errorDstAddress;
783}
784
790
791void
792DsrOptionRerrHeader::Print(std::ostream& os) const
793{
794 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
795 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
796 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress << " )";
797}
798
801{
802 return 20;
803}
804
805void
818
821{
822 Buffer::Iterator i = start;
823
824 SetType(i.ReadU8());
825 SetLength(i.ReadU8());
826 m_errorType = i.ReadU8();
827 m_salvage = i.ReadU8();
830
833 Buffer::Iterator dataStart = i;
835 Buffer::Iterator dataEnd = i;
836 m_errorData.Begin().Write(dataStart, dataEnd);
837
838 return GetSerializedSize();
839}
840
843{
844 Alignment retVal = {4, 0};
845 return retVal;
846}
847
849
850TypeId
852{
853 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnreachHeader")
855 .SetParent<DsrOptionRerrHeader>()
856 .SetGroupName("Dsr");
857 return tid;
858}
859
860TypeId
865
867 : m_salvage(0)
868{
869 SetType(3);
870 SetLength(18);
871 SetErrorType(1);
872}
873
877
878void
880{
881 m_salvage = salvage;
882}
883
884uint8_t
889
890void
892{
893 m_errorSrcAddress = errorSrcAddress;
894}
895
901
902void
904{
905 m_errorDstAddress = errorDstAddress;
906}
907
913
914void
919
925
926void
931
937
938void
940{
941 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
942 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
943 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
944 << " unreach node = " << m_unreachNode << " )";
945}
946
949{
950 return 20;
951}
952
953void
967
984
987{
988 Alignment retVal = {4, 0};
989 return retVal;
990}
991
993
994TypeId
996{
997 static TypeId tid = TypeId("ns3::dsr::DsrOptionRerrUnsupportedHeader")
999 .SetParent<DsrOptionRerrHeader>()
1000 .SetGroupName("Dsr");
1001 return tid;
1002}
1003
1004TypeId
1009
1011 : m_salvage(0)
1012{
1013 SetType(3);
1014 SetLength(14);
1015 SetErrorType(3);
1016}
1017
1021
1022void
1024{
1025 m_salvage = salvage;
1026}
1027
1028uint8_t
1033
1034void
1036{
1037 m_errorSrcAddress = errorSrcAddress;
1038}
1039
1045
1046void
1048{
1049 m_errorDstAddress = errorDstAddress;
1050}
1051
1057
1058void
1060{
1061 m_unsupported = unsupported;
1062}
1063
1064uint16_t
1069
1070void
1072{
1073 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1074 << " errorType = " << (uint32_t)m_errorType << " salvage = " << (uint32_t)m_salvage
1075 << " error source = " << m_errorSrcAddress << " error dst = " << m_errorDstAddress
1076 << " unsupported option = " << m_unsupported << " )";
1077}
1078
1081{
1082 return 16;
1083}
1084
1085void
1098
1101{
1102 Buffer::Iterator i = start;
1103
1104 SetType(i.ReadU8());
1105 SetLength(i.ReadU8());
1106 SetErrorType(i.ReadU8());
1107 m_salvage = i.ReadU8();
1110 m_unsupported = i.ReadU16();
1111
1112 return GetSerializedSize();
1113}
1114
1117{
1118 Alignment retVal = {4, 0};
1119 return retVal;
1120}
1121
1123
1124TypeId
1126{
1127 static TypeId tid = TypeId("ns3::dsr::DsrOptionAckReqHeader")
1129 .SetParent<DsrOptionHeader>()
1130 .SetGroupName("Dsr");
1131 return tid;
1132}
1133
1134TypeId
1136{
1137 return GetTypeId();
1138}
1139
1141 : m_identification(0)
1142
1143{
1144 SetType(160);
1145 SetLength(2);
1146}
1147
1151
1152void
1153DsrOptionAckReqHeader::SetAckId(uint16_t identification)
1154{
1155 m_identification = identification;
1156}
1157
1158uint16_t
1160{
1161 return m_identification;
1162}
1163
1164void
1165DsrOptionAckReqHeader::Print(std::ostream& os) const
1166{
1167 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1168 << " id = " << m_identification << " )";
1169}
1170
1173{
1174 return 4;
1175}
1176
1177void
1179{
1180 Buffer::Iterator i = start;
1181
1182 i.WriteU8(GetType());
1183 i.WriteU8(GetLength());
1185}
1186
1189{
1190 Buffer::Iterator i = start;
1191
1192 SetType(i.ReadU8());
1193 SetLength(i.ReadU8());
1195
1196 return GetSerializedSize();
1197}
1198
1201{
1202 Alignment retVal = {4, 0};
1203 return retVal;
1204}
1205
1207
1208TypeId
1210{
1211 static TypeId tid = TypeId("ns3::dsr::DsrOptionAckHeader")
1213 .SetParent<DsrOptionHeader>()
1214 .SetGroupName("Dsr");
1215 return tid;
1216}
1217
1218TypeId
1220{
1221 return GetTypeId();
1222}
1223
1225 : m_identification(0)
1226{
1227 SetType(32);
1228 SetLength(10);
1229}
1230
1234
1235void
1236DsrOptionAckHeader::SetAckId(uint16_t identification)
1237{
1238 m_identification = identification;
1239}
1240
1241uint16_t
1243{
1244 return m_identification;
1245}
1246
1247void
1249{
1250 m_realSrcAddress = realSrcAddress;
1251}
1252
1255{
1256 return m_realSrcAddress;
1257}
1258
1259void
1261{
1262 m_realDstAddress = realDstAddress;
1263}
1264
1267{
1268 return m_realDstAddress;
1269}
1270
1271void
1272DsrOptionAckHeader::Print(std::ostream& os) const
1273{
1274 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1275 << " id = " << m_identification << " real src = " << m_realSrcAddress
1276 << " real dst = " << m_realDstAddress << " )";
1277}
1278
1281{
1282 return 12;
1283}
1284
1285void
1296
1299{
1300 Buffer::Iterator i = start;
1301
1302 SetType(i.ReadU8());
1303 SetLength(i.ReadU8());
1307
1308 return GetSerializedSize();
1309}
1310
1313{
1314 Alignment retVal = {4, 0};
1315 return retVal;
1316}
1317} /* namespace dsr */
1318} /* namespace ns3 */
iterator in a Buffer instance
Definition buffer.h:89
void WriteU8(uint8_t data)
Definition buffer.h:870
void Write(const uint8_t *buffer, uint32_t size)
Definition buffer.cc:937
void WriteU16(uint16_t data)
Definition buffer.cc:848
void Read(uint8_t *buffer, uint32_t size)
Definition buffer.cc:1114
void WriteHtonU16(uint16_t data)
Definition buffer.h:904
uint16_t ReadNtohU16()
Definition buffer.h:943
uint16_t ReadU16()
Definition buffer.h:1024
void Next()
go forward by one byte
Definition buffer.h:842
automatically resized byte buffer
Definition buffer.h:83
Buffer::Iterator Begin() const
Definition buffer.h:1063
void AddAtEnd(uint32_t end)
Definition buffer.cc:349
Buffer::Iterator End() const
Definition buffer.h:1070
Ipv4 addresses are stored in host order in this class.
static Ipv4Address Deserialize(const uint8_t buf[4])
a unique identifier for an interface.
Definition type-id.h:48
TypeId AddConstructor()
Record in this TypeId the fact that the default constructor is accessible.
Definition type-id.h:670
Header of Dsr Option ack.
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.
Header of Dsr Option ack request.
~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 salvage 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.
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.
Header of Dsr Option Route Reply.
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.
Header of Dsr Option Route Request.
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 deserializing 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.
Header of Dsr Option Source Route.
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 deserialize 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 salvage 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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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.