A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ipv4-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#include "
ipv4-header.h
"
10
11
#include "ns3/abort.h"
12
#include "ns3/assert.h"
13
#include "ns3/header.h"
14
#include "ns3/log.h"
15
16
namespace
ns3
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"Ipv4Header"
);
20
21
NS_OBJECT_ENSURE_REGISTERED
(Ipv4Header);
22
23
Ipv4Header::Ipv4Header
()
24
: m_calcChecksum(false),
25
m_payloadSize(0),
26
m_identification(0),
27
m_tos(0),
28
m_ttl(0),
29
m_protocol(0),
30
m_flags(0),
31
m_fragmentOffset(0),
32
m_checksum(0),
33
m_goodChecksum(true),
34
m_headerSize(5 * 4)
35
{
36
}
37
38
void
39
Ipv4Header::EnableChecksum
()
40
{
41
NS_LOG_FUNCTION
(
this
);
42
m_calcChecksum
=
true
;
43
}
44
45
void
46
Ipv4Header::SetPayloadSize
(uint16_t size)
47
{
48
NS_LOG_FUNCTION
(
this
<< size);
49
m_payloadSize
= size;
50
}
51
52
uint16_t
53
Ipv4Header::GetPayloadSize
()
const
54
{
55
NS_LOG_FUNCTION
(
this
);
56
return
m_payloadSize
;
57
}
58
59
uint16_t
60
Ipv4Header::GetIdentification
()
const
61
{
62
NS_LOG_FUNCTION
(
this
);
63
return
m_identification
;
64
}
65
66
void
67
Ipv4Header::SetIdentification
(uint16_t identification)
68
{
69
NS_LOG_FUNCTION
(
this
<< identification);
70
m_identification
= identification;
71
}
72
73
void
74
Ipv4Header::SetTos
(uint8_t tos)
75
{
76
NS_LOG_FUNCTION
(
this
<<
static_cast<
uint32_t
>
(tos));
77
m_tos
= tos;
78
}
79
80
void
81
Ipv4Header::SetDscp
(
DscpType
dscp)
82
{
83
NS_LOG_FUNCTION
(
this
<< dscp);
84
m_tos
&= 0x3;
// Clear out the DSCP part, retain 2 bits of ECN
85
m_tos
|= (dscp << 2);
86
}
87
88
void
89
Ipv4Header::SetEcn
(
EcnType
ecn)
90
{
91
NS_LOG_FUNCTION
(
this
<< ecn);
92
m_tos
&= 0xFC;
// Clear out the ECN part, retain 6 bits of DSCP
93
m_tos
|= ecn;
94
}
95
96
Ipv4Header::DscpType
97
Ipv4Header::GetDscp
()
const
98
{
99
NS_LOG_FUNCTION
(
this
);
100
// Extract only first 6 bits of TOS byte, i.e 0xFC
101
return
DscpType
((
m_tos
& 0xFC) >> 2);
102
}
103
104
std::string
105
Ipv4Header::DscpTypeToString
(
DscpType
dscp)
const
106
{
107
NS_LOG_FUNCTION
(
this
<< dscp);
108
switch
(dscp)
109
{
110
case
DscpDefault
:
111
return
"Default"
;
112
case
DSCP_CS1
:
113
return
"CS1"
;
114
case
DSCP_AF11
:
115
return
"AF11"
;
116
case
DSCP_AF12
:
117
return
"AF12"
;
118
case
DSCP_AF13
:
119
return
"AF13"
;
120
case
DSCP_CS2
:
121
return
"CS2"
;
122
case
DSCP_AF21
:
123
return
"AF21"
;
124
case
DSCP_AF22
:
125
return
"AF22"
;
126
case
DSCP_AF23
:
127
return
"AF23"
;
128
case
DSCP_CS3
:
129
return
"CS3"
;
130
case
DSCP_AF31
:
131
return
"AF31"
;
132
case
DSCP_AF32
:
133
return
"AF32"
;
134
case
DSCP_AF33
:
135
return
"AF33"
;
136
case
DSCP_CS4
:
137
return
"CS4"
;
138
case
DSCP_AF41
:
139
return
"AF41"
;
140
case
DSCP_AF42
:
141
return
"AF42"
;
142
case
DSCP_AF43
:
143
return
"AF43"
;
144
case
DSCP_CS5
:
145
return
"CS5"
;
146
case
DSCP_EF
:
147
return
"EF"
;
148
case
DSCP_CS6
:
149
return
"CS6"
;
150
case
DSCP_CS7
:
151
return
"CS7"
;
152
default
:
153
return
"Unrecognized DSCP"
;
154
};
155
}
156
157
Ipv4Header::EcnType
158
Ipv4Header::GetEcn
()
const
159
{
160
NS_LOG_FUNCTION
(
this
);
161
// Extract only last 2 bits of TOS byte, i.e 0x3
162
return
EcnType
(
m_tos
& 0x3);
163
}
164
165
std::string
166
Ipv4Header::EcnTypeToString
(
EcnType
ecn)
const
167
{
168
NS_LOG_FUNCTION
(
this
<< ecn);
169
switch
(ecn)
170
{
171
case
ECN_NotECT
:
172
return
"Not-ECT"
;
173
case
ECN_ECT1
:
174
return
"ECT (1)"
;
175
case
ECN_ECT0
:
176
return
"ECT (0)"
;
177
case
ECN_CE
:
178
return
"CE"
;
179
default
:
180
return
"Unknown ECN"
;
181
};
182
}
183
184
uint8_t
185
Ipv4Header::GetTos
()
const
186
{
187
NS_LOG_FUNCTION
(
this
);
188
return
m_tos
;
189
}
190
191
void
192
Ipv4Header::SetMoreFragments
()
193
{
194
NS_LOG_FUNCTION
(
this
);
195
m_flags
|=
MORE_FRAGMENTS
;
196
}
197
198
void
199
Ipv4Header::SetLastFragment
()
200
{
201
NS_LOG_FUNCTION
(
this
);
202
m_flags
&= ~MORE_FRAGMENTS;
203
}
204
205
bool
206
Ipv4Header::IsLastFragment
()
const
207
{
208
NS_LOG_FUNCTION
(
this
);
209
return
!(
m_flags
&
MORE_FRAGMENTS
);
210
}
211
212
void
213
Ipv4Header::SetDontFragment
()
214
{
215
NS_LOG_FUNCTION
(
this
);
216
m_flags
|=
DONT_FRAGMENT
;
217
}
218
219
void
220
Ipv4Header::SetMayFragment
()
221
{
222
NS_LOG_FUNCTION
(
this
);
223
m_flags
&= ~DONT_FRAGMENT;
224
}
225
226
bool
227
Ipv4Header::IsDontFragment
()
const
228
{
229
NS_LOG_FUNCTION
(
this
);
230
return
(
m_flags
&
DONT_FRAGMENT
);
231
}
232
233
void
234
Ipv4Header::SetFragmentOffset
(uint16_t offsetBytes)
235
{
236
NS_LOG_FUNCTION
(
this
<< offsetBytes);
237
// check if the user is trying to set an invalid offset
238
NS_ABORT_MSG_IF
((offsetBytes & 0x7),
"offsetBytes must be multiple of 8 bytes"
);
239
m_fragmentOffset
= offsetBytes;
240
}
241
242
uint16_t
243
Ipv4Header::GetFragmentOffset
()
const
244
{
245
NS_LOG_FUNCTION
(
this
);
246
// -fstrict-overflow sensitive, see bug 1868
247
if
(
m_fragmentOffset
+
m_payloadSize
> 65535 - 5 * 4)
248
{
249
NS_LOG_WARN
(
"Fragment will exceed the maximum packet size once reassembled"
);
250
}
251
252
return
m_fragmentOffset
;
253
}
254
255
void
256
Ipv4Header::SetTtl
(uint8_t ttl)
257
{
258
NS_LOG_FUNCTION
(
this
<<
static_cast<
uint32_t
>
(ttl));
259
m_ttl
= ttl;
260
}
261
262
uint8_t
263
Ipv4Header::GetTtl
()
const
264
{
265
NS_LOG_FUNCTION
(
this
);
266
return
m_ttl
;
267
}
268
269
uint8_t
270
Ipv4Header::GetProtocol
()
const
271
{
272
NS_LOG_FUNCTION
(
this
);
273
return
m_protocol
;
274
}
275
276
void
277
Ipv4Header::SetProtocol
(uint8_t protocol)
278
{
279
NS_LOG_FUNCTION
(
this
<<
static_cast<
uint32_t
>
(protocol));
280
m_protocol
= protocol;
281
}
282
283
void
284
Ipv4Header::SetSource
(
Ipv4Address
source)
285
{
286
NS_LOG_FUNCTION
(
this
<< source);
287
m_source
= source;
288
}
289
290
Ipv4Address
291
Ipv4Header::GetSource
()
const
292
{
293
NS_LOG_FUNCTION
(
this
);
294
return
m_source
;
295
}
296
297
void
298
Ipv4Header::SetDestination
(
Ipv4Address
dst)
299
{
300
NS_LOG_FUNCTION
(
this
<< dst);
301
m_destination
= dst;
302
}
303
304
Ipv4Address
305
Ipv4Header::GetDestination
()
const
306
{
307
NS_LOG_FUNCTION
(
this
);
308
return
m_destination
;
309
}
310
311
bool
312
Ipv4Header::IsChecksumOk
()
const
313
{
314
NS_LOG_FUNCTION
(
this
);
315
return
m_goodChecksum
;
316
}
317
318
TypeId
319
Ipv4Header::GetTypeId
()
320
{
321
static
TypeId
tid =
TypeId
(
"ns3::Ipv4Header"
)
322
.
SetParent
<
Header
>()
323
.SetGroupName(
"Internet"
)
324
.AddConstructor<
Ipv4Header
>();
325
return
tid;
326
}
327
328
TypeId
329
Ipv4Header::GetInstanceTypeId
()
const
330
{
331
NS_LOG_FUNCTION
(
this
);
332
return
GetTypeId
();
333
}
334
335
void
336
Ipv4Header::Print
(std::ostream& os)
const
337
{
338
NS_LOG_FUNCTION
(
this
<< &os);
339
// ipv4, right ?
340
std::string flags;
341
if
(
m_flags
== 0)
342
{
343
flags =
"none"
;
344
}
345
else
if
((
m_flags
&
MORE_FRAGMENTS
) && (
m_flags
&
DONT_FRAGMENT
))
346
{
347
flags =
"MF|DF"
;
348
}
349
else
if
(
m_flags
&
DONT_FRAGMENT
)
350
{
351
flags =
"DF"
;
352
}
353
else
if
(
m_flags
&
MORE_FRAGMENTS
)
354
{
355
flags =
"MF"
;
356
}
357
else
358
{
359
flags =
"XX"
;
360
}
361
os <<
"tos 0x"
<< std::hex <<
m_tos
<< std::dec <<
" "
362
<<
"DSCP "
<<
DscpTypeToString
(
GetDscp
()) <<
" "
363
<<
"ECN "
<<
EcnTypeToString
(
GetEcn
()) <<
" "
364
<<
"ttl "
<<
m_ttl
<<
" "
365
<<
"id "
<<
m_identification
<<
" "
366
<<
"protocol "
<<
m_protocol
<<
" "
367
<<
"offset (bytes) "
<<
m_fragmentOffset
<<
" "
368
<<
"flags ["
<< flags <<
"] "
369
<<
"length: "
<< (
m_payloadSize
+ 5 * 4) <<
" "
<<
m_source
<<
" > "
<<
m_destination
;
370
}
371
372
uint32_t
373
Ipv4Header::GetSerializedSize
()
const
374
{
375
NS_LOG_FUNCTION
(
this
);
376
// return 5 * 4;
377
return
m_headerSize
;
378
}
379
380
void
381
Ipv4Header::Serialize
(
Buffer::Iterator
start)
const
382
{
383
NS_LOG_FUNCTION
(
this
<< &start);
384
Buffer::Iterator
i = start;
385
386
uint8_t verIhl = (4 << 4) | (5);
387
i.
WriteU8
(verIhl);
388
i.
WriteU8
(
m_tos
);
389
i.
WriteHtonU16
(
m_payloadSize
+ 5 * 4);
390
i.
WriteHtonU16
(
m_identification
);
391
uint32_t
fragmentOffset =
m_fragmentOffset
/ 8;
392
uint8_t flagsFrag = (fragmentOffset >> 8) & 0x1f;
393
if
(
m_flags
&
DONT_FRAGMENT
)
394
{
395
flagsFrag |= (1 << 6);
396
}
397
if
(
m_flags
&
MORE_FRAGMENTS
)
398
{
399
flagsFrag |= (1 << 5);
400
}
401
i.
WriteU8
(flagsFrag);
402
uint8_t frag = fragmentOffset & 0xff;
403
i.
WriteU8
(frag);
404
i.
WriteU8
(
m_ttl
);
405
i.
WriteU8
(
m_protocol
);
406
i.
WriteHtonU16
(0);
407
i.
WriteHtonU32
(
m_source
.
Get
());
408
i.
WriteHtonU32
(
m_destination
.
Get
());
409
410
if
(
m_calcChecksum
)
411
{
412
i = start;
413
uint16_t checksum = i.
CalculateIpChecksum
(20);
414
NS_LOG_LOGIC
(
"checksum="
<< checksum);
415
i = start;
416
i.
Next
(10);
417
i.
WriteU16
(checksum);
418
}
419
}
420
421
uint32_t
422
Ipv4Header::Deserialize
(
Buffer::Iterator
start)
423
{
424
NS_LOG_FUNCTION
(
this
<< &start);
425
Buffer::Iterator
i = start;
426
427
uint8_t verIhl = i.
ReadU8
();
428
uint8_t ihl = verIhl & 0x0f;
429
uint16_t headerSize = ihl * 4;
430
431
if
((verIhl >> 4) != 4)
432
{
433
NS_LOG_WARN
(
"Trying to decode a non-IPv4 header, refusing to do it."
);
434
return
0;
435
}
436
437
m_tos
= i.
ReadU8
();
438
uint16_t size = i.
ReadNtohU16
();
439
m_payloadSize
= size - headerSize;
440
m_identification
= i.
ReadNtohU16
();
441
uint8_t flags = i.
ReadU8
();
442
m_flags
= 0;
443
if
(flags & (1 << 6))
444
{
445
m_flags
|=
DONT_FRAGMENT
;
446
}
447
if
(flags & (1 << 5))
448
{
449
m_flags
|=
MORE_FRAGMENTS
;
450
}
451
i.
Prev
();
452
m_fragmentOffset
= i.
ReadU8
() & 0x1f;
453
m_fragmentOffset
<<= 8;
454
m_fragmentOffset
|= i.
ReadU8
();
455
m_fragmentOffset
<<= 3;
456
m_ttl
= i.
ReadU8
();
457
m_protocol
= i.
ReadU8
();
458
m_checksum
= i.
ReadU16
();
459
/* i.Next (2); // checksum */
460
m_source
.
Set
(i.
ReadNtohU32
());
461
m_destination
.
Set
(i.
ReadNtohU32
());
462
m_headerSize
= headerSize;
463
464
if
(
m_calcChecksum
)
465
{
466
i = start;
467
uint16_t checksum = i.
CalculateIpChecksum
(headerSize);
468
NS_LOG_LOGIC
(
"checksum="
<< checksum);
469
470
m_goodChecksum
= (checksum == 0);
471
}
472
return
GetSerializedSize
();
473
}
474
475
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition
buffer.h:1016
ns3::Buffer::Iterator::CalculateIpChecksum
uint16_t CalculateIpChecksum(uint16_t size)
Calculate the checksum.
Definition
buffer.cc:1124
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition
buffer.h:870
ns3::Buffer::Iterator::WriteU16
void WriteU16(uint16_t data)
Definition
buffer.cc:848
ns3::Buffer::Iterator::WriteHtonU16
void WriteHtonU16(uint16_t data)
Definition
buffer.h:904
ns3::Buffer::Iterator::ReadNtohU32
uint32_t ReadNtohU32()
Definition
buffer.h:967
ns3::Buffer::Iterator::WriteHtonU32
void WriteHtonU32(uint32_t data)
Definition
buffer.h:922
ns3::Buffer::Iterator::ReadNtohU16
uint16_t ReadNtohU16()
Definition
buffer.h:943
ns3::Buffer::Iterator::Prev
void Prev()
go backward by one byte
Definition
buffer.h:849
ns3::Buffer::Iterator::ReadU16
uint16_t ReadU16()
Definition
buffer.h:1024
ns3::Buffer::Iterator::Next
void Next()
go forward by one byte
Definition
buffer.h:842
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv4Address::Set
void Set(uint32_t address)
input address is in host order.
Definition
ipv4-address.cc:183
ns3::Ipv4Address::Get
uint32_t Get() const
Get the host-order 32-bit IP address.
Definition
ipv4-address.cc:176
ns3::Ipv4Header
Packet header for IPv4.
Definition
ipv4-header.h:23
ns3::Ipv4Header::m_source
Ipv4Address m_source
source address
Definition
ipv4-header.h:250
ns3::Ipv4Header::IsChecksumOk
bool IsChecksumOk() const
Definition
ipv4-header.cc:312
ns3::Ipv4Header::Print
void Print(std::ostream &os) const override
Definition
ipv4-header.cc:336
ns3::Ipv4Header::SetDestination
void SetDestination(Ipv4Address destination)
Definition
ipv4-header.cc:298
ns3::Ipv4Header::GetSource
Ipv4Address GetSource() const
Definition
ipv4-header.cc:291
ns3::Ipv4Header::m_fragmentOffset
uint16_t m_fragmentOffset
Fragment offset.
Definition
ipv4-header.h:249
ns3::Ipv4Header::SetDontFragment
void SetDontFragment()
Don't fragment this packet: if you need to anyway, drop it.
Definition
ipv4-header.cc:213
ns3::Ipv4Header::EcnTypeToString
std::string EcnTypeToString(EcnType ecn) const
Definition
ipv4-header.cc:166
ns3::Ipv4Header::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
ipv4-header.cc:329
ns3::Ipv4Header::MORE_FRAGMENTS
@ MORE_FRAGMENTS
Definition
ipv4-header.h:238
ns3::Ipv4Header::DONT_FRAGMENT
@ DONT_FRAGMENT
Definition
ipv4-header.h:237
ns3::Ipv4Header::GetTos
uint8_t GetTos() const
Definition
ipv4-header.cc:185
ns3::Ipv4Header::SetLastFragment
void SetLastFragment()
This packet is the last packet of a fragmented ipv4 packet.
Definition
ipv4-header.cc:199
ns3::Ipv4Header::m_ttl
uint32_t m_ttl
TTL.
Definition
ipv4-header.h:246
ns3::Ipv4Header::m_protocol
uint32_t m_protocol
Protocol.
Definition
ipv4-header.h:247
ns3::Ipv4Header::SetPayloadSize
void SetPayloadSize(uint16_t size)
Definition
ipv4-header.cc:46
ns3::Ipv4Header::GetEcn
EcnType GetEcn() const
Definition
ipv4-header.cc:158
ns3::Ipv4Header::m_identification
uint16_t m_identification
identification
Definition
ipv4-header.h:244
ns3::Ipv4Header::GetIdentification
uint16_t GetIdentification() const
Definition
ipv4-header.cc:60
ns3::Ipv4Header::IsDontFragment
bool IsDontFragment() const
Definition
ipv4-header.cc:227
ns3::Ipv4Header::GetProtocol
uint8_t GetProtocol() const
Definition
ipv4-header.cc:270
ns3::Ipv4Header::m_payloadSize
uint16_t m_payloadSize
payload size
Definition
ipv4-header.h:243
ns3::Ipv4Header::SetTtl
void SetTtl(uint8_t ttl)
Definition
ipv4-header.cc:256
ns3::Ipv4Header::IsLastFragment
bool IsLastFragment() const
Definition
ipv4-header.cc:206
ns3::Ipv4Header::m_tos
uint32_t m_tos
TOS, also used as DSCP + ECN value.
Definition
ipv4-header.h:245
ns3::Ipv4Header::m_goodChecksum
bool m_goodChecksum
true if checksum is correct
Definition
ipv4-header.h:253
ns3::Ipv4Header::SetMoreFragments
void SetMoreFragments()
This packet is not the last packet of a fragmented ipv4 packet.
Definition
ipv4-header.cc:192
ns3::Ipv4Header::GetDestination
Ipv4Address GetDestination() const
Definition
ipv4-header.cc:305
ns3::Ipv4Header::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
ipv4-header.cc:381
ns3::Ipv4Header::SetDscp
void SetDscp(DscpType dscp)
Set DSCP Field.
Definition
ipv4-header.cc:81
ns3::Ipv4Header::m_destination
Ipv4Address m_destination
destination address
Definition
ipv4-header.h:251
ns3::Ipv4Header::SetMayFragment
void SetMayFragment()
If you need to fragment this packet, you can do it.
Definition
ipv4-header.cc:220
ns3::Ipv4Header::EcnType
EcnType
ECN Type defined in RFC 3168
Definition
ipv4-header.h:103
ns3::Ipv4Header::ECN_ECT0
@ ECN_ECT0
Definition
ipv4-header.h:107
ns3::Ipv4Header::ECN_NotECT
@ ECN_NotECT
Definition
ipv4-header.h:105
ns3::Ipv4Header::ECN_ECT1
@ ECN_ECT1
Definition
ipv4-header.h:106
ns3::Ipv4Header::ECN_CE
@ ECN_CE
Definition
ipv4-header.h:108
ns3::Ipv4Header::m_checksum
uint16_t m_checksum
checksum
Definition
ipv4-header.h:252
ns3::Ipv4Header::m_headerSize
uint16_t m_headerSize
IP header size.
Definition
ipv4-header.h:254
ns3::Ipv4Header::GetDscp
DscpType GetDscp() const
Definition
ipv4-header.cc:97
ns3::Ipv4Header::GetPayloadSize
uint16_t GetPayloadSize() const
Definition
ipv4-header.cc:53
ns3::Ipv4Header::SetEcn
void SetEcn(EcnType ecn)
Set ECN Field.
Definition
ipv4-header.cc:89
ns3::Ipv4Header::DscpType
DscpType
DiffServ codepoints.
Definition
ipv4-header.h:61
ns3::Ipv4Header::DSCP_AF23
@ DSCP_AF23
Definition
ipv4-header.h:73
ns3::Ipv4Header::DSCP_CS2
@ DSCP_CS2
Definition
ipv4-header.h:70
ns3::Ipv4Header::DscpDefault
@ DscpDefault
Definition
ipv4-header.h:62
ns3::Ipv4Header::DSCP_AF31
@ DSCP_AF31
Definition
ipv4-header.h:76
ns3::Ipv4Header::DSCP_AF32
@ DSCP_AF32
Definition
ipv4-header.h:77
ns3::Ipv4Header::DSCP_AF13
@ DSCP_AF13
Definition
ipv4-header.h:68
ns3::Ipv4Header::DSCP_AF22
@ DSCP_AF22
Definition
ipv4-header.h:72
ns3::Ipv4Header::DSCP_AF43
@ DSCP_AF43
Definition
ipv4-header.h:83
ns3::Ipv4Header::DSCP_AF11
@ DSCP_AF11
Definition
ipv4-header.h:66
ns3::Ipv4Header::DSCP_CS3
@ DSCP_CS3
Definition
ipv4-header.h:75
ns3::Ipv4Header::DSCP_AF42
@ DSCP_AF42
Definition
ipv4-header.h:82
ns3::Ipv4Header::DSCP_AF21
@ DSCP_AF21
Definition
ipv4-header.h:71
ns3::Ipv4Header::DSCP_AF33
@ DSCP_AF33
Definition
ipv4-header.h:78
ns3::Ipv4Header::DSCP_AF12
@ DSCP_AF12
Definition
ipv4-header.h:67
ns3::Ipv4Header::DSCP_CS5
@ DSCP_CS5
Definition
ipv4-header.h:85
ns3::Ipv4Header::DSCP_EF
@ DSCP_EF
Definition
ipv4-header.h:86
ns3::Ipv4Header::DSCP_CS4
@ DSCP_CS4
Definition
ipv4-header.h:80
ns3::Ipv4Header::DSCP_CS7
@ DSCP_CS7
Definition
ipv4-header.h:89
ns3::Ipv4Header::DSCP_CS6
@ DSCP_CS6
Definition
ipv4-header.h:88
ns3::Ipv4Header::DSCP_CS1
@ DSCP_CS1
Definition
ipv4-header.h:65
ns3::Ipv4Header::DSCP_AF41
@ DSCP_AF41
Definition
ipv4-header.h:81
ns3::Ipv4Header::DscpTypeToString
std::string DscpTypeToString(DscpType dscp) const
Definition
ipv4-header.cc:105
ns3::Ipv4Header::m_flags
uint32_t m_flags
flags
Definition
ipv4-header.h:248
ns3::Ipv4Header::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
ipv4-header.cc:373
ns3::Ipv4Header::GetFragmentOffset
uint16_t GetFragmentOffset() const
Definition
ipv4-header.cc:243
ns3::Ipv4Header::SetProtocol
void SetProtocol(uint8_t num)
Definition
ipv4-header.cc:277
ns3::Ipv4Header::SetFragmentOffset
void SetFragmentOffset(uint16_t offsetBytes)
The offset is measured in bytes for the packet start.
Definition
ipv4-header.cc:234
ns3::Ipv4Header::SetIdentification
void SetIdentification(uint16_t identification)
Definition
ipv4-header.cc:67
ns3::Ipv4Header::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ipv4-header.cc:319
ns3::Ipv4Header::GetTtl
uint8_t GetTtl() const
Definition
ipv4-header.cc:263
ns3::Ipv4Header::EnableChecksum
void EnableChecksum()
Enable checksum calculation for this header.
Definition
ipv4-header.cc:39
ns3::Ipv4Header::SetTos
void SetTos(uint8_t tos)
Definition
ipv4-header.cc:74
ns3::Ipv4Header::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
ipv4-header.cc:422
ns3::Ipv4Header::SetSource
void SetSource(Ipv4Address source)
Definition
ipv4-header.cc:284
ns3::Ipv4Header::Ipv4Header
Ipv4Header()
Construct a null IPv4 header.
Definition
ipv4-header.cc:23
ns3::Ipv4Header::m_calcChecksum
bool m_calcChecksum
true if the checksum must be calculated
Definition
ipv4-header.h:241
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_ABORT_MSG_IF
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition
abort.h:97
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition
log.h:271
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition
log.h:250
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ipv4-header.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
internet
model
ipv4-header.cc
Generated on Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0