[root@ArchDev ~]# lsusb
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
说明FT232模块已经被正确识别。dmesg也能看到类似的输出
[ 3939.433684] usb 1-1: Detected FT232RL
[ 3939.433691] usb 1-1: Number of endpoints 2
[ 3939.433697] usb 1-1: Endpoint 1 MaxPacketSize 64
[ 3939.433703] usb 1-1: Endpoint 2 MaxPacketSize 64
[ 3939.433708] usb 1-1: Setting MaxPacketSize 64
[ 3939.442346] usb 1-1: FTDI USB Serial Device converter now attached to [B]ttyUSB0[/B]
CP2102模块的话,输出稍有不同:
# lsusb
Bus 001 Device 003: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
# dmesg
[ 3421.303602] cp210x 1-1:1.0: cp210x converter detected
[ 3421.554407] usb 1-1: reset full-speed USB device number 3 using uhci_hcd
[ 3421.703370] usb 1-1: cp210x converter now attached to ttyUSB0
got 1 bytes from modem, data looks like: 1b .
got 1 bytes from modem, data looks like: f6 .
got 1 bytes from modem, data looks like: 02 .
got 1 bytes from modem, data looks like: 00 .
got 1 bytes from modem, data looks like: 41 A
got 1 bytes from modem, data looks like: 03 .
got 1 bytes from modem, data looks like: 42 B
Received DOWNLOAD ACK from phone, your code is running now!
battery_compal_e88_init: starting up
OSMOCOM Layer 1 (revision osmocon_v0.0.0-1351-g074c78a-modified)
-O --only-scan Do a scan and show available ARFCNs, no data logging
[B]./cell_log --only-scan[/B]
...
<000e> cell_log.c:248 Cell: [COLOR="red"]ARFCN=56[/COLOR] PWR=-67dB [COLOR="Blue"]MCC=460 MNC=00[/COLOR] (China, China Mobile)
例如这里选取信号最强的ARFCN=56 (China Mobile),有了这个就可以开始抓取Common Control Channel (CCCH)了:
GSMTAP Header之后是 Link Access Procedure, Channel Dm,即LAPDm。参考TS 04.06有3个关键字段: Address Field,Control Field,Length Field
Address Field除了上面说的SAPI外都可以不关注。 Control Field比较关键,里面记录了该LAPDm的分片信息。Frame type: Information frame说明当前是I帧(I frame),其余bit为N(S)和N(R)。Send sequence number N(S)标记该分片的顺序,从0开始递增。看Wireshark源码说实际有些N(S)可能不是从0开始的,这里组包就不判断N(S)是否为0直接按顺序附加。N(R)是Receive sequence number,看文档上I帧传输时N(R)的状态没看明白,直接默认同时间只有1个下行短信了,这样收到的N(R)基本是一样的(事实上大部分时候都是如此) Length Field除了长度信息,还有 More segments 标记,直到这个位为0才表示接收完一个完整的SMS报文
static void
[B]dissect_lapdm[/B](tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
... ...
/* Rely on caller to provide a way to group fragments */
fragment_id = (pinfo->circuit_id << 4) | (sapi << 1) | pinfo->p2p_dir;
/* This doesn't seem the best way of doing it as doesn't
take N(S) into account, but N(S) isn't always 0 for
the first fragment!
*/
fd_m = [B]fragment_add_seq_next[/B] (&lapdm_reassembly_table, payload, 0,
pinfo,
fragment_id, /* guint32 ID for fragments belonging together */
NULL,
/*n_s guint32 fragment sequence number */
len, /* guint32 fragment length */
m); /* More fragments? */
... ...
}