packet-ieee80211-radio.c 92 KB
Newer Older
Anders Broman's avatar
Anders Broman committed
1
/* packet-ieee80211-radio.c
2
 * Routines for pseudo 802.11 header dissection and radio packet timing calculation
Anders Broman's avatar
Anders Broman committed
3
4
5
6
7
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
8
9
10
 * Copyright 2012 Parc Inc and Samsung Electronics
 * Copyright 2015, 2016 & 2017 Cisco Inc
 *
Anders Broman's avatar
Anders Broman committed
11
12
 * Copied from README.developer
 *
13
 * SPDX-License-Identifier: GPL-2.0-or-later
Anders Broman's avatar
Anders Broman committed
14
15
 */

16
#include "config.h"
Anders Broman's avatar
Anders Broman committed
17
18

#include <epan/packet.h>
19
#include <epan/expert.h>
20
#include <wiretap/wtap.h>
21
#include <epan/prefs.h>
22
#include <epan/proto_data.h>
23
#include <epan/tap.h>
24

Anders Broman's avatar
Anders Broman committed
25
#include "packet-ieee80211.h"
26
#include "packet-ieee80211-radio.h"
27
#include "packet-ieee80211-radiotap-defs.h"
28
#include "math.h"
Anders Broman's avatar
Anders Broman committed
29

Jakub Zawadzki's avatar
Jakub Zawadzki committed
30
31
32
void proto_register_ieee80211_radio(void);
void proto_reg_handoff_ieee80211_radio(void);

33
static dissector_handle_t wlan_radio_handle;
34
static dissector_handle_t wlan_noqos_radio_handle;
Anders Broman's avatar
Anders Broman committed
35
static dissector_handle_t ieee80211_handle;
36
static dissector_handle_t ieee80211_noqos_handle;
Anders Broman's avatar
Anders Broman committed
37

38
static int proto_wlan_radio = -1;
Anders Broman's avatar
Anders Broman committed
39
40
41
42

/* ************************************************************************* */
/*                Header field info values for radio information             */
/* ************************************************************************* */
43
44
45
46
47
48
49
50
51
52
53
static int hf_wlan_radio_phy = -1;
static int hf_wlan_radio_11_fhss_hop_set = -1;
static int hf_wlan_radio_11_fhss_hop_pattern = -1;
static int hf_wlan_radio_11_fhss_hop_index = -1;
static int hf_wlan_radio_11a_channel_type = -1;
static int hf_wlan_radio_11a_turbo_type = -1;
static int hf_wlan_radio_11g_mode = -1;
static int hf_wlan_radio_11n_mcs_index = -1;
static int hf_wlan_radio_11n_bandwidth = -1;
static int hf_wlan_radio_11n_short_gi = -1;
static int hf_wlan_radio_11n_greenfield = -1;
54
static int hf_wlan_radio_11n_fec = -1;
55
56
static int hf_wlan_radio_11n_stbc_streams = -1;
static int hf_wlan_radio_11n_ness = -1;
57
58
static int hf_wlan_radio_11ac_stbc = -1;
static int hf_wlan_radio_11ac_txop_ps_not_allowed = -1;
59
static int hf_wlan_radio_11ac_short_gi = -1;
60
61
62
63
64
65
66
67
68
69
70
static int hf_wlan_radio_11ac_short_gi_nsym_disambig = -1;
static int hf_wlan_radio_11ac_ldpc_extra_ofdm_symbol = -1;
static int hf_wlan_radio_11ac_beamformed = -1;
static int hf_wlan_radio_11ac_bandwidth = -1;
static int hf_wlan_radio_11ac_user = -1;
static int hf_wlan_radio_11ac_nsts = -1;
static int hf_wlan_radio_11ac_mcs = -1;
static int hf_wlan_radio_11ac_nss = -1;
static int hf_wlan_radio_11ac_fec = -1;
static int hf_wlan_radio_11ac_gid = -1;
static int hf_wlan_radio_11ac_p_aid = -1;
71
72
73
static int hf_wlan_radio_data_rate = -1;
static int hf_wlan_radio_channel = -1;
static int hf_wlan_radio_frequency = -1;
74
static int hf_wlan_radio_short_preamble = -1;
75
static int hf_wlan_radio_signal_percent = -1;
76
static int hf_wlan_radio_signal_db = -1;
Guy Harris's avatar
Guy Harris committed
77
static int hf_wlan_radio_signal_dbm = -1;
78
static int hf_wlan_radio_noise_percent = -1;
79
static int hf_wlan_radio_noise_db = -1;
Guy Harris's avatar
Guy Harris committed
80
81
static int hf_wlan_radio_noise_dbm = -1;
static int hf_wlan_radio_snr = -1;
82
static int hf_wlan_radio_timestamp = -1;
83
84
85
static int hf_wlan_last_part_of_a_mpdu = -1;
static int hf_wlan_a_mpdu_delim_crc_error = -1;
static int hf_wlan_a_mpdu_aggregate_id = -1;
86
87
static int hf_wlan_radio_duration = -1;
static int hf_wlan_radio_preamble = -1;
88
89
90
91
92
static int hf_wlan_radio_aggregate = -1;
static int hf_wlan_radio_aggregate_duration = -1;
static int hf_wlan_radio_ifs = -1;
static int hf_wlan_radio_start_tsf = -1;
static int hf_wlan_radio_end_tsf = -1;
93
static int hf_wlan_zero_length_psdu_type = -1;
94
95
96
97
98
99

static expert_field ei_wlan_radio_assumed_short_preamble = EI_INIT;
static expert_field ei_wlan_radio_assumed_non_greenfield = EI_INIT;
static expert_field ei_wlan_radio_assumed_no_stbc = EI_INIT;
static expert_field ei_wlan_radio_assumed_no_extension_streams = EI_INIT;
static expert_field ei_wlan_radio_assumed_bcc_fec = EI_INIT;
Anders Broman's avatar
Anders Broman committed
100

101
static int wlan_radio_tap = -1;
102
103
static int wlan_radio_timeline_tap = -1;

104
105
/* Settings */
static gboolean wlan_radio_always_short_preamble = FALSE;
106
static gboolean wlan_radio_tsf_at_end = TRUE;
107
static gboolean wlan_radio_timeline_enabled = FALSE;
108

109
110
111
112
static const value_string phy_vals[] = {
    { PHDR_802_11_PHY_11_FHSS,       "802.11 FHSS" },
    { PHDR_802_11_PHY_11_IR,         "802.11 IR" },
    { PHDR_802_11_PHY_11_DSSS,       "802.11 DSSS" },
113
114
115
116
117
118
119
    { PHDR_802_11_PHY_11B,           "802.11b (HR/DSSS)" },
    { PHDR_802_11_PHY_11A,           "802.11a (OFDM)" },
    { PHDR_802_11_PHY_11G,           "802.11g (ERP)" },
    { PHDR_802_11_PHY_11N,           "802.11n (HT)" },
    { PHDR_802_11_PHY_11AC,          "802.11ac (VHT)" },
    { PHDR_802_11_PHY_11AD,          "802.11ad (DMG)" },
    { PHDR_802_11_PHY_11AH,          "802.11ah (S1G)" },
Guy Harris's avatar
Guy Harris committed
120
    { PHDR_802_11_PHY_11AX,          "802.11ax (HE)" },
121
122
    { 0, NULL }
};
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

static const value_string channel_type_11a_vals[] = {
    { PHDR_802_11A_CHANNEL_TYPE_NORMAL,          "Normal" },
    { PHDR_802_11A_CHANNEL_TYPE_HALF_CLOCKED,    "Half-clocked" },
    { PHDR_802_11A_CHANNEL_TYPE_QUARTER_CLOCKED, "Quarter-clocked" },
    { 0, NULL }
};

static const value_string turbo_type_11a_vals[] = {
    { PHDR_802_11A_TURBO_TYPE_NORMAL,        "Non-turbo" },
    { PHDR_802_11A_TURBO_TYPE_TURBO,         "Turbo" },
    { PHDR_802_11A_TURBO_TYPE_DYNAMIC_TURBO, "Dynamic turbo" },
    { PHDR_802_11A_TURBO_TYPE_STATIC_TURBO,  "Static turbo" },
    { 0, NULL }
};

static const value_string mode_11g_vals[] = {
    { PHDR_802_11G_MODE_NORMAL,  "None" },
    { PHDR_802_11G_MODE_SUPER_G, "Super G" },
    { 0, NULL }
};

145
static const value_string bandwidth_vals[] = {
146
147
148
149
150
151
152
    { PHDR_802_11_BANDWIDTH_20_MHZ,  "20 MHz" },
    { PHDR_802_11_BANDWIDTH_40_MHZ,  "40 MHz" },
    { PHDR_802_11_BANDWIDTH_20_20L,  "20 MHz + 20 MHz lower" },
    { PHDR_802_11_BANDWIDTH_20_20U,  "20 MHz + 20 MHz upper" },
    { PHDR_802_11_BANDWIDTH_80_MHZ,  "80 MHz" },
    { PHDR_802_11_BANDWIDTH_40_40L,  "40 MHz + 40 MHz lower" },
    { PHDR_802_11_BANDWIDTH_40_40U,  "40 MHz + 40 MHz upper" },
153
154
155
156
    { PHDR_802_11_BANDWIDTH_20LL,    "20 MHz, channel 1/4" },
    { PHDR_802_11_BANDWIDTH_20LU,    "20 MHz, channel 2/4" },
    { PHDR_802_11_BANDWIDTH_20UL,    "20 MHz, channel 3/4" },
    { PHDR_802_11_BANDWIDTH_20UU,    "20 MHz, channel 4/4" },
157
158
159
    { PHDR_802_11_BANDWIDTH_160_MHZ, "160 MHz" },
    { PHDR_802_11_BANDWIDTH_80_80L,  "80 MHz + 80 MHz lower" },
    { PHDR_802_11_BANDWIDTH_80_80U,  "80 MHz + 80 MHz upper" },
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
    { PHDR_802_11_BANDWIDTH_40LL,    "40 MHz, channel 1/4" },
    { PHDR_802_11_BANDWIDTH_40LU,    "40 MHz, channel 2/4" },
    { PHDR_802_11_BANDWIDTH_40UL,    "40 MHz, channel 3/4" },
    { PHDR_802_11_BANDWIDTH_40UU,    "40 MHz, channel 4/4" },
    { PHDR_802_11_BANDWIDTH_20LLL,   "20 MHz, channel 1/8" },
    { PHDR_802_11_BANDWIDTH_20LLU,   "20 MHz, channel 2/8" },
    { PHDR_802_11_BANDWIDTH_20LUL,   "20 MHz, channel 3/8" },
    { PHDR_802_11_BANDWIDTH_20LUU,   "20 MHz, channel 4/8" },
    { PHDR_802_11_BANDWIDTH_20ULL,   "20 MHz, channel 5/8" },
    { PHDR_802_11_BANDWIDTH_20ULU,   "20 MHz, channel 6/8" },
    { PHDR_802_11_BANDWIDTH_20UUL,   "20 MHz, channel 7/8" },
    { PHDR_802_11_BANDWIDTH_20UUU,   "20 MHz, channel 8/8" },
    { 0, NULL }
};

static const value_string fec_vals[] = {
    { 0, "BEC" },
    { 1, "LDPC" },
178
179
180
    { 0, NULL }
};

181
182
183
184
185
186
static const value_string zero_length_psdu_vals[] = {
	{ 0, "sounding PPDU" },
	{ 1, "data not captured" },
	{ 255, "vendor-specific" },
	{ 0, NULL }
};
187
/*
188
189
190
191
192
 * Lookup for the MCS index (0-76)
 * returning the number of data bits per symbol
 * assumes 52 subcarriers (20MHz)
 * symbols are 4us for long guard interval, 3.6us for short guard interval
 * Note: MCS 32 is special - only valid for 40Mhz channel.
193
 */
194
WS_DLL_PUBLIC_DEF const guint16 ieee80211_ht_Dbps[MAX_MCS_INDEX+1] = {
195
196
    /* MCS  0 - 1 stream */
    26, 52, 78, 104, 156, 208, 234, 260,
197

198
199
    /* MCS  8 - 2 stream */
    52, 104, 156, 208, 312, 416, 468, 520,
200

201
202
    /* MCS 16 - 3 stream */
    78, 156, 234, 312, 468, 624, 702, 780,
203

204
205
    /* MCS 24 - 4 stream */
    104, 208, 312, 416, 624, 832, 936, 1040,
206

207
208
    /* MCS 32 - 1 stream */
    12, /* only valid for 40Mhz - 11a/g DUP mode */
209

210
211
    /* MCS 33 - 2 stream */
    156, 208, 260, 234, 312, 390,
212

213
214
    /* MCS 39 - 3 stream */
    208, 260, 260, 312, 364, 364, 416, 312, 390, 390, 468, 546, 546, 624,
215

216
217
218
    /* MCS 53 - 4 stream */
    260, 312, 364, 312, 364, 416, 468, 416, 468, 520, 520, 572,
    390, 468, 546, 468, 546, 624, 702, 624, 702, 780, 780, 858
219
};
220

221
222
223
224
225
226
227
228
/*
 * Calculates data rate corresponding to a given 802.11n MCS index,
 * bandwidth, and guard interval.
 */
float ieee80211_htrate(int mcs_index, gboolean bandwidth, gboolean short_gi)
{
    return (float)(ieee80211_ht_Dbps[mcs_index] * (bandwidth ? 108 : 52) / 52.0 / (short_gi ? 3.6 : 4.0));
}
229

230
231
232
233
234
235
static const guint8 ieee80211_ht_streams[MAX_MCS_INDEX+1] = {
       1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,
       1,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,
       4,4,4,4,4,4,4,4,4,4,4,4,4
};

236
237
238
239
240
241
242
243
244
static const guint8 ieee80211_ht_Nes[MAX_MCS_INDEX+1] = {
       1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,
       1,1,1,1,1,2,2,2, 1,1,1,1,2,2,2,2,
       1,
       1,1,1,1,1,1,
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2
};

245
#define MAX_MCS_VHT_INDEX     9
246
247
248
249
250
251
252
253
254
255
256
257
258
259

/*
 * Maps a VHT bandwidth index to ieee80211_vhtinfo.rates index.
 */
static const int ieee80211_vht_bw2rate_index[] = {
  /*  20Mhz total */ 0,
  /*  40Mhz total */ 1, 0, 0,
  /*  80Mhz total */ 2, 1, 1, 0, 0, 0, 0,
  /* 160Mhz total */ 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0
};

struct mcs_vht_info {
  const char *modulation;
  const char *coding_rate;
260
  float data_bits_per_symbol; /* assuming 20MHz / 52 subcarriers */
261
262
263
264
};

static const struct mcs_vht_info ieee80211_vhtinfo[MAX_MCS_VHT_INDEX+1] = {
  /* MCS  0  */
265
  { "BPSK",  "1/2", 26 },
266
  /* MCS  1  */
267
  { "QPSK",  "1/2", 52 },
268
  /* MCS  2  */
269
  { "QPSK",  "3/4", 78 },
270
  /* MCS  3  */
271
  { "16-QAM", "1/2", 104 },
272
  /* MCS  4  */
273
  { "16-QAM", "3/4", 156 },
274
  /* MCS  5  */
275
  { "64-QAM", "2/3", 208 },
276
  /* MCS  6  */
277
  { "64-QAM", "3/4", 234 },
278
  /* MCS  7  */
279
  { "64-QAM", "5/6", 260 },
280
  /* MCS  8  */
281
  { "256-QAM", "3/4", 312 },
282
  /* MCS  9  */
283
  { "256-QAM", "5/6", (float)(1040/3.0) }
284
285
};

286
287
288
/* map a bandwidth index to the number of data subcarriers */
static const guint subcarriers[4] = { 52, 108, 234, 468 };

289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#define MAX_VHT_NSS             8

struct mcs_vht_valid {
    gboolean valid[4][MAX_VHT_NSS]; /* indexed by bandwidth and NSS-1 */
};

static const struct mcs_vht_valid ieee80211_vhtvalid[MAX_MCS_VHT_INDEX+1] = {
        /* MCS  0  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  1  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  2  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  3  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  4  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  5  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  6  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  FALSE, TRUE,  TRUE,  TRUE,  FALSE, TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  7  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  8  */
        {
            {   /* 20 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        },
        /* MCS  9  */
        {
            {   /* 20 Mhz */  { FALSE, FALSE, TRUE,  FALSE, FALSE, TRUE,  FALSE, FALSE },
                /* 40 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
                /* 80 Mhz */  { TRUE,  TRUE,  TRUE,  TRUE,  TRUE,  FALSE, TRUE,  TRUE },
                /* 160 Mhz */ { TRUE,  TRUE,  FALSE, TRUE,  TRUE,  TRUE,  TRUE,  TRUE },
            }
        }
};

378
379
380
381
/*
 * Calculates data rate corresponding to a given 802.11ac MCS index,
 * bandwidth, and guard interval.
 */
382
static float ieee80211_vhtrate(int mcs_index, guint bandwidth_index, gboolean short_gi)
383
384
385
{
    return (float)(ieee80211_vhtinfo[mcs_index].data_bits_per_symbol * subcarriers[bandwidth_index] / (short_gi ? 3.6 : 4.0) / 52.0);
}
386

387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
/*
 * HE SU OFDM MCS rate table converted from http://mcsindex.com/
 * indexed by (NSTS,MCS,BW,GI)
 */
#define HE_MAX_NSTS 8
#define HE_MAX_MCS  12
#define HE_SU_MAX_BW   4
#define HE_MAX_GI   3
static float he_ofdm_tab[HE_MAX_NSTS][HE_MAX_MCS][HE_SU_MAX_BW][HE_MAX_GI] = {
  {
      {{     8.6f,     8.1f,    7.3f},{     17.2f,    16.3f,    14.6f},{     36.0f,    34.0f,    30.6f},{     72.1f,    68.1f,    61.3f}},
      {{    17.2f,    16.3f,   14.6f},{     34.4f,    32.5f,    29.3f},{     72.1f,    68.1f,    61.3f},{    144.1f,   136.1f,   122.5f}},
      {{    25.8f,    24.4f,   21.9f},{     51.6f,    48.8f,    43.9f},{    108.1f,   102.1f,    91.9f},{    216.2f,   204.2f,   183.8f}},
      {{    34.4f,    32.5f,   29.3f},{     68.8f,    65.0f,    58.5f},{    144.1f,   136.1f,   122.5f},{    288.2f,   272.2f,   245.0f}},
      {{    51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f},{    432.4f,   408.3f,   367.5f}},
      {{    68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f},{    576.5f,   544.4f,   490.0f}},
      {{    77.4f,    73.1f,   65.8f},{    154.9f,   146.3f,   131.6f},{    324.3f,   306.3f,   275.6f},{    648.5f,   612.5f,   551.3f}},
      {{    86.0f,    81.3f,   73.1f},{    172.1f,   162.5f,   146.3f},{    360.3f,   340.3f,   306.3f},{    720.6f,   680.6f,   612.5f}},
      {{   103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f},{    864.7f,   816.7f,   735.0f}},
      {{   114.7f,   108.3f,   97.5f},{    229.4f,   216.7f,   195.0f},{    480.4f,   453.7f,   408.3f},{    960.8f,   907.4f,   816.7f}},
      {{   129.0f,   121.9f,  109.7f},{    258.1f,   243.8f,   219.4f},{    540.4f,   510.4f,   459.4f},{   1080.9f,  1020.8f,   918.8f}},
      {{   143.4f,   135.4f,  121.9f},{    286.8f,   270.8f,   243.8f},{    600.5f,   567.1f,   510.4f},{   1201.0f,  1134.3f,  1020.8f}}
  },{
      {{    17.2f,    16.3f,   14.6f},{     34.4f,    32.5f,    29.3f},{     72.1f,    68.1f,    61.3f},{    144.1f,   136.1f,   122.5f}},
      {{    34.4f,    32.5f,   29.3f},{     68.8f,    65.0f,    58.5f},{    144.1f,   136.1f,   122.5f},{    288.2f,   272.2f,   245.0f}},
      {{    51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f},{    432.4f,   408.3f,   367.5f}},
      {{    68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f},{    576.5f,   544.4f,   490.0f}},
      {{   103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f},{    864.7f,   816.7f,   735.0f}},
      {{   137.6f,   130.0f,  117.0f},{    275.3f,   260.0f,   234.0f},{    576.5f,   544.4f,   490.0f},{   1152.9f,  1088.9f,   980.0f}},
      {{   154.9f,   146.3f,  131.6f},{    309.7f,   292.5f,   263.3f},{    648.5f,   612.5f,   551.3f},{   1297.1f,  1225.0f,  1102.5f}},
      {{   172.1f,   162.5f,  146.3f},{    344.1f,   325.0f,   292.5f},{    720.6f,   680.6f,   612.5f},{   1441.2f,  1361.1f,  1225.0f}},
      {{   206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   229.4f,   216.7f,  195.0f},{    458.8f,   433.3f,   390.0f},{    960.8f,   907.4f,   816.7f},{   1921.6f,  1814.8f,  1633.3f}},
      {{   258.1f,   243.8f,  219.4f},{    516.2f,   487.5f,   438.8f},{   1080.9f,  1020.8f,   918.8f},{   2161.8f,  2041.7f,  1837.5f}},
      {{   286.8f,   270.8f,  243.8f},{    573.5f,   541.7f,   487.5f},{   1201.0f,  1134.3f,  1020.8f},{   2402.0f,  2268.5f,  2041.7f}}
  },{
      {{    25.8f,    24.4f,   21.9f},{     51.6f,    48.8f,    43.9f},{    108.1f,   102.1f,    91.9f},{    216.2f,   204.2f,   183.8f}},
      {{    51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f},{    432.4f,   408.3f,   367.5f}},
      {{    77.4f,    73.1f,   65.8f},{    154.9f,   146.3f,   131.6f},{    324.3f,   306.3f,   275.6f},{    648.5f,   612.5f,   551.3f}},
      {{   103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f},{    864.7f,   816.7f,   735.0f}},
      {{   154.9f,   146.3f,  131.6f},{    309.7f,   292.5f,   263.3f},{    648.5f,   612.5f,   551.3f},{   1297.1f,  1225.0f,  1102.5f}},
      {{   206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   232.3f,   219.4f,  197.4f},{    464.6f,   438.8f,   394.9f},{    972.8f,   918.8f,   826.9f},{   1945.6f,  1837.5f,  1653.8f}},
      {{   258.1f,   243.8f,  219.4f},{    516.2f,   487.5f,   438.8f},{   1080.9f,  1020.8f,   918.8f},{   2161.8f,  2041.7f,  1837.5f}},
      {{   309.7f,   292.5f,  263.3f},{    619.4f,   585.0f,   526.5f},{   1297.1f,  1225.0f,  1102.5f},{   2594.1f,  2450.0f,  2205.0f}},
      {{   344.1f,   325.0f,  292.5f},{    688.2f,   650.0f,   585.0f},{   1441.2f,  1361.1f,  1225.0f},{   2882.4f,  2722.2f,  2450.0f}},
      {{   387.1f,   365.6f,  329.1f},{    774.3f,   731.3f,   658.1f},{   1621.3f,  1531.3f,  1378.1f},{   3242.6f,  3062.5f,  2756.3f}},
      {{   430.1f,   406.3f,  365.6f},{    860.3f,   812.5f,   731.3f},{   1801.5f,  1701.4f,  1531.3f},{   3602.9f,  3402.8f,  3062.5f}}
  },{
      {{    34.4f,    32.5f,   29.3f},{     68.8f,    65.0f,    58.5f},{    144.1f,   136.1f,   122.5f},{    288.2f,   272.2f,   245.0f}},
      {{    68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f},{    576.5f,   544.4f,   490.0f}},
      {{   103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f},{    864.7f,   816.7f,   735.0f}},
      {{   137.6f,   130.0f,  117.0f},{    275.3f,   260.0f,   234.0f},{    576.5f,   544.4f,   490.0f},{   1152.9f,  1088.9f,   980.0f}},
      {{   206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   275.3f,   260.0f,  234.0f},{    550.6f,   520.0f,   468.0f},{   1152.9f,  1088.9f,   980.0f},{   2305.9f,  2177.8f,  1960.0f}},
      {{   309.7f,   292.5f,  263.3f},{    619.4f,   585.0f,   526.5f},{   1297.1f,  1225.0f,  1102.5f},{   2594.1f,  2450.0f,  2205.0f}},
      {{   344.1f,   325.0f,  292.5f},{    688.2f,   650.0f,   585.0f},{   1441.2f,  1361.1f,  1225.0f},{   2882.4f,  2722.2f,  2450.0f}},
      {{   412.9f,   390.0f,  351.0f},{    825.9f,   780.0f,   702.0f},{   1729.4f,  1633.3f,  1470.0f},{   3458.8f,  3266.7f,  2940.0f}},
      {{   458.8f,   433.3f,  390.0f},{    917.6f,   866.7f,   780.0f},{   1921.6f,  1814.8f,  1633.3f},{   3843.1f,  3629.6f,  3266.7f}},
      {{   516.2f,   487.5f,  438.8f},{   1032.4f,   975.0f,   877.5f},{   2161.8f,  2041.7f,  1837.5f},{   4323.5f,  4083.3f,  3675.0f}},
      {{   573.5f,   541.7f,  487.5f},{   1147.1f,  1083.3f,   975.0f},{   2402.0f,  2268.5f,  2041.7f},{   4803.9f,  4537.0f,  4083.3f}}
  },{
      {{    43.0f,    40.6f,   36.6f},{     86.0f,    81.3f,    73.1f},{    180.1f,   170.1f,   153.1f},{    360.3f,   340.3f,   306.3f}},
      {{    86.0f,    81.3f,   73.1f},{    172.1f,   162.5f,   146.3f},{    360.3f,   340.3f,   306.3f},{    720.6f,   680.6f,   612.5f}},
      {{   129.0f,   121.9f,  109.7f},{    258.1f,   243.8f,   219.4f},{    540.4f,   510.4f,   459.4f},{   1080.9f,  1020.8f,   918.8f}},
      {{   172.1f,   162.5f,  146.3f},{    344.1f,   325.0f,   292.5f},{    720.6f,   680.6f,   612.5f},{   1441.2f,  1361.1f,  1225.0f}},
      {{   258.1f,   243.8f,  219.4f},{    516.2f,   487.5f,   438.8f},{   1080.9f,  1020.8f,   918.8f},{   2161.8f,  2041.7f,  1837.5f}},
      {{   344.1f,   325.0f,  292.5f},{    688.2f,   650.0f,   585.0f},{   1441.2f,  1361.1f,  1225.0f},{   2882.4f,  2722.2f,  2450.0f}},
      {{   387.1f,   365.6f,  329.1f},{    774.3f,   731.3f,   658.1f},{   1621.3f,  1531.3f,  1378.1f},{   3242.6f,  3062.5f,  2756.3f}},
      {{   430.1f,   406.3f,  365.6f},{    860.3f,   812.5f,   731.3f},{   1801.5f,  1701.4f,  1531.3f},{   3602.9f,  3402.8f,  3062.5f}},
      {{   516.2f,   487.5f,  438.8f},{   1032.4f,   975.0f,   877.5f},{   2161.8f,  2041.7f,  1837.5f},{   4323.5f,  4083.3f,  3675.0f}},
      {{   573.5f,   541.7f,  487.5f},{   1147.1f,  1083.3f,   975.0f},{   2402.0f,  2268.5f,  2041.7f},{   4803.9f,  4537.0f,  4083.3f}},
      {{   645.2f,   609.4f,  548.4f},{   1290.4f,  1218.8f,  1096.9f},{   2702.2f,  2552.1f,  2296.9f},{   5404.4f,  5104.2f,  4593.8f}},
      {{   716.9f,   677.1f,  609.4f},{   1433.8f,  1354.2f,  1218.8f},{   3002.5f,  2835.6f,  2552.1f},{   6004.9f,  5671.3f,  5104.2f}}
  },{
      {{    51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f},{    432.4f,   408.3f,   367.5f}},
      {{   103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f},{    864.7f,   816.7f,   735.0f}},
      {{   154.9f,   146.3f,  131.6f},{    309.7f,   292.5f,   263.3f},{    648.5f,   612.5f,   551.3f},{   1297.1f,  1225.0f,  1102.5f}},
      {{   206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   309.7f,   292.5f,  263.3f},{    619.4f,   585.0f,   526.5f},{   1297.1f,  1225.0f,  1102.5f},{   2594.1f,  2450.0f,  2205.0f}},
      {{   412.9f,   390.0f,  351.0f},{    825.9f,   780.0f,   702.0f},{   1729.4f,  1633.3f,  1470.0f},{   3458.8f,  3266.7f,  2940.0f}},
      {{   464.6f,   438.8f,  394.9f},{    929.1f,   877.5f,   789.8f},{   1945.6f,  1837.5f,  1653.8f},{   3891.2f,  3675.0f,  3307.5f}},
      {{   516.2f,   487.5f,  438.8f},{   1032.4f,   975.0f,   877.5f},{   2161.8f,  2041.7f,  1837.5f},{   4323.5f,  4083.3f,  3675.0f}},
      {{   619.4f,   585.0f,  526.5f},{   1238.8f,  1170.0f,  1053.0f},{   2594.1f,  2450.0f,  2205.0f},{   5188.2f,  4900.0f,  4410.0f}},
      {{   688.2f,   650.0f,  585.0f},{   1376.5f,  1300.0f,  1170.0f},{   2882.4f,  2722.2f,  2450.0f},{   5764.7f,  5444.4f,  4900.0f}},
      {{   774.3f,   731.3f,  658.1f},{   1548.5f,  1462.5f,  1316.3f},{   3242.6f,  3062.5f,  2756.3f},{   6485.3f,  6125.0f,  5512.5f}},
      {{   860.3f,   812.5f,  731.3f},{   1720.6f,  1625.0f,  1462.5f},{   3602.9f,  3402.8f,  3062.5f},{   7205.9f,  6805.6f,  6125.0f}}
  },{
      {{    60.2f,    56.9f,   51.2f},{    120.4f,   113.8f,   102.4f},{    252.2f,   238.2f,   214.4f},{    504.4f,   476.4f,   428.8f}},
      {{   120.4f,   113.8f,  102.4f},{    240.9f,   227.5f,   204.8f},{    504.4f,   476.4f,   428.8f},{   1008.8f,   952.8f,   857.5f}},
      {{   180.7f,   170.6f,  153.6f},{    361.3f,   341.3f,   307.1f},{    756.6f,   714.6f,   643.1f},{   1513.2f,  1429.2f,  1286.3f}},
      {{   240.9f,   227.5f,  204.8f},{    481.8f,   455.0f,   409.5f},{   1008.8f,   952.8f,   857.5f},{   2017.6f,  1905.6f,  1715.0f}},
      {{   361.3f,   341.3f,  307.1f},{    722.6f,   682.5f,   614.3f},{   1513.2f,  1429.2f,  1286.3f},{   3026.5f,  2858.3f,  2572.5f}},
      {{   481.8f,   455.0f,  409.5f},{    963.5f,   910.0f,   819.0f},{   2017.6f,  1905.6f,  1715.0f},{   4035.3f,  3811.1f,  3430.0f}},
      {{   542.0f,   511.9f,  460.7f},{   1084.0f,  1023.8f,   921.4f},{   2269.9f,  2143.8f,  1929.4f},{   4539.7f,  4287.5f,  3858.8f}},
      {{   602.2f,   568.8f,  511.9f},{   1204.4f,  1137.5f,  1023.8f},{   2522.1f,  2381.9f,  2143.8f},{   5044.1f,  4763.9f,  4287.5f}},
      {{   722.6f,   682.5f,  614.3f},{   1445.3f,  1365.0f,  1228.5f},{   3026.5f,  2858.3f,  2572.5f},{   6052.9f,  5716.7f,  5145.0f}},
      {{   802.9f,   758.3f,  682.5f},{   1605.9f,  1516.7f,  1365.0f},{   3362.7f,  3175.9f,  2858.3f},{   6725.5f,  6351.9f,  5716.7f}},
      {{   903.3f,   853.1f,  767.8f},{   1806.6f,  1706.3f,  1535.6f},{   3783.1f,  3572.9f,  3215.6f},{   7566.2f,  7145.8f,  6431.3f}},
      {{  1003.7f,   947.9f,  853.1f},{   2007.4f,  1895.8f,  1706.3f},{   4203.4f,  3969.9f,  3572.9f},{   8406.9f,  7939.8f,  7145.8f}}
  },{
      {{    68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f},{    576.5f,   544.4f,   490.0f}},
      {{   137.6f,   130.0f,  117.0f},{    275.3f,   260.0f,   234.0f},{    576.5f,   544.4f,   490.0f},{   1152.9f,  1088.9f,   980.0f}},
      {{   206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   275.3f,   260.0f,  234.0f},{    550.6f,   520.0f,   468.0f},{   1152.9f,  1088.9f,   980.0f},{   2305.9f,  2177.8f,  1960.0f}},
      {{   412.9f,   390.0f,  351.0f},{    825.9f,   780.0f,   702.0f},{   1729.4f,  1633.3f,  1470.0f},{   3458.8f,  3266.7f,  2940.0f}},
      {{   550.6f,   520.0f,  468.0f},{   1101.2f,  1040.0f,   936.0f},{   2305.9f,  2177.8f,  1960.0f},{   4611.8f,  4355.6f,  3920.0f}},
      {{   619.4f,   585.0f,  526.5f},{   1238.8f,  1170.0f,  1053.0f},{   2594.1f,  2450.0f,  2205.0f},{   5188.2f,  4900.0f,  4410.0f}},
      {{   688.2f,   650.0f,  585.0f},{   1376.5f,  1300.0f,  1170.0f},{   2882.4f,  2722.2f,  2450.0f},{   5764.7f,  5444.4f,  4900.0f}},
      {{   825.9f,   780.0f,  702.0f},{   1651.8f,  1560.0f,  1404.0f},{   3458.8f,  3266.7f,  2940.0f},{   6917.6f,  6533.3f,  5880.0f}},
      {{   917.6f,   866.7f,  780.0f},{   1835.3f,  1733.3f,  1560.0f},{   3843.1f,  3629.6f,  3266.7f},{   7686.3f,  7259.3f,  6533.3f}},
      {{  1032.4f,   975.0f,  877.5f},{   2064.7f,  1950.0f,  1755.0f},{   4323.5f,  4083.3f,  3675.0f},{   8647.1f,  8166.7f,  7350.0f}},
      {{  1147.1f,  1083.3f,  975.0f},{   2294.1f,  2166.7f,  1950.0f},{   4803.9f,  4537.0f,  4083.3f},{   9607.8f,  9074.1f,  8166.7f}}
  }
};

/*
 * Calculates 802.11ax HE SU data rate corresponding to a given 802.11ax MCS index,
 * bandwidth, and guard interval.
 */
static float ieee80211_he_ofdm_rate(guint nsts, guint mcs, guint bw, guint gi)
{
  float rate=0.0;
  if ( ((nsts-1) < HE_MAX_NSTS) && (mcs < HE_MAX_MCS) && ( bw < HE_SU_MAX_BW) && ( gi < HE_MAX_GI ) ) {
    rate = he_ofdm_tab[nsts-1][mcs][bw][gi];
  }
  return rate;
}

/*
 * HE MU OFDMA MCS rate table converted from http://mcsindex.com/
 * indexed by (NSTS,MCS,RU,GI)
 */
#define HE_MU_MAX_RU 6
static float he_mu_ofdma_tab[HE_MAX_NSTS][HE_MAX_MCS][HE_MU_MAX_RU][HE_MAX_GI] = {
  {
      {{    0.9f,    0.8f,    0.8f},{     1.8f,    1.7f,    1.5f},{     3.8f,    3.5f,    3.2f},{      8.6f,     8.1f,    7.3f},{     17.2f,    16.3f,    14.6f},{     36.0f,    34.0f,    30.6f}},
      {{    1.8f,    1.7f,    1.5f},{     3.5f,    3.3f,    3.0f},{     7.5f,    7.1f,    6.4f},{     17.2f,    16.3f,   14.6f},{     34.4f,    32.5f,    29.3f},{     72.1f,    68.1f,    61.3f}},
      {{    2.6f,    2.5f,    2.3f},{     5.3f,    5.0f,    4.5f},{    11.3f,   10.6f,    9.6f},{     25.8f,    24.4f,   21.9f},{     51.6f,    48.8f,    43.9f},{    108.1f,   102.1f,    91.9f}},
      {{    3.5f,    3.3f,    3.0f},{     7.1f,    6.7f,    6.0f},{    15.0f,   14.2f,   12.8f},{     34.4f,    32.5f,   29.3f},{     68.8f,    65.0f,    58.5f},{    144.1f,   136.1f,   122.5f}},
      {{    5.3f,    5.0f,    4.5f},{    10.6f,   10.0f,    9.0f},{    22.5f,   21.3f,   19.1f},{     51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f}},
      {{    7.1f,    6.7f,    6.0f},{    14.1f,   13.3f,   12.0f},{    30.0f,   28.3f,   25.5f},{     68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f}},
      {{    7.9f,    7.5f,    6.8f},{    15.9f,   15.0f,   13.5f},{    33.8f,   31.9f,   28.7f},{     77.4f,    73.1f,   65.8f},{    154.9f,   146.3f,   131.6f},{    324.3f,   306.3f,   275.6f}},
      {{    8.8f,    8.3f,    7.5f},{    17.6f,   16.7f,   15.0f},{    37.5f,   35.4f,   31.9f},{     86.0f,    81.3f,   73.1f},{    172.1f,   162.5f,   146.3f},{    360.3f,   340.3f,   306.3f}},
      {{   10.6f,   10.0f,    9.0f},{    21.2f,   20.0f,   18.0f},{    45.0f,   42.5f,   38.3f},{    103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f}},
      {{   11.8f,   11.1f,   10.0f},{    23.5f,   22.2f,   20.0f},{    50.0f,   47.2f,   42.5f},{    114.7f,   108.3f,   97.5f},{    229.4f,   216.7f,   195.0f},{    480.4f,   453.7f,   408.3f}},
      {{   13.2f,   12.5f,   11.3f},{    26.5f,   25.0f,   22.5f},{    56.3f,   53.1f,   47.8f},{    129.0f,   121.9f,  109.7f},{    258.1f,   243.8f,   219.4f},{    540.4f,   510.4f,   459.4f}},
      {{   14.7f,   13.9f,   12.5f},{    29.4f,   27.8f,   25.0f},{    62.5f,   59.0f,   53.1f},{    143.4f,   135.4f,  121.9f},{    286.8f,   270.8f,   243.8f},{    600.5f,   567.1f,   510.4f}}
  },{
      {{    1.8f,    1.7f,    1.5f},{     3.5f,    3.3f,    3.0f},{     7.5f,    7.1f,    6.4f},{     17.2f,    16.3f,   14.6f},{     34.4f,    32.5f,    29.3f},{     72.1f,    68.1f,    61.3f}},
      {{    3.5f,    3.3f,    3.0f},{     7.1f,    6.7f,    6.0f},{    15.0f,   14.2f,   12.8f},{     34.4f,    32.5f,   29.3f},{     68.8f,    65.0f,    58.5f},{    144.1f,   136.1f,   122.5f}},
      {{    5.3f,    5.0f,    4.5f},{    10.6f,   10.0f,    9.0f},{    22.5f,   21.3f,   19.1f},{     51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f}},
      {{    7.1f,    6.7f,    6.0f},{    14.1f,   13.3f,   12.0f},{    30.0f,   28.3f,   25.5f},{     68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f}},
      {{   10.6f,   10.0f,    9.0f},{    21.2f,   20.0f,   18.0f},{    45.0f,   42.5f,   38.3f},{    103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f}},
      {{   14.1f,   13.3f,   12.0f},{    28.2f,   26.7f,   24.0f},{    60.0f,   56.7f,   51.0f},{    137.6f,   130.0f,  117.0f},{    275.3f,   260.0f,   234.0f},{    576.5f,   544.4f,   490.0f}},
      {{   15.9f,   15.0f,   13.5f},{    31.8f,   30.0f,   27.0f},{    67.5f,   63.8f,   57.4f},{    154.9f,   146.3f,  131.6f},{    309.7f,   292.5f,   263.3f},{    648.5f,   612.5f,   551.3f}},
      {{   17.6f,   16.7f,   15.0f},{    35.3f,   33.3f,   30.0f},{    75.0f,   70.8f,   63.8f},{    172.1f,   162.5f,  146.3f},{    344.1f,   325.0f,   292.5f},{    720.6f,   680.6f,   612.5f}},
      {{   21.2f,   20.0f,   18.0f},{    42.4f,   40.0f,   36.0f},{    90.0f,   85.0f,   76.5f},{    206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f}},
      {{   23.5f,   22.2f,   20.0f},{    47.1f,   44.4f,   40.0f},{   100.0f,   94.4f,   85.0f},{    229.4f,   216.7f,  195.0f},{    458.8f,   433.3f,   390.0f},{    960.8f,   907.4f,   816.7f}},
      {{   26.5f,   25.0f,   22.5f},{    52.9f,   50.0f,   45.0f},{   112.5f,  106.3f,   95.6f},{    258.1f,   243.8f,  219.4f},{    516.2f,   487.5f,   438.8f},{   1080.9f,  1020.8f,   918.8f}},
      {{   29.4f,   27.8f,   25.0f},{    58.8f,   55.6f,   50.0f},{   125.0f,  118.1f,  106.3f},{    286.8f,   270.8f,  243.8f},{    573.5f,   541.7f,   487.5f},{   1201.0f,  1134.3f,  1020.8f}}
  },{
      {{    2.6f,    2.5f,    2.3f},{     5.3f,    5.0f,    4.5f},{    11.3f,   10.6f,    9.6f},{     25.8f,    24.4f,   21.9f},{     51.6f,    48.8f,    43.9f},{    108.1f,   102.1f,    91.9f}},
      {{    5.3f,    5.0f,    4.5f},{    10.6f,   10.0f,    9.0f},{    22.5f,   21.3f,   19.1f},{     51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f}},
      {{    7.9f,    7.5f,    6.8f},{    15.9f,   15.0f,   13.5f},{    33.8f,   31.9f,   28.7f},{     77.4f,    73.1f,   65.8f},{    154.9f,   146.3f,   131.6f},{    324.3f,   306.3f,   275.6f}},
      {{   10.6f,   10.0f,    9.0f},{    21.2f,   20.0f,   18.0f},{    45.0f,   42.5f,   38.3f},{    103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f}},
      {{   15.9f,   15.0f,   13.5f},{    31.8f,   30.0f,   27.0f},{    67.5f,   63.8f,   57.4f},{    154.9f,   146.3f,  131.6f},{    309.7f,   292.5f,   263.3f},{    648.5f,   612.5f,   551.3f}},
      {{   21.2f,   20.0f,   18.0f},{    42.4f,   40.0f,   36.0f},{    90.0f,   85.0f,   76.5f},{    206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f}},
      {{   23.8f,   22.5f,   20.3f},{    47.6f,   45.0f,   40.5f},{   101.3f,   95.6f,   86.1f},{    232.3f,   219.4f,  197.4f},{    464.6f,   438.8f,   394.9f},{    972.8f,   918.8f,   826.9f}},
      {{   26.5f,   25.0f,   22.5f},{    52.9f,   50.0f,   45.0f},{   112.5f,  106.3f,   95.6f},{    258.1f,   243.8f,  219.4f},{    516.2f,   487.5f,   438.8f},{   1080.9f,  1020.8f,   918.8f}},
      {{   31.8f,   30.0f,   27.0f},{    63.5f,   60.0f,   54.0f},{   135.0f,  127.5f,  114.8f},{    309.7f,   292.5f,  263.3f},{    619.4f,   585.0f,   526.5f},{   1297.1f,  1225.0f,  1102.5f}},
      {{   35.3f,   33.3f,   30.0f},{    70.6f,   66.7f,   60.0f},{   150.0f,  141.7f,  127.5f},{    344.1f,   325.0f,  292.5f},{    688.2f,   650.0f,   585.0f},{   1441.2f,  1361.1f,  1225.0f}},
      {{   39.7f,   37.5f,   33.8f},{    79.4f,   75.0f,   67.5f},{   168.8f,  159.4f,  143.4f},{    387.1f,   365.6f,  329.1f},{    774.3f,   731.3f,   658.1f},{   1621.3f,  1531.3f,  1378.1f}},
      {{   44.1f,   41.7f,   37.5f},{    88.2f,   83.3f,   75.0f},{   187.5f,  177.1f,  159.4f},{    430.1f,   406.3f,  365.6f},{    860.3f,   812.5f,   731.3f},{   1801.5f,  1701.4f,  1531.3f}}
  },{
      {{    3.5f,    3.3f,    3.0f},{     7.1f,    6.7f,    6.0f},{    15.0f,   14.2f,   12.8f},{     34.4f,    32.5f,   29.3f},{     68.8f,    65.0f,    58.5f},{    144.1f,   136.1f,   122.5f}},
      {{    7.1f,    6.7f,    6.0f},{    14.1f,   13.3f,   12.0f},{    30.0f,   28.3f,   25.5f},{     68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f}},
      {{   10.6f,   10.0f,    9.0f},{    21.2f,   20.0f,   18.0f},{    45.0f,   42.5f,   38.3f},{    103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f}},
      {{   14.1f,   13.3f,   12.0f},{    28.2f,   26.7f,   24.0f},{    60.0f,   56.7f,   51.0f},{    137.6f,   130.0f,  117.0f},{    275.3f,   260.0f,   234.0f},{    576.5f,   544.4f,   490.0f}},
      {{   21.2f,   20.0f,   18.0f},{    42.4f,   40.0f,   36.0f},{    90.0f,   85.0f,   76.5f},{    206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f}},
      {{   28.2f,   26.7f,   24.0f},{    56.5f,   53.3f,   48.0f},{   120.0f,  113.3f,  102.0f},{    275.3f,   260.0f,  234.0f},{    550.6f,   520.0f,   468.0f},{   1152.9f,  1088.9f,   980.0f}},
      {{   31.8f,   30.0f,   27.0f},{    63.5f,   60.0f,   54.0f},{   135.0f,  127.5f,  114.8f},{    309.7f,   292.5f,  263.3f},{    619.4f,   585.0f,   526.5f},{   1297.1f,  1225.0f,  1102.5f}},
      {{   35.3f,   33.3f,   30.0f},{    70.6f,   66.7f,   60.0f},{   150.0f,  141.7f,  127.5f},{    344.1f,   325.0f,  292.5f},{    688.2f,   650.0f,   585.0f},{   1441.2f,  1361.1f,  1225.0f}},
      {{   42.4f,   40.0f,   36.0f},{    84.7f,   80.0f,   72.0f},{   180.0f,  170.0f,  153.0f},{    412.9f,   390.0f,  351.0f},{    825.9f,   780.0f,   702.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   47.1f,   44.4f,   40.0f},{    94.1f,   88.9f,   80.0f},{   200.0f,  188.9f,  170.0f},{    458.8f,   433.3f,  390.0f},{    917.6f,   866.7f,   780.0f},{   1921.6f,  1814.8f,  1633.3f}},
      {{   52.9f,   50.0f,   45.0f},{   105.9f,  100.0f,   90.0f},{   225.0f,  212.5f,  191.3f},{    516.2f,   487.5f,  438.8f},{   1032.4f,   975.0f,   877.5f},{   2161.8f,  2041.7f,  1837.5f}},
      {{   58.8f,   55.6f,   50.0f},{   117.6f,  111.1f,  100.0f},{   250.0f,  236.1f,  212.5f},{    573.5f,   541.7f,  487.5f},{   1147.1f,  1083.3f,   975.0f},{   2402.0f,  2268.5f,  2041.7f}}
  },{
      {{    4.4f,    4.2f,    3.8f},{     8.8f,    8.3f,    7.5f},{    18.8f,   17.7f,   15.9f},{     43.0f,    40.6f,   36.6f},{     86.0f,    81.3f,    73.1f},{    180.1f,   170.1f,   153.1f}},
      {{    8.8f,    8.3f,    7.5f},{    17.6f,   16.7f,   15.0f},{    37.5f,   35.4f,   31.9f},{     86.0f,    81.3f,   73.1f},{    172.1f,   162.5f,   146.3f},{    360.3f,   340.3f,   306.3f}},
      {{   13.2f,   12.5f,   11.3f},{    26.5f,   25.0f,   22.5f},{    56.3f,   53.1f,   47.8f},{    129.0f,   121.9f,  109.7f},{    258.1f,   243.8f,   219.4f},{    540.4f,   510.4f,   459.4f}},
      {{   17.6f,   16.7f,   15.0f},{    35.3f,   33.3f,   30.0f},{    75.0f,   70.8f,   63.8f},{    172.1f,   162.5f,  146.3f},{    344.1f,   325.0f,   292.5f},{    720.6f,   680.6f,   612.5f}},
      {{   26.5f,   25.0f,   22.5f},{    52.9f,   50.0f,   45.0f},{   112.5f,  106.3f,   95.6f},{    258.1f,   243.8f,  219.4f},{    516.2f,   487.5f,   438.8f},{   1080.9f,  1020.8f,   918.8f}},
      {{   35.3f,   33.3f,   30.0f},{    70.6f,   66.7f,   60.0f},{   150.0f,  141.7f,  127.5f},{    344.1f,   325.0f,  292.5f},{    688.2f,   650.0f,   585.0f},{   1441.2f,  1361.1f,  1225.0f}},
      {{   39.7f,   37.5f,   33.8f},{    79.4f,   75.0f,   67.5f},{   168.8f,  159.4f,  143.4f},{    387.1f,   365.6f,  329.1f},{    774.3f,   731.3f,   658.1f},{   1621.3f,  1531.3f,  1378.1f}},
      {{   44.1f,   41.7f,   37.5f},{    88.2f,   83.3f,   75.0f},{   187.5f,  177.1f,  159.4f},{    430.1f,   406.3f,  365.6f},{    860.3f,   812.5f,   731.3f},{   1801.5f,  1701.4f,  1531.3f}},
      {{   52.9f,   50.0f,   45.0f},{   105.9f,  100.0f,   90.0f},{   225.0f,  212.5f,  191.3f},{    516.2f,   487.5f,  438.8f},{   1032.4f,   975.0f,   877.5f},{   2161.8f,  2041.7f,  1837.5f}},
      {{   58.8f,   55.6f,   50.0f},{   117.6f,  111.1f,  100.0f},{   250.0f,  236.1f,  212.5f},{    573.5f,   541.7f,  487.5f},{   1147.1f,  1083.3f,   975.0f},{   2402.0f,  2268.5f,  2041.7f}},
      {{   66.2f,   62.5f,   56.3f},{   132.4f,  125.0f,  112.5f},{   281.3f,  265.6f,  239.1f},{    645.2f,   609.4f,  548.4f},{   1290.4f,  1218.8f,  1096.9f},{   2702.2f,  2552.1f,  2296.9f}},
      {{   73.5f,   69.4f,   62.5f},{   147.1f,  138.9f,  125.0f},{   312.5f,  295.1f,  265.6f},{    716.9f,   677.1f,  609.4f},{   1433.8f,  1354.2f,  1218.8f},{   3002.5f,  2835.6f,  2552.1f}}
  },{
      {{    5.3f,    5.0f,    4.5f},{    10.6f,   10.0f,    9.0f},{    22.5f,   21.3f,   19.1f},{     51.6f,    48.8f,   43.9f},{    103.2f,    97.5f,    87.8f},{    216.2f,   204.2f,   183.8f}},
      {{   10.6f,   10.0f,    9.0f},{    21.2f,   20.0f,   18.0f},{    45.0f,   42.5f,   38.3f},{    103.2f,    97.5f,   87.8f},{    206.5f,   195.0f,   175.5f},{    432.4f,   408.3f,   367.5f}},
      {{   15.9f,   15.0f,   13.5f},{    31.8f,   30.0f,   27.0f},{    67.5f,   63.8f,   57.4f},{    154.9f,   146.3f,  131.6f},{    309.7f,   292.5f,   263.3f},{    648.5f,   612.5f,   551.3f}},
      {{   21.2f,   20.0f,   18.0f},{    42.4f,   40.0f,   36.0f},{    90.0f,   85.0f,   76.5f},{    206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f}},
      {{   31.8f,   30.0f,   27.0f},{    63.5f,   60.0f,   54.0f},{   135.0f,  127.5f,  114.8f},{    309.7f,   292.5f,  263.3f},{    619.4f,   585.0f,   526.5f},{   1297.1f,  1225.0f,  1102.5f}},
      {{   42.4f,   40.0f,   36.0f},{    84.7f,   80.0f,   72.0f},{   180.0f,  170.0f,  153.0f},{    412.9f,   390.0f,  351.0f},{    825.9f,   780.0f,   702.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   47.6f,   45.0f,   40.5f},{    95.3f,   90.0f,   81.0f},{   202.5f,  191.3f,  172.1f},{    464.6f,   438.8f,  394.9f},{    929.1f,   877.5f,   789.8f},{   1945.6f,  1837.5f,  1653.8f}},
      {{   52.9f,   50.0f,   45.0f},{   105.9f,  100.0f,   90.0f},{   225.0f,  212.5f,  191.3f},{    516.2f,   487.5f,  438.8f},{   1032.4f,   975.0f,   877.5f},{   2161.8f,  2041.7f,  1837.5f}},
      {{   63.5f,   60.0f,   54.0f},{   127.1f,  120.0f,  108.0f},{   270.0f,  255.0f,  229.5f},{    619.4f,   585.0f,  526.5f},{   1238.8f,  1170.0f,  1053.0f},{   2594.1f,  2450.0f,  2205.0f}},
      {{   70.6f,   66.7f,   60.0f},{   141.2f,  133.3f,  120.0f},{   300.0f,  283.3f,  255.0f},{    688.2f,   650.0f,  585.0f},{   1376.5f,  1300.0f,  1170.0f},{   2882.4f,  2722.2f,  2450.0f}},
      {{   79.4f,   75.0f,   67.5f},{   158.8f,  150.0f,  135.0f},{   337.5f,  318.8f,  286.9f},{    774.3f,   731.3f,  658.1f},{   1548.5f,  1462.5f,  1316.3f},{   3242.6f,  3062.5f,  2756.3f}},
      {{   88.2f,   83.3f,   75.0f},{   176.5f,  166.7f,  150.0f},{   375.0f,  354.2f,  318.8f},{    860.3f,   812.5f,  731.3f},{   1720.6f,  1625.0f,  1462.5f},{   3602.9f,  3402.8f,  3062.5f}}
  },{
      {{    6.2f,    5.8f,    5.3f},{    12.4f,   11.7f,   10.5f},{    26.3f,   24.8f,   22.3f},{     60.2f,    56.9f,   51.2f},{    120.4f,   113.8f,   102.4f},{    252.2f,   238.2f,   214.4f}},
      {{   12.4f,   11.7f,   10.5f},{    24.7f,   23.3f,   21.0f},{    52.5f,   49.6f,   44.6f},{    120.4f,   113.8f,  102.4f},{    240.9f,   227.5f,   204.8f},{    504.4f,   476.4f,   428.8f}},
      {{   18.5f,   17.5f,   15.8f},{    37.1f,   35.0f,   31.5f},{    78.8f,   74.4f,   66.9f},{    180.7f,   170.6f,  153.6f},{    361.3f,   341.3f,   307.1f},{    756.6f,   714.6f,   643.1f}},
      {{   24.7f,   23.3f,   21.0f},{    49.4f,   46.7f,   42.0f},{   105.0f,   99.2f,   89.3f},{    240.9f,   227.5f,  204.8f},{    481.8f,   455.0f,   409.5f},{   1008.8f,   952.8f,   857.5f}},
      {{   37.1f,   35.0f,   31.5f},{    74.1f,   70.0f,   63.0f},{   157.5f,  148.8f,  133.9f},{    361.3f,   341.3f,  307.1f},{    722.6f,   682.5f,   614.3f},{   1513.2f,  1429.2f,  1286.3f}},
      {{   49.4f,   46.7f,   42.0f},{    98.8f,   93.3f,   84.0f},{   210.0f,  198.3f,  178.5f},{    481.8f,   455.0f,  409.5f},{    963.5f,   910.0f,   819.0f},{   2017.6f,  1905.6f,  1715.0f}},
      {{   55.6f,   52.5f,   47.3f},{   111.2f,  105.0f,   94.5f},{   236.3f,  223.1f,  200.8f},{    542.0f,   511.9f,  460.7f},{   1084.0f,  1023.8f,   921.4f},{   2269.9f,  2143.8f,  1929.4f}},
      {{   61.8f,   58.3f,   52.5f},{   123.5f,  116.7f,  105.0f},{   262.5f,  247.9f,  223.1f},{    602.2f,   568.8f,  511.9f},{   1204.4f,  1137.5f,  1023.8f},{   2522.1f,  2381.9f,  2143.8f}},
      {{   74.1f,   70.0f,   63.0f},{   148.2f,  140.0f,  126.0f},{   315.0f,  297.5f,  267.8f},{    722.6f,   682.5f,  614.3f},{   1445.3f,  1365.0f,  1228.5f},{   3026.5f,  2858.3f,  2572.5f}},
      {{   82.4f,   77.8f,   70.0f},{   164.7f,  155.6f,  140.0f},{   350.0f,  330.6f,  297.5f},{    802.9f,   758.3f,  682.5f},{   1605.9f,  1516.7f,  1365.0f},{   3362.7f,  3175.9f,  2858.3f}},
      {{   92.6f,   87.5f,   78.8f},{   185.3f,  175.0f,  157.5f},{   393.8f,  371.9f,  334.7f},{    903.3f,   853.1f,  767.8f},{   1806.6f,  1706.3f,  1535.6f},{   3783.1f,  3572.9f,  3215.6f}},
      {{  102.9f,   97.2f,   87.5f},{   205.9f,  194.4f,  175.0f},{   437.5f,  413.2f,  371.9f},{   1003.7f,   947.9f,  853.1f},{   2007.4f,  1895.8f,  1706.3f},{   4203.4f,  3969.9f,  3572.9f}}
  },{
      {{    7.1f,    6.7f,    6.0f},{    14.1f,   13.3f,   12.0f},{    30.0f,   28.3f,   25.5f},{     68.8f,    65.0f,   58.5f},{    137.6f,   130.0f,   117.0f},{    288.2f,   272.2f,   245.0f}},
      {{   14.1f,   13.3f,   12.0f},{    28.2f,   26.7f,   24.0f},{    60.0f,   56.7f,   51.0f},{    137.6f,   130.0f,  117.0f},{    275.3f,   260.0f,   234.0f},{    576.5f,   544.4f,   490.0f}},
      {{   21.2f,   20.0f,   18.0f},{    42.4f,   40.0f,   36.0f},{    90.0f,   85.0f,   76.5f},{    206.5f,   195.0f,  175.5f},{    412.9f,   390.0f,   351.0f},{    864.7f,   816.7f,   735.0f}},
      {{   28.2f,   26.7f,   24.0f},{    56.5f,   53.3f,   48.0f},{   120.0f,  113.3f,  102.0f},{    275.3f,   260.0f,  234.0f},{    550.6f,   520.0f,   468.0f},{   1152.9f,  1088.9f,   980.0f}},
      {{   42.4f,   40.0f,   36.0f},{    84.7f,   80.0f,   72.0f},{   180.0f,  170.0f,  153.0f},{    412.9f,   390.0f,  351.0f},{    825.9f,   780.0f,   702.0f},{   1729.4f,  1633.3f,  1470.0f}},
      {{   56.5f,   53.3f,   48.0f},{   112.9f,  106.7f,   96.0f},{   240.0f,  226.7f,  204.0f},{    550.6f,   520.0f,  468.0f},{   1101.2f,  1040.0f,   936.0f},{   2305.9f,  2177.8f,  1960.0f}},
      {{   63.5f,   60.0f,   54.0f},{   127.1f,  120.0f,  108.0f},{   270.0f,  255.0f,  229.5f},{    619.4f,   585.0f,  526.5f},{   1238.8f,  1170.0f,  1053.0f},{   2594.1f,  2450.0f,  2205.0f}},
      {{   70.6f,   66.7f,   60.0f},{   141.2f,  133.3f,  120.0f},{   300.0f,  283.3f,  255.0f},{    688.2f,   650.0f,  585.0f},{   1376.5f,  1300.0f,  1170.0f},{   2882.4f,  2722.2f,  2450.0f}},
      {{   84.7f,   80.0f,   72.0f},{   169.4f,  160.0f,  144.0f},{   360.0f,  340.0f,  306.0f},{    825.9f,   780.0f,  702.0f},{   1651.8f,  1560.0f,  1404.0f},{   3458.8f,  3266.7f,  2940.0f}},
      {{   94.1f,   88.9f,   80.0f},{   188.2f,  177.8f,  160.0f},{   400.0f,  377.8f,  340.0f},{    917.6f,   866.7f,  780.0f},{   1835.3f,  1733.3f,  1560.0f},{   3843.1f,  3629.6f,  3266.7f}},
      {{  105.9f,  100.0f,   90.0f},{   211.8f,  200.0f,  180.0f},{   450.0f,  425.0f,  382.5f},{   1032.4f,   975.0f,  877.5f},{   2064.7f,  1950.0f,  1755.0f},{   4323.5f,  4083.3f,  3675.0f}},
      {{  117.6f,  111.1f,  100.0f},{   235.3f,  222.2f,  200.0f},{   500.0f,  472.2f,  425.0f},{   1147.1f,  1083.3f,  975.0f},{   2294.1f,  2166.7f,  1950.0f},{   4803.9f,  4537.0f,  4083.3f}}
  }

};

/*
 * Calculates 802.11ax HE SU data rate corresponding to a given 802.11ax MCS index,
 * bandwidth, and guard interval.
 */
static float ieee80211_he_mu_ofdma_rate(guint nsts, guint mcs, guint ru, guint gi)
{
  float rate=0.0;
  if ( ((nsts-1) < HE_MAX_NSTS) && (mcs < HE_MAX_MCS) && ( (ru-4) < HE_MU_MAX_RU) && ( gi < HE_MAX_GI ) ) {
    rate = he_mu_ofdma_tab[nsts-1][mcs][ru-4][gi];
  }
  return rate;
}

643
static gint ett_wlan_radio = -1;
644
static gint ett_wlan_radio_11ac_user = -1;
645
static gint ett_wlan_radio_duration = -1;
646
647
648
649
650
651
652
static gint ett_wlan_radio_aggregate = -1;

/* previous frame details, for aggregate detection */
struct previous_frame_info {
  gboolean has_tsf_timestamp;
  guint64 tsf_timestamp;
  guint phy;
653
  union ieee_802_11_phy_info phy_info;
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
  guint prev_length;
  struct wlan_radio *radio_info;
};

static struct previous_frame_info previous_frame;
static struct aggregate *current_aggregate;
static wmem_list_t *agg_tracker_list;

static guint calculate_11n_duration(guint frame_length,
  struct ieee_802_11n* info_n,
  int stbc_streams)
{
  guint bits;
  guint bits_per_symbol;
  guint Mstbc;
  guint symbols;

  /* data field calculation */
  if (1) {
    /* see ieee80211n-2009 20.3.11 (20-32) - for BCC FEC */
    bits = 8 * frame_length + 16 + ieee80211_ht_Nes[info_n->mcs_index] * 6;
    Mstbc = stbc_streams ? 2 : 1;
    bits_per_symbol = ieee80211_ht_Dbps[info_n->mcs_index] *
        (info_n->bandwidth == PHDR_802_11_BANDWIDTH_40_MHZ ? 2 : 1);
    symbols = bits / (bits_per_symbol * Mstbc);
  } else {
    /* TODO: handle LDPC FEC, it changes the rounding */
  }
  /* round up to whole symbols */
  if ((bits % (bits_per_symbol * Mstbc)) > 0)
    symbols++;

  symbols *= Mstbc;
  return (symbols * (info_n->short_gi ? 36 : 40) + 5) / 10;
}

/* TODO: this is a crude quick hack, need proper calculation of bits/symbols/FEC/etc */
static guint calculate_11ac_duration(guint frame_length, float data_rate)
{
  guint bits = 8 * frame_length + 16;
  return (guint) (bits / data_rate);
}

static void adjust_agg_tsf(gpointer data, gpointer user_data)
{
  struct wlan_radio *wlan_radio_info = (struct wlan_radio *)data;
  guint64 *ppdu_start = (guint64 *)user_data;

  wlan_radio_info->start_tsf += (*ppdu_start);
  wlan_radio_info->end_tsf += (*ppdu_start);
704
705
  if (wlan_radio_info->prior_aggregate_data == 0)
	  wlan_radio_info->ifs += (*ppdu_start);
706
}
Anders Broman's avatar
Anders Broman committed
707
708

/*
709
 * Dissect 802.11 pseudo-header containing radio information.
Anders Broman's avatar
Anders Broman committed
710
 */
711
static void
712
dissect_wlan_radio_phdr(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, struct ieee_802_11_phdr *phdr)
Anders Broman's avatar
Anders Broman committed
713
{
714
715
  proto_item *ti;
  proto_tree *radio_tree;
716
717
  float data_rate = 0.0f;
  gboolean have_data_rate = FALSE;
718
  gboolean has_short_preamble = FALSE;
719
  gboolean short_preamble = TRUE;
720
721
722
  guint bandwidth = 0;
  gboolean can_calculate_rate = FALSE;
  proto_item *p_item;
723
724
725
726

  guint frame_length = tvb_reported_length(tvb); /* length of 802.11 frame data */

  /* durations in microseconds */
727
  guint preamble = 0, agg_preamble = 0; /* duration of plcp */
728
729
  gboolean have_duration = FALSE;
  guint duration = 0; /* duration of whole frame (plcp + mac data + any trailing parts) */
730
  guint prior_duration = 0; /* duration of previous part of aggregate */
Anders Broman's avatar
Anders Broman committed
731

732
  struct wlan_radio *wlan_radio_info;
733
734
735
  int phy = phdr->phy;
  union ieee_802_11_phy_info *phy_info = &phdr->phy_info;

Anders Broman's avatar
Anders Broman committed
736
737
738
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "Radio");
  col_clear(pinfo->cinfo, COL_INFO);

739
  /* Calculate the data rate, if we have the necessary data */
Simon Barber's avatar
Simon Barber committed
740
  if (phdr->has_data_rate) {
741
    data_rate = phdr->data_rate * 0.5f;
742
    have_data_rate = TRUE;
743
744
  }

745
746
747
  /* this is the first time we are looking at this frame during a
   * capture dissection, so we know the dissection is done in
   * frame order (subsequent dissections may be random access) */
748
  if (!pinfo->fd->visited) {
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
    wlan_radio_info = wmem_new0(wmem_file_scope(), struct wlan_radio);
    p_add_proto_data(wmem_file_scope(), pinfo, proto_wlan_radio, 0, wlan_radio_info);

    /* A-MPDU / aggregate detection
     * Different generators need different detection algorithms
     * One common pattern is to report all subframes in the aggregate with the same
     * tsf, referenced to the start of the AMPDU (Broadcom). Another pattern is to
     * report the tsf on the first subframe, then tsf=0 for the rest of the subframes
     * (Intel).
     * Another pattern is to report TSF = -1 for all frames but the last, and the
     * last has the tsf referenced to the end of the PPDU. (QCA)
     */
    /* TODO: add code to work around problem with captures from Macbooks where
     * aggregate subframes frames with FCS errors sometimes have incorrect
     * PHY information.
     */
    if (pinfo->fd->num > 1 &&
        (phdr->phy == PHDR_802_11_PHY_11N || phdr->phy == PHDR_802_11_PHY_11AC) &&
        phdr->phy == previous_frame.phy &&
        phdr->has_tsf_timestamp && previous_frame.has_tsf_timestamp &&
        (phdr->tsf_timestamp == previous_frame.tsf_timestamp || /* find matching TSFs */
         (!current_aggregate && previous_frame.tsf_timestamp && phdr->tsf_timestamp == 0) || /* Intel detect second frame */
771
         (previous_frame.tsf_timestamp == G_MAXUINT64) /* QCA, detect last frame */
772
773
774
775
776
777
        )) {
      /* we're in an aggregate */
      if (!current_aggregate) {
        /* this is the second frame in an aggregate
         * where we first detect the aggregate */
        current_aggregate = wmem_new0(wmem_file_scope(), struct aggregate);
778
779
        current_aggregate->phy = previous_frame.phy;
        current_aggregate->phy_info = previous_frame.phy_info;
780
781
782

        /* go back to the first frame in the aggregate,
         * and mark it as part of this aggregate */
Guy Harris's avatar
Guy Harris committed
783
784
        if (previous_frame.radio_info != NULL)
          previous_frame.radio_info->aggregate = current_aggregate;
785
786
787
788
789
790
791
792
793
794
795
796
797
798
      }
      wlan_radio_info->aggregate = current_aggregate;

      /* accumulate the length of the prior subframes in the aggregate.
       * Round up previous frame length (padding) */
      if (previous_frame.prev_length % 4 != 0) {
        previous_frame.prev_length = (previous_frame.prev_length | 3) + 1;
      }
      /* Also add the MPDU delimiter length */
      previous_frame.prev_length += 4;
      /* TODO: add padding to meet minimum subframe timing constraint */
      wlan_radio_info->prior_aggregate_data = previous_frame.prev_length;
      previous_frame.prev_length += frame_length;

799
800
801
802
803
804
805
806
807
808
      /* work around macbook/QCA FCS error frame PHY rate bug here
       * Some Macbook generators and some QCA generators erroneously report
       * low PHY rates for some subframes within an aggregate that have FCS errors.
       * All subframes must have the same PHY rate.
       * Here we take the highest reported rate for the aggregate. */
      switch (phdr->phy) {
      case PHDR_802_11_PHY_11N:
        {
          struct ieee_802_11n *info_n = &phy_info->info_11n;
          struct ieee_802_11n *agg_info_n = &current_aggregate->phy_info.info_11n;
809

810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
          if (info_n->has_mcs_index && agg_info_n->has_mcs_index &&
              info_n->mcs_index > agg_info_n->mcs_index)
              current_aggregate->phy_info = *phy_info;
        }
        break;

      case PHDR_802_11_PHY_11AC:
        {
          struct ieee_802_11ac *info_ac = &phy_info->info_11ac;
          struct ieee_802_11ac *agg_info_ac = &current_aggregate->phy_info.info_11ac;

          if (info_ac->mcs[0] > agg_info_ac->mcs[0])
              current_aggregate->phy_info = *phy_info;
        }
        break;
      }
      /* TODO record a warning if the PHY rate does not match the aggregate */
827
828
829
830
831
832
833
834
835
      phy = current_aggregate->phy;
      phy_info = &current_aggregate->phy_info;
    } else {
      current_aggregate = NULL;
      previous_frame.prev_length = frame_length;
    }
    previous_frame.has_tsf_timestamp = phdr->has_tsf_timestamp;
    previous_frame.tsf_timestamp = phdr->tsf_timestamp;
    previous_frame.phy = phdr->phy;
836
    previous_frame.phy_info = phdr->phy_info;
837
  } else {
Guy Harris's avatar
Guy Harris committed
838
    /* this frame has already been seen, so get its info structure */
839
840
    wlan_radio_info = (struct wlan_radio *) p_get_proto_data(wmem_file_scope(), pinfo, proto_wlan_radio, 0);

841
    if (wlan_radio_info && wlan_radio_info->aggregate) {
842
843
844
845
846
      phy = wlan_radio_info->aggregate->phy;
      phy_info = &wlan_radio_info->aggregate->phy_info;
    }
  }

847
848
  ti = proto_tree_add_item(tree, proto_wlan_radio, tvb, 0, 0, ENC_NA);
  radio_tree = proto_item_add_subtree (ti, ett_wlan_radio);
Anders Broman's avatar
Anders Broman committed
849

850
851
  if (phy != PHDR_802_11_PHY_UNKNOWN) {
    proto_tree_add_uint(radio_tree, hf_wlan_radio_phy, tvb, 0, 0, phy);
852

853
    switch (phy) {
854

855
      case PHDR_802_11_PHY_11_FHSS:
856
      {
857
        struct ieee_802_11_fhss *info_fhss = &phy_info->info_11_fhss;
858
859

        if (info_fhss->has_hop_set) {
860
          proto_tree_add_uint(radio_tree, hf_wlan_radio_11_fhss_hop_set, tvb, 0, 0,
861
                   info_fhss->hop_set);
862
        }
863
        if (info_fhss->has_hop_pattern) {
864
          proto_tree_add_uint(radio_tree, hf_wlan_radio_11_fhss_hop_pattern, tvb, 0, 0,
865
                   info_fhss->hop_pattern);
866
        }
867
        if (info_fhss->has_hop_index) {
868
          proto_tree_add_uint(radio_tree, hf_wlan_radio_11_fhss_hop_index, tvb, 0, 0,
869
                   info_fhss->hop_index);
870
871
        }
        break;
872
      }
873

874
      case PHDR_802_11_PHY_11B:
875
      {