helium / sx1302_hal

SX1302 Hardware Abstraction Layer and Tools (packet forwarder...)
Other
38 stars 45 forks source link

Add ability to produce WireShark-compatible PCAP packet logging. #38

Open ke6jjj opened 1 year ago

ke6jjj commented 1 year ago

Summary

This PR adds the ability to log received LoRa packets to "PCAP" file in a format that has been standardized by the WireShark network analysis project.

Usage

PCAP logging can be enabled via the JSON configuration file. When enabled, PCAP logging can be reset via SIGHUP to allow for log rotation without restarting the packet forwarder.

JSON path Value
gateway_conf.pcap_dump_path Pathname of the PCAP file to create (or append to) when logging packets

Example config

With this patch, PCAP logging is disabled by default, but it can be enabled by adding a pcap_dump_path item to gateway_conf item the global JSON configuration. For example:

{
    ...
    "gateway_conf": {
        ...
        "pcap_dump_path": "/var/tmp/lora.pcap"
    }
}

To rotate the PCAP file (for example, once a day), move the current PCAP output to a new location (say, /var/tmp/lora-YYYY-MM-DD.pcap) then deliver a SIGHUP (signal 1) signal to the packet forwarder. It will open and initialize a new /var/tmp/lora.pcap file on receipt.