LoRa Gateway 笔记 3.1.3 帮助程序 util_pkt_logger 进行 LoRa 空口抓包

前言

以前小能手使用 SX1276 做过一个 LoRa抓包工具,最大的局限是不能抓多个频点的数据。而 LoRaGateway 的帮助程序 util_pkt_logger 就提供了这个现成的功能,使用 SX1301 可以同时监听至少8路信道。

本文在 Semtech AE 的帮助下,成功完成了对网关下行空口的监听,于是做个记录,可能会帮助到有需要的朋友。

小能手整理了 LoRa Gateway 的开发笔记系列,详细可点此查看

1 对 LoRaWAN 节点进行抓包

进入 \lora_gateway\util_pkt_logger 目录,直接 make clean all,即可完成编译操作。

在调整完 global_conf.json 的频点配置之后即可进行抓包,数据包会被写入到日志文件中。默认可抓取 LoRaWAN 节点的上行数据包。

pi@ttn-gateway:/opt/ttn-gateway/lora_gateway $ cd util_pkt_logger/
pi@ttn-gateway:/opt/ttn-gateway/lora_gateway/util_pkt_logger $ ./util_pkt_logger 
loragw_pkt_logger: INFO: found global configuration file global_conf.json, trying to parse it
loragw_pkt_logger: INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
loragw_pkt_logger: INFO: lorawan_public 1, clksrc 1
loragw_pkt_logger: INFO: radio 0 enabled (type SX1255), center frequency 500700000, RSSI offset -176.000000, tx enabled 0, tx_notch_freq 0
loragw_pkt_logger: INFO: radio 1 enabled (type SX1255), center frequency 501500000, RSSI offset -176.000000, tx enabled 0, tx_notch_freq 0
loragw_pkt_logger: INFO: LoRa multi-SF channel 0 enabled, radio 0 selected, IF -400000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 1 enabled, radio 0 selected, IF -200000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 2 enabled, radio 0 selected, IF 0 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 3 enabled, radio 0 selected, IF 200000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 4 enabled, radio 1 selected, IF -400000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 5 enabled, radio 1 selected, IF -200000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 6 enabled, radio 1 selected, IF 0 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 7 enabled, radio 1 selected, IF 200000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa standard channel 8 disabled
loragw_pkt_logger: INFO: FSK channel 8 disabled
loragw_pkt_logger: INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
loragw_pkt_logger: INFO: gateway MAC address is configured to AA555A0000000000
loragw_pkt_logger: INFO: found local configuration file local_conf.json, trying to parse it
loragw_pkt_logger: INFO: local_conf.json does not contain a JSON object named SX1301_conf
loragw_pkt_logger: INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
loragw_pkt_logger: INFO: gateway MAC address is configured to AA555A0000000101
loragw_pkt_logger: INFO: concentrator started, packet can now be received
loragw_pkt_logger: INFO: Now writing to log file pktlog_AA555A0000000101_20190513T092441Z.csv

2 监听其他 LoRa 网关的下行包

默认情况 util_pkt_logger 运行时 RX I/Q invert 是关闭的,我们要接收其他网关的数据包的就要打开它。

源文件为:\lora_gateway\libloragw\src\loragw_hal.c

void lgw_constant_adjust(void) {

    /* I/Q path setup */
    lgw_reg_w(LGW_MODEM_INVERT_IQ,0); /* default 1 */ 0-enable Rx I/Q invert
}

重新编译后,即可使用。

注意:既要编译 \lora_gateway\libloragw,也要编译 \lora_gateway\util_pkt_logger,以保证能使用到最新的库文件。

抓包日志如下:

pi@ttn-gateway:/opt/ttn-gateway/lora_gateway/util_pkt_logger $ tail -f pktlog_AA555A0000000101_20190513T094616Z.csv 
"gateway ID","node MAC","UTC timestamp","us count","frequency","RF chain","RX chain","status","size","modulation","bandwidth","datarate","coderate","RSSI","SNR","payload"
"AA555A0000000101","","2019-05-13 09:46:22.262Z",   8233788, 500500000,0, 1,"CRC_OK" , 12,"LORA",125000,"SF12"  ,"4/5",-130, +7.2,"60376200-02206701-93113387"
"AA555A0000000101","","2019-05-13 09:46:36.829Z",  22827267, 500500000,0, 1,"CRC_OK" , 43,"LORA",125000,"SF7"   ,"4/5",-133, +3.2,"60C3AA68-E0A00E02-009EA175-EA08A56F-E2BB4581-4AFD453A-17DCA68A-41C729D6-EBBC84A2-724BB81B-717740"
"AA555A0000000101","","2019-05-13 09:46:42.261Z",  28233732, 501500000,1, 6,"CRC_OK" , 12,"LORA",125000,"SF12"  ,"4/5",-133, +3.8,"60376200-02206901-16C1C4C6"
"AA555A0000000101","","2019-05-13 09:46:52.261Z",  38233700, 500900000,0, 3,"CRC_OK" , 12,"LORA",125000,"SF12"  ,"4/5",-125, +6.2,"60376200-02206A01-BE6B087E"
"AA555A0000000101","","2019-05-13 09:47:02.263Z",  48233676, 501700000,1, 7,"CRC_OK" , 12,"LORA",125000,"SF12"  ,"4/5",-136, +2.0,"60376200-02206B01-C7D12879"
"AA555A0000000101","","2019-05-13 09:47:12.263Z",  58234660, 501100000,1, 4,"CRC_OK" , 12,"LORA",125000,"SF12"  ,"4/5",-127, +4.0,"60376200-02206C01-A31BEA2E"

3 监听 未使能CRC 的数据包

void lgw_constant_adjust(void) {
    lgw_reg_w(LGW_ONLY_CRC_EN,0);
    lgw_reg_w(LGW_MBWSSF_ONLY_CRC_EN,0);
}

END


lora_pkt_fwd是一个LoRaWAN数据包转发程序,用于将LoRaWAN设备(如传感器或节点)的数据包转发到LoRa网关,并进一步传输到网络服务器。它处理物理层和数据链路层的通信,实现了数据包的接收和发送功能。 lora_pkt_fwd的主要功能包括: 1. 接收功能:lora_pkt_fwd负责接收来自LoRaWAN设备的数据包。它监听指定的频率和数据速率,等待设备发送数据。一旦接收到数据包,它将对其进行解码,并提取出有效负载数据。 2. 发送功能:lora_pkt_fwd可将解码后的数据包转发到已配置的LoRa网关。它通过与网关建立连接发送数据包,然后等待网关将数据包发送到网络服务器。通过此过程,它实现了从设备到网络服务器的数据传输。 3. 协议支持:lora_pkt_fwd支持多种LoRaWAN协议版本,如LoRaWAN 1.0.2和LoRaWAN 1.1。它能够根据所需的协议配置自身的行为,以便与所连接的设备和网络兼容。 4. 配置管理:lora_pkt_fwd提供了可编辑的配置文件,可以根据需要自定义参数。用户可以配置通信频率、数据速率、网络服务器地址和端口等信息。这使得它可以适应不同的LoRa网关和网络环境。 总而言之,lora_pkt_fwd是一个功能强大的LoRaWAN数据包转发程序,能够接收、解码和发送数据包,从设备到网络服务器进行可靠的数据传输。它提供了灵活的配置选项,以适应各种LoRaWAN协议和网络设置。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值