A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
wifi-phy-header.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2018 Sébastien Deronne
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: Sébastien Deronne <sebastien.deronne@gmail.com>
19
*/
20
21
#include "
wifi-phy-header.h
"
22
23
namespace
ns3
{
24
25
NS_OBJECT_ENSURE_REGISTERED
(DsssSigHeader);
26
27
DsssSigHeader::DsssSigHeader
()
28
: m_rate (0b00001010),
29
m_length (0)
30
{
31
}
32
33
DsssSigHeader::~DsssSigHeader
()
34
{
35
}
36
37
TypeId
38
DsssSigHeader::GetTypeId
(
void
)
39
{
40
static
TypeId
tid =
TypeId
(
"ns3::DsssSigHeader"
)
41
.
SetParent
<
Header
> ()
42
.SetGroupName (
"Wifi"
)
43
.AddConstructor<
DsssSigHeader
> ()
44
;
45
return
tid;
46
}
47
48
TypeId
49
DsssSigHeader::GetInstanceTypeId
(
void
)
const
50
{
51
return
GetTypeId
();
52
}
53
54
void
55
DsssSigHeader::Print
(std::ostream &os)
const
56
{
57
os <<
"SIGNAL="
<<
GetRate
()
58
<<
" LENGTH="
<<
m_length
;
59
}
60
61
uint32_t
62
DsssSigHeader::GetSerializedSize
(
void
)
const
63
{
64
return
6;
65
}
66
67
void
68
DsssSigHeader::SetRate
(uint64_t rate)
69
{
70
/* Here is the binary representation for a given rate:
71
* 1 Mbit/s: 00001010
72
* 2 Mbit/s: 00010100
73
* 5.5 Mbit/s: 00110111
74
* 11 Mbit/s: 01101110
75
*/
76
switch
(rate)
77
{
78
case
1000000:
79
m_rate
= 0b00001010;
80
break
;
81
case
2000000:
82
m_rate
= 0b00010100;
83
break
;
84
case
5500000:
85
m_rate
= 0b00110111;
86
break
;
87
case
11000000:
88
m_rate
= 0b01101110;
89
break
;
90
default
:
91
NS_ASSERT_MSG
(
false
,
"Invalid rate"
);
92
break
;
93
}
94
}
95
96
uint64_t
97
DsssSigHeader::GetRate
(
void
)
const
98
{
99
uint64_t rate = 0;
100
switch
(
m_rate
)
101
{
102
case
0b00001010:
103
rate = 1000000;
104
break
;
105
case
0b00010100:
106
rate = 2000000;
107
break
;
108
case
0b00110111:
109
rate = 5500000;
110
break
;
111
case
0b01101110:
112
rate = 11000000;
113
break
;
114
default
:
115
NS_ASSERT_MSG
(
false
,
"Invalid rate"
);
116
break
;
117
}
118
return
rate;
119
}
120
121
void
122
DsssSigHeader::SetLength
(uint16_t length)
123
{
124
m_length
= length;
125
}
126
127
uint16_t
128
DsssSigHeader::GetLength
(
void
)
const
129
{
130
return
m_length
;
131
}
132
133
void
134
DsssSigHeader::Serialize
(
Buffer::Iterator
start
)
const
135
{
136
start
.WriteU8 (
m_rate
);
137
start
.WriteU8 (0);
/* SERVICE */
138
start
.WriteU16 (
m_length
);
139
start
.WriteU16 (0);
/* CRC */
140
}
141
142
uint32_t
143
DsssSigHeader::Deserialize
(
Buffer::Iterator
start
)
144
{
145
Buffer::Iterator
i =
start
;
146
m_rate
= i.
ReadU8
();
147
i.
ReadU8
();
/* SERVICE */
148
m_length
= i.
ReadU16
();
149
i.
ReadU16
();
/* CRC */
150
return
i.
GetDistanceFrom
(
start
);
151
}
152
153
NS_OBJECT_ENSURE_REGISTERED
(
LSigHeader
);
154
155
LSigHeader::LSigHeader
()
156
: m_rate (0b1101),
157
m_length (0)
158
{
159
}
160
161
LSigHeader::~LSigHeader
()
162
{
163
}
164
165
TypeId
166
LSigHeader::GetTypeId
(
void
)
167
{
168
static
TypeId
tid =
TypeId
(
"ns3::LSigHeader"
)
169
.
SetParent
<
Header
> ()
170
.SetGroupName (
"Wifi"
)
171
.AddConstructor<
LSigHeader
> ()
172
;
173
return
tid;
174
}
175
176
TypeId
177
LSigHeader::GetInstanceTypeId
(
void
)
const
178
{
179
return
GetTypeId
();
180
}
181
182
void
183
LSigHeader::Print
(std::ostream &os)
const
184
{
185
os <<
"SIGNAL="
<<
GetRate
()
186
<<
" LENGTH="
<<
m_length
;
187
}
188
189
uint32_t
190
LSigHeader::GetSerializedSize
(
void
)
const
191
{
192
return
3;
193
}
194
195
void
196
LSigHeader::SetRate
(uint64_t rate, uint16_t channelWidth)
197
{
198
if
(channelWidth == 5)
199
{
200
rate *= 4;
//corresponding 20 MHz rate if 5 MHz is used
201
}
202
else
if
(channelWidth == 10)
203
{
204
rate *= 2;
//corresponding 20 MHz rate if 10 MHz is used
205
}
206
/* Here is the binary representation for a given rate:
207
* 6 Mbit/s: 1101
208
* 9 Mbit/s: 1111
209
* 12 Mbit/s: 0101
210
* 18 Mbit/s: 0111
211
* 24 Mbit/s: 1001
212
* 36 Mbit/s: 1011
213
* 48 Mbit/s: 0001
214
* 54 Mbit/s: 0011
215
*/
216
switch
(rate)
217
{
218
case
6000000:
219
m_rate
= 0b1101;
220
break
;
221
case
9000000:
222
m_rate
= 0b1111;
223
break
;
224
case
12000000:
225
m_rate
= 0b0101;
226
break
;
227
case
18000000:
228
m_rate
= 0b0111;
229
break
;
230
case
24000000:
231
m_rate
= 0b1001;
232
break
;
233
case
36000000:
234
m_rate
= 0b1011;
235
break
;
236
case
48000000:
237
m_rate
= 0b0001;
238
break
;
239
case
54000000:
240
m_rate
= 0b0011;
241
break
;
242
default
:
243
NS_ASSERT_MSG
(
false
,
"Invalid rate"
);
244
break
;
245
}
246
}
247
248
uint64_t
249
LSigHeader::GetRate
(uint16_t channelWidth)
const
250
{
251
uint64_t rate = 0;
252
switch
(
m_rate
)
253
{
254
case
0b1101:
255
rate = 6000000;
256
break
;
257
case
0b1111:
258
rate = 9000000;
259
break
;
260
case
0b0101:
261
rate = 12000000;
262
break
;
263
case
0b0111:
264
rate = 18000000;
265
break
;
266
case
0b1001:
267
rate = 24000000;
268
break
;
269
case
0b1011:
270
rate = 36000000;
271
break
;
272
case
0b0001:
273
rate = 48000000;
274
break
;
275
case
0b0011:
276
rate = 54000000;
277
break
;
278
default
:
279
NS_ASSERT_MSG
(
false
,
"Invalid rate"
);
280
break
;
281
}
282
if
(channelWidth == 5)
283
{
284
rate /= 4;
//compute corresponding 5 MHz rate
285
}
286
else
if
(channelWidth == 10)
287
{
288
rate /= 2;
//compute corresponding 10 MHz rate
289
}
290
return
rate;
291
}
292
293
void
294
LSigHeader::SetLength
(uint16_t length)
295
{
296
NS_ASSERT_MSG
(length < 4096,
"Invalid length"
);
297
m_length
= length;
298
}
299
300
uint16_t
301
LSigHeader::GetLength
(
void
)
const
302
{
303
return
m_length
;
304
}
305
306
void
307
LSigHeader::Serialize
(
Buffer::Iterator
start
)
const
308
{
309
uint8_t byte = 0;
310
uint16_t bytes = 0;
311
312
byte |=
m_rate
;
313
byte |= (
m_length
& 0x07) << 5;
314
start
.WriteU8 (byte);
315
316
bytes |= (
m_length
& 0x0ff8) >> 3;
317
start
.WriteU16 (bytes);
318
}
319
320
uint32_t
321
LSigHeader::Deserialize
(
Buffer::Iterator
start
)
322
{
323
Buffer::Iterator
i =
start
;
324
325
uint8_t byte = i.
ReadU8
();
326
m_rate
= byte & 0x0f;
327
m_length
= (byte >> 5) & 0x07;
328
329
uint16_t bytes = i.
ReadU16
();
330
m_length
|= (bytes << 3) & 0x0ff8;
331
332
return
i.
GetDistanceFrom
(
start
);
333
}
334
335
NS_OBJECT_ENSURE_REGISTERED
(
HtSigHeader
);
336
337
HtSigHeader::HtSigHeader
()
338
: m_mcs (0),
339
m_cbw20_40 (0),
340
m_htLength (0),
341
m_aggregation (0),
342
m_sgi (0)
343
{
344
}
345
346
HtSigHeader::~HtSigHeader
()
347
{
348
}
349
350
TypeId
351
HtSigHeader::GetTypeId
(
void
)
352
{
353
static
TypeId
tid =
TypeId
(
"ns3::HtSigHeader"
)
354
.
SetParent
<
Header
> ()
355
.SetGroupName (
"Wifi"
)
356
.AddConstructor<
HtSigHeader
> ()
357
;
358
return
tid;
359
}
360
361
TypeId
362
HtSigHeader::GetInstanceTypeId
(
void
)
const
363
{
364
return
GetTypeId
();
365
}
366
367
void
368
HtSigHeader::Print
(std::ostream &os)
const
369
{
370
os <<
"MCS="
<< +
m_mcs
371
<<
" HT_LENGTH="
<<
m_htLength
372
<<
" CHANNEL_WIDTH="
<<
GetChannelWidth
()
373
<<
" SGI="
<< +
m_sgi
374
<<
" AGGREGATION="
<< +
m_aggregation
;
375
}
376
377
uint32_t
378
HtSigHeader::GetSerializedSize
(
void
)
const
379
{
380
return
6;
381
}
382
383
void
384
HtSigHeader::SetMcs
(uint8_t mcs)
385
{
386
NS_ASSERT
(mcs <= 31);
387
m_mcs
= mcs;
388
}
389
390
uint8_t
391
HtSigHeader::GetMcs
(
void
)
const
392
{
393
return
m_mcs
;
394
}
395
396
void
397
HtSigHeader::SetChannelWidth
(uint16_t channelWidth)
398
{
399
m_cbw20_40
= (channelWidth > 20) ? 1 : 0;
400
}
401
402
uint16_t
403
HtSigHeader::GetChannelWidth
(
void
)
const
404
{
405
return
m_cbw20_40
? 40 : 20;
406
}
407
408
void
409
HtSigHeader::SetHtLength
(uint16_t length)
410
{
411
m_htLength
= length;
412
}
413
414
uint16_t
415
HtSigHeader::GetHtLength
(
void
)
const
416
{
417
return
m_htLength
;
418
}
419
420
void
421
HtSigHeader::SetAggregation
(
bool
aggregation)
422
{
423
m_aggregation
= aggregation ? 1 : 0;
424
}
425
426
bool
427
HtSigHeader::GetAggregation
(
void
)
const
428
{
429
return
m_aggregation
? true :
false
;
430
}
431
432
void
433
HtSigHeader::SetShortGuardInterval
(
bool
sgi
)
434
{
435
m_sgi
=
sgi
? 1 : 0;
436
}
437
438
bool
439
HtSigHeader::GetShortGuardInterval
(
void
)
const
440
{
441
return
m_sgi
? true :
false
;
442
}
443
444
void
445
HtSigHeader::Serialize
(
Buffer::Iterator
start
)
const
446
{
447
uint8_t byte =
m_mcs
;
448
byte |= ((
m_cbw20_40
& 0x01) << 7);
449
start
.WriteU8 (byte);
450
start
.WriteU16 (
m_htLength
);
451
byte = (0x01 << 2);
//Set Reserved bit #2 to 1
452
byte |= ((
m_aggregation
& 0x01) << 3);
453
byte |= ((
m_sgi
& 0x01) << 7);
454
start
.WriteU8 (byte);
455
start
.WriteU16 (0);
456
}
457
458
uint32_t
459
HtSigHeader::Deserialize
(
Buffer::Iterator
start
)
460
{
461
Buffer::Iterator
i =
start
;
462
uint8_t byte = i.
ReadU8
();
463
m_mcs
= byte & 0x7f;
464
m_cbw20_40
= ((byte >> 7) & 0x01);
465
m_htLength
= i.
ReadU16
();
466
byte = i.
ReadU8
();
467
m_aggregation
= ((byte >> 3) & 0x01);
468
m_sgi
= ((byte >> 7) & 0x01);
469
i.
ReadU16
();
470
return
i.
GetDistanceFrom
(
start
);
471
}
472
473
NS_OBJECT_ENSURE_REGISTERED
(
VhtSigHeader
);
474
475
VhtSigHeader::VhtSigHeader
()
476
: m_bw (0),
477
m_nsts (0),
478
m_sgi (0),
479
m_sgi_disambiguation (0),
480
m_suMcs (0),
481
m_mu (false)
482
{
483
}
484
485
VhtSigHeader::~VhtSigHeader
()
486
{
487
}
488
489
TypeId
490
VhtSigHeader::GetTypeId
(
void
)
491
{
492
static
TypeId
tid =
TypeId
(
"ns3::VhtSigHeader"
)
493
.
SetParent
<
Header
> ()
494
.SetGroupName (
"Wifi"
)
495
.AddConstructor<
VhtSigHeader
> ()
496
;
497
return
tid;
498
}
499
500
TypeId
501
VhtSigHeader::GetInstanceTypeId
(
void
)
const
502
{
503
return
GetTypeId
();
504
}
505
506
void
507
VhtSigHeader::Print
(std::ostream &os)
const
508
{
509
os <<
"SU_MCS="
<< +
m_suMcs
510
<<
" CHANNEL_WIDTH="
<<
GetChannelWidth
()
511
<<
" SGI="
<< +
m_sgi
512
<<
" NSTS="
<< +
m_nsts
513
<<
" MU="
<< +
m_mu
;
514
}
515
516
uint32_t
517
VhtSigHeader::GetSerializedSize
(
void
)
const
518
{
519
uint32_t size = 0;
520
size += 3;
//VHT-SIG-A1
521
size += 3;
//VHT-SIG-A2
522
if
(
m_mu
)
523
{
524
size += 4;
//VHT-SIG-B
525
}
526
return
size;
527
}
528
529
void
530
VhtSigHeader::SetMuFlag
(
bool
mu)
531
{
532
m_mu
= mu;
533
}
534
535
void
536
VhtSigHeader::SetChannelWidth
(uint16_t channelWidth)
537
{
538
if
(channelWidth == 160)
539
{
540
m_bw
= 3;
541
}
542
else
if
(channelWidth == 80)
543
{
544
m_bw
= 2;
545
}
546
else
if
(channelWidth == 40)
547
{
548
m_bw
= 1;
549
}
550
else
551
{
552
m_bw
= 0;
553
}
554
}
555
556
uint16_t
557
VhtSigHeader::GetChannelWidth
(
void
)
const
558
{
559
if
(
m_bw
== 3)
560
{
561
return
160;
562
}
563
else
if
(
m_bw
== 2)
564
{
565
return
80;
566
}
567
else
if
(
m_bw
== 1)
568
{
569
return
40;
570
}
571
else
572
{
573
return
20;
574
}
575
}
576
577
void
578
VhtSigHeader::SetNStreams
(uint8_t nStreams)
579
{
580
NS_ASSERT
(nStreams <= 8);
581
m_nsts
= (nStreams - 1);
582
}
583
584
uint8_t
585
VhtSigHeader::GetNStreams
(
void
)
const
586
{
587
return
(
m_nsts
+ 1);
588
}
589
590
void
591
VhtSigHeader::SetShortGuardInterval
(
bool
sgi
)
592
{
593
m_sgi
=
sgi
? 1 : 0;
594
}
595
596
bool
597
VhtSigHeader::GetShortGuardInterval
(
void
)
const
598
{
599
return
m_sgi
? true :
false
;
600
}
601
602
void
603
VhtSigHeader::SetShortGuardIntervalDisambiguation
(
bool
disambiguation)
604
{
605
m_sgi_disambiguation
= disambiguation ? 1 : 0;
606
}
607
608
bool
609
VhtSigHeader::GetShortGuardIntervalDisambiguation
(
void
)
const
610
{
611
return
m_sgi_disambiguation
? true :
false
;
612
}
613
614
void
615
VhtSigHeader::SetSuMcs
(uint8_t mcs)
616
{
617
NS_ASSERT
(mcs <= 9);
618
m_suMcs
= mcs;
619
}
620
621
uint8_t
622
VhtSigHeader::GetSuMcs
(
void
)
const
623
{
624
return
m_suMcs
;
625
}
626
627
void
628
VhtSigHeader::Serialize
(
Buffer::Iterator
start
)
const
629
{
630
//VHT-SIG-A1
631
uint8_t byte =
m_bw
;
632
byte |= (0x01 << 2);
//Set Reserved bit #2 to 1
633
start
.WriteU8 (byte);
634
uint16_t bytes = (
m_nsts
& 0x07) << 2;
635
bytes |= (0x01 << (23 - 8));
//Set Reserved bit #23 to 1
636
start
.WriteU16 (bytes);
637
638
//VHT-SIG-A2
639
byte =
m_sgi
& 0x01;
640
byte |= ((
m_sgi_disambiguation
& 0x01) << 1);
641
byte |= ((
m_suMcs
& 0x0f) << 4);
642
start
.WriteU8 (byte);
643
bytes = (0x01 << (9 - 8));
//Set Reserved bit #9 to 1
644
start
.WriteU16 (bytes);
645
646
if
(
m_mu
)
647
{
648
//VHT-SIG-B
649
start
.WriteU32 (0);
650
}
651
}
652
653
uint32_t
654
VhtSigHeader::Deserialize
(
Buffer::Iterator
start
)
655
{
656
Buffer::Iterator
i =
start
;
657
658
//VHT-SIG-A1
659
uint8_t byte = i.
ReadU8
();
660
m_bw
= byte & 0x03;
661
uint16_t bytes = i.
ReadU16
();
662
m_nsts
= ((bytes >> 2) & 0x07);
663
664
//VHT-SIG-A2
665
byte = i.
ReadU8
();
666
m_sgi
= byte & 0x01;
667
m_sgi_disambiguation
= ((byte >> 1) & 0x01);
668
m_suMcs
= ((byte >> 4) & 0x0f);
669
i.
ReadU16
();
670
671
if
(
m_mu
)
672
{
673
//VHT-SIG-B
674
i.
ReadU32
();
675
}
676
677
return
i.
GetDistanceFrom
(
start
);
678
}
679
680
681
NS_OBJECT_ENSURE_REGISTERED
(
HeSigHeader
);
682
683
HeSigHeader::HeSigHeader
()
684
: m_format (1),
685
m_bssColor (0),
686
m_ul_dl (0),
687
m_mcs (0),
688
m_spatialReuse (0),
689
m_bandwidth (0),
690
m_gi_ltf_size (0),
691
m_nsts (0),
692
m_mu (false)
693
{
694
}
695
696
HeSigHeader::~HeSigHeader
()
697
{
698
}
699
700
TypeId
701
HeSigHeader::GetTypeId
(
void
)
702
{
703
static
TypeId
tid =
TypeId
(
"ns3::HeSigHeader"
)
704
.
SetParent
<
Header
> ()
705
.SetGroupName (
"Wifi"
)
706
.AddConstructor<
HeSigHeader
> ()
707
;
708
return
tid;
709
}
710
711
TypeId
712
HeSigHeader::GetInstanceTypeId
(
void
)
const
713
{
714
return
GetTypeId
();
715
}
716
717
void
718
HeSigHeader::Print
(std::ostream &os)
const
719
{
720
os <<
"MCS="
<< +
m_mcs
721
<<
" CHANNEL_WIDTH="
<<
GetChannelWidth
()
722
<<
" GI="
<<
GetGuardInterval
()
723
<<
" NSTS="
<< +
m_nsts
724
<<
" BSSColor="
<< +
m_bssColor
725
<<
" MU="
<< +
m_mu
;
726
}
727
728
uint32_t
729
HeSigHeader::GetSerializedSize
(
void
)
const
730
{
731
uint32_t size = 0;
732
size += 4;
//HE-SIG-A1
733
size += 4;
//HE-SIG-A2
734
if
(
m_mu
)
735
{
736
size += 1;
//HE-SIG-B
737
}
738
return
size;
739
}
740
741
void
742
HeSigHeader::SetMuFlag
(
bool
mu)
743
{
744
m_mu
= mu;
745
}
746
747
void
748
HeSigHeader::SetMcs
(uint8_t mcs)
749
{
750
NS_ASSERT
(mcs <= 11);
751
m_mcs
= mcs;
752
}
753
754
uint8_t
755
HeSigHeader::GetMcs
(
void
)
const
756
{
757
return
m_mcs
;
758
}
759
760
void
761
HeSigHeader::SetBssColor
(uint8_t bssColor)
762
{
763
NS_ASSERT
(bssColor < 64);
764
m_bssColor
= bssColor;
765
}
766
767
uint8_t
768
HeSigHeader::GetBssColor
(
void
)
const
769
{
770
return
m_bssColor
;
771
}
772
773
void
774
HeSigHeader::SetChannelWidth
(uint16_t channelWidth)
775
{
776
if
(channelWidth == 160)
777
{
778
m_bandwidth
= 3;
779
}
780
else
if
(channelWidth == 80)
781
{
782
m_bandwidth
= 2;
783
}
784
else
if
(channelWidth == 40)
785
{
786
m_bandwidth
= 1;
787
}
788
else
789
{
790
m_bandwidth
= 0;
791
}
792
}
793
794
uint16_t
795
HeSigHeader::GetChannelWidth
(
void
)
const
796
{
797
if
(
m_bandwidth
== 3)
798
{
799
return
160;
800
}
801
else
if
(
m_bandwidth
== 2)
802
{
803
return
80;
804
}
805
else
if
(
m_bandwidth
== 1)
806
{
807
return
40;
808
}
809
else
810
{
811
return
20;
812
}
813
}
814
815
void
816
HeSigHeader::SetGuardIntervalAndLtfSize
(uint16_t gi, uint8_t ltf)
817
{
818
if
(gi == 800 && ltf == 1)
819
{
820
m_gi_ltf_size
= 0;
821
}
822
else
if
(gi == 800 && ltf == 2)
823
{
824
m_gi_ltf_size
= 1;
825
}
826
else
if
(gi == 1600 && ltf == 2)
827
{
828
m_gi_ltf_size
= 2;
829
}
830
else
831
{
832
m_gi_ltf_size
= 3;
833
}
834
}
835
836
uint16_t
837
HeSigHeader::GetGuardInterval
(
void
)
const
838
{
839
if
(
m_gi_ltf_size
== 3)
840
{
841
//we currently do not consider DCM nor STBC fields
842
return
3200;
843
}
844
else
if
(
m_gi_ltf_size
== 2)
845
{
846
return
1600;
847
}
848
else
849
{
850
return
800;
851
}
852
}
853
854
void
855
HeSigHeader::SetNStreams
(uint8_t nStreams)
856
{
857
NS_ASSERT
(nStreams <= 8);
858
m_nsts
= (nStreams - 1);
859
}
860
861
uint8_t
862
HeSigHeader::GetNStreams
(
void
)
const
863
{
864
return
(
m_nsts
+ 1);
865
}
866
867
void
868
HeSigHeader::Serialize
(
Buffer::Iterator
start
)
const
869
{
870
//HE-SIG-A1
871
uint8_t byte =
m_format
& 0x01;
872
byte |= ((
m_ul_dl
& 0x01) << 2);
873
byte |= ((
m_mcs
& 0x0f) << 3);
874
start
.WriteU8 (byte);
875
uint16_t bytes = (
m_bssColor
& 0x3f);
876
bytes |= (0x01 << 6);
//Reserved set to 1
877
bytes |= ((
m_spatialReuse
& 0x0f) << 7);
878
bytes |= ((
m_bandwidth
& 0x03) << 11);
879
bytes |= ((
m_gi_ltf_size
& 0x03) << 13);
880
bytes |= ((
m_nsts
& 0x01) << 15);
881
start
.WriteU16 (bytes);
882
start
.WriteU8 ((
m_nsts
>> 1) & 0x03);
883
884
//HE-SIG-A2
885
uint32_t sigA2 = 0;
886
sigA2 |= (0x01 << 14);
//Set Reserved bit #14 to 1
887
start
.WriteU32 (sigA2);
888
889
if
(
m_mu
)
890
{
891
//HE-SIG-B
892
start
.WriteU8 (0);
893
}
894
}
895
896
uint32_t
897
HeSigHeader::Deserialize
(
Buffer::Iterator
start
)
898
{
899
Buffer::Iterator
i =
start
;
900
901
//HE-SIG-A1
902
uint8_t byte = i.
ReadU8
();
903
m_format
= (byte & 0x01);
904
m_ul_dl
= ((byte >> 2) & 0x01);
905
m_mcs
= ((byte >> 3) & 0x0f);
906
uint16_t bytes = i.
ReadU16
();
907
m_bssColor
= (bytes & 0x3f);
908
m_spatialReuse
= ((bytes >> 7) & 0x0f);
909
m_bandwidth
= ((bytes >> 11) & 0x03);
910
m_gi_ltf_size
= ((bytes >> 13) & 0x03);
911
m_nsts
= ((bytes >> 15) & 0x01);
912
byte = i.
ReadU8
();
913
m_nsts
|= (byte & 0x03) << 1;
914
915
//HE-SIG-A2
916
i.
ReadU32
();
917
918
if
(
m_mu
)
919
{
920
//HE-SIG-B
921
i.
ReadU8
();
922
}
923
924
return
i.
GetDistanceFrom
(
start
);
925
}
926
927
}
//namespace ns3
ns3::Buffer::Iterator::ReadU16
uint16_t ReadU16(void)
Definition:
buffer.h:1029
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::HeSigHeader::GetChannelWidth
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
Definition:
wifi-phy-header.cc:795
ns3::DsssSigHeader::Print
void Print(std::ostream &os) const
Definition:
wifi-phy-header.cc:55
ns3::HtSigHeader::Print
void Print(std::ostream &os) const
Definition:
wifi-phy-header.cc:368
ns3::HeSigHeader::m_bandwidth
uint8_t m_bandwidth
Bandwidth field.
Definition:
wifi-phy-header.h:440
ns3::HtSigHeader::m_sgi
uint8_t m_sgi
Short Guard Interval.
Definition:
wifi-phy-header.h:230
ns3::Buffer::Iterator::ReadU32
uint32_t ReadU32(void)
Definition:
buffer.cc:972
ns3::HeSigHeader::m_spatialReuse
uint8_t m_spatialReuse
Spatial Reuse field.
Definition:
wifi-phy-header.h:439
ns3::HtSigHeader::m_cbw20_40
uint8_t m_cbw20_40
CBW 20/40.
Definition:
wifi-phy-header.h:227
ns3::HtSigHeader::SetMcs
void SetMcs(uint8_t mcs)
Fill the MCS field of HT-SIG.
Definition:
wifi-phy-header.cc:384
ns3::HtSigHeader::m_htLength
uint16_t m_htLength
HT length.
Definition:
wifi-phy-header.h:228
ns3::HeSigHeader::m_format
uint8_t m_format
Format bit.
Definition:
wifi-phy-header.h:435
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::VhtSigHeader::SetChannelWidth
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of VHT-SIG-A1 (in MHz).
Definition:
wifi-phy-header.cc:536
NS_ASSERT_MSG
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
ns3::HeSigHeader::m_ul_dl
uint8_t m_ul_dl
UL/DL bit.
Definition:
wifi-phy-header.h:437
ns3::HtSigHeader::GetChannelWidth
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
Definition:
wifi-phy-header.cc:403
ns3::HeSigHeader::SetMuFlag
void SetMuFlag(bool mu)
Set the Multi-User (MU) flag.
Definition:
wifi-phy-header.cc:742
ns3::HeSigHeader::m_mcs
uint8_t m_mcs
MCS field.
Definition:
wifi-phy-header.h:438
ns3::HeSigHeader::SetNStreams
void SetNStreams(uint8_t nStreams)
Fill the number of streams field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:855
visualizer.core.start
def start()
Definition:
core.py:1855
ns3::HeSigHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
wifi-phy-header.cc:701
ns3::VhtSigHeader
Implements the IEEE 802.11ac PHY header (VHT-SIG-A1/A2/B).
Definition:
wifi-phy-header.h:239
ns3::HtSigHeader::HtSigHeader
HtSigHeader()
Definition:
wifi-phy-header.cc:337
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition:
assert.h:67
ns3::HeSigHeader::~HeSigHeader
virtual ~HeSigHeader()
Definition:
wifi-phy-header.cc:696
ns3::HeSigHeader::Print
void Print(std::ostream &os) const
Definition:
wifi-phy-header.cc:718
ns3::HtSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:445
ns3::HeSigHeader::m_gi_ltf_size
uint8_t m_gi_ltf_size
GI+LTF Size field.
Definition:
wifi-phy-header.h:441
ns3::VhtSigHeader::GetChannelWidth
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
Definition:
wifi-phy-header.cc:557
ns3::VhtSigHeader::GetInstanceTypeId
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
wifi-phy-header.cc:501
ns3::VhtSigHeader::SetShortGuardIntervalDisambiguation
void SetShortGuardIntervalDisambiguation(bool disambiguation)
Fill the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:603
ns3::LSigHeader::SetRate
void SetRate(uint64_t rate, uint16_t channelWidth=20)
Fill the RATE field of L-SIG (in bit/s).
Definition:
wifi-phy-header.cc:196
ns3::HeSigHeader::m_nsts
uint8_t m_nsts
NSTS.
Definition:
wifi-phy-header.h:442
ns3::HeSigHeader::SetBssColor
void SetBssColor(uint8_t bssColor)
Fill the BSS Color field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:761
ns3::DsssSigHeader::SetRate
void SetRate(uint64_t rate)
Fill the RATE field of L-SIG (in bit/s).
Definition:
wifi-phy-header.cc:68
std
STL namespace.
ns3::VhtSigHeader::m_nsts
uint8_t m_nsts
NSTS.
Definition:
wifi-phy-header.h:329
ns3::DsssSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:143
ns3::HeSigHeader::GetMcs
uint8_t GetMcs(void) const
Return the MCS field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:755
ns3::DsssSigHeader::GetLength
uint16_t GetLength(void) const
Return the LENGTH field of L-SIG (in bytes).
Definition:
wifi-phy-header.cc:128
ns3::DsssSigHeader::m_length
uint16_t m_length
LENGTH field.
Definition:
wifi-phy-header.h:79
ns3::VhtSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:654
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::VhtSigHeader::m_bw
uint8_t m_bw
BW.
Definition:
wifi-phy-header.h:328
ns3::DsssSigHeader::GetInstanceTypeId
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
wifi-phy-header.cc:49
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:783
ns3::LSigHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
wifi-phy-header.cc:166
ns3::DsssSigHeader::DsssSigHeader
DsssSigHeader()
Definition:
wifi-phy-header.cc:27
ns3::HtSigHeader::GetInstanceTypeId
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
wifi-phy-header.cc:362
ns3::DsssSigHeader::~DsssSigHeader
virtual ~DsssSigHeader()
Definition:
wifi-phy-header.cc:33
ns3::DsssSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:134
ns3::HtSigHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wifi-phy-header.cc:378
ns3::HeSigHeader::SetMcs
void SetMcs(uint8_t mcs)
Fill the MCS field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:748
ns3::LSigHeader::m_rate
uint8_t m_rate
RATE field.
Definition:
wifi-phy-header.h:135
ns3::VhtSigHeader::SetNStreams
void SetNStreams(uint8_t nStreams)
Fill the number of streams field of VHT-SIG-A1.
Definition:
wifi-phy-header.cc:578
ns3::LSigHeader::Print
void Print(std::ostream &os) const
Definition:
wifi-phy-header.cc:183
ns3::VhtSigHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wifi-phy-header.cc:517
ns3::VhtSigHeader::SetSuMcs
void SetSuMcs(uint8_t mcs)
Fill the SU VHT MCS field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:615
ns3::HeSigHeader::m_mu
bool m_mu
This is used to decide whether MU SIG-B should be added or not.
Definition:
wifi-phy-header.h:445
ns3::HeSigHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wifi-phy-header.cc:729
ns3::HtSigHeader::GetShortGuardInterval
bool GetShortGuardInterval(void) const
Return the short guard interval field of HT-SIG.
Definition:
wifi-phy-header.cc:439
ns3::LSigHeader::GetLength
uint16_t GetLength(void) const
Return the LENGTH field of L-SIG (in bytes).
Definition:
wifi-phy-header.cc:301
ns3::LSigHeader::LSigHeader
LSigHeader()
Definition:
wifi-phy-header.cc:155
ns3::HtSigHeader::~HtSigHeader
virtual ~HtSigHeader()
Definition:
wifi-phy-header.cc:346
ns3::LSigHeader
Implements the IEEE 802.11 OFDM and ERP OFDM L-SIG PHY header.
Definition:
wifi-phy-header.h:89
ns3::VhtSigHeader::SetMuFlag
void SetMuFlag(bool mu)
Set the Multi-User (MU) flag.
Definition:
wifi-phy-header.cc:530
ns3::VhtSigHeader::~VhtSigHeader
virtual ~VhtSigHeader()
Definition:
wifi-phy-header.cc:485
ns3::VhtSigHeader::GetNStreams
uint8_t GetNStreams(void) const
Return the number of streams.
Definition:
wifi-phy-header.cc:585
ns3::LSigHeader::SetLength
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition:
wifi-phy-header.cc:294
ns3::HeSigHeader::GetNStreams
uint8_t GetNStreams(void) const
Return the number of streams.
Definition:
wifi-phy-header.cc:862
ns3::HtSigHeader::SetAggregation
void SetAggregation(bool aggregation)
Fill the aggregation field of HT-SIG.
Definition:
wifi-phy-header.cc:421
ns3::VhtSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:628
ns3::HeSigHeader::SetChannelWidth
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of HE-SIG-A1 (in MHz).
Definition:
wifi-phy-header.cc:774
ns3::LSigHeader::m_length
uint16_t m_length
LENGTH field.
Definition:
wifi-phy-header.h:136
ns3::DsssSigHeader::m_rate
uint8_t m_rate
RATE field.
Definition:
wifi-phy-header.h:78
ns3::HtSigHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
wifi-phy-header.cc:351
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::VhtSigHeader::Print
void Print(std::ostream &os) const
Definition:
wifi-phy-header.cc:507
ns3::HtSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:459
ns3::HeSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:897
ns3::HtSigHeader::GetAggregation
bool GetAggregation(void) const
Return the aggregation field of HT-SIG.
Definition:
wifi-phy-header.cc:427
ns3::VhtSigHeader::m_sgi_disambiguation
uint8_t m_sgi_disambiguation
Short GI NSYM Disambiguation.
Definition:
wifi-phy-header.h:333
ns3::HeSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:868
ns3::HtSigHeader::GetMcs
uint8_t GetMcs(void) const
Return the MCS field of HT-SIG.
Definition:
wifi-phy-header.cc:391
ns3::VhtSigHeader::m_suMcs
uint8_t m_suMcs
SU VHT MCS.
Definition:
wifi-phy-header.h:334
ns3::VhtSigHeader::m_sgi
uint8_t m_sgi
Short GI.
Definition:
wifi-phy-header.h:332
ns3::HtSigHeader::SetChannelWidth
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of HT-SIG (in MHz).
Definition:
wifi-phy-header.cc:397
ns3::DsssSigHeader::GetRate
uint64_t GetRate(void) const
Return the RATE field of L-SIG (in bit/s).
Definition:
wifi-phy-header.cc:97
ns3::LSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:307
wifi-phy-header.h
ns3::HtSigHeader
Implements the IEEE 802.11n PHY header (HT-SIG1/2).
Definition:
wifi-phy-header.h:146
ns3::LSigHeader::~LSigHeader
virtual ~LSigHeader()
Definition:
wifi-phy-header.cc:161
ns3::VhtSigHeader::m_mu
bool m_mu
This is used to decide whether MU SIG-B should be added or not.
Definition:
wifi-phy-header.h:337
ns3::VhtSigHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
wifi-phy-header.cc:490
ns3::HtSigHeader::SetHtLength
void SetHtLength(uint16_t length)
Fill the HT length field of HT-SIG (in bytes).
Definition:
wifi-phy-header.cc:409
ns3::VhtSigHeader::GetSuMcs
uint8_t GetSuMcs(void) const
Return the SU VHT MCS field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:622
ns3::VhtSigHeader::GetShortGuardInterval
bool GetShortGuardInterval(void) const
Return the short GI field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:597
ns3::HeSigHeader
Implements the IEEE 802.11ax HE-SIG PHY header (HE-SIG-A1/A2/B)
Definition:
wifi-phy-header.h:346
ns3::DsssSigHeader
Implements the IEEE 802.11 DSSS SIG PHY header.
Definition:
wifi-phy-header.h:34
ns3::HtSigHeader::GetHtLength
uint16_t GetHtLength(void) const
Return the HT length field of HT-SIG (in bytes).
Definition:
wifi-phy-header.cc:415
ns3::HeSigHeader::SetGuardIntervalAndLtfSize
void SetGuardIntervalAndLtfSize(uint16_t gi, uint8_t ltf)
Fill the GI + LTF size field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:816
ns3::DsssSigHeader::SetLength
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition:
wifi-phy-header.cc:122
ns3::HeSigHeader::GetInstanceTypeId
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
wifi-phy-header.cc:712
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:1021
ns3::VhtSigHeader::SetShortGuardInterval
void SetShortGuardInterval(bool sgi)
Fill the short guard interval field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:591
ns3::LSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:321
ns3::HeSigHeader::GetGuardInterval
uint16_t GetGuardInterval(void) const
Return the guard interval (in nanoseconds).
Definition:
wifi-phy-header.cc:837
ns3::DsssSigHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wifi-phy-header.cc:62
ns3::LSigHeader::GetRate
uint64_t GetRate(uint16_t channelWidth=20) const
Return the RATE field of L-SIG (in bit/s).
Definition:
wifi-phy-header.cc:249
ns3::HtSigHeader::m_mcs
uint8_t m_mcs
Modulation and Coding Scheme index.
Definition:
wifi-phy-header.h:226
ns3::HeSigHeader::GetBssColor
uint8_t GetBssColor(void) const
Return the BSS Color field in the HE-SIG-A1.
Definition:
wifi-phy-header.cc:768
ns3::DsssSigHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
wifi-phy-header.cc:38
ns3::HtSigHeader::SetShortGuardInterval
void SetShortGuardInterval(bool sgi)
Fill the short guard interval field of HT-SIG.
Definition:
wifi-phy-header.cc:433
ns3::LSigHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wifi-phy-header.cc:190
ns3::HeSigHeader::HeSigHeader
HeSigHeader()
Definition:
wifi-phy-header.cc:683
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::HtSigHeader::m_aggregation
uint8_t m_aggregation
Aggregation.
Definition:
wifi-phy-header.h:229
ns3::VhtSigHeader::GetShortGuardIntervalDisambiguation
bool GetShortGuardIntervalDisambiguation(void) const
Return the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:609
ns3::VhtSigHeader::VhtSigHeader
VhtSigHeader()
Definition:
wifi-phy-header.cc:475
ns3::LSigHeader::GetInstanceTypeId
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
wifi-phy-header.cc:177
ns3::HeSigHeader::m_bssColor
uint8_t m_bssColor
BSS color field.
Definition:
wifi-phy-header.h:436
src
wifi
model
wifi-phy-header.cc
Generated on Sun Jun 28 2020 12:05:54 for ns-3 by
1.8.14