All of lore.kernel.org
 help / color / mirror / Atom feed
* Introducing packet problems to vcan interface
@ 2021-09-07 15:01 Eric Curtin
  2021-09-08 12:01 ` Oliver Hartkopp
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Curtin @ 2021-09-07 15:01 UTC (permalink / raw)
  To: linux-can

Hi Guys,

I'm new to CAN in general, I was running the following commands
to set up a CAN interface and send it some data to see how it
handles undesirable scenarios.

sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
sudo tc qdisc add dev vcan0 root netem loss 10%
sudo tc qdisc add dev vcan0 root netem duplicate 10%
sudo tc qdisc add dev vcan0 root netem corrupt 10%
sudo tc qdisc add dev vcan0 root netem loss 10%

followed by:

./j1939cat -i ../4M.bin vcan0:0x80 :0x90,0x12300

But the packet problems introduced by TC, seem to have no effect
on the cat time. Does TC work with CAN, the timing to transmit the
data is the same with TC introducing problems. Should I be
expecting retransmissions etc. to occur?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Introducing packet problems to vcan interface
  2021-09-07 15:01 Introducing packet problems to vcan interface Eric Curtin
@ 2021-09-08 12:01 ` Oliver Hartkopp
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Hartkopp @ 2021-09-08 12:01 UTC (permalink / raw)
  To: Eric Curtin, linux-can

Hi Eric,


On 07.09.21 17:01, Eric Curtin wrote:

> I'm new to CAN in general, I was running the following commands
> to set up a CAN interface and send it some data to see how it
> handles undesirable scenarios.

Welcome to the CAN world ;-)

> sudo modprobe vcan
> sudo ip link add dev vcan0 type vcan
> sudo ip link set up vcan0
> sudo tc qdisc add dev vcan0 root netem loss 10%
> sudo tc qdisc add dev vcan0 root netem duplicate 10%
> sudo tc qdisc add dev vcan0 root netem corrupt 10%
> sudo tc qdisc add dev vcan0 root netem loss 10%
> 
> followed by:
> 
> ./j1939cat -i ../4M.bin vcan0:0x80 :0x90,0x12300
> 
> But the packet problems introduced by TC, seem to have no effect
> on the cat time. Does TC work with CAN, the timing to transmit the
> data is the same with TC introducing problems. Should I be
> expecting retransmissions etc. to occur?
> 

I needed to check the original documentation myself:

http://rtime.felk.cvut.cz/can/socketcan-qdisc-final.pdf

The handling of local loopbacks (IFF_ECHO) can be done in af_can.c for 
some CAN interfaces that do not support IFF_ECHO on driver level.

This is the default setting for vcan interfaces due to performance reasons.

To change this default, the virtual CAN driver has to expose its 
IFF_ECHO capabilty. This is done by providing a module parameter:

# rmmod vcan
# modprobe vcan echo=1

The PDF says:

3.3. Qdiscs and virtual CAN interface

It is possible to use qdiscs with virtual CAN interface (vcan). This can 
be used, for example, to roughly simulate the transmission delay of the 
real CAN interfaces. One only needs to insert vcan module with echo 
parameter set to 1.

Maybe there are other interesting details for you too.

I checked your above tests with echo=1 and it worked for me.

Best regards,
Oliver


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-08 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 15:01 Introducing packet problems to vcan interface Eric Curtin
2021-09-08 12:01 ` Oliver Hartkopp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.