Wireshark解析MAC-LTE

标签: Wireshark LTE


1. 写在前面

PDCP上面是RRC,http://wiki.wireshark.org/LTE%20RRC 这里说,

if you are using Wireshark to decode MAC-LTE, RLC-LTE, PDCP-LTE then the RRC dissector will be called appropriately, if enabled by preference settings.

PDCP再往底层就该是RLC和MAC了~
和PDCP一样,RLC也可以用UDP封装,也给出了例子。
所以先放一放RLC,先看看MAC层吧
除了DCT2000,有三种方式:

This shares the same framing format as the UDP format described above. This (BSD-licensed) program gives an example of how you might write MAC-LTE frames directly in a file of this format. Currently, this does not have its own registered DLT, so if (as the same program does) you use DLT 147 you will need to edit the preferences of the DLT_USER dissector (add an entry with DLT=147, Payload Protocol=mac-lte-framed) OR

  • 第三种大概是私人定制的感觉,还没研究明白

your own framing protocol. The functions get_mac_lte_proto_data() and set_mac_lte_proto_data() are available for querying and setting the necessary context information associated with a frame.

下面对前两种方式的做一些尝试~


2. UDP封装方式

2.1 修改设置

将Preferences里面的Try Heuristic LTE-MAC framing over UDP这一行勾上

设置
设置

2.2 编译运行

过程类似Wireshark解析PDCP-LTE,还是用比较笨的方法解决编译中的问题!

  • 去掉#include "../wireshark/epan/dissectors/packet-mac-lte.h"
  • gcc -g -o test pdcp_lte_logger.c 编译,根据报错信息,加入了如下代码段
//#include "../wireshark/epan/dissectors/packet-mac-lte.h"
/* radioType */
#define FDD_RADIO 1
#define TDD_RADIO 2

/* Direction */
#define DIRECTION_UPLINK   0
#define DIRECTION_DOWNLINK 1

/* rntiType */
#define NO_RNTI  0
#define P_RNTI   1
#define RA_RNTI  2
#define C_RNTI   3
#define SI_RNTI  4
#define SPS_RNTI 5
#define M_RNTI   6

/* Signature.  Rather than try to define a port for this, or make the
   port number a preference, frames will start with this string (with no
   terminating NULL */
#define MAC_LTE_START_STRING "mac-lte"

/* Fixed fields.  This is followed by the following 3 mandatory fields:
   - radioType (1 byte)
   - direction (1 byte)
   - rntiType (1 byte)
   (where the allowed values are defined above */

/* Optional fields. Attaching this info to frames will allow you
   to show you display/filter/plot/add-custom-columns on these fields, so should
   be added if available.
   The format is to have the tag, followed by the value (there is no length field,
   it's implicit from the 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  0x0C
/* 0 byte */

#define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL 0x0D
/* 0 byte */

/* 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_logger.c里的
    MAC_LTE_SUBFRAME_TAG改为MAC_LTE_FRAME_SUBFRAME_TAG
    MAC_LTE_PREDFINED_DATA_TAG改为MAC_LTE_PREDEFINED_DATA_TAG
  • 再次编译通过
  • ./test 127.0.0.1 10000运行,这里127.0.0.1和10000分别是UDP报文的目的IP和PORT,可以根据需求设定。
    运行截图
    运行截图

3. 说不清的方式——the compact format decoded by the mac-lte-framed dissector.

3.1 设置

edit the preferences of the DLT_USER dissector (add an entry with DLT=147, Payload Protocol=mac-lte-framed)

工具栏edit-->prefrences-->protocol-->DLT_USER


DLT_USER配置
DLT_USER配置

点击edit,然后按照下图添加一个条目~


DLT_USER配置
DLT_USER配置

这样就OK啦~

3.2 编译运行

还是先看例子mac_pcap_sample_code.c~嘛~下面图中这几句话看得我也是醉了。。和我一样把定义从packet-mac-lte.h中粘贴出来~

- -|||
- -|||

在31行左右的位置开始,以注释的方式给出了一个makefile,直接按照这个样式建一个makefile用着就好了

run: mac_pcap_sample_code
    @ ./$?

mac_pcap_sample_code: mac_pcap_sample_code.c
    gcc -Wall $? -o $@

clean:
    rm -f mac_pcap_sample_code test1.pcap

终端输入命令make即可编译运行,运行后回生成test1.pcap
用wireshark打开test1.pcap

测试成果
测试成果

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,319评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,801评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,567评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,156评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,019评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,090评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,500评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,192评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,474评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,566评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,338评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,212评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,572评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,890评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,169评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,478评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,661评论 2 335

推荐阅读更多精彩内容

  • 3.1. 介绍 现在,您已经安装了Wireshark并有可能热衷于开始捕捉您的第一个数据包。在接下来的章节中,我们...
    wwyyzz阅读 1,363评论 0 1
  • 老师说,做一点儿就得写一点儿,嗯。就从比较高层的PDCP做起吧~ 1. 基本信息get√ 读了一篇叫做“LTE协议...
    natsumi阅读 4,409评论 0 1
  • 我喜欢漂泊 流浪 于千万年的荒漠中 遇见那个 闪耀着金色光泽的童话 古铜色彩的河州 身后 寒风冷雨 极目 凄雾...
    诗歌刘振扬阅读 324评论 0 2
  • 问题 想要将一个目录下所有文件中的yyyymmdd-hh24:mi:ss替换成yyyy-mm-dd+hh24:mi...
    是阿离阅读 733评论 0 0
  • 有时候,突然有那么一阵子特别想爸妈,不一定是自己最难受或者最需要别人关心的时候,总会让思维躲在一个安静的角落...
    俞潜沉阅读 1,236评论 4 4