Wireshark是可以解析LTE的空口数据。但是在wireshark的实现中,这些数据都是被封装到UDP报文中。然后根据wireshark的格式文件对LTE的数据加上头信息。头信息的定义参考附件packet-mac-lte.h文件

大致结构如下:

typedef struct mac_lte_info

{

/* Needed for decode */

guint8          radioType;

guint8          direction;

guint8          rntiType;

/* Extra info to display */

guint16         rnti;

guint16         ueid;

/* Timing info */

guint16         sysframeNumber;

guint16         subframeNumber;

gboolean        sfnSfInfoPresent;

/* Optional field. More interesting for TDD (FDD is always -4 subframeNumber) */

gboolean        subframeNumberOfGrantPresent;

guint16         subframeNumberOfGrant;

/* Flag set only if doing PHY-level data test - i.e. there may not be a

well-formed MAC PDU so just show as raw data */

gboolean        isPredefinedData;

/* Length of DL PDU or UL grant size in bytes */

guint16         length;

/* 0=newTx, 1=first-retx, etc */

guint8          reTxCount;

guint8          isPHICHNACK; /* FALSE=PDCCH retx grant, TRUE=PHICH NACK */

/* UL only.  Indicates if the R10 extendedBSR-Sizes parameter is set */

gboolean        isExtendedBSRSizes;

/* UL only.  Indicates if the R10 simultaneousPUCCH-PUSCH parameter is set for PCell */

gboolean        isSimultPUCCHPUSCHPCell;

/* UL only.  Indicates if the R10 extendedBSR-Sizes parameter is set for PSCell */

gboolean        isSimultPUCCHPUSCHPSCell;

/* Status of CRC check. For UE it is DL only. For eNodeB it is UL

only. For an analyzer, it is present for both DL and UL. */

gboolean        crcStatusValid;

mac_lte_crc_status crcStatus;

/* Carrier ID */

mac_lte_carrier_id   carrierId;

/* DL only.  Is this known to be a retransmission? */

mac_lte_dl_retx dl_retx;

/* DL only. CE mode to be used for RAR decoding */

mac_lte_ce_mode ceMode;

/* DL and UL. NB-IoT mode of the UE */

mac_lte_nb_mode nbMode;

/* UL only, for now used for CE mode A RAR decoding */

guint8          nUlRb;

/* More Physical layer info (see direction above for which side of union to use) */

union {

struct mac_lte_ul_phy_info

{

guint8 present;  /* Remaining UL fields are present and should be displayed */

guint8 modulation_type;

guint8 tbs_index;

guint8 resource_block_length;

guint8 resource_block_start;

guint8 harq_id;

gboolean ndi;

} ul_info;

struct mac_lte_dl_phy_info

{

guint8 present; /* Remaining DL fields are present and should be displayed */

guint8 dci_format;

guint8 resource_allocation_type;

guint8 aggregation_level;

guint8 mcs_index;

guint8 redundancy_version_index;

guint8 resource_block_length;

guint8 harq_id;

gboolean ndi;

guint8   transport_block;  /* 0..1 */

} dl_info;

} detailed_phy_info;

/* Relating to out-of-band events */

/* N.B. dissector will only look to these fields if length is 0... */

mac_lte_oob_event  oob_event;

guint8             rapid;

guint8             rach_attempt_number;

#define MAX_SRs 20

guint16            number_of_srs;

guint16            oob_ueid[MAX_SRs];

guint16            oob_rnti[MAX_SRs];

} mac_lte_info;

在进行头信息编码的时候,每个值都有一个TAG对应。TAG的定义如下

#define MAC_LTE_RNTI_TAG            0x02

/* 2 bytes, network order */

#define MAC_LTE_UEID_TAG            0x03

/* 2 bytes, network order */

#define MAC_LTE_FRAME_SUBFRAME_TAG  0x04

/* 2 bytes, network order, SFN is stored in 12 MSB and SF in 4 LSB */

#define MAC_LTE_PREDEFINED_DATA_TAG 0x05

/* 1 byte */

#define MAC_LTE_RETX_TAG            0x06

/* 1 byte */

#define MAC_LTE_CRC_STATUS_TAG      0x07

/* 1 byte */

#define MAC_LTE_EXT_BSR_SIZES_TAG   0x08

/* 0 byte */

#define MAC_LTE_SEND_PREAMBLE_TAG   0x09

/* 2 bytes, RAPID value (1 byte) followed by RACH attempt number (1 byte) */

#define MAC_LTE_CARRIER_ID_TAG      0x0A

/* 1 byte */

#define MAC_LTE_PHY_TAG             0x0B

/* variable length, length (1 byte) then depending on direction

in UL: modulation type (1 byte), TBS index (1 byte), RB length (1 byte),

RB start (1 byte), HARQ id (1 byte), NDI (1 byte)

in DL: DCI format (1 byte), resource allocation type (1 byte), aggregation level (1 byte),

MCS index (1 byte), redundancy version (1 byte), resource block length (1 byte),

HARQ id (1 byte), NDI (1 byte), TB (1 byte), DL reTx (1 byte) */

#define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL_TAG  0x0C

/* 0 byte */

#define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL_TAG 0x0D

/* 0 byte */

#define MAC_LTE_CE_MODE_TAG         0x0E

/* 1 byte containing mac_lte_ce_mode enum value */

#define MAC_LTE_NB_MODE_TAG         0x0F

/* 1 byte containing mac_lte_nb_mode enum value */

#define MAC_LTE_N_UL_RB_TAG         0x10

/* 1 byte containing the number of UL resource blocks: 6, 15, 25, 50, 75 or 100 */

#define MAC_LTE_SR_TAG              0x11

/* 2 bytes for the number of items, followed by that number of ueid, rnti (2 bytes each) */

/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU

continues until the end of the frame) */

#define MAC_LTE_PAYLOAD_TAG 0x01

在编码前需要再加上一个头MAC_LTE_START_STRING=” mac-lte”。这个是用来指示封装的什么数据。Wireshark可以解析的有MAC-LTERLC-LTEPDCP-LTE。其中MAC-LTE已经包含了RLC以及PDCP的数据。如果只是想解析RLC-LTE的数据。那么就指定RLC_LTE_START_STRING=” rlc-lte”。同理PDCP-LTE的数据,PDCP_LTE_START_STRING=” pdcp-lte”.

下面来看对应的代码:

参数的定义:

packet:LTE空口数据(RRC+PDCP+RLC+MAC)

direction:上行消息还是下行消息

rntiType:rnti的类型。

from scapy import *

def Write_info_to_pcap(direction,rntiType,packet):

    try:

        src_addr='192.168.0.1'

        dst_addr='192.168.0.1       
CRNTI_dict={b'\x00':b'\x00\x00',b'\x01':b'\xFF\xFE',b'\x02':b'\x05\x00',b'\x03':b'\x05\x00',b'\x04':b'\xFF\xFF'} MAC_LTE_START_STRING = b"mac-lte" radioType = b'\x01' DIRECTION = direction C_RNTI = rntiType MAC_LTE_RNTI_TAG = b'\x02' rnti = CRNTI_dict[rntiType] MAC_LTE_UEID_TAG = b'\x03' UEID = b'\x65\x00' MAC_LTE_SUBFRAME_TAG = b'\x04' subframe = b'\x01\x00' MAC_LTE_CRC_STATUS_TAG = b'\x07' crcStatus = b'\x01' MAC_LTE_NB_MODE_TAG = b'\x0F' nb_mode_value = b'\x01' MAC_LTE_PREDFINED_DATA_TAG=b'\x05' isPredefinedData=b'\x00' MAC_LTE_PAYLOAD_TAG = b'\x01' payload = MAC_LTE_START_STRING + radioType + DIRECTION + C_RNTI + MAC_LTE_RNTI_TAG \ + rnti + MAC_LTE_UEID_TAG + UEID + MAC_LTE_SUBFRAME_TAG + \ subframe + MAC_LTE_CRC_STATUS_TAG + crcStatus + \ MAC_LTE_NB_MODE_TAG + nb_mode_value + MAC_LTE_PREDFINED_DATA_TAG + \ isPredefinedData + MAC_LTE_PAYLOAD_TAG + packet pcap_packet = IP(tos=169, src=src_addr, dst=dst_addr, proto=17) / UDP(sport=61300, dport=10000) / payload wrpcap(“lte-mac.pcap”, pcap_packet, append=True) except BaseException as e: write_info_in_log(log_handle,"Write_info_to_pcap_error:"+str(e))

最后在wireshark对应的设置:

1编辑->首选项->Protocols->UDP-> Try heuristic sub-dissectors first

2分析->启用的协议->全部启用->搜索skype相关的配置去除->ok;设置“全部启用"主要是为了启用LTE的消息解析库,也可以只增加LTE消息解析的启用。

这样,wireshark上就可以解析到对应的空口数据了

python构造wireshark可以解析的LTE空口数据的更多相关文章

  1. LTE空口协议——是空口3GPP协议 不是网络IP协议

    [LTE基础知识]LTE空口协议分析 from:https://www.mscbsc.com/viewnews-102038.html控制面协议 控制面协议结构如下图所示. PDCP在网络侧终止于eN ...

  2. python爬虫之html解析Beautifulsoup和Xpath

    Beautiifulsoup Beautiful Soup 是一个HTML/XML的解析器,主要的功能也是如何解析和提取 HTML/XML 数据.BeautifulSoup 用来解析 HTML 比较简 ...

  3. Python命令行参数解析模块getopt使用实例

    Python命令行参数解析模块getopt使用实例 这篇文章主要介绍了Python命令行参数解析模块getopt使用实例,本文讲解了使用语法格式.短选项参数实例.长选项参数实例等内容,需要的朋友可以参 ...

  4. 第14.11节 Python中使用BeautifulSoup解析http报文:使用查找方法快速定位内容

    一. 引言 在<第14.10节 Python中使用BeautifulSoup解析http报文:html标签相关属性的访问>介绍了BeautifulSoup对象的主要属性,通过这些属性可以访 ...

  5. julia与python中的列表解析.jl

    julia与python中的列表解析.jl #=julia与python中的列表解析.jl 2016年3月16日 07:30:47 codegay julia是一门很年轻的科学计算语言 julia文档 ...

  6. python 解析XML python模块xml.dom解析xml实例代码

    分享下python中使用模块xml.dom解析xml文件的实例代码,学习下python解析xml文件的方法. 原文转自:http://www.jbxue.com/article/16587.html ...

  7. Python 迭代器和列表解析

    Python 迭代器和列表解析 1)迭代器 一种特殊的数据结构,以对象形式存在 >>> i1 = l1.__iter__() >>> i1 = iter(l1) 可 ...

  8. 使用Python解析豆瓣上Json格式数据

    现在的API接口多为xml或json,json解析更简洁相对xml来说 以豆瓣的API接口为例,解析返回的json数据: https://api.douban.com/v2/book/1220562 ...

  9. python常见排序算法解析

    python——常见排序算法解析   算法是程序员的灵魂. 下面的博文是我整理的感觉还不错的算法实现 原理的理解是最重要的,我会常回来看看,并坚持每天刷leetcode 本篇主要实现九(八)大排序算法 ...

随机推荐

  1. 激活modelsim se 10.4 时运行patch_dll.bat不能生成TXT

    问题描述: 激活modelsim时运行patch_dll.bat总是在DOS界面一闪而过,不能生成LICENSE.TXT 问题解决: 先取消文件 mgls64.dll 的只读属性(这句话在README ...

  2. eclipse + MinGW调试程序printf输出被buffer的问题

    比如说一个 1. int x = 1;2. printf("xxx")3. int y = 2;调试的时候,运行第二行,但是控制台没有输出.必须调试到整个程序都结束的时候才会把所有 ...

  3. linux $* 和$@ if [ ](字符串比较)

    $* 将命令后面的参数理解为一个类似为字符串,$@理解为多个单个的参数,类似理解成数据 $#参数总数 [root@mini0 test]# ./test4.sh jskd sj21 Using the ...

  4. window安装mysql

    window安装mysql 1. 官网下载mysql zip安装包,然后解压到你想安装的目录,假设解压的目录是P:\mysql 解压完的目录:bin docs include lib share CO ...

  5. Call to a member function cellExists() on a non-object /phpexcel/Classes/PHPExcel/Calculation.php on line 3241

    PHP Fatal error: Call to a member function cellExists() on a non-object in /home/edata/eframework/we ...

  6. Oracle基础学习登陆SQLPLUS(一)

    SQLPLUS是ORACLE公司开发的非常简洁的管理工具,SQLPLUS是最好的,最核心的ORACLE管理工具.SQLPLUS简洁而高效,舍弃浮华,反璞归真.使用sqlplus,进入sqlplus并进 ...

  7. java String去除两端的空格和空字符

    java中String有个trim()能够去掉一个字符串的前后空格.但是trim()只能去掉字符串中前后的半角空格,而无法去掉全角空格.去掉全角空格需要在trim()方法的基础上加上一些判断.Stri ...

  8. Oracle数据迁移expdp/impdp

    Oracle数据迁移expdp/impdp目的:指导项目侧自行进行简单的数据泵迁移工作. 本文实验环境:Oracle 11.2.0.4,利用数据库自带的scott示例用户进行试验测试. 1.首先需要创 ...

  9. day10上节内容补充和初始函数

    1.上节内容补充 文件的删除和修改: #文件的删除和修改 #文件中全部都要修改 # with open('歌词',encoding='utf-8') as f1,open('歌词.bak','w',e ...

  10. LeetCode具体分析 :: Recover Binary Search Tree [Tree]

    Recover the tree without changing its structure. Note: A solution using O(n) space is pretty straigh ...