[关闭]
@natsumi 2015-03-25T00:12:21.000000Z 字数 3897 阅读 3074

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,有三种方式:

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


2. UDP封装方式

2.1 修改设置

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

2.2 编译运行

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

  1. //#include "../wireshark/epan/dissectors/packet-mac-lte.h"
  2. /* radioType */
  3. #define FDD_RADIO 1
  4. #define TDD_RADIO 2
  5. /* Direction */
  6. #define DIRECTION_UPLINK 0
  7. #define DIRECTION_DOWNLINK 1
  8. /* rntiType */
  9. #define NO_RNTI 0
  10. #define P_RNTI 1
  11. #define RA_RNTI 2
  12. #define C_RNTI 3
  13. #define SI_RNTI 4
  14. #define SPS_RNTI 5
  15. #define M_RNTI 6
  16. /* Signature. Rather than try to define a port for this, or make the
  17. port number a preference, frames will start with this string (with no
  18. terminating NULL */
  19. #define MAC_LTE_START_STRING "mac-lte"
  20. /* Fixed fields. This is followed by the following 3 mandatory fields:
  21. - radioType (1 byte)
  22. - direction (1 byte)
  23. - rntiType (1 byte)
  24. (where the allowed values are defined above */
  25. /* Optional fields. Attaching this info to frames will allow you
  26. to show you display/filter/plot/add-custom-columns on these fields, so should
  27. be added if available.
  28. The format is to have the tag, followed by the value (there is no length field,
  29. it's implicit from the tag) */
  30. #define MAC_LTE_RNTI_TAG 0x02
  31. /* 2 bytes, network order */
  32. #define MAC_LTE_UEID_TAG 0x03
  33. /* 2 bytes, network order */
  34. #define MAC_LTE_FRAME_SUBFRAME_TAG 0x04
  35. /* 2 bytes, network order, SFN is stored in 12 MSB and SF in 4 LSB */
  36. #define MAC_LTE_PREDEFINED_DATA_TAG 0x05
  37. /* 1 byte */
  38. #define MAC_LTE_RETX_TAG 0x06
  39. /* 1 byte */
  40. #define MAC_LTE_CRC_STATUS_TAG 0x07
  41. /* 1 byte */
  42. #define MAC_LTE_EXT_BSR_SIZES_TAG 0x08
  43. /* 0 byte */
  44. #define MAC_LTE_SEND_PREAMBLE_TAG 0x09
  45. /* 2 bytes, RAPID value (1 byte) followed by RACH attempt number (1 byte) */
  46. #define MAC_LTE_CARRIER_ID_TAG 0x0A
  47. /* 1 byte */
  48. #define MAC_LTE_PHY_TAG 0x0B
  49. /* variable length, length (1 byte) then depending on direction
  50. in UL: modulation type (1 byte), TBS index (1 byte), RB length (1 byte),
  51. RB start (1 byte), HARQ id (1 byte), NDI (1 byte)
  52. in DL: DCI format (1 byte), resource allocation type (1 byte), aggregation level (1 byte),
  53. MCS index (1 byte), redundancy version (1 byte), resource block length (1 byte),
  54. HARQ id (1 byte), NDI (1 byte), TB (1 byte), DL reTx (1 byte) */
  55. #define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL 0x0C
  56. /* 0 byte */
  57. #define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL 0x0D
  58. /* 0 byte */
  59. /* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU
  60. continues until the end of the frame) */
  61. #define MAC_LTE_PAYLOAD_TAG 0x01

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
此处输入图片的描述
点击edit,然后按照下图添加一个条目~
此处输入图片的描述
这样就OK啦~

3.2 编译运行

还是先看例子mac_pcap_sample_code.c~嘛~下面图中这几句话看得我也是醉了。。和我一样把定义从packet-mac-lte.h中粘贴出来~
此处输入图片的描述
在31行左右的位置开始,以注释的方式给出了一个makefile,直接按照这个样式建一个makefile用着就好了

  1. run: mac_pcap_sample_code
  2. @ ./$?
  3. mac_pcap_sample_code: mac_pcap_sample_code.c
  4. gcc -Wall $? -o $@
  5. clean:
  6. rm -f mac_pcap_sample_code test1.pcap

终端输入命令make即可编译运行,运行后回生成test1.pcap
用wireshark打开test1.pcap
此处输入图片的描述

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注