aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ieee80211-radio.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-30 12:13:21 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-30 19:14:21 +0000
commita683dd3edfd91c5d4089fcf279d23ad8560ddec0 (patch)
tree50dc9dff0397441ca1f8374c2958b9c399831ba9 /epan/dissectors/packet-ieee80211-radio.c
parentcc640f03b959c90e8a9bfe9afe7c56b30caa6b41 (diff)
Make the data rate field float, and calculate it for 802.11n.
Bug: 10637 Change-Id: Ifd4094f308246e92500cc7149c0d42c8496fb9f4 Reviewed-on: https://code.wireshark.org/review/5005 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-ieee80211-radio.c')
-rw-r--r--epan/dissectors/packet-ieee80211-radio.c449
1 files changed, 435 insertions, 14 deletions
diff --git a/epan/dissectors/packet-ieee80211-radio.c b/epan/dissectors/packet-ieee80211-radio.c
index f9f2bf2be5..0280160a5b 100644
--- a/epan/dissectors/packet-ieee80211-radio.c
+++ b/epan/dissectors/packet-ieee80211-radio.c
@@ -58,6 +58,406 @@ static const value_string bandwidth_vals[] = {
{ 0, NULL }
};
+/*
+ * Data rates corresponding to a given 802.11n MCS index, bandwidth, and
+ * guard interval.
+ *
+ * Indices are:
+ *
+ * the MCS index (0-76);
+ *
+ * 0 for 20 MHz, 1 for 40 MHz;
+ *
+ * 0 for a long guard interval, 1 for a short guard interval.
+ */
+WS_DLL_PUBLIC_DEF
+const float ieee80211_float_htrates[MAX_MCS_INDEX+1][2][2] = {
+ /* MCS 0 */
+ { /* 20 Mhz */ { 6.5f, /* SGI */ 7.2f, },
+ /* 40 Mhz */ { 13.5f, /* SGI */ 15.0f, },
+ },
+
+ /* MCS 1 */
+ { /* 20 Mhz */ { 13.0f, /* SGI */ 14.4f, },
+ /* 40 Mhz */ { 27.0f, /* SGI */ 30.0f, },
+ },
+
+ /* MCS 2 */
+ { /* 20 Mhz */ { 19.5f, /* SGI */ 21.7f, },
+ /* 40 Mhz */ { 40.5f, /* SGI */ 45.0f, },
+ },
+
+ /* MCS 3 */
+ { /* 20 Mhz */ { 26.0f, /* SGI */ 28.9f, },
+ /* 40 Mhz */ { 54.0f, /* SGI */ 60.0f, },
+ },
+
+ /* MCS 4 */
+ { /* 20 Mhz */ { 39.0f, /* SGI */ 43.3f, },
+ /* 40 Mhz */ { 81.0f, /* SGI */ 90.0f, },
+ },
+
+ /* MCS 5 */
+ { /* 20 Mhz */ { 52.0f, /* SGI */ 57.8f, },
+ /* 40 Mhz */ { 108.0f, /* SGI */ 120.0f, },
+ },
+
+ /* MCS 6 */
+ { /* 20 Mhz */ { 58.5f, /* SGI */ 65.0f, },
+ /* 40 Mhz */ { 121.5f, /* SGI */ 135.0f, },
+ },
+
+ /* MCS 7 */
+ { /* 20 Mhz */ { 65.0f, /* SGI */ 72.2f, },
+ /* 40 Mhz */ { 135.0f, /* SGI */ 150.0f, },
+ },
+
+ /* MCS 8 */
+ { /* 20 Mhz */ { 13.0f, /* SGI */ 14.4f, },
+ /* 40 Mhz */ { 27.0f, /* SGI */ 30.0f, },
+ },
+
+ /* MCS 9 */
+ { /* 20 Mhz */ { 26.0f, /* SGI */ 28.9f, },
+ /* 40 Mhz */ { 54.0f, /* SGI */ 60.0f, },
+ },
+
+ /* MCS 10 */
+ { /* 20 Mhz */ { 39.0f, /* SGI */ 43.3f, },
+ /* 40 Mhz */ { 81.0f, /* SGI */ 90.0f, },
+ },
+
+ /* MCS 11 */
+ { /* 20 Mhz */ { 52.0f, /* SGI */ 57.8f, },
+ /* 40 Mhz */ { 108.0f, /* SGI */ 120.0f, },
+ },
+
+ /* MCS 12 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 13 */
+ { /* 20 Mhz */ { 104.0f, /* SGI */ 115.6f, },
+ /* 40 Mhz */ { 216.0f, /* SGI */ 240.0f, },
+ },
+
+ /* MCS 14 */
+ { /* 20 Mhz */ { 117.0f, /* SGI */ 130.0f, },
+ /* 40 Mhz */ { 243.0f, /* SGI */ 270.0f, },
+ },
+
+ /* MCS 15 */
+ { /* 20 Mhz */ { 130.0f, /* SGI */ 144.4f, },
+ /* 40 Mhz */ { 270.0f, /* SGI */ 300.0f, },
+ },
+
+ /* MCS 16 */
+ { /* 20 Mhz */ { 19.5f, /* SGI */ 21.7f, },
+ /* 40 Mhz */ { 40.5f, /* SGI */ 45.0f, },
+ },
+
+ /* MCS 17 */
+ { /* 20 Mhz */ { 39.0f, /* SGI */ 43.3f, },
+ /* 40 Mhz */ { 81.0f, /* SGI */ 90.0f, },
+ },
+
+ /* MCS 18 */
+ { /* 20 Mhz */ { 58.5f, /* SGI */ 65.0f, },
+ /* 40 Mhz */ { 121.5f, /* SGI */ 135.0f, },
+ },
+
+ /* MCS 19 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 20 */
+ { /* 20 Mhz */ { 117.0f, /* SGI */ 130.0f, },
+ /* 40 Mhz */ { 243.0f, /* SGI */ 270.0f, },
+ },
+
+ /* MCS 21 */
+ { /* 20 Mhz */ { 156.0f, /* SGI */ 173.3f, },
+ /* 40 Mhz */ { 324.0f, /* SGI */ 360.0f, },
+ },
+
+ /* MCS 22 */
+ { /* 20 Mhz */ { 175.5f, /* SGI */ 195.0f, },
+ /* 40 Mhz */ { 364.5f, /* SGI */ 405.0f, },
+ },
+
+ /* MCS 23 */
+ { /* 20 Mhz */ { 195.0f, /* SGI */ 216.7f, },
+ /* 40 Mhz */ { 405.0f, /* SGI */ 450.0f, },
+ },
+
+ /* MCS 24 */
+ { /* 20 Mhz */ { 26.0f, /* SGI */ 28.9f, },
+ /* 40 Mhz */ { 54.0f, /* SGI */ 60.0f, },
+ },
+
+ /* MCS 25 */
+ { /* 20 Mhz */ { 52.0f, /* SGI */ 57.8f, },
+ /* 40 Mhz */ { 108.0f, /* SGI */ 120.0f, },
+ },
+
+ /* MCS 26 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 27 */
+ { /* 20 Mhz */ { 104.0f, /* SGI */ 115.6f, },
+ /* 40 Mhz */ { 216.0f, /* SGI */ 240.0f, },
+ },
+
+ /* MCS 28 */
+ { /* 20 Mhz */ { 156.0f, /* SGI */ 173.3f, },
+ /* 40 Mhz */ { 324.0f, /* SGI */ 360.0f, },
+ },
+
+ /* MCS 29 */
+ { /* 20 Mhz */ { 208.0f, /* SGI */ 231.1f, },
+ /* 40 Mhz */ { 432.0f, /* SGI */ 480.0f, },
+ },
+
+ /* MCS 30 */
+ { /* 20 Mhz */ { 234.0f, /* SGI */ 260.0f, },
+ /* 40 Mhz */ { 486.0f, /* SGI */ 540.0f, },
+ },
+
+ /* MCS 31 */
+ { /* 20 Mhz */ { 260.0f, /* SGI */ 288.9f, },
+ /* 40 Mhz */ { 540.0f, /* SGI */ 600.0f, },
+ },
+
+ /* MCS 32 */
+ { /* 20 Mhz */ { 0.0f, /* SGI */ 0.0f, }, /* not valid */
+ /* 40 Mhz */ { 6.0f, /* SGI */ 6.7f, },
+ },
+
+ /* MCS 33 */
+ { /* 20 Mhz */ { 39.0f, /* SGI */ 43.3f, },
+ /* 40 Mhz */ { 81.0f, /* SGI */ 90.0f, },
+ },
+
+ /* MCS 34 */
+ { /* 20 Mhz */ { 52.0f, /* SGI */ 57.8f, },
+ /* 40 Mhz */ { 108.0f, /* SGI */ 120.0f, },
+ },
+
+ /* MCS 35 */
+ { /* 20 Mhz */ { 65.0f, /* SGI */ 72.2f, },
+ /* 40 Mhz */ { 135.0f, /* SGI */ 150.0f, },
+ },
+
+ /* MCS 36 */
+ { /* 20 Mhz */ { 58.5f, /* SGI */ 65.0f, },
+ /* 40 Mhz */ { 121.5f, /* SGI */ 135.0f, },
+ },
+
+ /* MCS 37 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 38 */
+ { /* 20 Mhz */ { 97.5f, /* SGI */ 108.3f, },
+ /* 40 Mhz */ { 202.5f, /* SGI */ 225.0f, },
+ },
+
+ /* MCS 39 */
+ { /* 20 Mhz */ { 52.0f, /* SGI */ 57.8f, },
+ /* 40 Mhz */ { 108.0f, /* SGI */ 120.0f, },
+ },
+
+ /* MCS 40 */
+ { /* 20 Mhz */ { 65.0f, /* SGI */ 72.2f, },
+ /* 40 Mhz */ { 135.0f, /* SGI */ 150.0f, },
+ },
+
+ /* MCS 41 */
+ { /* 20 Mhz */ { 65.0f, /* SGI */ 72.2f, },
+ /* 40 Mhz */ { 135.0f, /* SGI */ 150.0f, },
+ },
+
+ /* MCS 42 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 43 */
+ { /* 20 Mhz */ { 91.0f, /* SGI */ 101.1f, },
+ /* 40 Mhz */ { 189.0f, /* SGI */ 210.0f, },
+ },
+
+ /* MCS 44 */
+ { /* 20 Mhz */ { 91.0f, /* SGI */ 101.1f, },
+ /* 40 Mhz */ { 189.0f, /* SGI */ 210.0f, },
+ },
+
+ /* MCS 45 */
+ { /* 20 Mhz */ { 104.0f, /* SGI */ 115.6f, },
+ /* 40 Mhz */ { 216.0f, /* SGI */ 240.0f, },
+ },
+
+ /* MCS 46 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 47 */
+ { /* 20 Mhz */ { 97.5f, /* SGI */ 108.3f, },
+ /* 40 Mhz */ { 202.5f, /* SGI */ 225.0f, },
+ },
+
+ /* MCS 48 */
+ { /* 20 Mhz */ { 97.5f, /* SGI */ 108.3f, },
+ /* 40 Mhz */ { 202.5f, /* SGI */ 225.0f, },
+ },
+
+ /* MCS 49 */
+ { /* 20 Mhz */ { 117.0f, /* SGI */ 130.0f, },
+ /* 40 Mhz */ { 243.0f, /* SGI */ 270.0f, },
+ },
+
+ /* MCS 50 */
+ { /* 20 Mhz */ { 136.5f, /* SGI */ 151.7f, },
+ /* 40 Mhz */ { 283.5f, /* SGI */ 315.0f, },
+ },
+
+ /* MCS 51 */
+ { /* 20 Mhz */ { 136.5f, /* SGI */ 151.7f, },
+ /* 40 Mhz */ { 283.5f, /* SGI */ 315.0f, },
+ },
+
+ /* MCS 52 */
+ { /* 20 Mhz */ { 156.0f, /* SGI */ 173.3f, },
+ /* 40 Mhz */ { 324.0f, /* SGI */ 360.0f, },
+ },
+
+ /* MCS 53 */
+ { /* 20 Mhz */ { 65.0f, /* SGI */ 72.2f, },
+ /* 40 Mhz */ { 135.0f, /* SGI */ 150.0f, },
+ },
+
+ /* MCS 54 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 55 */
+ { /* 20 Mhz */ { 91.0f, /* SGI */ 101.1f, },
+ /* 40 Mhz */ { 189.0f, /* SGI */ 210.0f, },
+ },
+
+ /* MCS 56 */
+ { /* 20 Mhz */ { 78.0f, /* SGI */ 86.7f, },
+ /* 40 Mhz */ { 162.0f, /* SGI */ 180.0f, },
+ },
+
+ /* MCS 57 */
+ { /* 20 Mhz */ { 91.0f, /* SGI */ 101.1f, },
+ /* 40 Mhz */ { 189.0f, /* SGI */ 210.0f, },
+ },
+
+ /* MCS 58 */
+ { /* 20 Mhz */ { 104.0f, /* SGI */ 115.6f, },
+ /* 40 Mhz */ { 216.0f, /* SGI */ 240.0f, },
+ },
+
+ /* MCS 59 */
+ { /* 20 Mhz */ { 117.0f, /* SGI */ 130.0f, },
+ /* 40 Mhz */ { 243.0f, /* SGI */ 270.0f, },
+ },
+
+ /* MCS 60 */
+ { /* 20 Mhz */ { 104.0f, /* SGI */ 115.6f, },
+ /* 40 Mhz */ { 216.0f, /* SGI */ 240.0f, },
+ },
+
+ /* MCS 61 */
+ { /* 20 Mhz */ { 117.0f, /* SGI */ 130.0f, },
+ /* 40 Mhz */ { 243.0f, /* SGI */ 270.0f, },
+ },
+
+ /* MCS 62 */
+ { /* 20 Mhz */ { 130.0f, /* SGI */ 144.4f, },
+ /* 40 Mhz */ { 270.0f, /* SGI */ 300.0f, },
+ },
+
+ /* MCS 63 */
+ { /* 20 Mhz */ { 130.0f, /* SGI */ 144.4f, },
+ /* 40 Mhz */ { 270.0f, /* SGI */ 300.0f, },
+ },
+
+ /* MCS 64 */
+ { /* 20 Mhz */ { 143.0f, /* SGI */ 158.9f, },
+ /* 40 Mhz */ { 297.0f, /* SGI */ 330.0f, },
+ },
+
+ /* MCS 65 */
+ { /* 20 Mhz */ { 97.5f, /* SGI */ 108.3f, },
+ /* 40 Mhz */ { 202.5f, /* SGI */ 225.0f, },
+ },
+
+ /* MCS 66 */
+ { /* 20 Mhz */ { 117.0f, /* SGI */ 130.0f, },
+ /* 40 Mhz */ { 243.0f, /* SGI */ 270.0f, },
+ },
+
+ /* MCS 67 */
+ { /* 20 Mhz */ { 136.5f, /* SGI */ 151.7f, },
+ /* 40 Mhz */ { 283.5f, /* SGI */ 315.0f, },
+ },
+
+ /* MCS 68 */
+ { /* 20 Mhz */ { 117.0f, /* SGI */ 130.0f, },
+ /* 40 Mhz */ { 243.0f, /* SGI */ 270.0f, },
+ },
+
+ /* MCS 69 */
+ { /* 20 Mhz */ { 136.5f, /* SGI */ 151.7f, },
+ /* 40 Mhz */ { 283.5f, /* SGI */ 315.0f, },
+ },
+
+ /* MCS 70 */
+ { /* 20 Mhz */ { 156.0f, /* SGI */ 173.3f, },
+ /* 40 Mhz */ { 324.0f, /* SGI */ 360.0f, },
+ },
+
+ /* MCS 71 */
+ { /* 20 Mhz */ { 175.5f, /* SGI */ 195.0f, },
+ /* 40 Mhz */ { 364.5f, /* SGI */ 405.0f, },
+ },
+
+ /* MCS 72 */
+ { /* 20 Mhz */ { 156.0f, /* SGI */ 173.3f, },
+ /* 40 Mhz */ { 324.0f, /* SGI */ 360.0f, },
+ },
+
+ /* MCS 73 */
+ { /* 20 Mhz */ { 175.5f, /* SGI */ 195.0f, },
+ /* 40 Mhz */ { 364.5f, /* SGI */ 405.0f, },
+ },
+
+ /* MCS 74 */
+ { /* 20 Mhz */ { 195.0f, /* SGI */ 216.7f, },
+ /* 40 Mhz */ { 405.0f, /* SGI */ 450.0f, },
+ },
+
+ /* MCS 75 */
+ { /* 20 Mhz */ { 195.0f, /* SGI */ 216.7f, },
+ /* 40 Mhz */ { 405.0f, /* SGI */ 450.0f, },
+ },
+
+ /* MCS 76 */
+ { /* 20 Mhz */ { 214.5f, /* SGI */ 238.3f, },
+ /* 40 Mhz */ { 445.5f, /* SGI */ 495.0f, },
+ },
+};
+
static gint ett_radio = -1;
/*
@@ -69,18 +469,40 @@ dissect_radio (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
{
proto_item *ti = NULL;
proto_tree *radio_tree = NULL;
+ float data_rate = 0.0f;
+ gboolean have_data_rate = FALSE;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Radio");
col_clear(pinfo->cinfo, COL_INFO);
- /* Add the radio information to the column information */
-
+ /* Calculate the data rate, if we have the necessary data */
if (pinfo->pseudo_header->ieee_802_11.presence_flags & PHDR_802_11_HAS_DATA_RATE) {
- col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%u.%u",
- pinfo->pseudo_header->ieee_802_11.data_rate / 2,
- pinfo->pseudo_header->ieee_802_11.data_rate & 1 ? 5 : 0);
+ data_rate = pinfo->pseudo_header->ieee_802_11.data_rate * 0.5f;
+ have_data_rate = TRUE;
+ } else {
+ /* Do we have all the fields we need to look it up? */
+#define PHDR_802_11_ALL_MCS_FIELDS \
+ (PHDR_802_11_HAS_MCS_INDEX | \
+ PHDR_802_11_HAS_BANDWIDTH | \
+ PHDR_802_11_HAS_SHORT_GI)
+
+ guint bandwidth_40;
+
+ if ((pinfo->pseudo_header->ieee_802_11.presence_flags & PHDR_802_11_ALL_MCS_FIELDS) == PHDR_802_11_ALL_MCS_FIELDS) {
+ bandwidth_40 =
+ (pinfo->pseudo_header->ieee_802_11.bandwidth == PHDR_802_11_BANDWIDTH_40_MHZ) ?
+ 1 : 0;
+ if (pinfo->pseudo_header->ieee_802_11.mcs_index < MAX_MCS_INDEX) {
+ data_rate = ieee80211_float_htrates[pinfo->pseudo_header->ieee_802_11.mcs_index][bandwidth_40][pinfo->pseudo_header->ieee_802_11.short_gi];
+ have_data_rate = TRUE;
+ }
+ }
}
+ /* Add the radio information to the column information */
+ if (have_data_rate)
+ col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%.1f", data_rate);
+
if (pinfo->pseudo_header->ieee_802_11.presence_flags & PHDR_802_11_HAS_SIGNAL_PERCENT) {
/*
* For tagged Peek files, this is presumably signal strength as a
@@ -103,14 +525,6 @@ dissect_radio (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
ti = proto_tree_add_item(tree, proto_radio, tvb, 0, 0, ENC_NA);
radio_tree = proto_item_add_subtree (ti, ett_radio);
- if (pinfo->pseudo_header->ieee_802_11.presence_flags & PHDR_802_11_HAS_DATA_RATE) {
- proto_tree_add_uint64_format_value(radio_tree, hf_data_rate, tvb, 0, 0,
- (guint64)pinfo->pseudo_header->ieee_802_11.data_rate * 500000,
- "%u.%u Mb/s",
- pinfo->pseudo_header->ieee_802_11.data_rate / 2,
- pinfo->pseudo_header->ieee_802_11.data_rate & 1 ? 5 : 0);
- }
-
if (pinfo->pseudo_header->ieee_802_11.presence_flags & PHDR_802_11_HAS_MCS_INDEX) {
proto_tree_add_uint(radio_tree, hf_mcs_index, tvb, 0, 0,
pinfo->pseudo_header->ieee_802_11.mcs_index);
@@ -126,6 +540,13 @@ dissect_radio (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
pinfo->pseudo_header->ieee_802_11.short_gi);
}
+ if (have_data_rate) {
+ proto_tree_add_float_format_value(radio_tree, hf_data_rate, tvb, 0, 0,
+ data_rate,
+ "%.1f Mb/s",
+ data_rate);
+ }
+
if (pinfo->pseudo_header->ieee_802_11.presence_flags & PHDR_802_11_HAS_CHANNEL) {
proto_tree_add_uint(radio_tree, hf_channel, tvb, 0, 0,
pinfo->pseudo_header->ieee_802_11.channel);
@@ -174,7 +595,7 @@ dissect_radio (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
static hf_register_info hf_radio[] = {
{&hf_data_rate,
- {"Data rate", "wlan.data_rate", FT_UINT64, BASE_DEC, NULL, 0,
+ {"Data rate", "wlan.data_rate", FT_FLOAT, BASE_NONE, NULL, 0,
"Data rate (bits/s)", HFILL }},
{&hf_mcs_index,