Workshop
Build your bench, and go further
Enough to move from reading to practice: a virtual CAN bus, the commands that matter, the vocabulary, and where to go next.
A CAN bench without a car
You don't need a vehicle to get started. Linux ships with SocketCAN; a virtual vcan interface behaves like a real bus, and the ICSim simulator provides a dashboard to drive.
sudo modprobe vcan sudo ip link add dev vcan0 type vcan sudo ip link set up vcan0
./icsim vcan0 # the simulated dashboard ./controls vcan0 # the controller that generates the traffic
Reproduce it for real
The virtual bench is enough to learn the method; copper makes it concrete. Four builds, from the simplest at fifteen euros to the most striking for a demo, all documented and reproducible.
| Build | Hardware | What it reproduces |
|---|---|---|
| Two-node bench | 2 Arduino or ESP32, 2 transceivers (MCP2515 or native TWAI), 2 resistors of 120 ohms | The heart of reversing: one node sends, the other listens. Sniff, diff, inject. |
| ESP32 bridge | 1 ESP32 with ESP32RET or CANMIM | Capture, replay and man-in-the-middle on a real bus, driven from the PC (SavvyCAN). |
| Raspberry Pi + CAN-HAT | 1 Raspberry Pi, 1 CAN hat (PiCAN, Waveshare) | The same candump / cansend as the Workshop, but on a physical can0 interface. |
| Real instrument cluster | A scrapyard cluster, a power supply, a terminated bus | The needles move for real when you forge the frames. The demo that sticks. |
- Wiring: CAN-H to CAN-H, CAN-L to CAN-L, and a 120 ohm resistor at each end of the bus.
- The classic trap: many MCP2515 modules use an 8 MHz crystal, not 16. If the clock does not match, the bus stays silent.
- Bit rate: most examples run at 250 or 500 kbit/s, and both nodes must be set the same.
The bridge to this site: a Raspberry Pi with a CAN-HAT exposes a real SocketCAN interface. Every command shown above works unchanged, and ICSim runs on it with no modification.
sudo ip link set can0 type can bitrate 500000 sudo ip link set up can0 ./icsim can0 # the same cluster, on the physical bus ./controls can0
- Two-node bench step by step (SparkFun CAN Bus Shield)Two Arduinos, wiring and termination explained.
- ESP32RETTurn an ESP32 into a capture-and-replay tool, compatible with SavvyCAN.
- CANMIMMan-in-the-middle on CAN with an ESP32: read, filter, inject, re-emit.
- Pro-CHASER (research testbed)A Raspberry Pi + CAN-HAT bench described in a publication.
can-utils cheat sheet
| Command | What it does |
|---|---|
| candump vcan0 | Show every frame on the bus live. |
| candump -l vcan0 | Log to a file (candump-*.log) for replay. |
| canplayer -I file.log | Replay a recording exactly as captured. |
| cansend vcan0 123#DEADBEEF | Send a frame: identifier 0x123, data DE AD BE EF. |
| cangen vcan0 -I i -L 8 -D r | Generate random frames: load and fuzzing. |
| cansniffer vcan0 | A view grouped by identifier, with changing bytes highlighted. |
| cansend vcan0 000#0000000000000000 | Hammer identifier 0: an illustration of a denial of service. |
Glossary
- ECU
- One of the vehicle's computers: engine, braking, cabin, and so on.
- Frame
- The unit of data transmitted on the bus: one identifier and up to eight bytes.
- Identifier (CAN ID)
- The field that describes a frame's contents and sets its arbitration priority.
- ISO-TP
- The transport layer (ISO 15765-2) that segments messages longer than eight bytes.
- UDS
- Standardised diagnostic services (ISO 14229), on top of the bus.
- DoIP
- Diagnostics over IP (ISO 13400): diagnostics carried by Ethernet.
- SecOC
- Secure Onboard Communication: authenticates messages (a MAC and a freshness counter).
- DTC
- Diagnostic Trouble Code: a fault code recorded by an ECU.
- PID (OBD)
- Parameter ID: the identifier of a standard value readable through the OBD-II port.
- CAN-FD
- An evolution of CAN: a higher bit rate and up to 64 data bytes per frame.
- Bus-off
- The state in which a node disconnects itself after too many errors.
To go further
- The Car Hacker's Handbook (OpenGarages)The entry-level reference, free and open.
- can-utils (SocketCAN repository)The command-line tools.
- ICSim, the dashboard simulatorTo practise replay without a car.
- UNECE WP.29 (R155 / R156)The regulatory framework for vehicle cybersecurity.
- ISO/SAE 21434Automotive cybersecurity engineering.