nRF Sniffer for 802.15.4 v0.7.2

Integrating nRF Sniffer Python module into a script

In your script, include the nRF Sniffer Python module and specify the parameters for the API function that starts the capture process. These mandatory and optional parameters define what packets are saved to the pcap file.

To integrate the nRF Sniffer Python module into your script:

  1. Open your custom Python script and include the nRF Sniffer module:
    from nrf802154_sniffer import Nrf802154Sniffer
  2. Check the name of the port to which you connected the nRF Sniffer device. The name is used to set the dev parameter.
  3. Check the number of the channel on which you want to listen for packets. The number is used to set the channel parameter.
  4. At the point in your script where you want to start the capture process, add the following lines to start the capture. Use the parameter values from the previous steps. For example:
    sniffer = Nrf802154Sniffer()
    sniffer.extcap_capture(fifo="file.pcap", dev="/dev/ttyACM3", channel=26)
    In this code, the nRF Sniffer script captures packets from the sniffer on port /dev/ttyACM3 on the channel 26 and saves the results to the file.pcap file.
    See the following table for the description of all parameters of the extcap_capture() function and their possible values.
    Parameter Type Description
    file Mandatory Defines the name of the pcap file to which the captured packets will be saved. The parameter value can also include the path to the file directory if you want to save it in a custom directory. By default, the script saves the file in the working directory.
    dev Mandatory Defines the serial port used to communicate with the nRF Sniffer hardware.
    channel Mandatory Specifies the 802.15.4 radio channel number on which the nRF Sniffer listens for packets.
    metadata Optional Specifies the metadata type for the packet capture. It can have one of the following values:
    • None - No metadata is selected for capture. This is the default setting.
    • "ieee802154-tap" - Selects the IEEE 802.15.4 TAP metadata type for capture. Use this parameter if you are using Wireshark v3.0 or later.
    • "user" - Selects the custom Lua dissector metadata type for capture. Use this parameter if you are using a Wireshark version earlier than v3.0. Make sure to install the OOB metadata Lua dissector plugin in Wireshark before inspecting the captured data if you use this metadata type.
    control_in Unused Specifies a file that Wireshark is going to use to control the capture plugin during run time. Currently unused.
    control_out Unused Specifies a file that Wireshark is going to use to control the capture plugin during run time. Currently unused.
  5. At the point in your script where you want to stop the capture process, add the following lines:
    sniffer.stop_sig_handler()
    Note: You can add the lines that start and stop the script multiple times in your script. Make sure to stop the capture before you start a new capture process.
When you run the script with the nRF Sniffer hardware, the nRF Sniffer captures packets and saves the results into the pcap file. Open this file in Wireshark to inspect captured data.