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