老師說,做一點(diǎn)兒就得寫一點(diǎn)兒雏蛮,嗯。就從比較高層的PDCP做起吧~
1. 基本信息get√
- 讀了一篇叫做“LTE協(xié)議棧軟件分析測試方法”的文章(一搜即得)。啟發(fā):可以用以太網(wǎng)代替PHY層嘶朱,用wireshark來解析高層協(xié)議
“通過udpsocket編程來發(fā)送MAC層協(xié)議數(shù)據(jù)包,同時將RRC光酣、PD-CP疏遏、RLC、MAC層的協(xié)議數(shù)據(jù)包通過udp socket編程抄送至網(wǎng)絡(luò)封包捕獲程序”
- 再看wireshark關(guān)于PDCP的說明救军,http://wiki.wireshark.org/PDCP-LTE
- 只支持ROHC負(fù)載.
- 支持從RLC-LTE SDUs财异、DCT2000 log files、packet-pdcp-lte.h中定義的UDP格式中讀取PDCP框架唱遭。還給出了一個UDP封裝的例子戳寸,pdcp_lte_logger.c
- Preference Settings
- Show User-Plane uncompessed data as IP. Default is Off.
- Show unciphered Signalling-Plane data as RRC. Default if Off.
- Attempt to decode ROHC data. Default is Off.
- Try Heuristic LTE-PDCP over UDP framing. Default is Off.
- Which layer info to show in Info column. Default is RLC.
- PDCP UE security keys. A table of (UEId, RRCKey, UPKeys) entries.
- Attempt to decipher Signalling (RRC) SDUs. Default is Off.
Attempt to decipher User-plane (IP) SDUs. Default is Off.
- 其實(shí)看了http://blog.csdn.net/u011208220/article/details/38131789,就只改了"Try Heuristic LTE-PDCP over UDP framing"這一項(xiàng)拷泽,回頭可以勾上其他的在試試^^
2 pdcp_lte_logger.c編譯
- 由于已知這段代碼的作用是將PDCP封裝到UDP數(shù)據(jù)包發(fā)送給指定服務(wù)器疫鹊,就在掃了一眼代碼之后就馬上開始嘗試編譯啦袖瞻。
- 原代碼中有一句
#include "../wireshark/epan/dissectors/packet-pdcp-lte.h"
,我也很機(jī)智的把wireshark
目錄改成我的wireshark-1.99.2
- 但還是出了很多編譯錯誤比如“未知的proto_item類型”拆吆,主要是因?yàn)?code>pdcp_lte_logger.c包含了
packet-pdcp-lte.h
,而后者又包含了packet-rohc.h
聋迎。這兩個頭文件中都使用了“未知的”類型。這里所說的“未知”枣耀,我認(rèn)為應(yīng)該是相對于單獨(dú)編譯pdcp_lte_logger.c的情景下霉晕。
--------------------so,親測有效的蠢方法如下--------------------
- 去掉
#include "../wireshark/epan/dissectors/packet-pdcp-lte.h"
捞奕,但這時編譯會報(bào)錯牺堰,因?yàn)樯倭松厦嬲f的兩個頭文件,就有很多未定義的東西颅围,這時候看錯誤提示什么沒定義就去頭文件中找到粘貼到pdcp_lte_logger.c - 于是伟葫,就相當(dāng)于在pdcp_lte_logger.c中加入了如下代碼段,再
gcc -g -o test pdcp_lte_logger.c
編譯谷浅。
//#include "../wireshark-1.99.2/epan/dissectors/packet-pdcp-lte.h"
/* Direction */
#define DIRECTION_UPLINK 0
#define DIRECTION_DOWNLINK 1
/* 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 PDCP_LTE_START_STRING "pdcp-lte"
/* Fixed fields. This is followed by the following 3 mandatory fields:
- no_header_pdu (1 byte)
- plane (1 byte)
- rohc_compression ( byte)
(where the allowed values are defined above) */
/* Conditional field. This field is mandatory in case of User Plane PDCP PDU.
The format is to have the tag, followed by the value (there is no length field,
it's implicit from the tag).
The allowed values are defined above. */
#define PDCP_LTE_SEQNUM_LENGTH_TAG 0x02
/* 1 byte */
/* 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 PDCP_LTE_DIRECTION_TAG 0x03
/* 1 byte */
#define PDCP_LTE_LOG_CHAN_TYPE_TAG 0x04
/* 1 byte */
#define PDCP_LTE_BCCH_TRANSPORT_TYPE_TAG 0x05
/* 1 byte */
#define PDCP_LTE_ROHC_IP_VERSION_TAG 0x06
/* 2 bytes, network order */
#define PDCP_LTE_ROHC_CID_INC_INFO_TAG 0x07
/* 1 byte */
#define PDCP_LTE_ROHC_LARGE_CID_PRES_TAG 0x08
/* 1 byte */
#define PDCP_LTE_ROHC_MODE_TAG 0x09
/* 1 byte */
#define PDCP_LTE_ROHC_RND_TAG 0x0A
/* 1 byte */
#define PDCP_LTE_ROHC_UDP_CHECKSUM_PRES_TAG 0x0B
/* 1 byte */
#define PDCP_LTE_ROHC_PROFILE_TAG 0x0C
/* 2 bytes, network order */
#define PDCP_LTE_CHANNEL_ID_TAG 0x0D
/* 2 bytes, network order */
#define PDCP_LTE_UEID_TAG 0x0E
/* 2 bytes, network order */
/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU
continues until the end of the frame) */
#define PDCP_LTE_PAYLOAD_TAG 0x01
enum rohc_mode
{
MODE_NOT_SET = 0,
UNIDIRECTIONAL = 1,
OPTIMISTIC_BIDIRECTIONAL = 2,
RELIABLE_BIDIRECTIONAL = 3
};
enum pdcp_plane
{
SIGNALING_PLANE = 1,
USER_PLANE = 2
};
typedef enum LogicalChannelType
{
Channel_DCCH=1,
Channel_BCCH=2,
Channel_CCCH=3,
Channel_PCCH=4
} LogicalChannelType;
typedef enum
{
BCH_TRANSPORT=1,
DLSCH_TRANSPORT=2
} BCCHTransportType;
#define PDCP_SN_LENGTH_5_BITS 5
#define PDCP_SN_LENGTH_7_BITS 7
#define PDCP_SN_LENGTH_12_BITS 12
#define PDCP_SN_LENGTH_15_BITS 15
3. 運(yùn)行小有成果
./test 127.0.0.1 10000
運(yùn)行扒俯,這里127.0.0.1和10000分別是UDP報(bào)文的目的IP和PORT,可以根據(jù)需求設(shè)定一疯。
最后總算是出來了一些PDCP解析的樣子~
具體代碼過完年再研究吧~
記下這些東西不知不覺都已經(jīng)除夕了新年快樂