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