the-tcpdump-group / tcpdump

the TCPdump network dissector
https://www.tcpdump.org/
Other
2.67k stars 838 forks source link

Can tcpdump be used as a serial port debugger? #895

Closed hongyi-zhao closed 3 years ago

hongyi-zhao commented 3 years ago

I try to debug a driverless vehicle chassis with its CAN interface connected to a computer via an RS-232 to USB converter. Can tcpdump be used as a serial port debugger for this scenario?

Regards, HY

gvanem commented 3 years ago

How about a RS-232 to EtherNet converter like these; from Perle or on eBay.

hongyi-zhao commented 3 years ago

The connection method I mentioned above is suggested by the chassis vendor. OTOH, I don't have the device you told here.

guyharris commented 3 years ago

There are two issues here:

  1. Using tcpdump to capture the traffic.
  2. Using tcpdump to parse the captured traffic.

Currently, tcpdump can't do the first of those except with an RS-232 to Ethernet converter. Changing that would need support in libpcap, with a libpcap module that can read from the converter.

Changing the latter would require tcpdump dissector support for whatever formats are produced by the converters in question. I doubt that what CAN support is in tcpdump can handle the various forms of RS-232 to Ethernet supported by the converters, so that would require tcpdump changes.

What RS-232 to USB converter are you using?

hongyi-zhao commented 3 years ago

Changing the latter would require tcpdump dissector support for whatever formats are produced by the converters in question. I doubt that what CAN support is in tcpdump can handle the various forms of RS-232 to Ethernet supported by the converters, so that would require tcpdump changes.

It seems wireshark can do this job. See the following for more info:

https://wiki.wireshark.org/CaptureSetup/USB https://www.wireshark.org/docs/dfref/u/usb.html

What RS-232 to USB converter are you using?

IMO, it's only a converter. Are there different kinds of such converters?

guyharris commented 3 years ago

It seems wireshark can do this job.

What Wireshark can do is capture raw USB traffic and dissect it. How useful that would be for dissecting USB-to-serial traffic is another matter - there does not appear to be any code path in Wireshark to hand the data on USB to any CAN dissector.

Are there different kinds of such converters?

To quote the Wikipedia "USB adapter" page:

For the computer to be able to detect and process the data signals drivers must be installed on the computer. Some chip models have drivers installed by default, including FTDI, while drivers for other chip models must be manually installed (e.g. for Windows and MacOS, WCH CH340, Silicon Labs 210x.

The requirement for a driver seems to indicate that not all adapters use the same protocol over USB to encapsulate serial data.

gvanem commented 3 years ago

... not all adapters use the same protocol over USB to encapsulate serial data.

Some converters (like the one from eBay above) uses MQTT which should be simple to decode.