How can I create several virtual sockets and link them together to create a virtual bus?
I want to simulate an application in which many nodes communicate to each other via CAN.
How can I create several virtual sockets and link them together to create a virtual bus?
I want to simulate an application in which many nodes communicate to each other via CAN.
All you need is cangw tool from can-utils. Create two virtual interfaces:
ip link add dev vcan0 type vcan
ip link add dev vcan1 type vcan
ip link set up vcan0
ip link set up vcan1
Create routing rule, so that all packets coming to vcan0 will be sent to vcan1:
cangw -A -s vcan0 -d vcan1 -e
Listen to vcan1 in one terminal:
candump vcan1
And send packet from another terminal:
cansend vcan0 123#0011
You'll see, that candump will get this CAN packet:
vcan1 123 [2] 00 11