How can I sniff packets communicated through a serial port on Linux?
There are a few options:
sersniff is a simple program to tunnel/sniff between 2 serial ports.
Serial to Network Proxy (ser2net) provides a way for a user to connect from a network connection to a serial port.
SerialSpy acts as a serial pass-through device. It listens for incoming data on two serial ports and forwards it so the devices act as if they are directly connected. It also logs the data as it moves through the ports.
sercd is an RFC 2217-compliant serial port redirector. It lets you share a serial port through a network. It is based on sredird. The RFC2217 protocol is an extension to telnet and allows changing communication port parameters.
SerLooK is a KDE application for inspecting data going over serial lines. It can work as a binary terminal that sends and receives data through a defined port (Point to Point mode) and displays them on separate views. Each view can be configured to display data in hexadecimal, decimal, octal, binary, and raw ASCII. It is also possible to perform I/O through terminal emulation views and define a secondary port and monitor the traffic between two external hosts using a "Y" cable (Snooper mode).
nullmodem creates a virtual network of pseudo-terminals. It can be used as an adapter to connect two programs that normally need serial interface cards.
ttywatch monitors, logs, and multiplexes terminal I/O. It has full log rotation built in, and can use telnet as well as local TTY ports.
Serial line sniffer (slsnif) is a serial port logging utility. It listens to the specified serial port and logs all data going through this port in both directions.
I tried interceptty, and was successful in using it. First I ran it on the port of interest:
Then I connected the program-under-test to the pseudo-terminal
/dev/pts/5 that interceptty created.
I tried to use slsnif, but I found that I got an error:
Failed to open a pty: No such file or directory
This mailing list item indicates that slsnif only supports the "legacy" pseudo-terminals (
/dev/ttyp0 etc) which are probably not used on current Linux kernels.