<s>
SocketCAN	B-Application
is	O
a	O
set	O
of	O
open	B-License
source	I-License
CAN	B-Protocol
drivers	O
and	O
a	O
networking	O
stack	O
contributed	O
by	O
Volkswagen	O
Research	O
to	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
SocketCAN	B-Application
was	O
formerly	O
known	O
as	O
Low	O
Level	O
CAN	B-Protocol
Framework	O
(	O
LLCF	O
)	O
.	O
</s>
<s>
Traditional	O
CAN	B-Protocol
drivers	O
for	O
Linux	B-Operating_System
are	O
based	O
on	O
the	O
model	O
of	O
character	O
devices	O
.	O
</s>
<s>
Typically	O
they	O
only	O
allow	O
sending	O
to	O
and	O
receiving	O
from	O
the	O
CAN	B-Protocol
controller	I-Protocol
.	O
</s>
<s>
The	O
SocketCAN	B-Application
concept	O
on	O
the	O
other	O
hand	O
uses	O
the	O
model	O
of	O
network	O
devices	O
,	O
which	O
allows	O
multiple	O
applications	O
to	O
access	O
one	O
CAN	B-Protocol
device	O
simultaneously	O
.	O
</s>
<s>
Also	O
,	O
a	O
single	O
application	O
is	O
able	O
to	O
access	O
multiple	O
CAN	B-Protocol
networks	O
in	O
parallel	O
.	O
</s>
<s>
The	O
SocketCAN	B-Application
concept	O
extends	O
the	O
Berkeley	B-Protocol
sockets	I-Protocol
API	O
in	O
Linux	B-Operating_System
by	O
introducing	O
a	O
new	O
protocol	O
family	O
,	O
PF_CAN	O
,	O
that	O
coexists	O
with	O
other	O
protocol	O
families	O
,	O
such	O
as	O
PF_INET	O
for	O
the	O
Internet	B-Protocol
Protocol	I-Protocol
.	O
</s>
<s>
The	O
communication	O
with	O
the	O
CAN	B-Protocol
bus	I-Protocol
is	O
therefore	O
done	O
analogously	O
to	O
the	O
use	O
of	O
the	O
Internet	B-Protocol
Protocol	I-Protocol
via	O
sockets	O
.	O
</s>
<s>
Fundamental	O
components	O
of	O
SocketCAN	B-Application
are	O
the	O
network	O
device	O
drivers	O
for	O
different	O
CAN	B-Protocol
controllers	I-Protocol
and	O
the	O
implementation	O
of	O
the	O
CAN	B-Protocol
protocol	O
family	O
.	O
</s>
<s>
The	O
protocol	O
family	O
,	O
PF_CAN	O
,	O
provides	O
the	O
structures	O
to	O
enable	O
different	O
protocols	O
on	O
the	O
bus	O
:	O
Raw	O
sockets	O
for	O
direct	O
CAN	B-Protocol
communication	O
and	O
transport	O
protocols	O
for	O
point-to-point	O
connections	O
.	O
</s>
<s>
Moreover	O
the	O
broadcast	O
manager	O
which	O
is	O
part	O
of	O
the	O
CAN	B-Protocol
protocol	O
family	O
provides	O
functions	O
e.g.	O
</s>
<s>
for	O
sending	O
CAN	B-Protocol
messages	O
periodically	O
or	O
realize	O
complex	O
message	O
filters	O
.	O
</s>
<s>
Since	O
Linux	B-Operating_System
kernel	I-Operating_System
Version	O
5.10	O
the	O
protocol	O
family	O
also	O
includes	O
an	O
ISO-TP	B-General_Concept
implementation	O
,	O
CAN_ISOTP	O
.	O
</s>
<s>
Patches	O
for	O
CAN	B-Protocol
were	O
added	O
in	O
the	O
2.6.25	O
Linux	B-Operating_System
kernel	I-Operating_System
.	O
</s>
<s>
The	O
application	O
first	O
sets	O
up	O
its	O
access	O
to	O
the	O
CAN	B-Protocol
interface	O
by	O
initialising	O
a	O
socket	O
(	O
much	O
like	O
in	O
TCP/IP	O
communications	O
)	O
,	O
then	O
binding	O
that	O
socket	O
to	O
an	O
interface	O
(	O
or	O
all	O
interfaces	O
,	O
if	O
the	O
application	O
so	O
desires	O
)	O
.	O
</s>
<s>
Once	O
bound	O
,	O
the	O
socket	O
can	B-Protocol
then	O
be	O
used	O
like	O
a	O
UDP	B-Protocol
socket	O
via	O
read	O
,	O
write	O
,	O
etc	O
...	O
</s>
<s>
Python	B-Language
added	O
support	O
for	O
SocketCAN	B-Application
in	O
version	O
3.3	O
.	O
</s>
<s>
An	O
open	B-License
source	I-License
library	O
provides	O
SocketCAN	B-Application
support	O
for	O
Python	B-Language
2	O
and	O
Python	B-Language
3	O
.	O
</s>
<s>
Installing	O
a	O
CAN	B-Protocol
device	O
requires	O
loading	O
the	O
can_dev	O
module	O
and	O
configuring	O
the	O
IP	O
link	O
to	O
specify	O
the	O
CAN	B-Protocol
bus	I-Protocol
bitrate	O
,	O
for	O
example	O
:	O
</s>
<s>
There	O
is	O
also	O
a	O
virtual	O
CAN	B-Protocol
driver	O
for	O
testing	O
purposes	O
which	O
can	B-Protocol
be	O
loaded	O
and	O
created	O
in	O
Linux	B-Operating_System
with	O
the	O
commands	O
below	O
.	O
</s>
<s>
The	O
following	O
code	O
snippet	O
is	O
a	O
working	O
example	O
of	O
the	O
SocketCAN	B-Application
API	O
,	O
that	O
sends	O
a	O
packet	O
using	O
the	O
raw	O
interface	O
.	O
</s>
<s>
It	O
is	O
based	O
on	O
the	O
notes	O
documented	O
in	O
the	O
Linux	B-Operating_System
Kernel	I-Operating_System
.	O
</s>
<s>
The	O
packet	O
can	B-Protocol
be	O
analyzed	O
on	O
the	O
vcan0	O
interface	O
using	O
the	O
candump	O
utility	O
which	O
is	O
part	O
of	O
the	O
SocketCAN	B-Application
can-utils	O
package	O
.	O
</s>
