Skip to content

Commit 4d5ddaf

Browse files
baarsep-l-
authored andcommitted
SOME/IP documentation (#1762)
1 parent 4766a5e commit 4d5ddaf

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

doc/scapy/advanced_usage.rst

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,102 @@ Create CAN-frames from an ISOTP message::
15801580

15811581
ISOTP(src=0x241, dst=0x641, exdst=0x41, exsrc=0x55, data=b"\x3eabc" * 10).fragment()
15821582

1583+
SOME/IP and SOME/IP SD messages
1584+
-------------------------------
1585+
1586+
Creating a SOME/IP message
1587+
^^^^^^^^^^^^^^^^^^^^^^^^^^
1588+
1589+
This example shows a SOME/IP message which requests a service 0x1234 with the method 0x421. Different types of SOME/IP messages follow the same procedure and their specifications can be seen here ``http://www.some-ip.com/papers/cache/AUTOSAR_TR_SomeIpExample_4.2.1.pdf``.
1590+
1591+
1592+
Load the contribution::
1593+
1594+
load_contrib("automotive.someip")
1595+
1596+
Create UDP package::
1597+
1598+
u = UDP(sport=30509, dport=30509)
1599+
1600+
Create IP package::
1601+
1602+
i = IP(src="192.168.0.13", dst="192.168.0.10")
1603+
1604+
Create SOME/IP package::
1605+
1606+
sip = SOMEIP()
1607+
sip.iface_ver = 0
1608+
sip.proto_ver = 1
1609+
sip.msg_type = "REQUEST"
1610+
sip.retcode = "E_OK"
1611+
sip.msg_id.srv_id = 0x1234
1612+
sip.msg_id.method_id = 0x421
1613+
1614+
Add the payload::
1615+
1616+
sip.add_payload(Raw ("Hello"))
1617+
1618+
Stack it and send it::
1619+
1620+
p = i/u/sip
1621+
send(p)
1622+
1623+
Creating a SOME/IP SD message
1624+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1625+
1626+
In this example a SOME/IP SD offer service message is shown with an IPv4 endpoint. Different entries and options basically follow the same procedure as shown here and can be seen at ``https://www.autosar.org/fileadmin/user_upload/standards/classic/4-3/AUTOSAR_SWS_ServiceDiscovery.pdf``.
1627+
1628+
Load the contribution::
1629+
1630+
load_contrib("automotive.someip_sd")
1631+
1632+
Create UDP package::
1633+
1634+
u = UDP(sport=30490, dport=30490)
1635+
1636+
The UDP port must be the one which was chosen for the SOME/IP SD transmission.
1637+
1638+
Create IP package::
1639+
1640+
i = IP(src="192.168.0.13", dst="224.224.224.245")
1641+
1642+
The IP source must be from the service and the destination address needs to be the chosen multicast address.
1643+
1644+
Create the entry array input::
1645+
1646+
ea = SDEntry_Service()
1647+
1648+
ea.type = 0x01
1649+
ea.srv_id = 0x1234
1650+
ea.inst_id = 0x5678
1651+
ea.major_ver = 0x00
1652+
ea.ttl = 3
1653+
1654+
Create the options array input::
1655+
1656+
oa = SDOption_IP4_Endpoint()
1657+
oa.addr = "192.168.0.13"
1658+
oa.l4_proto = 0x11
1659+
oa.port = 30509
1660+
1661+
l4_proto defines the protocol for the communication with the endpoint, UDP in this case.
1662+
1663+
Create the SD package and put in the inputs::
1664+
1665+
sd = SD()
1666+
sd.set_entryArray(ea)
1667+
sd.set_optionArray(oa)
1668+
spsd = sd.get_someip(True)
1669+
1670+
The get_someip method stacks the SOMEIP/SD message on top of a SOME/IP message, which has the desired SOME/IP values prefilled for the SOME/IP SD package transmission.
1671+
1672+
Stack it and send it::
1673+
1674+
p = i/u/spsd
1675+
send(p)
1676+
1677+
1678+
15831679

15841680
Setup
15851681
-----
@@ -1836,6 +1932,39 @@ can be chosen to fit the bitrate of a CAN bus under test.
18361932
ifconfig can0 up
18371933
ifconfig can1 up
18381934

1935+
Raspberry Pi SOME/IP setup
1936+
~~~~~~~~~~~~~~~~~~~~~~~~~~
1937+
1938+
To build a small test environment in which you can send SOME/IP messages to and from server instances or disguise yourself as a server, one Raspberry Pi, your laptop and the vsomeip library are sufficient.
1939+
1940+
#. | **Download image**
1941+
1942+
Download the latest raspbian image (``https://www.raspberrypi.org/downloads/raspbian/``) and install it on the Raspberry.
1943+
1944+
#. | **Vsomeip setup**
1945+
1946+
Download the vsomeip library on the Rapsberry, apply the git patch so it can work with the newer boost libraries and then install it.
1947+
1948+
::
1949+
1950+
git clone https://github.com/GENIVI/vsomeip.git
1951+
cd vsomeip
1952+
wget -O 0001-Support-boost-v1.66.patch.zip \
1953+
https://github.com/GENIVI/vsomeip/files/2244890/0001-Support-boost-v1.66.patch.zip
1954+
unzip 0001-Support-boost-v1.66.patch.zip
1955+
git apply 0001-Support-boost-v1.66.patch
1956+
mkdir build
1957+
cd build
1958+
cmake -DENABLE_SIGNAL_HANDLING=1 ..
1959+
make
1960+
make install
1961+
1962+
#. | **Make applications**
1963+
1964+
Write some small applications which function as either a service or a client and use the scapy SOME/IP implementation to communicate with the client or the server. Examples for vsomeip applications are available on the vsomeip github wiki page (``https://github.com/GENIVI/vsomeip/wiki/vsomeip-in-10-minutes``).
1965+
1966+
1967+
18391968
Software Setup
18401969
^^^^^^^^^^^^^^
18411970

0 commit comments

Comments
 (0)