From f474eaedd849c963ec78faff87ac9edeee0f2e47 Mon Sep 17 00:00:00 2001 From: Martin Mathieson Date: Mon, 23 Mar 2009 22:16:25 +0000 Subject: [PATCH] Add CRC error flag to frames, and show in stats window. svn path=/trunk/; revision=27837 --- epan/dissectors/packet-catapult-dct2000.c | 8 +++++- epan/dissectors/packet-mac-lte.c | 30 ++++++++++++++++++-- epan/dissectors/packet-mac-lte.h | 2 ++ gtk/mac_lte_stat_dlg.c | 34 +++++++++++++++++------ 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c index f4fc970cee..37cc2718de 100644 --- a/epan/dissectors/packet-catapult-dct2000.c +++ b/epan/dissectors/packet-catapult-dct2000.c @@ -1326,6 +1326,8 @@ static void attach_mac_lte_info(packet_info *pinfo) } /* Populate the struct from outhdr values */ + p_mac_lte_info->crcStatus = TRUE; + p_mac_lte_info->radioType = outhdr_values[i++]; p_mac_lte_info->rntiType = outhdr_values[i++]; p_mac_lte_info->direction = outhdr_values[i++]; @@ -1333,10 +1335,14 @@ static void attach_mac_lte_info(packet_info *pinfo) p_mac_lte_info->isPredefinedData = outhdr_values[i++]; p_mac_lte_info->rnti = outhdr_values[i++]; p_mac_lte_info->ueid = outhdr_values[i++]; + p_mac_lte_info->length = outhdr_values[i++]; if (outhdr_values_found > 8) { p_mac_lte_info->reTxCount = outhdr_values[i++]; } - p_mac_lte_info->length = outhdr_values[i++]; + if (outhdr_values_found > 9) { + p_mac_lte_info->crcStatus = outhdr_values[i++]; + } + /* Store info in packet */ p_add_proto_data(pinfo->fd, proto_mac_lte, p_mac_lte_info); diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c index e809c20185..2200cc218a 100644 --- a/epan/dissectors/packet-mac-lte.c +++ b/epan/dissectors/packet-mac-lte.c @@ -43,7 +43,6 @@ - more testing of control bodies - TDD mode - add a preference so that padding can be verified against an expected pattern? - - context value to show CRC-passed flag */ /* Initialize the protocol and registered fields. */ @@ -62,6 +61,7 @@ static int hf_mac_lte_context_predefined_frame = -1; static int hf_mac_lte_context_length = -1; static int hf_mac_lte_context_bch_transport_channel = -1; static int hf_mac_lte_context_retx_count = -1; +static int hf_mac_lte_context_crc_status = -1; /* MAC SCH header fields */ static int hf_mac_lte_ulsch_header = -1; @@ -163,6 +163,13 @@ static const value_string bch_transport_channel_vals[] = { 0, NULL } }; +static const value_string crc_status_vals[] = +{ + { 0, "CRC Status Failed"}, + { 1, "CRC Status OK"}, + { 0, NULL } +}; + #define UE_CONTENTION_RESOLUTION_IDENTITY_LCID 0x1c @@ -1059,11 +1066,24 @@ void dissect_mac_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } + ti = proto_tree_add_uint(mac_lte_tree, hf_mac_lte_context_crc_status, + tvb, 0, 0, p_mac_lte_info->crcStatus); + PROTO_ITEM_SET_GENERATED(ti); + if (p_mac_lte_info->crcStatus != TRUE) { + expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, + "Frame has CRC error"); + if (check_col(pinfo->cinfo, COL_INFO)) { + col_append_fstr(pinfo->cinfo, COL_INFO, ""); + } + } + + /* Set context-info parts of tap struct */ tap_info.rnti = p_mac_lte_info->rnti; tap_info.rnti_type = p_mac_lte_info->rntiType; tap_info.is_predefined_data = p_mac_lte_info->isPredefinedData; tap_info.reTxCount = p_mac_lte_info->reTxCount; + tap_info.crcStatus = p_mac_lte_info->crcStatus; tap_info.direction = p_mac_lte_info->direction; /* Also set total number of bytes (won't be used for UL/DL-SCH) */ @@ -1191,10 +1211,16 @@ void proto_register_mac_lte(void) }, { &hf_mac_lte_context_retx_count, { "ReTX count", - "mac-lte.bch-transport-channel", FT_UINT8, BASE_DEC, 0, 0x0, + "mac-lte.retx-count", FT_UINT8, BASE_DEC, 0, 0x0, "Number of times this PDU has been retransmitted", HFILL } }, + { &hf_mac_lte_context_crc_status, + { "CRC Status", + "mac-lte.crc-status", FT_UINT8, BASE_DEC, VALS(crc_status_vals), 0x0, + "CRC Status as reported by PHY", HFILL + } + }, /*******************************************/ diff --git a/epan/dissectors/packet-mac-lte.h b/epan/dissectors/packet-mac-lte.h index 884ea14179..56df48b67f 100644 --- a/epan/dissectors/packet-mac-lte.h +++ b/epan/dissectors/packet-mac-lte.h @@ -53,6 +53,7 @@ typedef struct mac_lte_info guint8 isPredefinedData; guint16 length; guint8 reTxCount; + guint8 crcStatus; } mac_lte_info; @@ -62,6 +63,7 @@ typedef struct mac_lte_tap_info { guint8 rnti_type; guint8 is_predefined_data; guint8 reTxCount; + guint8 crcStatus; guint8 direction; /* Number of bytes (which part is used depends upon context settings) */ diff --git a/gtk/mac_lte_stat_dlg.c b/gtk/mac_lte_stat_dlg.c index 907637649a..65e9121d2a 100644 --- a/gtk/mac_lte_stat_dlg.c +++ b/gtk/mac_lte_stat_dlg.c @@ -75,9 +75,11 @@ enum { RNTI_COLUMN, UL_FRAMES_COLUMN, UL_BYTES_COLUMN, + UL_CRC_ERRORS_COLUMN, UL_RETX_FRAMES_COLUMN, DL_FRAMES_COLUMN, DL_BYTES_COLUMN, + DL_CRC_ERRORS_COLUMN, DL_RETX_FRAMES_COLUMN, TABLE_COLUMN, NUM_UE_COLUMNS @@ -100,8 +102,8 @@ enum { }; static const gchar *ue_titles[] = { "RNTI", - "UL Frames", "UL Bytes", "UL ReTX Frames", - "DL Frames", "DL Bytes", "DL ReTX Frames"}; + "UL Frames", "UL Bytes", "UL CRC Errors", "UL ReTX Frames", + "DL Frames", "DL Bytes", "DL CRC Errors", "DL ReTX Frames"}; static const gchar *channel_titles[] = { "CCCH", "LCID 1", "LCID 2", "LCID 3", "LCID 4", "LCID 5", @@ -118,10 +120,12 @@ typedef struct mac_lte_row_data { guint32 UL_frames; guint32 UL_total_bytes; + guint32 UL_CRC_errors; guint32 UL_retx_frames; guint32 DL_frames; guint32 DL_total_bytes; + guint32 DL_CRC_errors; guint32 DL_retx_frames; guint32 UL_bytes_for_lcid[11]; @@ -243,6 +247,8 @@ static mac_lte_ep_t* alloc_mac_lte_ep(struct mac_lte_tap_info *si, packet_info * ep->stats.DL_frames = 0; ep->stats.UL_total_bytes = 0; ep->stats.DL_total_bytes = 0; + ep->stats.UL_CRC_errors = 0; + ep->stats.DL_CRC_errors = 0; ep->stats.UL_retx_frames = 0; ep->stats.DL_retx_frames = 0; @@ -331,6 +337,16 @@ mac_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_, te->number_of_packets++; te->stats.rnti = si->rnti; te->stats.is_predefined_data = si->is_predefined_data; + if (!si->crcStatus) { + if (si->direction == DIRECTION_UPLINK) { + te->stats.UL_CRC_errors++; + return 1; + } + else { + te->stats.DL_CRC_errors++; + return 1; + } + } /* Uplink */ if (si->direction == DIRECTION_UPLINK) { @@ -483,13 +499,13 @@ mac_lte_stat_draw(void *phs) /* Common channel data */ g_snprintf(buff, sizeof(buff), "BCH Frames: %u", common_stats.bch_frames); - gtk_label_set_text(GTK_LABEL(mac_lte_common_bch_frames), buff); + gtk_label_set_text(GTK_LABEL(mac_lte_common_bch_frames), buff); g_snprintf(buff, sizeof(buff), "BCH Bytes: %u", common_stats.bch_bytes); - gtk_label_set_text(GTK_LABEL(mac_lte_common_bch_bytes), buff); + gtk_label_set_text(GTK_LABEL(mac_lte_common_bch_bytes), buff); g_snprintf(buff, sizeof(buff), "PCH Frames: %u", common_stats.pch_frames); - gtk_label_set_text(GTK_LABEL(mac_lte_common_pch_frames), buff); + gtk_label_set_text(GTK_LABEL(mac_lte_common_pch_frames), buff); g_snprintf(buff, sizeof(buff), "PCH Bytes: %u", common_stats.pch_bytes); - gtk_label_set_text(GTK_LABEL(mac_lte_common_pch_bytes), buff); + gtk_label_set_text(GTK_LABEL(mac_lte_common_pch_bytes), buff); /* Per-UE table entries */ ues_store = GTK_LIST_STORE(gtk_tree_view_get_model(hs->ue_table)); @@ -507,9 +523,11 @@ mac_lte_stat_draw(void *phs) RNTI_COLUMN, tmp->stats.rnti, UL_FRAMES_COLUMN, tmp->stats.UL_frames, UL_BYTES_COLUMN, tmp->stats.UL_total_bytes, + UL_CRC_ERRORS_COLUMN, tmp->stats.UL_CRC_errors, UL_RETX_FRAMES_COLUMN, tmp->stats.UL_retx_frames, DL_FRAMES_COLUMN, tmp->stats.DL_frames, DL_BYTES_COLUMN, tmp->stats.DL_total_bytes, + DL_CRC_ERRORS_COLUMN, tmp->stats.DL_CRC_errors, DL_RETX_FRAMES_COLUMN, tmp->stats.DL_retx_frames, TABLE_COLUMN, tmp, -1); @@ -663,8 +681,8 @@ static void mac_lte_stat_dlg_create(void) /* Create the table of UE data */ store = gtk_list_store_new(NUM_UE_COLUMNS, G_TYPE_INT, - G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, /* UL */ - G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, /* DL */ + G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, /* UL */ + G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, /* DL */ G_TYPE_POINTER); hs->ue_table = GTK_TREE_VIEW(tree_view_new(GTK_TREE_MODEL(store))); gtk_container_add(GTK_CONTAINER (ues_scrolled_window), GTK_WIDGET(hs->ue_table));