# Running the Sniffer

## Connecting Board and PC

Most of the current transceiver boards are equipped with a USB connector. If the USB cord is plugged into the PC, the OS will load a driver and assign a virtual serial port. Before starting the sniffer, the name of the serial port needs to be determined.

Linux:

The device names are usually:

- `/dev/ttyS[0-9]` for regular RS232 serial ports,
- `/dev/ttyUSB[0-9]` for FTDI and CP210x based boards and
- `/dev/ttyACM[0-9]` for CDC devices like the Raven RZUSB stick.

The assigned name of a serial port can be found with the command `dmesg`.

      $ dmesg | grep tty
      usb 4-1: FTDI USB Serial Device converter now attached to ttyUSB0
      cdc_acm 2-3.1:1.0: ttyACM0: USB ACM device
      usb 2-3.3: cp2101 converter now attached to ttyUSB1

Windows

The name of the assigned COM port can be found with the Device Manager. A quick way to open this tool (see http://en.wikipedia.org/wiki/Device_Manager) is either to type `devmgmt.msc` in `cmd.exe` window or click: `Start -> Run -> devmgmt.msc -> OK`

## Running the Sniffer

Command Line Usage

The sniffer application is launched with the following command in Linux

     $ python script/sniffer.py -p /dev/ttyUSB0 | wireshark -ki -

or with this command in Windows:

     $ python script/sniffer.py -p COM1 | wireshark -ki -

All command line options of script are displayed with the command `python script/sniffer.py -h`. The following options are supported

        -p PORT:
            Serial port, the data rate is optionally seperated by ":", e.g. -p COM1:38400
        -c CHANNEL:
            Initial channel to be used.
        -r RATE:
            Initial data rate to be used.
        -h:
            Show help and exit.
        -V:
            Show version and exit.

After running this command from the command line, the sniffer control window and the wireshark window will appear on the screen.

Another method of running the sniffer tool is simply to collect the captured data in a logfile:

     $ python script/sniffer.py -p /dev/ttyUSB0 -c 26 > log.pcap

An option of storing the data in the background is using the Linux/Unix command `tee`:

     $ python script/sniffer.py -p /dev/ttyUSB0 -c 26 | tee log.pcap | wireshark -ki -

If just a terminal without an X-Windows is available, the tool `tshark` can be used as backend:

     $ python script/sniffer.py -p /dev/ttyUSB0 -c 26 | tshark -i -

The Lua dissector for the P2P protocoll, that is used, e.g. for the wireless UART, can be enabled with the following command line:

     $ python script/sniffer.py -p /dev/ttyUSB0 -c 26 | wireshark -Xlua_script:script/p2p.lua -ki -

GUI Usage

In the sniffer control window there are two the scroll lists: Channel (see option `-c`) and Rate (see option `-r`) this transceiver parameters can be canged interactively during a session. With the button Quit the GUI and the tool `sniffer.py` is closed, but wireshark remains open. A quick method to exit `sniffer.py` and `wireshark` is pressing "Ctrl-C" at the command line.

Wireshark and sniffer.py