can-utils
can-utils provides Linux SocketCAN tools for transmitting, receiving, logging and observing bus load. Use the SocketCAN Command Generator to select options and copy commands.
Installing can-utils Tools
On Debian / Ubuntu, install the distribution packages:
sudo apt install can-utils iproute2Follow the configuration guide to configure and bring up the interface first. Replace can0 below with your actual interface. CAN FD requires support from the device, driver and interface configuration.
Common Debugging Tools
| Tool | Purpose |
|---|---|
| cansend | Send one frame |
| cangen | Send frames with a configured gap and count |
| candump | Receive, filter and log frames |
| canbusload | Calculate load from received frames |
| cansniffer | Observe changes in frame data |
Frame Transmission: cansend
Select cansend options and copy the command with the SocketCAN Command Generator.
# Standard ID, four payload bytes
cansend can0 123#11223344
# Extended ID: eight hexadecimal digits, without an X prefix
cansend can0 12345678#55667788
# A small extended ID still needs eight digits
cansend can0 00000123#11223344
# Remote frame requesting eight bytes, with no payload
cansend can0 123#R8Standard IDs range from 000 to 7FF; extended IDs from 00000000 to 1FFFFFFF. Classic CAN carries 0–8 data bytes. cansend sends only one frame; use cangen for repeated transmission.
CAN FD frames
# CAN FD without BRS: the 0 after ## is a flag
cansend can0 123##0112233445566778899AABBCC
# CAN FD with BRS: the 1 after ## is a flag
cansend can0 123##1112233445566778899AABBCCBoth examples carry 12 bytes: 11 22 33 44 55 66 77 88 99 AA BB CC. The first hexadecimal character after ## is a flag, not payload. CAN FD has no remote frames. Valid wire lengths are 0–8, 12, 16, 20, 24, 32, 48 and 64 bytes. BRS uses the interface’s configured data bit rate.
Frame Listening: candump
Select candump options and copy the command with the SocketCAN Command Generator.
candump -x can0
candump -x can0 can1
candump -c -x anyany receives from all CAN interfaces. -x shows RX/TX and CAN FD BRS/ESI information. The number in square brackets is the payload byte count, not the raw FD DLC. Press Ctrl+C to stop.
Filters
# Exactly match standard ID 0x123, data frames only
candump can0,123:C00007FF
# Match either standard ID
candump can0,123:C00007FF,456:C00007FF
# Standard data frames with IDs 0x120–0x12F
candump can0,120:C00007F0
# Exclude data frames with standard ID 0x123, retaining other frames
candump can0,123~C00007FF
# Exclude both IDs: j combines the inverted filters with AND
candump can0,123~C00007FF,456~C00007FF,j
# Exactly match an extended ID, data frames only
candump can0,12345678:DFFFFFFFUse ID:mask for inclusion and ID~mask for exclusion. Mask bits set to 1 are compared. C00007FF also checks standard format and non-RTR; DFFFFFFF checks extended format and non-RTR. A filter such as 123:7FF can also match remote frames and extended IDs sharing those lower 11 bits.
Display options
| Option | Meaning |
|---|---|
-t a | Absolute timestamp |
-t A | Absolute timestamp with date |
-t z | Time relative to the first frame |
-t d | Time since the previous frame |
-a | Additional ASCII display |
-H | Hardware timestamps, requiring device and driver support |
-x | Direction and FD flags |
candump -t z -a -x can0Logging
# Automatically named log; frame display is disabled by default
candump -l can0
# Named log in replayable format
candump -f 'capture.log' can0
# Display and log; -s 0 after -f restores display output
candump -t a -x -f 'capture.log' -s 0 can0
# Write replayable log format to standard output
candump -L can0
# Record for a total of 60 seconds (requires the timeout command)
timeout 60 candump -f 'capture.log' can0An existing named log is overwritten; the parent directory must exist. candump can0 > file.txt saves terminal text. For replay, use the log format produced by -f, -l or -L.
Advanced options
# Exit after 1000 received frames
candump -n 1000 can0
# Request a 1 MiB receive buffer; system limits apply
candump -r 1048576 can0
# Exit after five seconds without frames, not after five seconds in total
candump -T 5000 can0
# Receive regular frames and all error classes; decode errors for display
candump -e can0,0:0,#1FFFFFFF
# Receive only error frames
candump -e can0,0~0,#1FFFFFFF
# Report socket receive drops
candump -d can0-e formats error frames for reading; #error_mask subscribes to them. -n limits the count; -r sets the receive buffer. -s needs a level, such as -s 2 for silent operation.
Interactive Monitoring: cansniffer
Select cansniffer options and copy the command with the SocketCAN Command Generator.
cansniffer -c can0Watch data changes grouped by ID. Use -f 1 for CAN FD, -f 0 for Classic CAN or -f 2 for automatic detection. Refresh, hold and hide timers take units of 10 ms, so -l 20 means 200 ms. While the tool is running, type +123 or -123 and press Enter to show or hide standard ID 0x123. Official options and keys.
Log replay: canplayer
Select canplayer options and copy the command with the SocketCAN Command Generator.
Record a log with candump -f capture.log can0. After recording, replay frames logged on can0 to an active vcan0 interface:
canplayer -I 'capture.log' vcan0=can0The mapping is transmit-interface=log-interface. With mappings, only mapped log interfaces are replayed. Without mappings, the tool sends on the interfaces named in the log. By default it replays once using the recorded timestamps. Use -l for the replay count, -n for a frame limit or -i to step through frames with Enter. Official options.
Bidirectional communication test: canfdtest
Select canfdtest options and copy the command with the SocketCAN Command Generator.
Connect both interfaces to the same test bus and configure matching bit rates. For Classic CAN, run the first command on the responder, then the second on the test host:
canfdtest -i 077 -o 078 -s 8 -x can1
canfdtest -i 077 -o 078 -s 8 -x -g -l 100 -f 50 can0The test host sends requests and checks responses. For CAN FD, add -d on both ends. For BRS, add -b on both ends and use matching data bit rates. Press Ctrl+C to stop the responder after testing. Official options.
Find these three tools under “More commands” in the SocketCAN Command Generator.
Bus Load Monitoring: canbusload
Select canbusload options and copy the command with the SocketCAN Command Generator.
# Classic CAN at 500 kbit/s
canbusload -r -t -b -c can0@500000
# CAN FD: nominal 500 kbit/s, data 2 Mbit/s
canbusload -r -t -b -c can0@500000,2000000
# Multiple interfaces with independent bit rates
canbusload -r -t -b -c can0@500000,2000000 can1@1000000Use interface@nominal_bitrate[,data_bitrate], with rates in bit/s. These rates are used only for calculation and do not configure the interfaces.
| Option | Meaning |
|---|---|
-r | Redraw in place |
-t | Show current time |
-b | Show bars |
-c | Color output |
Neither -e nor -i | Worst-case stuffing estimate |
-e | Bit-by-bit stuffing calculation for Classic CAN |
-i | Ignore stuffing |
The default estimate can exceed 100%, and dropped frames affect results. Use estimation for CAN FD; do not use -e for FD traffic. -s enables statistics and -v enables visualization in v2025.01; consult canbusload -h on your system.
CAN Frame Generation Tool: cangen
Select cangen options and copy the command with the SocketCAN Command Generator.
# Fixed ID and data, 10 ms gap, 100 frames
cangen -g 10 -I 123 -L 8 -D 1122334455667788 -n 100 can0
# Extended ID, fixed eight-byte length, incrementing data
cangen -e -g 100 -I 12345678 -L 8 -D i -n 100 can0
# CAN FD with BRS, fixed 12-byte payload, 100 frames
cangen -f -b -g 100 -I 123 -L 12 -D 112233445566778899AABBCC -n 100 can0
# Random ID, length and data, 100 frames
cangen -g 100 -I r -L r -D r -n 100 can0-I, -L and -D control ID, length and data. They accept fixed values, i (increment) and r (random). IDs and fixed payloads are hexadecimal. A fixed -L value is a decimal byte count: use -L 64 for 64 FD bytes, not DLC 15.
-n sets the count; omitting it sends continuously until Ctrl+C. -g is a gap in milliseconds, affected by scheduling and bus arbitration. -g 0 sends as fast as possible and increases bus load. Use -p 10 to wait for a writable send queue with a 10 ms timeout. -v prints sent frames.
More tools
ISO-TP tools include isotpsend, isotprecv and isotpdump. Consult the installed version’s help for options.
References: can-utils upstream project, Linux SocketCAN documentation.
Option reference and official help
Expand advanced options in the command generator for the controls below. Options refer to can-utils v2025.01; use each command’s -h for your installed version.
| Tool | Official help | Additional options |
|---|---|---|
cansend | Frame syntax | ESI and BRS use flag bits 2 and 1; eight-byte Classic frames accept raw DLC suffixes _9–_F |
candump | Options | -i binary, -S byte swap, -D stay running after interface down, -8 raw DLC; repeated -c changes coloring scope |
cangen | Options and generation modes | -I e/o random even/odd IDs, lowercase x random nibbles in -D, -c burst size, -P priority, -i ignore ENOBUFS, -x disable local loopback |
canbusload | Options | -s statistics (press r to reset), -v visualization, any@rate to monitor all interfaces |
# CAN FD, BRS + ESI, eight data bytes
cansend vcan0 123##31122334455667788
# Random even ID and second byte; bursts of four, 100 frames total
cangen -I e -L 8 -D 11xx334455667788 -c 4 -g 100 -n 100 can0
# Keep running after interface down, with binary data and raw DLC
candump -D -i -8 can0
# One calculation rate for all channels, statistics and visualization
canbusload -r -s -v any@500000Physical controllers normally determine ESI themselves; raw DLC needs CC_LEN8_DLC support. Do not combine candump -L with binary, ASCII or byte-swap display formats. cangen -a uses absolute time gaps; -t uses SO_TXTIME and needs a suitable queueing discipline, driver and privileges. In v2025.01, --start uses CLOCK_TAI nanoseconds, and --mark sets the SO_TXTIME socket mark. See official help for CAN XL and random mixed-frame mode -m.