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