
Recall first from Callbacks, queues and service discovery
- Communication Management invokes registered receive handlers in an implementation-selected context and serializes invocations of the same receive handler.
- GetNewSamples invokes the sample-processing callable in the context of its caller.
- FindService gives a snapshot, while StartFindService monitors the matching set until monitoring stops.
Applications and the routing manager
3 min readThe last lesson finished the ara::com API surface. This lesson answers how the open-source vsomeip stack implements SOME/IP and how its JSON configuration declares a service.
A provider and a consumer can exchange messages on the same Linux machine while Wireshark sees zero SOME/IP packets on lo. That can be the expected result. Linux supports local communication through Unix-domain sockets, and vsomeip can use them for communication between local applications. Wireshark capturing an IP interface sees traffic sent through that interface. The first thing to establish when diagnosing an empty capture is which transport the applications actually used. unix(7): Unix-domain sockets
vsomeip is the open-source SOME/IP implementation maintained by COVESA, formerly the GENIVI Alliance. Its C++ API lets a provider offer a service and handle incoming requests. A consumer requests a service, receives availability updates and sends requests. The library handles SOME/IP messaging, service discovery and the sockets used to reach peers. For the raw API used here, the applications agree on the meaning and layout of the payload bytes. The temperature example uses a fixed sample so that a successful reply can be checked without sensor hardware.
The the vsomeip component that coordinates application registration, service availability and message routing for a local vsomeip domain runs in one designated process in that domain. The JSON routing value names the application that hosts it. An ordinary provider can host the routing manager while it also runs its service logic. A deployment can instead use a separate routing-manager daemon and set routing to the application name used by that daemon. In either arrangement, the other applications connect to the designated manager. In this lesson the provider hosts it for the localhost run, so start the provider first.
Use distinct application names and client IDs within the local domain. The configured client ID identifies an application for SOME/IP messaging. The service ID identifies the service and the instance ID selects a particular deployment of that service. A provider can restart with the same configuration and offer the same instance again. A client can select that instance without using the provider's application name in a request_service call.
When you launch a program, VSOMEIP_CONFIGURATION can point to its JSON file and VSOMEIP_APPLICATION_NAME can select the application name when the code calls create_application() without a name. For a same-machine run, both processes use the same JSON and select their respective names. The executable name is independent of these configured names. When an application cannot initialize or connect, check the file path, application name and routing value before changing any service IDs. Those settings determine whether the application can join the intended local domain.
Service identity and endpoints in JSON
3 min readThe temperature example uses service 0x1234, instance 0x0001, method 0x0001, event 0x8001 and eventgroup 0x0001. These are example assignments. The repeated value 0x0001 is deliberate. Each occurrence belongs to a different identifier field. The consumer must request the service and instance that the provider offers, and the request's method ID must match the provider's registered handler.
Save this configuration as temp.json. The example ports and multicast address are settings chosen for the lesson. Discovery is disabled for the first run because local applications share a routing manager.
{
"unicast": "127.0.0.1",
"applications": [
{"name": "temp-provider", "id": "0x1001"},
{"name": "temp-client", "id": "0x1002"}
],
"routing": "temp-provider",
"services": [
{
"service": "0x1234",
"instance": "0x0001",
"unreliable": "30510",
"reliable": "30511",
"events": [
{"event": "0x8001", "is_field": "false", "is_reliable": "false"}
],
"eventgroups": [
{"eventgroup": "0x0001", "events": ["0x8001"]}
]
}
],
"service-discovery": {
"enable": "false",
"multicast": "224.244.224.245",
"port": "30490",
"protocol": "udp"
}
}
Read the services entry as a deployment record for one service instance. The top-level unicast sets the local IP address used for network communication. The unreliable port configures the instance's UDP endpoint and the reliable port configures its TCP endpoint. Those names refer to the transport specified by vsomeip. In a network run the consumer chooses the transport for the method request when it creates the request. create_request(false) selects UDP and create_request(true) selects TCP. On a shared local routing manager, that choice can still result in delivery over local IPC.
The running provider makes the instance available by calling offer_service. It registers the method with register_message_handler, using the service, instance and method IDs. There is no method list to add to this JSON for the handler to work. The example's events and eventgroups entries describe event transport and group membership. To publish the event, the provider still calls offer_event with the event ID and its group and uses notify to send a sample. A consumer that wants updates registers a message handler for the event, calls request_event with the matching group, and calls subscribe for that eventgroup after the service becomes available. The method-only program in this lesson leaves the event idle.
There are two places where multicast can affect this service. The service-discovery object sets the multicast address and UDP port for discovery traffic when discovery is enabled. Event notification traffic uses the service's delivery settings. An eventgroup can declare its own multicast object with address and port for UDP notifications and a threshold that controls when multicast delivery is used based on the number of subscribers. The example omits the eventgroup multicast settings. Changing the discovery multicast address only changes where the participants exchange discovery traffic. A UDP method request still goes to the provider's unicast endpoint.
Running the temperature exchange and capturing it
5 min readThe same executable can run as the provider or the consumer. Save the following as temperature.cpp. The provider returns a one-byte unsigned whole-degree Celsius sample with value 23, encoded as 17 in a hexadecimal byte view. The request has an empty payload. The consumer stops after reading one response, and an atomic flag prevents repeated availability callbacks from sending more requests.
#include <atomic>
#include <cstdint>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <vsomeip/vsomeip.hpp>
int main(int argc, char **argv) {
if (argc != 2 || (std::string(argv[1]) != "provider" &&
std::string(argv[1]) != "client")) {
std::cerr << "Usage: temperature provider|client\n";
return 1;
}
constexpr vsomeip::service_t service = 0x1234;
constexpr vsomeip::instance_t instance = 0x0001;
constexpr vsomeip::method_t method = 0x0001;
const auto runtime = vsomeip::runtime::get();
const auto app = runtime->create_application();
if (!app->init()) {
std::cerr << "vsomeip initialization failed\n";
return 1;
}
const bool provider = std::string(argv[1]) == "provider";
std::atomic<bool> sent{false};
int status = provider ? 0 : 1;
if (provider) {
app->register_message_handler(service, instance, method,
[&](const std::shared_ptr<vsomeip::message> &request) {
auto response = runtime->create_response(request);
auto payload = runtime->create_payload();
payload->set_data(std::vector<vsomeip::byte_t>{23});
response->set_payload(payload);
app->send(response);
});
app->offer_service(service, instance);
} else {
app->register_message_handler(service, instance, method,
[&](const std::shared_ptr<vsomeip::message> &response) {
auto payload = response->get_payload();
if (response->get_message_type() == vsomeip::message_type_e::MT_RESPONSE &&
response->get_return_code() == vsomeip::return_code_e::E_OK &&
payload && payload->get_length() == 1) {
std::cout << static_cast<unsigned>(payload->get_data()[0]) << " C\n";
status = 0;
} else {
std::cerr << "Unexpected temperature response\n";
}
app->stop();
});
app->register_availability_handler(service, instance,
[&](vsomeip::service_t, vsomeip::instance_t, bool available) {
if (available && !sent.exchange(true)) {
auto request = runtime->create_request(false);
request->set_service(service);
request->set_instance(instance);
request->set_method(method);
app->send(request);
}
});
app->request_service(service, instance);
}
app->start();
return status;
}
Build against the installed vsomeip 3 development headers and library. This program and the two JSON files were built and run for this review with vsomeip 3.8.0 compiled from the COVESA source on Ubuntu 24.04. vsomeip also prints its own info lines on the console, so look for the client's result line, which is 23 C. Run the first launch command in one terminal and the second in another, both from the directory containing the executable and configuration. The provider stays active, so leave it running until the consumer finishes. If the consumer waits indefinitely, interrupt it and check availability and the provider's initialization messages before restarting.
g++ -std=c++17 -Wall -Wextra -pthread temperature.cpp -lvsomeip3 -o temperature
VSOMEIP_CONFIGURATION="$PWD/temp.json" VSOMEIP_APPLICATION_NAME=temp-provider ./temperature provider
VSOMEIP_CONFIGURATION="$PWD/temp.json" VSOMEIP_APPLICATION_NAME=temp-client ./temperature client
For the IP capture, stop the localhost provider and run the same binaries on the same Ubuntu machine in two network namespaces. Network namespaces give the processes separate network interfaces and routing tables. A veth pair connects those interfaces directly, and a capture on either end can see the IP exchange. Use the localhost run to verify that the programs can communicate locally and the namespace run to inspect the SOME/IP bytes on an IP interface. network_namespaces(7): network namespace isolation, veth(4): virtual Ethernet pairs
sudo ip netns add temp-p
sudo ip netns add temp-c
sudo ip link add temp-p0 type veth peer name temp-c0
sudo ip link set temp-p0 netns temp-p
sudo ip link set temp-c0 netns temp-c
sudo ip -n temp-p addr add 10.77.0.1/24 dev temp-p0
sudo ip -n temp-c addr add 10.77.0.2/24 dev temp-c0
sudo ip -n temp-p link set lo up
sudo ip -n temp-c link set lo up
sudo ip -n temp-p link set temp-p0 up
sudo ip -n temp-c link set temp-c0 up
sudo ip -n temp-p route add 224.244.224.245/32 dev temp-p0
sudo ip -n temp-c route add 224.244.224.245/32 dev temp-c0
Make two copies of temp.json, named provider.json and client.json. In both, set service-discovery.enable to "true" and keep the same discovery address and port. In provider.json set unicast to "10.77.0.1" and add a top-level "network": "temp-wire-p". Keep its routing and services settings. In client.json set unicast to "10.77.0.2", add "network": "temp-wire-c", change routing to "temp-client" and set services to []. The consumer learns the provider's endpoint through discovery. Each namespace has its own routing manager for this run. Giving each one a distinct vsomeip network value keeps their filesystem-based local sockets distinct even though both processes share the same filesystem.
Start the capture in one terminal. Then launch the provider and consumer in two more terminals from the project directory.
sudo ip netns exec temp-p tcpdump -i temp-p0 -w temperature.pcap
sudo ip netns exec temp-p env VSOMEIP_CONFIGURATION="$PWD/provider.json" VSOMEIP_APPLICATION_NAME=temp-provider "$PWD/temperature" provider
sudo ip netns exec temp-c env VSOMEIP_CONFIGURATION="$PWD/client.json" VSOMEIP_APPLICATION_NAME=temp-client "$PWD/temperature" client
Stop the capture with Ctrl+C and open temperature.pcap in Wireshark. Apply the display filter udp.port == 30510 and, if needed, use Decode As to select SOME/IP for UDP port 30510. Find the request going to 10.77.0.1 and the response coming back. Check service 0x1234 and method 0x0001, match the client and session IDs across the two messages, and inspect the response for the payload byte 17 in hexadecimal. To check instance 0x0001, inspect the service offer in the discovery traffic on UDP port 30490. The method request header carries the service and method IDs. The discovery offer identifies the instance and its endpoint. In the run used to check this lesson, the UDP request on port 30510 was 12 34 00 01 00 00 00 08 10 02 00 01 01 00 00 00: service 0x1234, method 0x0001, length 8, client ID 0x1002 (the ID of temp-client in the applications list), session ID 1, protocol version 1, interface version 0, message type 0x00 (request) and return code 0. The response was 12 34 00 01 00 00 00 09 10 02 00 01 01 00 80 00 17: the same service, method, client and session IDs, length 9, message type 0x80 (response) and the payload byte 17. The offer in the discovery traffic carried instance 0x0001 with an IPv4 endpoint option for UDP port 30510 and one for TCP port 30511. On your machine the UDP source port and the session numbers will differ.
If only discovery traffic appears, check the announced service and instance and whether the consumer received an availability callback. If a request appears without a response, check the method ID against the provider's handler. A reply with the expected byte and matching request IDs verifies the transport and the sample together. After stopping the processes, sudo ip netns del temp-p and sudo ip netns del temp-c remove the lab namespaces.
In the next lesson, CommonAPI and Franca IDL, you will see how a written interface definition can replace the manually coordinated method signatures and payload handling used by this example.
Key takeaways
- A vsomeip routing manager can run inside an application or in a separate daemon.
- The service and instance identify a deployment, while application code registers handlers for individual methods.
- The service discovery multicast settings and the eventgroup multicast settings control different traffic.
- A successful exchange over local Unix-domain sockets can leave the IP loopback capture empty.
Reflect
- Explain to a colleague, in two sentences: identify the provider, consumer, and routing manager in a vsomeip deployment
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Man pageunix(7): Unix-domain sockets
- Man pagenetwork_namespaces(7): network namespace isolation
- Man pageveth(4): virtual Ethernet pairs
Official documentation first. Links checked when the lesson was published.