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 < 20)
199
{
200
//conversion for 5 MHz and 10 MHz
201
rate *= (20 / channelWidth);
202
}
203
/* Here is the binary representation for a given rate:
204
* 6 Mbit/s: 1101
205
* 9 Mbit/s: 1111
206
* 12 Mbit/s: 0101
207
* 18 Mbit/s: 0111
208
* 24 Mbit/s: 1001
209
* 36 Mbit/s: 1011
210
* 48 Mbit/s: 0001
211
* 54 Mbit/s: 0011
212
*/
213
switch
(rate)
214
{
215
case
6000000:
216
m_rate
= 0b1101;
217
break
;
218
case
9000000:
219
m_rate
= 0b1111;
220
break
;
221
case
12000000:
222
m_rate
= 0b0101;
223
break
;
224
case
18000000:
225
m_rate
= 0b0111;
226
break
;
227
case
24000000:
228
m_rate
= 0b1001;
229
break
;
230
case
36000000:
231
m_rate
= 0b1011;
232
break
;
233
case
48000000:
234
m_rate
= 0b0001;
235
break
;
236
case
54000000:
237
m_rate
= 0b0011;
238
break
;
239
default
:
240
NS_ASSERT_MSG
(
false
,
"Invalid rate"
);
241
break
;
242
}
243
}
244
245
uint64_t
246
LSigHeader::GetRate
(uint16_t channelWidth)
const
247
{
248
uint64_t rate = 0;
249
switch
(
m_rate
)
250
{
251
case
0b1101:
252
rate = 6000000;
253
break
;
254
case
0b1111:
255
rate = 9000000;
256
break
;
257
case
0b0101:
258
rate = 12000000;
259
break
;
260
case
0b0111:
261
rate = 18000000;
262
break
;
263
case
0b1001:
264
rate = 24000000;
265
break
;
266
case
0b1011:
267
rate = 36000000;
268
break
;
269
case
0b0001:
270
rate = 48000000;
271
break
;
272
case
0b0011:
273
rate = 54000000;
274
break
;
275
default
:
276
NS_ASSERT_MSG
(
false
,
"Invalid rate"
);
277
break
;
278
}
279
if
(channelWidth == 5)
280
{
281
rate /= 4;
//compute corresponding 5 MHz rate
282
}
283
else
if
(channelWidth == 10)
284
{
285
rate /= 2;
//compute corresponding 10 MHz rate
286
}
287
return
rate;
288
}
289
290
void
291
LSigHeader::SetLength
(uint16_t length)
292
{
293
NS_ASSERT_MSG
(length < 4096,
"Invalid length"
);
294
m_length
= length;
295
}
296
297
uint16_t
298
LSigHeader::GetLength
(
void
)
const
299
{
300
return
m_length
;
301
}
302
303
void
304
LSigHeader::Serialize
(
Buffer::Iterator
start
)
const
305
{
306
uint8_t byte = 0;
307
uint16_t bytes = 0;
308
309
byte |=
m_rate
;
310
byte |= (
m_length
& 0x07) << 5;
311
start
.WriteU8 (byte);
312
313
bytes |= (
m_length
& 0x0ff8) >> 3;
314
start
.WriteU16 (bytes);
315
}
316
317
uint32_t
318
LSigHeader::Deserialize
(
Buffer::Iterator
start
)
319
{
320
Buffer::Iterator
i =
start
;
321
322
uint8_t byte = i.
ReadU8
();
323
m_rate
= byte & 0x0f;
324
m_length
= (byte >> 5) & 0x07;
325
326
uint16_t bytes = i.
ReadU16
();
327
m_length
|= (bytes << 3) & 0x0ff8;
328
329
return
i.
GetDistanceFrom
(
start
);
330
}
331
332
NS_OBJECT_ENSURE_REGISTERED
(
HtSigHeader
);
333
334
HtSigHeader::HtSigHeader
()
335
: m_mcs (0),
336
m_cbw20_40 (0),
337
m_htLength (0),
338
m_aggregation (0),
339
m_sgi (0)
340
{
341
}
342
343
HtSigHeader::~HtSigHeader
()
344
{
345
}
346
347
TypeId
348
HtSigHeader::GetTypeId
(
void
)
349
{
350
static
TypeId
tid =
TypeId
(
"ns3::HtSigHeader"
)
351
.
SetParent
<
Header
> ()
352
.SetGroupName (
"Wifi"
)
353
.AddConstructor<
HtSigHeader
> ()
354
;
355
return
tid;
356
}
357
358
TypeId
359
HtSigHeader::GetInstanceTypeId
(
void
)
const
360
{
361
return
GetTypeId
();
362
}
363
364
void
365
HtSigHeader::Print
(std::ostream &os)
const
366
{
367
os <<
"MCS="
<< +
m_mcs
368
<<
" HT_LENGTH="
<<
m_htLength
369
<<
" CHANNEL_WIDTH="
<<
GetChannelWidth
()
370
<<
" FEC_CODING="
<< (
m_fecCoding
?
"LDPC"
:
"BCC"
)
371
<<
" SGI="
<< +
m_sgi
372
<<
" AGGREGATION="
<< +
m_aggregation
;
373
}
374
375
uint32_t
376
HtSigHeader::GetSerializedSize
(
void
)
const
377
{
378
return
6;
379
}
380
381
void
382
HtSigHeader::SetMcs
(uint8_t mcs)
383
{
384
NS_ASSERT
(mcs <= 31);
385
m_mcs
= mcs;
386
}
387
388
uint8_t
389
HtSigHeader::GetMcs
(
void
)
const
390
{
391
return
m_mcs
;
392
}
393
394
void
395
HtSigHeader::SetChannelWidth
(uint16_t channelWidth)
396
{
397
m_cbw20_40
= (channelWidth > 20) ? 1 : 0;
398
}
399
400
uint16_t
401
HtSigHeader::GetChannelWidth
(
void
)
const
402
{
403
return
m_cbw20_40
? 40 : 20;
404
}
405
406
void
407
HtSigHeader::SetHtLength
(uint16_t length)
408
{
409
m_htLength
= length;
410
}
411
412
uint16_t
413
HtSigHeader::GetHtLength
(
void
)
const
414
{
415
return
m_htLength
;
416
}
417
418
void
419
HtSigHeader::SetAggregation
(
bool
aggregation)
420
{
421
m_aggregation
= aggregation ? 1 : 0;
422
}
423
424
bool
425
HtSigHeader::GetAggregation
(
void
)
const
426
{
427
return
m_aggregation
? true :
false
;
428
}
429
430
void
431
HtSigHeader::SetFecCoding
(
bool
ldpc)
432
{
433
m_fecCoding
= ldpc ? 1 : 0;
434
}
435
436
bool
437
HtSigHeader::IsLdpcFecCoding
(
void
)
const
438
{
439
return
m_fecCoding
? true :
false
;
440
}
441
442
void
443
HtSigHeader::SetShortGuardInterval
(
bool
sgi
)
444
{
445
m_sgi
=
sgi
? 1 : 0;
446
}
447
448
bool
449
HtSigHeader::GetShortGuardInterval
(
void
)
const
450
{
451
return
m_sgi
? true :
false
;
452
}
453
454
void
455
HtSigHeader::Serialize
(
Buffer::Iterator
start
)
const
456
{
457
uint8_t byte =
m_mcs
;
458
byte |= ((
m_cbw20_40
& 0x01) << 7);
459
start
.WriteU8 (byte);
460
start
.WriteU16 (
m_htLength
);
461
byte = (0x01 << 2);
//Set Reserved bit #2 to 1
462
byte |= ((
m_aggregation
& 0x01) << 3);
463
byte |= ((
m_fecCoding
& 0x01) << 6);
464
byte |= ((
m_sgi
& 0x01) << 7);
465
start
.WriteU8 (byte);
466
start
.WriteU16 (0);
467
}
468
469
uint32_t
470
HtSigHeader::Deserialize
(
Buffer::Iterator
start
)
471
{
472
Buffer::Iterator
i =
start
;
473
uint8_t byte = i.
ReadU8
();
474
m_mcs
= byte & 0x7f;
475
m_cbw20_40
= ((byte >> 7) & 0x01);
476
m_htLength
= i.
ReadU16
();
477
byte = i.
ReadU8
();
478
m_aggregation
= ((byte >> 3) & 0x01);
479
m_fecCoding
= ((byte >> 6) & 0x01);
480
m_sgi
= ((byte >> 7) & 0x01);
481
i.
ReadU16
();
482
return
i.
GetDistanceFrom
(
start
);
483
}
484
485
NS_OBJECT_ENSURE_REGISTERED
(
VhtSigHeader
);
486
487
VhtSigHeader::VhtSigHeader
()
488
: m_bw (0),
489
m_nsts (0),
490
m_sgi (0),
491
m_sgi_disambiguation (0),
492
m_suMcs (0),
493
m_mu (false)
494
{
495
}
496
497
VhtSigHeader::~VhtSigHeader
()
498
{
499
}
500
501
TypeId
502
VhtSigHeader::GetTypeId
(
void
)
503
{
504
static
TypeId
tid =
TypeId
(
"ns3::VhtSigHeader"
)
505
.
SetParent
<
Header
> ()
506
.SetGroupName (
"Wifi"
)
507
.AddConstructor<
VhtSigHeader
> ()
508
;
509
return
tid;
510
}
511
512
TypeId
513
VhtSigHeader::GetInstanceTypeId
(
void
)
const
514
{
515
return
GetTypeId
();
516
}
517
518
void
519
VhtSigHeader::Print
(std::ostream &os)
const
520
{
521
os <<
"SU_MCS="
<< +
m_suMcs
522
<<
" CHANNEL_WIDTH="
<<
GetChannelWidth
()
523
<<
" SGI="
<< +
m_sgi
524
<<
" NSTS="
<< +
m_nsts
525
<<
" CODING="
<< (
m_coding
?
"LDPC"
:
"BCC"
)
526
<<
" MU="
<< +
m_mu
;
527
}
528
529
uint32_t
530
VhtSigHeader::GetSerializedSize
(
void
)
const
531
{
532
uint32_t size = 0;
533
size += 3;
//VHT-SIG-A1
534
size += 3;
//VHT-SIG-A2
535
if
(
m_mu
)
536
{
537
size += 4;
//VHT-SIG-B
538
}
539
return
size;
540
}
541
542
void
543
VhtSigHeader::SetMuFlag
(
bool
mu)
544
{
545
m_mu
= mu;
546
}
547
548
void
549
VhtSigHeader::SetChannelWidth
(uint16_t channelWidth)
550
{
551
if
(channelWidth == 160)
552
{
553
m_bw
= 3;
554
}
555
else
if
(channelWidth == 80)
556
{
557
m_bw
= 2;
558
}
559
else
if
(channelWidth == 40)
560
{
561
m_bw
= 1;
562
}
563
else
564
{
565
m_bw
= 0;
566
}
567
}
568
569
uint16_t
570
VhtSigHeader::GetChannelWidth
(
void
)
const
571
{
572
if
(
m_bw
== 3)
573
{
574
return
160;
575
}
576
else
if
(
m_bw
== 2)
577
{
578
return
80;
579
}
580
else
if
(
m_bw
== 1)
581
{
582
return
40;
583
}
584
else
585
{
586
return
20;
587
}
588
}
589
590
void
591
VhtSigHeader::SetNStreams
(uint8_t nStreams)
592
{
593
NS_ASSERT
(nStreams <= 8);
594
m_nsts
= (nStreams - 1);
595
}
596
597
uint8_t
598
VhtSigHeader::GetNStreams
(
void
)
const
599
{
600
return
(
m_nsts
+ 1);
601
}
602
603
void
604
VhtSigHeader::SetShortGuardInterval
(
bool
sgi
)
605
{
606
m_sgi
=
sgi
? 1 : 0;
607
}
608
609
bool
610
VhtSigHeader::GetShortGuardInterval
(
void
)
const
611
{
612
return
m_sgi
? true :
false
;
613
}
614
615
void
616
VhtSigHeader::SetShortGuardIntervalDisambiguation
(
bool
disambiguation)
617
{
618
m_sgi_disambiguation
= disambiguation ? 1 : 0;
619
}
620
621
bool
622
VhtSigHeader::GetShortGuardIntervalDisambiguation
(
void
)
const
623
{
624
return
m_sgi_disambiguation
? true :
false
;
625
}
626
627
void
628
VhtSigHeader::SetCoding
(
bool
ldpc)
629
{
630
m_coding
= ldpc ? 1 : 0;
631
}
632
633
bool
634
VhtSigHeader::IsLdpcCoding
(
void
)
const
635
{
636
return
m_coding
? true :
false
;
637
638
}
639
640
void
641
VhtSigHeader::SetSuMcs
(uint8_t mcs)
642
{
643
NS_ASSERT
(mcs <= 9);
644
m_suMcs
= mcs;
645
}
646
647
uint8_t
648
VhtSigHeader::GetSuMcs
(
void
)
const
649
{
650
return
m_suMcs
;
651
}
652
653
void
654
VhtSigHeader::Serialize
(
Buffer::Iterator
start
)
const
655
{
656
//VHT-SIG-A1
657
uint8_t byte =
m_bw
;
658
byte |= (0x01 << 2);
//Set Reserved bit #2 to 1
659
start
.WriteU8 (byte);
660
uint16_t bytes = (
m_nsts
& 0x07) << 2;
661
bytes |= (0x01 << (23 - 8));
//Set Reserved bit #23 to 1
662
start
.WriteU16 (bytes);
663
664
//VHT-SIG-A2
665
byte =
m_sgi
& 0x01;
666
byte |= ((
m_sgi_disambiguation
& 0x01) << 1);
667
byte |= ((
m_coding
& 0x01) << 2);
668
byte |= ((
m_suMcs
& 0x0f) << 4);
669
start
.WriteU8 (byte);
670
bytes = (0x01 << (9 - 8));
//Set Reserved bit #9 to 1
671
start
.WriteU16 (bytes);
672
673
if
(
m_mu
)
674
{
675
//VHT-SIG-B
676
start
.WriteU32 (0);
677
}
678
}
679
680
uint32_t
681
VhtSigHeader::Deserialize
(
Buffer::Iterator
start
)
682
{
683
Buffer::Iterator
i =
start
;
684
685
//VHT-SIG-A1
686
uint8_t byte = i.
ReadU8
();
687
m_bw
= byte & 0x03;
688
uint16_t bytes = i.
ReadU16
();
689
m_nsts
= ((bytes >> 2) & 0x07);
690
691
//VHT-SIG-A2
692
byte = i.
ReadU8
();
693
m_sgi
= byte & 0x01;
694
m_sgi_disambiguation
= ((byte >> 1) & 0x01);
695
m_coding
= ((byte >> 2) & 0x01);
696
m_suMcs
= ((byte >> 4) & 0x0f);
697
i.
ReadU16
();
698
699
if
(
m_mu
)
700
{
701
//VHT-SIG-B
702
i.
ReadU32
();
703
}
704
705
return
i.
GetDistanceFrom
(
start
);
706
}
707
708
709
NS_OBJECT_ENSURE_REGISTERED
(
HeSigHeader
);
710
711
HeSigHeader::HeSigHeader
()
712
: m_format (1),
713
m_bssColor (0),
714
m_ul_dl (0),
715
m_mcs (0),
716
m_spatialReuse (0),
717
m_bandwidth (0),
718
m_gi_ltf_size (0),
719
m_nsts (0),
720
m_mu (false)
721
{
722
}
723
724
HeSigHeader::~HeSigHeader
()
725
{
726
}
727
728
TypeId
729
HeSigHeader::GetTypeId
(
void
)
730
{
731
static
TypeId
tid =
TypeId
(
"ns3::HeSigHeader"
)
732
.
SetParent
<
Header
> ()
733
.SetGroupName (
"Wifi"
)
734
.AddConstructor<
HeSigHeader
> ()
735
;
736
return
tid;
737
}
738
739
TypeId
740
HeSigHeader::GetInstanceTypeId
(
void
)
const
741
{
742
return
GetTypeId
();
743
}
744
745
void
746
HeSigHeader::Print
(std::ostream &os)
const
747
{
748
os <<
"MCS="
<< +
m_mcs
749
<<
" CHANNEL_WIDTH="
<<
GetChannelWidth
()
750
<<
" GI="
<<
GetGuardInterval
()
751
<<
" NSTS="
<< +
m_nsts
752
<<
" BSSColor="
<< +
m_bssColor
753
<<
" CODING="
<< (
m_coding
?
"LDPC"
:
"BCC"
)
754
<<
" MU="
<< +
m_mu
;
755
}
756
757
uint32_t
758
HeSigHeader::GetSerializedSize
(
void
)
const
759
{
760
uint32_t size = 0;
761
size += 4;
//HE-SIG-A1
762
size += 4;
//HE-SIG-A2
763
if
(
m_mu
)
764
{
765
size += 1;
//HE-SIG-B
766
}
767
return
size;
768
}
769
770
void
771
HeSigHeader::SetMuFlag
(
bool
mu)
772
{
773
m_mu
= mu;
774
}
775
776
void
777
HeSigHeader::SetMcs
(uint8_t mcs)
778
{
779
NS_ASSERT
(mcs <= 11);
780
m_mcs
= mcs;
781
}
782
783
uint8_t
784
HeSigHeader::GetMcs
(
void
)
const
785
{
786
return
m_mcs
;
787
}
788
789
void
790
HeSigHeader::SetBssColor
(uint8_t bssColor)
791
{
792
NS_ASSERT
(bssColor < 64);
793
m_bssColor
= bssColor;
794
}
795
796
uint8_t
797
HeSigHeader::GetBssColor
(
void
)
const
798
{
799
return
m_bssColor
;
800
}
801
802
void
803
HeSigHeader::SetChannelWidth
(uint16_t channelWidth)
804
{
805
if
(channelWidth == 160)
806
{
807
m_bandwidth
= 3;
808
}
809
else
if
(channelWidth == 80)
810
{
811
m_bandwidth
= 2;
812
}
813
else
if
(channelWidth == 40)
814
{
815
m_bandwidth
= 1;
816
}
817
else
818
{
819
m_bandwidth
= 0;
820
}
821
}
822
823
uint16_t
824
HeSigHeader::GetChannelWidth
(
void
)
const
825
{
826
if
(
m_bandwidth
== 3)
827
{
828
return
160;
829
}
830
else
if
(
m_bandwidth
== 2)
831
{
832
return
80;
833
}
834
else
if
(
m_bandwidth
== 1)
835
{
836
return
40;
837
}
838
else
839
{
840
return
20;
841
}
842
}
843
844
void
845
HeSigHeader::SetGuardIntervalAndLtfSize
(uint16_t gi, uint8_t ltf)
846
{
847
if
(gi == 800 && ltf == 1)
848
{
849
m_gi_ltf_size
= 0;
850
}
851
else
if
(gi == 800 && ltf == 2)
852
{
853
m_gi_ltf_size
= 1;
854
}
855
else
if
(gi == 1600 && ltf == 2)
856
{
857
m_gi_ltf_size
= 2;
858
}
859
else
860
{
861
m_gi_ltf_size
= 3;
862
}
863
}
864
865
uint16_t
866
HeSigHeader::GetGuardInterval
(
void
)
const
867
{
868
if
(
m_gi_ltf_size
== 3)
869
{
870
//we currently do not consider DCM nor STBC fields
871
return
3200;
872
}
873
else
if
(
m_gi_ltf_size
== 2)
874
{
875
return
1600;
876
}
877
else
878
{
879
return
800;
880
}
881
}
882
883
void
884
HeSigHeader::SetNStreams
(uint8_t nStreams)
885
{
886
NS_ASSERT
(nStreams <= 8);
887
m_nsts
= (nStreams - 1);
888
}
889
890
uint8_t
891
HeSigHeader::GetNStreams
(
void
)
const
892
{
893
return
(
m_nsts
+ 1);
894
}
895
896
void
897
HeSigHeader::SetCoding
(
bool
ldpc)
898
{
899
m_coding
= ldpc ? 1 : 0;
900
}
901
902
bool
903
HeSigHeader::IsLdpcCoding
(
void
)
const
904
{
905
return
m_coding
? true :
false
;
906
907
}
908
909
void
910
HeSigHeader::Serialize
(
Buffer::Iterator
start
)
const
911
{
912
//HE-SIG-A1
913
uint8_t byte =
m_format
& 0x01;
914
byte |= ((
m_ul_dl
& 0x01) << 2);
915
byte |= ((
m_mcs
& 0x0f) << 3);
916
start
.WriteU8 (byte);
917
uint16_t bytes = (
m_bssColor
& 0x3f);
918
bytes |= (0x01 << 6);
//Reserved set to 1
919
bytes |= ((
m_spatialReuse
& 0x0f) << 7);
920
bytes |= ((
m_bandwidth
& 0x03) << 11);
921
bytes |= ((
m_gi_ltf_size
& 0x03) << 13);
922
bytes |= ((
m_nsts
& 0x01) << 15);
923
start
.WriteU16 (bytes);
924
start
.WriteU8 ((
m_nsts
>> 1) & 0x03);
925
926
//HE-SIG-A2
927
uint32_t sigA2 = 0;
928
sigA2 |= ((
m_coding
& 0x01) << 7);
929
sigA2 |= (0x01 << 14);
//Set Reserved bit #14 to 1
930
start
.WriteU32 (sigA2);
931
932
if
(
m_mu
)
933
{
934
//HE-SIG-B
935
start
.WriteU8 (0);
936
}
937
}
938
939
uint32_t
940
HeSigHeader::Deserialize
(
Buffer::Iterator
start
)
941
{
942
Buffer::Iterator
i =
start
;
943
944
//HE-SIG-A1
945
uint8_t byte = i.
ReadU8
();
946
m_format
= (byte & 0x01);
947
m_ul_dl
= ((byte >> 2) & 0x01);
948
m_mcs
= ((byte >> 3) & 0x0f);
949
uint16_t bytes = i.
ReadU16
();
950
m_bssColor
= (bytes & 0x3f);
951
m_spatialReuse
= ((bytes >> 7) & 0x0f);
952
m_bandwidth
= ((bytes >> 11) & 0x03);
953
m_gi_ltf_size
= ((bytes >> 13) & 0x03);
954
m_nsts
= ((bytes >> 15) & 0x01);
955
byte = i.
ReadU8
();
956
m_nsts
|= (byte & 0x03) << 1;
957
958
//HE-SIG-A2
959
uint32_t sigA2 = i.
ReadU32
();
960
m_coding
= ((sigA2 >> 7) & 0x01);
961
962
if
(
m_mu
)
963
{
964
//HE-SIG-B
965
i.
ReadU8
();
966
}
967
968
return
i.
GetDistanceFrom
(
start
);
969
}
970
971
}
//namespace ns3
ns3::VhtSigHeader::IsLdpcCoding
bool IsLdpcCoding(void) const
Return whether LDPC is used or not.
Definition:
wifi-phy-header.cc:634
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:824
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:365
ns3::HeSigHeader::m_bandwidth
uint8_t m_bandwidth
Bandwidth field.
Definition:
wifi-phy-header.h:477
ns3::HtSigHeader::m_sgi
uint8_t m_sgi
Short Guard Interval.
Definition:
wifi-phy-header.h:243
ns3::HtSigHeader::SetFecCoding
void SetFecCoding(bool ldpc)
Fill the FEC coding field of HT-SIG.
Definition:
wifi-phy-header.cc:431
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:476
ns3::HtSigHeader::m_cbw20_40
uint8_t m_cbw20_40
CBW 20/40.
Definition:
wifi-phy-header.h:239
ns3::HtSigHeader::SetMcs
void SetMcs(uint8_t mcs)
Fill the MCS field of HT-SIG.
Definition:
wifi-phy-header.cc:382
ns3::HtSigHeader::m_htLength
uint16_t m_htLength
HT length.
Definition:
wifi-phy-header.h:240
ns3::VhtSigHeader::m_coding
uint8_t m_coding
SU/MU coding (0 for BCC, 1 for LDPC)
Definition:
wifi-phy-header.h:359
ns3::HeSigHeader::m_format
uint8_t m_format
Format bit.
Definition:
wifi-phy-header.h:472
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:549
ns3::HeSigHeader::m_ul_dl
uint8_t m_ul_dl
UL/DL bit.
Definition:
wifi-phy-header.h:474
ns3::HtSigHeader::GetChannelWidth
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
Definition:
wifi-phy-header.cc:401
ns3::HeSigHeader::SetMuFlag
void SetMuFlag(bool mu)
Set the Multi-User (MU) flag.
Definition:
wifi-phy-header.cc:771
ns3::HeSigHeader::m_mcs
uint8_t m_mcs
MCS field.
Definition:
wifi-phy-header.h:475
ns3::HeSigHeader::SetNStreams
void SetNStreams(uint8_t nStreams)
Fill the number of streams field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:884
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:729
ns3::VhtSigHeader
Implements the IEEE 802.11ac PHY header (VHT-SIG-A1/A2/B).
Definition:
wifi-phy-header.h:252
ns3::HtSigHeader::HtSigHeader
HtSigHeader()
Definition:
wifi-phy-header.cc:334
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:724
ns3::HeSigHeader::Print
void Print(std::ostream &os) const
Definition:
wifi-phy-header.cc:746
ns3::HtSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:455
ns3::HeSigHeader::m_gi_ltf_size
uint8_t m_gi_ltf_size
GI+LTF Size field.
Definition:
wifi-phy-header.h:478
ns3::VhtSigHeader::GetChannelWidth
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
Definition:
wifi-phy-header.cc:570
ns3::HeSigHeader::SetCoding
void SetCoding(bool ldpc)
Fill the coding field of HE-SIG-A2.
Definition:
wifi-phy-header.cc:897
ns3::VhtSigHeader::GetInstanceTypeId
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
wifi-phy-header.cc:513
ns3::VhtSigHeader::SetShortGuardIntervalDisambiguation
void SetShortGuardIntervalDisambiguation(bool disambiguation)
Fill the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:616
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:479
ns3::HeSigHeader::SetBssColor
void SetBssColor(uint8_t bssColor)
Fill the BSS Color field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:790
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:354
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:784
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:681
ns3::HeSigHeader::IsLdpcCoding
bool IsLdpcCoding(void) const
Return whether LDPC is used or not.
Definition:
wifi-phy-header.cc:903
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:353
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:359
ns3::VhtSigHeader::SetCoding
void SetCoding(bool ldpc)
Fill the coding field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:628
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:376
ns3::HeSigHeader::SetMcs
void SetMcs(uint8_t mcs)
Fill the MCS field of HE-SIG-A1.
Definition:
wifi-phy-header.cc:777
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:591
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:530
ns3::VhtSigHeader::SetSuMcs
void SetSuMcs(uint8_t mcs)
Fill the SU VHT MCS field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:641
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:485
ns3::HeSigHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wifi-phy-header.cc:758
ns3::HtSigHeader::GetShortGuardInterval
bool GetShortGuardInterval(void) const
Return the short guard interval field of HT-SIG.
Definition:
wifi-phy-header.cc:449
ns3::LSigHeader::GetLength
uint16_t GetLength(void) const
Return the LENGTH field of L-SIG (in bytes).
Definition:
wifi-phy-header.cc:298
ns3::HtSigHeader::m_fecCoding
uint8_t m_fecCoding
FEC coding (0 for BCC or 1 for LDPC)
Definition:
wifi-phy-header.h:242
ns3::LSigHeader::LSigHeader
LSigHeader()
Definition:
wifi-phy-header.cc:155
ns3::HtSigHeader::~HtSigHeader
virtual ~HtSigHeader()
Definition:
wifi-phy-header.cc:343
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:543
ns3::HeSigHeader::m_coding
uint8_t m_coding
Coding (0 for BCC, 1 for LDPC)
Definition:
wifi-phy-header.h:482
ns3::VhtSigHeader::~VhtSigHeader
virtual ~VhtSigHeader()
Definition:
wifi-phy-header.cc:497
ns3::VhtSigHeader::GetNStreams
uint8_t GetNStreams(void) const
Return the number of streams.
Definition:
wifi-phy-header.cc:598
ns3::LSigHeader::SetLength
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
Definition:
wifi-phy-header.cc:291
ns3::HeSigHeader::GetNStreams
uint8_t GetNStreams(void) const
Return the number of streams.
Definition:
wifi-phy-header.cc:891
ns3::HtSigHeader::SetAggregation
void SetAggregation(bool aggregation)
Fill the aggregation field of HT-SIG.
Definition:
wifi-phy-header.cc:419
ns3::VhtSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:654
ns3::HeSigHeader::SetChannelWidth
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of HE-SIG-A1 (in MHz).
Definition:
wifi-phy-header.cc:803
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:348
ns3::HtSigHeader::IsLdpcFecCoding
bool IsLdpcFecCoding(void) const
Return whether LDPC is used or not.
Definition:
wifi-phy-header.cc:437
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:519
ns3::HtSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:470
ns3::HeSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:940
ns3::HtSigHeader::GetAggregation
bool GetAggregation(void) const
Return the aggregation field of HT-SIG.
Definition:
wifi-phy-header.cc:425
ns3::VhtSigHeader::m_sgi_disambiguation
uint8_t m_sgi_disambiguation
Short GI NSYM Disambiguation.
Definition:
wifi-phy-header.h:358
ns3::HeSigHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wifi-phy-header.cc:910
ns3::HtSigHeader::GetMcs
uint8_t GetMcs(void) const
Return the MCS field of HT-SIG.
Definition:
wifi-phy-header.cc:389
ns3::VhtSigHeader::m_suMcs
uint8_t m_suMcs
SU VHT MCS.
Definition:
wifi-phy-header.h:360
ns3::VhtSigHeader::m_sgi
uint8_t m_sgi
Short GI.
Definition:
wifi-phy-header.h:357
ns3::HtSigHeader::SetChannelWidth
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of HT-SIG (in MHz).
Definition:
wifi-phy-header.cc:395
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:304
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:363
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition:
assert.h:88
ns3::VhtSigHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
wifi-phy-header.cc:502
ns3::HtSigHeader::SetHtLength
void SetHtLength(uint16_t length)
Fill the HT length field of HT-SIG (in bytes).
Definition:
wifi-phy-header.cc:407
ns3::VhtSigHeader::GetSuMcs
uint8_t GetSuMcs(void) const
Return the SU VHT MCS field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:648
ns3::VhtSigHeader::GetShortGuardInterval
bool GetShortGuardInterval(void) const
Return the short GI field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:610
ns3::HeSigHeader
Implements the IEEE 802.11ax HE-SIG PHY header (HE-SIG-A1/A2/B)
Definition:
wifi-phy-header.h:372
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:413
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:845
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:740
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:604
ns3::LSigHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start)
Definition:
wifi-phy-header.cc:318
ns3::HeSigHeader::GetGuardInterval
uint16_t GetGuardInterval(void) const
Return the guard interval (in nanoseconds).
Definition:
wifi-phy-header.cc:866
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:246
ns3::HtSigHeader::m_mcs
uint8_t m_mcs
Modulation and Coding Scheme index.
Definition:
wifi-phy-header.h:238
ns3::HeSigHeader::GetBssColor
uint8_t GetBssColor(void) const
Return the BSS Color field in the HE-SIG-A1.
Definition:
wifi-phy-header.cc:797
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:443
ns3::LSigHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wifi-phy-header.cc:190
ns3::HeSigHeader::HeSigHeader
HeSigHeader()
Definition:
wifi-phy-header.cc:711
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:241
ns3::VhtSigHeader::GetShortGuardIntervalDisambiguation
bool GetShortGuardIntervalDisambiguation(void) const
Return the short GI NSYM disambiguation field of VHT-SIG-A2.
Definition:
wifi-phy-header.cc:622
ns3::VhtSigHeader::VhtSigHeader
VhtSigHeader()
Definition:
wifi-phy-header.cc:487
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:473
src
wifi
model
wifi-phy-header.cc
Generated on Sat Jan 9 2021 14:08:55 for ns-3 by
1.8.14