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
lr-wpan-mac-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 The Boeing Company
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: kwong yin <kwong-sang.yin@boeing.com>
7
*/
8
#include "
lr-wpan-mac-header.h
"
9
10
#include <ns3/address-utils.h>
11
12
namespace
ns3
13
{
14
namespace
lrwpan
15
{
16
17
NS_OBJECT_ENSURE_REGISTERED
(LrWpanMacHeader);
18
19
// TODO: Test Compressed PAN Id, Security Enabled, different size Key
20
21
LrWpanMacHeader::LrWpanMacHeader
()
22
{
23
SetType
(
LRWPAN_MAC_DATA
);
// Assume Data frame
24
SetSecDisable
();
// Assume there is No Aux Sec but
25
SetNoFrmPend
();
// No Frame Pending
26
SetNoAckReq
();
// No Ack Frame will be expected from recipient
27
SetNoPanIdComp
();
// No PAN Id Compression since no addresses
28
SetFrmCtrlRes
(0);
// Initialize the 3 reserved bits to 0
29
SetDstAddrMode
(
NOADDR
);
// Assume there will be no src and dst address
30
SetSrcAddrMode
(
NOADDR
);
31
SetFrameVer
(1);
// Indicates an IEEE 802.15.4 frame
32
}
33
34
LrWpanMacHeader::LrWpanMacHeader
(
LrWpanMacType
wpanMacType, uint8_t seqNum)
35
{
36
SetType
(wpanMacType);
37
SetSeqNum
(seqNum);
38
SetSecDisable
();
// Assume there is No Aux Sec but
39
SetNoFrmPend
();
// No Frame Pending
40
SetNoAckReq
();
// No Ack Frame will be expected from recipient
41
SetNoPanIdComp
();
// No PAN Id Compression since no addresses
42
SetFrmCtrlRes
(0);
// Initialize the 3 reserved bits to 0
43
SetDstAddrMode
(
NOADDR
);
// Assume there will be no src and dst address
44
SetSrcAddrMode
(
NOADDR
);
45
SetFrameVer
(1);
// Indicates an IEEE 802.15.4 frame
46
}
47
48
LrWpanMacHeader::~LrWpanMacHeader
()
49
{
50
}
51
52
LrWpanMacHeader::LrWpanMacType
53
LrWpanMacHeader::GetType
()
const
54
{
55
switch
(
m_fctrlFrmType
)
56
{
57
case
0:
58
return
LRWPAN_MAC_BEACON
;
59
case
1:
60
return
LRWPAN_MAC_DATA
;
61
case
2:
62
return
LRWPAN_MAC_ACKNOWLEDGMENT
;
63
case
3:
64
return
LRWPAN_MAC_COMMAND
;
65
default
:
66
return
LRWPAN_MAC_RESERVED
;
67
}
68
}
69
70
uint16_t
71
LrWpanMacHeader::GetFrameControl
()
const
72
{
73
uint16_t val = 0;
74
75
val =
m_fctrlFrmType
& (0x07);
// Bit 0-2
76
val |= (
m_fctrlSecU
<< 3) & (0x01 << 3);
// Bit 3
77
val |= (
m_fctrlFrmPending
<< 4) & (0x01 << 4);
// Bit 4
78
val |= (
m_fctrlAckReq
<< 5) & (0x01 << 5);
// Bit 5
79
val |= (
m_fctrlPanIdComp
<< 6) & (0x01 << 6);
// Bit 6
80
val |= (
m_fctrlReserved
<< 7) & (0x07 << 7);
// Bit 7-9
81
val |= (
m_fctrlDstAddrMode
<< 10) & (0x03 << 10);
// Bit 10-11
82
val |= (
m_fctrlFrmVer
<< 12) & (0x03 << 12);
// Bit 12-13
83
val |= (
m_fctrlSrcAddrMode
<< 14) & (0x03 << 14);
// Bit 14-15
84
return
val;
85
}
86
87
bool
88
LrWpanMacHeader::IsSecEnable
()
const
89
{
90
return
(
m_fctrlSecU
== 1);
91
}
92
93
bool
94
LrWpanMacHeader::IsFrmPend
()
const
95
{
96
return
(
m_fctrlFrmPending
== 1);
97
}
98
99
bool
100
LrWpanMacHeader::IsAckReq
()
const
101
{
102
return
(
m_fctrlAckReq
== 1);
103
}
104
105
bool
106
LrWpanMacHeader::IsPanIdComp
()
const
107
{
108
return
(
m_fctrlPanIdComp
== 1);
109
}
110
111
uint8_t
112
LrWpanMacHeader::GetFrmCtrlRes
()
const
113
{
114
return
m_fctrlReserved
;
115
}
116
117
uint8_t
118
LrWpanMacHeader::GetDstAddrMode
()
const
119
{
120
return
m_fctrlDstAddrMode
;
121
}
122
123
uint8_t
124
LrWpanMacHeader::GetFrameVer
()
const
125
{
126
return
m_fctrlFrmVer
;
127
}
128
129
uint8_t
130
LrWpanMacHeader::GetSrcAddrMode
()
const
131
{
132
return
m_fctrlSrcAddrMode
;
133
}
134
135
uint8_t
136
LrWpanMacHeader::GetSeqNum
()
const
137
{
138
return
m_SeqNum
;
139
}
140
141
uint16_t
142
LrWpanMacHeader::GetDstPanId
()
const
143
{
144
return
m_addrDstPanId
;
145
}
146
147
Mac16Address
148
LrWpanMacHeader::GetShortDstAddr
()
const
149
{
150
return
m_addrShortDstAddr
;
151
}
152
153
Mac64Address
154
LrWpanMacHeader::GetExtDstAddr
()
const
155
{
156
return
m_addrExtDstAddr
;
157
}
158
159
uint16_t
160
LrWpanMacHeader::GetSrcPanId
()
const
161
{
162
return
m_addrSrcPanId
;
163
}
164
165
Mac16Address
166
LrWpanMacHeader::GetShortSrcAddr
()
const
167
{
168
return
m_addrShortSrcAddr
;
169
}
170
171
Mac64Address
172
LrWpanMacHeader::GetExtSrcAddr
()
const
173
{
174
return
m_addrExtSrcAddr
;
175
}
176
177
uint8_t
178
LrWpanMacHeader::GetSecControl
()
const
179
{
180
uint8_t val = 0;
181
182
val =
m_secctrlSecLevel
& (0x7);
// Bit 0-2
183
val |= (
m_secctrlKeyIdMode
<< 3) & (0x3 << 3);
// Bit 3-4
184
val |= (
m_secctrlReserved
<< 5) & (0x7 << 5);
// Bit 5-7
185
186
return
val;
187
}
188
189
uint32_t
190
LrWpanMacHeader::GetFrmCounter
()
const
191
{
192
return
m_auxFrmCntr
;
193
}
194
195
uint8_t
196
LrWpanMacHeader::GetSecLevel
()
const
197
{
198
return
m_secctrlSecLevel
;
199
}
200
201
uint8_t
202
LrWpanMacHeader::GetKeyIdMode
()
const
203
{
204
return
m_secctrlKeyIdMode
;
205
}
206
207
uint8_t
208
LrWpanMacHeader::GetSecCtrlReserved
()
const
209
{
210
return
m_secctrlReserved
;
211
}
212
213
uint32_t
214
LrWpanMacHeader::GetKeyIdSrc32
()
const
215
{
216
return
m_auxKeyIdKeySrc32
;
217
}
218
219
uint64_t
220
LrWpanMacHeader::GetKeyIdSrc64
()
const
221
{
222
return
m_auxKeyIdKeySrc64
;
223
}
224
225
uint8_t
226
LrWpanMacHeader::GetKeyIdIndex
()
const
227
{
228
return
m_auxKeyIdKeyIndex
;
229
}
230
231
bool
232
LrWpanMacHeader::IsBeacon
()
const
233
{
234
return
(
m_fctrlFrmType
==
LRWPAN_MAC_BEACON
);
235
}
236
237
bool
238
LrWpanMacHeader::IsData
()
const
239
{
240
return
(
m_fctrlFrmType
==
LRWPAN_MAC_DATA
);
241
}
242
243
bool
244
LrWpanMacHeader::IsAcknowledgment
()
const
245
{
246
return
(
m_fctrlFrmType
==
LRWPAN_MAC_ACKNOWLEDGMENT
);
247
}
248
249
bool
250
LrWpanMacHeader::IsCommand
()
const
251
{
252
return
(
m_fctrlFrmType
==
LRWPAN_MAC_COMMAND
);
253
}
254
255
void
256
LrWpanMacHeader::SetType
(
LrWpanMacType
wpanMacType)
257
{
258
m_fctrlFrmType
= wpanMacType;
259
}
260
261
void
262
LrWpanMacHeader::SetFrameControl
(uint16_t frameControl)
263
{
264
m_fctrlFrmType
= (frameControl) & (0x07);
// Bit 0-2
265
m_fctrlSecU
= (frameControl >> 3) & (0x01);
// Bit 3
266
m_fctrlFrmPending
= (frameControl >> 4) & (0x01);
// Bit 4
267
m_fctrlAckReq
= (frameControl >> 5) & (0x01);
// Bit 5
268
m_fctrlPanIdComp
= (frameControl >> 6) & (0x01);
// Bit 6
269
m_fctrlReserved
= (frameControl >> 7) & (0x07);
// Bit 7-9
270
m_fctrlDstAddrMode
= (frameControl >> 10) & (0x03);
// Bit 10-11
271
m_fctrlFrmVer
= (frameControl >> 12) & (0x03);
// Bit 12-13
272
m_fctrlSrcAddrMode
= (frameControl >> 14) & (0x03);
// Bit 14-15
273
}
274
275
void
276
LrWpanMacHeader::SetSecEnable
()
277
{
278
m_fctrlSecU
= 1;
279
}
280
281
void
282
LrWpanMacHeader::SetSecDisable
()
283
{
284
m_fctrlSecU
= 0;
285
}
286
287
void
288
LrWpanMacHeader::SetFrmPend
()
289
{
290
m_fctrlFrmPending
= 1;
291
}
292
293
void
294
LrWpanMacHeader::SetNoFrmPend
()
295
{
296
m_fctrlFrmPending
= 0;
297
}
298
299
void
300
LrWpanMacHeader::SetAckReq
()
301
{
302
m_fctrlAckReq
= 1;
303
}
304
305
void
306
LrWpanMacHeader::SetNoAckReq
()
307
{
308
m_fctrlAckReq
= 0;
309
}
310
311
void
312
LrWpanMacHeader::SetPanIdComp
()
313
{
314
m_fctrlPanIdComp
= 1;
315
}
316
317
void
318
LrWpanMacHeader::SetNoPanIdComp
()
319
{
320
m_fctrlPanIdComp
= 0;
321
}
322
323
void
324
LrWpanMacHeader::SetFrmCtrlRes
(uint8_t res)
325
{
326
m_fctrlReserved
= res;
327
}
328
329
void
330
LrWpanMacHeader::SetDstAddrMode
(uint8_t addrMode)
331
{
332
m_fctrlDstAddrMode
= addrMode;
333
}
334
335
void
336
LrWpanMacHeader::SetFrameVer
(uint8_t ver)
337
{
338
m_fctrlFrmVer
= ver;
339
}
340
341
void
342
LrWpanMacHeader::SetSrcAddrMode
(uint8_t addrMode)
343
{
344
m_fctrlSrcAddrMode
= addrMode;
345
}
346
347
void
348
LrWpanMacHeader::SetSeqNum
(uint8_t seqNum)
349
{
350
m_SeqNum
= seqNum;
351
}
352
353
void
354
LrWpanMacHeader::SetSrcAddrFields
(uint16_t panId,
Mac16Address
addr)
355
{
356
m_addrSrcPanId
= panId;
357
m_addrShortSrcAddr
= addr;
358
}
359
360
void
361
LrWpanMacHeader::SetSrcAddrFields
(uint16_t panId,
Mac64Address
addr)
362
{
363
m_addrSrcPanId
= panId;
364
m_addrExtSrcAddr
= addr;
365
}
366
367
void
368
LrWpanMacHeader::SetDstAddrFields
(uint16_t panId,
Mac16Address
addr)
369
{
370
m_addrDstPanId
= panId;
371
m_addrShortDstAddr
= addr;
372
}
373
374
void
375
LrWpanMacHeader::SetDstAddrFields
(uint16_t panId,
Mac64Address
addr)
376
{
377
m_addrDstPanId
= panId;
378
m_addrExtDstAddr
= addr;
379
}
380
381
void
382
LrWpanMacHeader::SetSecControl
(uint8_t secControl)
383
{
384
m_secctrlSecLevel
= (secControl) & (0x07);
// Bit 0-2
385
m_secctrlKeyIdMode
= (secControl >> 3) & (0x03);
// Bit 3-4
386
m_secctrlReserved
= (secControl >> 5) & (0x07);
// Bit 5-7
387
}
388
389
void
390
LrWpanMacHeader::SetFrmCounter
(
uint32_t
frmCntr)
391
{
392
m_auxFrmCntr
= frmCntr;
393
}
394
395
void
396
LrWpanMacHeader::SetSecLevel
(uint8_t secLevel)
397
{
398
m_secctrlSecLevel
= secLevel;
399
}
400
401
void
402
LrWpanMacHeader::SetKeyIdMode
(uint8_t keyIdMode)
403
{
404
m_secctrlKeyIdMode
= keyIdMode;
405
}
406
407
void
408
LrWpanMacHeader::SetSecCtrlReserved
(uint8_t res)
409
{
410
m_secctrlReserved
= res;
411
}
412
413
void
414
LrWpanMacHeader::SetKeyId
(uint8_t keyIndex)
415
{
416
m_auxKeyIdKeyIndex
= keyIndex;
417
}
418
419
void
420
LrWpanMacHeader::SetKeyId
(
uint32_t
keySrc, uint8_t keyIndex)
421
{
422
m_auxKeyIdKeyIndex
= keyIndex;
423
m_auxKeyIdKeySrc32
= keySrc;
424
}
425
426
void
427
LrWpanMacHeader::SetKeyId
(uint64_t keySrc, uint8_t keyIndex)
428
{
429
m_auxKeyIdKeyIndex
= keyIndex;
430
m_auxKeyIdKeySrc64
= keySrc;
431
}
432
433
TypeId
434
LrWpanMacHeader::GetTypeId
()
435
{
436
static
TypeId
tid =
TypeId
(
"ns3::lrwpan::LrWpanMacHeader"
)
437
.
AddDeprecatedName
(
"ns3::LrWpanMacHeader"
)
438
.
SetParent
<
Header
>()
439
.SetGroupName(
"LrWpan"
)
440
.AddConstructor<
LrWpanMacHeader
>();
441
return
tid;
442
}
443
444
TypeId
445
LrWpanMacHeader::GetInstanceTypeId
()
const
446
{
447
return
GetTypeId
();
448
}
449
450
void
451
LrWpanMacHeader::Print
(std::ostream& os)
const
452
{
453
os <<
" Frame Type = "
<< (
uint32_t
)
m_fctrlFrmType
454
<<
", Sec Enable = "
<< (
uint32_t
)
m_fctrlSecU
455
<<
", Frame Pending = "
<< (
uint32_t
)
m_fctrlFrmPending
456
<<
", Ack Request = "
<< (
uint32_t
)
m_fctrlAckReq
457
<<
", PAN ID Compress = "
<< (
uint32_t
)
m_fctrlPanIdComp
458
<<
", Frame Vers = "
<< (
uint32_t
)
m_fctrlFrmVer
459
<<
", Dst Addrs Mode = "
<< (
uint32_t
)
m_fctrlDstAddrMode
460
<<
", Src Addr Mode = "
<< (
uint32_t
)
m_fctrlSrcAddrMode
;
461
462
os <<
", Sequence Num = "
<<
static_cast<
uint16_t
>
(
m_SeqNum
);
463
464
switch
(
m_fctrlDstAddrMode
)
465
{
466
case
NOADDR
:
467
break
;
468
case
SHORTADDR
:
469
os <<
", Dst Addr Pan ID = "
<<
static_cast<
uint16_t
>
(
m_addrDstPanId
)
470
<<
", m_addrShortDstAddr = "
<<
m_addrShortDstAddr
;
471
break
;
472
case
EXTADDR
:
473
os <<
", Dst Addr Pan ID = "
<<
static_cast<
uint16_t
>
(
m_addrDstPanId
)
474
<<
", m_addrExtDstAddr = "
<<
m_addrExtDstAddr
;
475
break
;
476
}
477
478
switch
(
m_fctrlSrcAddrMode
)
479
{
480
case
NOADDR
:
481
break
;
482
case
SHORTADDR
:
483
os <<
", Src Addr Pan ID = "
<<
static_cast<
uint16_t
>
(
m_addrSrcPanId
)
484
<<
", m_addrShortSrcAddr = "
<<
m_addrShortSrcAddr
;
485
break
;
486
case
EXTADDR
:
487
os <<
", Src Addr Pan ID = "
<<
static_cast<
uint32_t
>
(
m_addrSrcPanId
)
488
<<
", m_addrExtSrcAddr = "
<<
m_addrExtDstAddr
;
489
break
;
490
}
491
492
if
(
IsSecEnable
())
493
{
494
os <<
" Security Level = "
<<
static_cast<
uint32_t
>
(
m_secctrlSecLevel
)
495
<<
", Key Id Mode = "
<<
static_cast<
uint32_t
>
(
m_secctrlKeyIdMode
)
496
<<
", Frame Counter = "
<<
static_cast<
uint32_t
>
(
m_auxFrmCntr
);
497
498
switch
(
m_secctrlKeyIdMode
)
499
{
500
case
IMPLICIT
:
501
break
;
502
case
NOKEYSOURCE
:
503
os <<
", Key Id - Key Index = "
<<
static_cast<
uint32_t
>
(
m_auxKeyIdKeyIndex
);
504
break
;
505
case
SHORTKEYSOURCE
:
506
os <<
", Key Id - Key Source 32 ="
<<
static_cast<
uint32_t
>
(
m_auxKeyIdKeySrc32
)
507
<<
", Key Id - Key Index = "
<<
static_cast<
uint32_t
>
(
m_auxKeyIdKeyIndex
);
508
break
;
509
case
LONGKEYSOURCE
:
510
os <<
", Key Id - Key Source 64 ="
<<
static_cast<
uint64_t
>
(
m_auxKeyIdKeySrc64
)
511
<<
", Key Id - Key Index = "
<<
static_cast<
uint32_t
>
(
m_auxKeyIdKeyIndex
);
512
break
;
513
}
514
}
515
}
516
517
uint32_t
518
LrWpanMacHeader::GetSerializedSize
()
const
519
{
520
/*
521
* Each mac header will have
522
* Frame Control : 2 octet
523
* Sequence Number : 1 Octet
524
* Dst PAN Id : 0/2 Octet
525
* Dst Address : 0/2/8 octet
526
* Src PAN Id : 0/2 octet
527
* Src Address : 0/2/8 octet
528
* Aux Sec Header : 0/5/6/10/14 octet
529
*/
530
531
uint32_t
size = 3;
532
533
switch
(
m_fctrlDstAddrMode
)
534
{
535
case
NOADDR
:
536
break
;
537
case
SHORTADDR
:
538
size += 4;
539
break
;
540
case
EXTADDR
:
541
size += 10;
542
break
;
543
}
544
545
switch
(
m_fctrlSrcAddrMode
)
546
{
547
case
NOADDR
:
548
break
;
549
case
SHORTADDR
:
550
// check if PAN Id compression is enabled
551
if
(!
IsPanIdComp
())
552
{
553
size += 4;
554
}
555
else
556
{
557
size += 2;
558
}
559
break
;
560
case
EXTADDR
:
561
// check if PAN Id compression is enabled
562
if
(!
IsPanIdComp
())
563
{
564
size += 10;
565
}
566
else
567
{
568
size += 8;
569
}
570
break
;
571
}
572
573
// check if security is enabled
574
if
(
IsSecEnable
())
575
{
576
size += 5;
577
switch
(
m_secctrlKeyIdMode
)
578
{
579
case
IMPLICIT
:
580
break
;
581
case
NOKEYSOURCE
:
582
size += 1;
583
break
;
584
case
SHORTKEYSOURCE
:
585
size += 5;
586
break
;
587
case
LONGKEYSOURCE
:
588
size += 9;
589
break
;
590
}
591
}
592
return
size;
593
}
594
595
void
596
LrWpanMacHeader::Serialize
(
Buffer::Iterator
start)
const
597
{
598
Buffer::Iterator
i = start;
599
uint16_t frameControl =
GetFrameControl
();
600
601
i.
WriteHtolsbU16
(frameControl);
602
i.
WriteU8
(
GetSeqNum
());
603
604
switch
(
m_fctrlDstAddrMode
)
605
{
606
case
NOADDR
:
607
break
;
608
case
SHORTADDR
:
609
i.
WriteHtolsbU16
(
GetDstPanId
());
610
WriteTo
(i,
m_addrShortDstAddr
);
611
break
;
612
case
EXTADDR
:
613
i.
WriteHtolsbU16
(
GetDstPanId
());
614
WriteTo
(i,
m_addrExtDstAddr
);
615
break
;
616
}
617
618
switch
(
m_fctrlSrcAddrMode
)
619
{
620
case
NOADDR
:
621
break
;
622
case
SHORTADDR
:
623
if
(!
IsPanIdComp
())
624
{
625
i.
WriteHtolsbU16
(
GetSrcPanId
());
626
}
627
WriteTo
(i,
m_addrShortSrcAddr
);
628
break
;
629
case
EXTADDR
:
630
if
(!
IsPanIdComp
())
631
{
632
i.
WriteHtolsbU16
(
GetSrcPanId
());
633
}
634
WriteTo
(i,
m_addrExtSrcAddr
);
635
break
;
636
}
637
638
if
(
IsSecEnable
())
639
{
640
i.
WriteU8
(
GetSecControl
());
641
i.
WriteHtolsbU32
(
GetFrmCounter
());
642
643
switch
(
m_secctrlKeyIdMode
)
644
{
645
case
IMPLICIT
:
646
break
;
647
case
NOKEYSOURCE
:
648
i.
WriteU8
(
GetKeyIdIndex
());
649
break
;
650
case
SHORTKEYSOURCE
:
651
i.
WriteHtolsbU32
(
GetKeyIdSrc32
());
652
i.
WriteU8
(
GetKeyIdIndex
());
653
break
;
654
case
LONGKEYSOURCE
:
655
i.
WriteHtolsbU64
(
GetKeyIdSrc64
());
656
i.
WriteU8
(
GetKeyIdIndex
());
657
break
;
658
}
659
}
660
}
661
662
uint32_t
663
LrWpanMacHeader::Deserialize
(
Buffer::Iterator
start)
664
{
665
Buffer::Iterator
i = start;
666
uint16_t frameControl = i.
ReadLsbtohU16
();
667
SetFrameControl
(frameControl);
668
669
SetSeqNum
(i.
ReadU8
());
670
switch
(
m_fctrlDstAddrMode
)
671
{
672
case
NOADDR
:
673
break
;
674
case
SHORTADDR
:
675
m_addrDstPanId
= i.
ReadLsbtohU16
();
676
ReadFrom
(i,
m_addrShortDstAddr
);
677
break
;
678
case
EXTADDR
:
679
m_addrDstPanId
= i.
ReadLsbtohU16
();
680
ReadFrom
(i,
m_addrExtDstAddr
);
681
break
;
682
}
683
684
switch
(
m_fctrlSrcAddrMode
)
685
{
686
case
NOADDR
:
687
break
;
688
case
SHORTADDR
:
689
if
(!
IsPanIdComp
())
690
{
691
m_addrSrcPanId
= i.
ReadLsbtohU16
();
692
}
693
else
694
{
695
if
(
m_fctrlDstAddrMode
> 0)
696
{
697
m_addrSrcPanId
=
m_addrDstPanId
;
698
}
699
}
700
ReadFrom
(i,
m_addrShortSrcAddr
);
701
break
;
702
case
EXTADDR
:
703
if
(!
IsPanIdComp
())
704
{
705
m_addrSrcPanId
= i.
ReadLsbtohU16
();
706
}
707
else
708
{
709
if
(
m_fctrlDstAddrMode
> 0)
710
{
711
m_addrSrcPanId
=
m_addrDstPanId
;
712
}
713
}
714
ReadFrom
(i,
m_addrExtSrcAddr
);
715
break
;
716
}
717
718
if
(
IsSecEnable
())
719
{
720
SetSecControl
(i.
ReadU8
());
721
SetFrmCounter
(i.
ReadLsbtohU32
());
722
723
switch
(
m_secctrlKeyIdMode
)
724
{
725
case
IMPLICIT
:
726
break
;
727
case
NOKEYSOURCE
:
728
SetKeyId
(i.
ReadU8
());
729
break
;
730
case
SHORTKEYSOURCE
:
731
SetKeyId
(i.
ReadLsbtohU32
(), i.
ReadU8
());
732
break
;
733
case
LONGKEYSOURCE
:
734
SetKeyId
(i.
ReadLsbtohU64
(), i.
ReadU8
());
735
break
;
736
}
737
}
738
return
i.
GetDistanceFrom
(start);
739
}
740
741
}
// namespace lrwpan
742
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::WriteHtolsbU16
void WriteHtolsbU16(uint16_t data)
Definition
buffer.cc:891
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8()
Definition
buffer.h:1016
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition
buffer.h:870
ns3::Buffer::Iterator::WriteHtolsbU32
void WriteHtolsbU32(uint32_t data)
Definition
buffer.cc:899
ns3::Buffer::Iterator::ReadLsbtohU16
uint16_t ReadLsbtohU16()
Definition
buffer.cc:1053
ns3::Buffer::Iterator::ReadLsbtohU64
uint64_t ReadLsbtohU64()
Definition
buffer.cc:1083
ns3::Buffer::Iterator::WriteHtolsbU64
void WriteHtolsbU64(uint64_t data)
Definition
buffer.cc:909
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(const Iterator &o) const
Definition
buffer.cc:769
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32()
Definition
buffer.cc:1065
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Mac16Address
This class can contain 16 bit addresses.
Definition
mac16-address.h:33
ns3::Mac64Address
an EUI-64 address
Definition
mac64-address.h:35
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::AddDeprecatedName
TypeId AddDeprecatedName(const std::string &name)
Add an deprecated name for a TypeId.
Definition
type-id.cc:862
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::lrwpan::LrWpanMacHeader
Represent the Mac Header with the Frame Control and Sequence Number fields.
Definition
lr-wpan-mac-header.h:43
ns3::lrwpan::LrWpanMacHeader::GetSecControl
uint8_t GetSecControl() const
Get the Auxiliary Security Header - Security Control Octet.
Definition
lr-wpan-mac-header.cc:178
ns3::lrwpan::LrWpanMacHeader::SetFrmPend
void SetFrmPend()
Set the Frame Control field "Frame Pending" bit to true.
Definition
lr-wpan-mac-header.cc:288
ns3::lrwpan::LrWpanMacHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
lr-wpan-mac-header.cc:518
ns3::lrwpan::LrWpanMacHeader::SetSecLevel
void SetSecLevel(uint8_t secLevel)
Set the Security Control field "Security Level" bits (3 bits)
Definition
lr-wpan-mac-header.cc:396
ns3::lrwpan::LrWpanMacHeader::GetType
LrWpanMacType GetType() const
Get the header type.
Definition
lr-wpan-mac-header.cc:53
ns3::lrwpan::LrWpanMacHeader::~LrWpanMacHeader
~LrWpanMacHeader() override
Definition
lr-wpan-mac-header.cc:48
ns3::lrwpan::LrWpanMacHeader::m_fctrlReserved
uint8_t m_fctrlReserved
Frame Control field Bit 7-9.
Definition
lr-wpan-mac-header.h:400
ns3::lrwpan::LrWpanMacHeader::IsSecEnable
bool IsSecEnable() const
Check if Security Enabled bit of Frame Control is enabled.
Definition
lr-wpan-mac-header.cc:88
ns3::lrwpan::LrWpanMacHeader::GetKeyIdIndex
uint8_t GetKeyIdIndex() const
Get the Auxiliary Security Header - Key Identifier - Key Index.
Definition
lr-wpan-mac-header.cc:226
ns3::lrwpan::LrWpanMacHeader::m_secctrlKeyIdMode
uint8_t m_secctrlKeyIdMode
Auxiliary security header - Security Control field - Bit 3-4 will indicate size of Key Id.
Definition
lr-wpan-mac-header.h:424
ns3::lrwpan::LrWpanMacHeader::m_auxKeyIdKeyIndex
uint8_t m_auxKeyIdKeyIndex
Auxiliary security header - Key Index (1 Octet)
Definition
lr-wpan-mac-header.h:439
ns3::lrwpan::LrWpanMacHeader::SetSecControl
void SetSecControl(uint8_t secLevel)
Set the auxiliary security header "Security Control" octet.
Definition
lr-wpan-mac-header.cc:382
ns3::lrwpan::LrWpanMacHeader::m_auxKeyIdKeySrc64
uint64_t m_auxKeyIdKeySrc64
Auxiliary security header - Key Source (8 Octets)
Definition
lr-wpan-mac-header.h:436
ns3::lrwpan::LrWpanMacHeader::GetShortSrcAddr
Mac16Address GetShortSrcAddr() const
Get the Source Short address.
Definition
lr-wpan-mac-header.cc:166
ns3::lrwpan::LrWpanMacHeader::SetType
void SetType(LrWpanMacType wpanMacType)
Set the Frame Control field "Frame Type" bits.
Definition
lr-wpan-mac-header.cc:256
ns3::lrwpan::LrWpanMacHeader::SetDstAddrMode
void SetDstAddrMode(uint8_t addrMode)
Set the Destination address mode.
Definition
lr-wpan-mac-header.cc:330
ns3::lrwpan::LrWpanMacHeader::m_addrDstPanId
uint16_t m_addrDstPanId
Dst PAN id (0 or 2 Octets)
Definition
lr-wpan-mac-header.h:411
ns3::lrwpan::LrWpanMacHeader::SetNoAckReq
void SetNoAckReq()
Set the Frame Control field "Ack. Request" bit to false.
Definition
lr-wpan-mac-header.cc:306
ns3::lrwpan::LrWpanMacHeader::GetSecLevel
uint8_t GetSecLevel() const
Get the Auxiliary Security Header - Security Control - Security Level bits.
Definition
lr-wpan-mac-header.cc:196
ns3::lrwpan::LrWpanMacHeader::SetSecCtrlReserved
void SetSecCtrlReserved(uint8_t res)
Set the Security Control field "Reserved" bits (3 bits)
Definition
lr-wpan-mac-header.cc:408
ns3::lrwpan::LrWpanMacHeader::SetDstAddrFields
void SetDstAddrFields(uint16_t panId, Mac16Address addr)
Set Destination address fields.
Definition
lr-wpan-mac-header.cc:368
ns3::lrwpan::LrWpanMacHeader::GetExtSrcAddr
Mac64Address GetExtSrcAddr() const
Get the Source Extended address.
Definition
lr-wpan-mac-header.cc:172
ns3::lrwpan::LrWpanMacHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
lr-wpan-mac-header.cc:434
ns3::lrwpan::LrWpanMacHeader::m_auxKeyIdKeySrc32
uint32_t m_auxKeyIdKeySrc32
Auxiliary security header - Key Source (4 Octets)
Definition
lr-wpan-mac-header.h:435
ns3::lrwpan::LrWpanMacHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
lr-wpan-mac-header.cc:663
ns3::lrwpan::LrWpanMacHeader::SHORTADDR
@ SHORTADDR
Definition
lr-wpan-mac-header.h:64
ns3::lrwpan::LrWpanMacHeader::EXTADDR
@ EXTADDR
Definition
lr-wpan-mac-header.h:65
ns3::lrwpan::LrWpanMacHeader::NOADDR
@ NOADDR
Definition
lr-wpan-mac-header.h:62
ns3::lrwpan::LrWpanMacHeader::IsData
bool IsData() const
Returns true if the header is a data.
Definition
lr-wpan-mac-header.cc:238
ns3::lrwpan::LrWpanMacHeader::IMPLICIT
@ IMPLICIT
Definition
lr-wpan-mac-header.h:73
ns3::lrwpan::LrWpanMacHeader::LONGKEYSOURCE
@ LONGKEYSOURCE
Definition
lr-wpan-mac-header.h:76
ns3::lrwpan::LrWpanMacHeader::SHORTKEYSOURCE
@ SHORTKEYSOURCE
Definition
lr-wpan-mac-header.h:75
ns3::lrwpan::LrWpanMacHeader::NOKEYSOURCE
@ NOKEYSOURCE
Definition
lr-wpan-mac-header.h:74
ns3::lrwpan::LrWpanMacHeader::m_fctrlFrmType
uint8_t m_fctrlFrmType
Frame Control field Bit 0-2 = 0 - Beacon, 1 - Data, 2 - Ack, 3 - Command.
Definition
lr-wpan-mac-header.h:392
ns3::lrwpan::LrWpanMacHeader::GetKeyIdSrc64
uint64_t GetKeyIdSrc64() const
Get the Auxiliary Security Header - Key Identifier - Key Source (4 Octets)
Definition
lr-wpan-mac-header.cc:220
ns3::lrwpan::LrWpanMacHeader::SetFrameControl
void SetFrameControl(uint16_t frameControl)
Set the whole Frame Control field.
Definition
lr-wpan-mac-header.cc:262
ns3::lrwpan::LrWpanMacHeader::m_addrShortDstAddr
Mac16Address m_addrShortDstAddr
Dst Short addr (0 or 2 Octets)
Definition
lr-wpan-mac-header.h:412
ns3::lrwpan::LrWpanMacHeader::m_SeqNum
uint8_t m_SeqNum
Sequence Number (1 Octet)
Definition
lr-wpan-mac-header.h:408
ns3::lrwpan::LrWpanMacHeader::IsBeacon
bool IsBeacon() const
Returns true if the header is a beacon.
Definition
lr-wpan-mac-header.cc:232
ns3::lrwpan::LrWpanMacHeader::Print
void Print(std::ostream &os) const override
Definition
lr-wpan-mac-header.cc:451
ns3::lrwpan::LrWpanMacHeader::LrWpanMacType
LrWpanMacType
The possible MAC types, see IEEE 802.15.4-2006, Table 79.
Definition
lr-wpan-mac-header.h:49
ns3::lrwpan::LrWpanMacHeader::LRWPAN_MAC_ACKNOWLEDGMENT
@ LRWPAN_MAC_ACKNOWLEDGMENT
LRWPAN_MAC_ACKNOWLEDGMENT.
Definition
lr-wpan-mac-header.h:52
ns3::lrwpan::LrWpanMacHeader::LRWPAN_MAC_RESERVED
@ LRWPAN_MAC_RESERVED
LRWPAN_MAC_RESERVED.
Definition
lr-wpan-mac-header.h:54
ns3::lrwpan::LrWpanMacHeader::LRWPAN_MAC_COMMAND
@ LRWPAN_MAC_COMMAND
LRWPAN_MAC_COMMAND.
Definition
lr-wpan-mac-header.h:53
ns3::lrwpan::LrWpanMacHeader::LRWPAN_MAC_BEACON
@ LRWPAN_MAC_BEACON
LRWPAN_MAC_BEACON.
Definition
lr-wpan-mac-header.h:50
ns3::lrwpan::LrWpanMacHeader::LRWPAN_MAC_DATA
@ LRWPAN_MAC_DATA
LRWPAN_MAC_DATA.
Definition
lr-wpan-mac-header.h:51
ns3::lrwpan::LrWpanMacHeader::GetFrmCounter
uint32_t GetFrmCounter() const
Get the Auxiliary Security Header - Frame Counter Octets.
Definition
lr-wpan-mac-header.cc:190
ns3::lrwpan::LrWpanMacHeader::SetPanIdComp
void SetPanIdComp()
Set the Frame Control field "PAN ID Compression" bit to true.
Definition
lr-wpan-mac-header.cc:312
ns3::lrwpan::LrWpanMacHeader::GetShortDstAddr
Mac16Address GetShortDstAddr() const
Get the Destination Short address.
Definition
lr-wpan-mac-header.cc:148
ns3::lrwpan::LrWpanMacHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
lr-wpan-mac-header.cc:596
ns3::lrwpan::LrWpanMacHeader::m_addrShortSrcAddr
Mac16Address m_addrShortSrcAddr
Src Short addr (0 or 2 Octets)
Definition
lr-wpan-mac-header.h:415
ns3::lrwpan::LrWpanMacHeader::GetFrameControl
uint16_t GetFrameControl() const
Get the Frame control field.
Definition
lr-wpan-mac-header.cc:71
ns3::lrwpan::LrWpanMacHeader::GetKeyIdMode
uint8_t GetKeyIdMode() const
Get the Auxiliary Security Header - Security Control - Key Identifier Mode bits.
Definition
lr-wpan-mac-header.cc:202
ns3::lrwpan::LrWpanMacHeader::SetSrcAddrMode
void SetSrcAddrMode(uint8_t addrMode)
Set the Source address mode.
Definition
lr-wpan-mac-header.cc:342
ns3::lrwpan::LrWpanMacHeader::IsCommand
bool IsCommand() const
Returns true if the header is a command.
Definition
lr-wpan-mac-header.cc:250
ns3::lrwpan::LrWpanMacHeader::m_addrSrcPanId
uint16_t m_addrSrcPanId
Src PAN id (0 or 2 Octets)
Definition
lr-wpan-mac-header.h:414
ns3::lrwpan::LrWpanMacHeader::GetKeyIdSrc32
uint32_t GetKeyIdSrc32() const
Get the Auxiliary Security Header - Key Identifier - Key Source (2 Octets)
Definition
lr-wpan-mac-header.cc:214
ns3::lrwpan::LrWpanMacHeader::GetSecCtrlReserved
uint8_t GetSecCtrlReserved() const
Get the Auxiliary Security Header - Security Control - Reserved bits.
Definition
lr-wpan-mac-header.cc:208
ns3::lrwpan::LrWpanMacHeader::SetFrmCtrlRes
void SetFrmCtrlRes(uint8_t res)
Set the Frame Control field "Reserved" bits.
Definition
lr-wpan-mac-header.cc:324
ns3::lrwpan::LrWpanMacHeader::SetKeyId
void SetKeyId(uint8_t keyIndex)
Set the Key Index.
Definition
lr-wpan-mac-header.cc:414
ns3::lrwpan::LrWpanMacHeader::GetSeqNum
uint8_t GetSeqNum() const
Get the frame Sequence number.
Definition
lr-wpan-mac-header.cc:136
ns3::lrwpan::LrWpanMacHeader::SetFrameVer
void SetFrameVer(uint8_t ver)
Set the Frame version.
Definition
lr-wpan-mac-header.cc:336
ns3::lrwpan::LrWpanMacHeader::m_secctrlSecLevel
uint8_t m_secctrlSecLevel
Auxiliary security header - Security Control field - Bit 0-2.
Definition
lr-wpan-mac-header.h:423
ns3::lrwpan::LrWpanMacHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
lr-wpan-mac-header.cc:445
ns3::lrwpan::LrWpanMacHeader::GetFrameVer
uint8_t GetFrameVer() const
Get the Frame Version of Frame control field.
Definition
lr-wpan-mac-header.cc:124
ns3::lrwpan::LrWpanMacHeader::SetFrmCounter
void SetFrmCounter(uint32_t frmCntr)
Set the auxiliary security header "Frame Counter" octet.
Definition
lr-wpan-mac-header.cc:390
ns3::lrwpan::LrWpanMacHeader::SetSrcAddrFields
void SetSrcAddrFields(uint16_t panId, Mac16Address addr)
Set Source address fields.
Definition
lr-wpan-mac-header.cc:354
ns3::lrwpan::LrWpanMacHeader::m_addrExtDstAddr
Mac64Address m_addrExtDstAddr
Dst Ext addr (0 or 8 Octets)
Definition
lr-wpan-mac-header.h:413
ns3::lrwpan::LrWpanMacHeader::m_fctrlDstAddrMode
uint8_t m_fctrlDstAddrMode
Frame Control field Bit 10-11 = 0 - No DstAddr, 2 - ShtDstAddr, 3 - ExtDstAddr.
Definition
lr-wpan-mac-header.h:401
ns3::lrwpan::LrWpanMacHeader::m_addrExtSrcAddr
Mac64Address m_addrExtSrcAddr
Src Ext addr (0 or 8 Octets)
Definition
lr-wpan-mac-header.h:416
ns3::lrwpan::LrWpanMacHeader::IsFrmPend
bool IsFrmPend() const
Check if Frame Pending bit of Frame Control is enabled.
Definition
lr-wpan-mac-header.cc:94
ns3::lrwpan::LrWpanMacHeader::LrWpanMacHeader
LrWpanMacHeader()
Definition
lr-wpan-mac-header.cc:21
ns3::lrwpan::LrWpanMacHeader::m_secctrlReserved
uint8_t m_secctrlReserved
Auxiliary security header - Security Control field - Bit 5-7.
Definition
lr-wpan-mac-header.h:432
ns3::lrwpan::LrWpanMacHeader::GetSrcPanId
uint16_t GetSrcPanId() const
Get the Source PAN ID.
Definition
lr-wpan-mac-header.cc:160
ns3::lrwpan::LrWpanMacHeader::SetNoPanIdComp
void SetNoPanIdComp()
Set the Frame Control field "PAN ID Compression" bit to false.
Definition
lr-wpan-mac-header.cc:318
ns3::lrwpan::LrWpanMacHeader::m_fctrlSrcAddrMode
uint8_t m_fctrlSrcAddrMode
Frame Control field Bit 14-15 = 0 - No SrcAddr, 2 - ShtSrcAddr, 3 - ExtSrcAddr.
Definition
lr-wpan-mac-header.h:404
ns3::lrwpan::LrWpanMacHeader::GetDstPanId
uint16_t GetDstPanId() const
Get the Destination PAN ID.
Definition
lr-wpan-mac-header.cc:142
ns3::lrwpan::LrWpanMacHeader::m_fctrlFrmPending
uint8_t m_fctrlFrmPending
Frame Control field Bit 4.
Definition
lr-wpan-mac-header.h:396
ns3::lrwpan::LrWpanMacHeader::m_fctrlPanIdComp
uint8_t m_fctrlPanIdComp
Frame Control field Bit 6 = 0 - no compression, 1 - using only DstPanId for both Src and DstPanId.
Definition
lr-wpan-mac-header.h:398
ns3::lrwpan::LrWpanMacHeader::m_fctrlFrmVer
uint8_t m_fctrlFrmVer
Frame Control field Bit 12-13.
Definition
lr-wpan-mac-header.h:403
ns3::lrwpan::LrWpanMacHeader::m_fctrlAckReq
uint8_t m_fctrlAckReq
Frame Control field Bit 5.
Definition
lr-wpan-mac-header.h:397
ns3::lrwpan::LrWpanMacHeader::SetNoFrmPend
void SetNoFrmPend()
Set the Frame Control field "Frame Pending" bit to false.
Definition
lr-wpan-mac-header.cc:294
ns3::lrwpan::LrWpanMacHeader::m_auxFrmCntr
uint32_t m_auxFrmCntr
Auxiliary security header - Frame Counter (4 Octets)
Definition
lr-wpan-mac-header.h:420
ns3::lrwpan::LrWpanMacHeader::SetAckReq
void SetAckReq()
Set the Frame Control field "Ack. Request" bit to true.
Definition
lr-wpan-mac-header.cc:300
ns3::lrwpan::LrWpanMacHeader::IsAckReq
bool IsAckReq() const
Check if Ack.
Definition
lr-wpan-mac-header.cc:100
ns3::lrwpan::LrWpanMacHeader::GetDstAddrMode
uint8_t GetDstAddrMode() const
Get the Dest.
Definition
lr-wpan-mac-header.cc:118
ns3::lrwpan::LrWpanMacHeader::m_fctrlSecU
uint8_t m_fctrlSecU
Frame Control field Bit 3 = 0 - no AuxSecHdr , 1 - security enabled AuxSecHdr present.
Definition
lr-wpan-mac-header.h:394
ns3::lrwpan::LrWpanMacHeader::SetSecEnable
void SetSecEnable()
Set the Frame Control field "Security Enabled" bit to true.
Definition
lr-wpan-mac-header.cc:276
ns3::lrwpan::LrWpanMacHeader::SetSecDisable
void SetSecDisable()
Set the Frame Control field "Security Enabled" bit to false.
Definition
lr-wpan-mac-header.cc:282
ns3::lrwpan::LrWpanMacHeader::GetExtDstAddr
Mac64Address GetExtDstAddr() const
Get the Destination Extended address.
Definition
lr-wpan-mac-header.cc:154
ns3::lrwpan::LrWpanMacHeader::IsAcknowledgment
bool IsAcknowledgment() const
Returns true if the header is an ack.
Definition
lr-wpan-mac-header.cc:244
ns3::lrwpan::LrWpanMacHeader::GetSrcAddrMode
uint8_t GetSrcAddrMode() const
Get the Source Addressing Mode of Frame control field.
Definition
lr-wpan-mac-header.cc:130
ns3::lrwpan::LrWpanMacHeader::IsPanIdComp
bool IsPanIdComp() const
Check if PAN ID Compression bit of Frame Control is enabled.
Definition
lr-wpan-mac-header.cc:106
ns3::lrwpan::LrWpanMacHeader::SetSeqNum
void SetSeqNum(uint8_t seqNum)
Set the Sequence number.
Definition
lr-wpan-mac-header.cc:348
ns3::lrwpan::LrWpanMacHeader::GetFrmCtrlRes
uint8_t GetFrmCtrlRes() const
Get the Reserved bits of Frame control field.
Definition
lr-wpan-mac-header.cc:112
ns3::lrwpan::LrWpanMacHeader::SetKeyIdMode
void SetKeyIdMode(uint8_t keyIdMode)
Set the Security Control field "Key Identifier Mode" bits (2 bits)
Definition
lr-wpan-mac-header.cc:402
uint32_t
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
lr-wpan-mac-header.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WriteTo
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Definition
address-utils.cc:21
ns3::ReadFrom
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Definition
address-utils.cc:74
src
lr-wpan
model
lr-wpan-mac-header.cc
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0