Using SOME/IP to communicate between two EC2 instances (2024)

Thanks

Randheer Ramesh

and

Atri Sarkar

for helping to put this together!
Using SOME/IP to communicate between two EC2 instances (2)

Context:

In this article , we will explore running SOME/IP application on a AWS EC2 instance. The application in itself is fairly simple. It is a client server application, where the client will send “World” and the server replies with “Hello, World!”. Along the way we will cover, setting up the EC2 with the vsomeip (an implementation of SOME/IP), enabling multicast in the AWS using VPC (you can skip this section if you are not using AWS EC2).

SOME/IP is a service oriented architecture, it is an application layer protocol. It can use both TCP and UDP for the transport layer. As you might have guessed, it runs on top of the IP. We will be using the C++ implementation of the protocol called vsomeip. Vsomeip is an open source implementation of SOME/IP by COVESA.

Setup the EC2 instances in AWS following the official documentation

First, Clone the vsomeip repository using the below command,

git clone git@github.com:COVESA/vsomeip.git

Next, execute the following command to build the project and store the build artefacts

cd vsomeip && \
mkdir build && \
cd build && \
cmake . && \
make && \
make install

Note: You might have to run the code using sudo make install as it is installing the vsomeip library in the system folder.

Multicast communication is not supported in AWS VPC. And in order to enable multicast communication between instances you need to create AWS Transit Gateway Multicast.

Steps to enable Multicast communication between instances.

  1. Create Transit Gateway

a. Open VPC Console in AWS

b. Open Transit gateway from the left pane

c. Create a Transit Gateway with multicast support

2. Create Transit Gateway Multicast Domain

a. Open the Transit Gateway Multicast Domain from the VPC Console

b. Create a new Transit Gateway Multicast Domain

c. Choose the Transit Gateway created earlier in step 1.

d. Also enable IGMPV2 Support

3. Create Transit Gateway Attachments

a. Open the Transit Gateway Attachments from the VPC Console

b. Create a new Transit Gateway Attachment

c. Choose the transit gateway from step1

d. In the attachment type, select VPC

e. And select the VPC id in which the instances are running.

f. Choose the subnet IDs from the VPC for attachment.

4. Create Transit Gateway Multicast Domain Associations

a. Open the Transit Gateway Multicast Domain from the VPC Console

b. Select the multicast Domain.

c. Then Create new Subnet Associations by clicking on the create association button

d. Select the subnets to associate.

5. Add Group Members in the Multicast Domain

a. Open the Multicast Domain from the VPC Console

b. Click on Actions

c. Give the Group IP(Multicast Address) and Select the network interfaces of EC2 instances from the list.

d. And click the Add Group Members

We will be building a simple server application that uses a UDP protocol and runs on the port 30509. This application will listen for requests from other SOME/IP services and responses back by appending “Hello, {request}“. It can be cloned from the git repository

git clone git@github.com:gnana-ganesh-tw/vsomeip-sample.git

This project contains the following folders

client

server

Build the client using the following command,

cd vsomeip-sample/client && \
mkdir build && \
cd build && \
cmake .. && \
make

Build the server application using the following command

cd vsomeip-sample/server && \
mkdir build && \
cd build && \
cmake .. && \
make

In the client folder all the code related to the client application is present, the interesting part here is the config file, lets go over it one by one,

{
"unicast" : "<your-client-IP>",
"netmask": "<your-netmask-IP>",
"logging" :
{
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
"dlt" : "false"
},
"applications" : [
{
"name" : "hello_world_client",
"id" : "0x1313"
}
],
"routing" : "hello_world_client",
"service-discovery" : {
"enable" : "true",
"multicast" : "224.224.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
  • unicast : This is the IP of the client application, you might have to change your client IP
  • netmask: This the net-mask address of your machine
  • logging: This specifies the log level of the application. Currently it is set to debug
  • applications: This specifies the application ID and name of the client application
  • routing: This is the routing service in your client application
  • service-discovery: This is the parameters used by the SOME/IP-SD protocol

Note: You can find the netmask address using the ifconfig command.

Similarly the configuration file of the server looks something like this

{
"unicast" : "<your-server-IP>",
"netmask": "<your-netmask-IP>",
"logging" : {
"level" : "debug",
"console" : "true",
"file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" },
"dlt" : "false"
},
"applications" : [
{
"name" : "hello_world_service",
"id" : "0x1212"
}
],
"services" : [
{
"service" : "0x1111",
"instance" : "0x2222",
"unreliable" : "30509"
}
],
"routing" : "hello_world_service",
"service-discovery" : {
"enable" : "true",
"multicast" : "224.224.224.245",
"port" : "30490",
"protocol" : "udp",
"initial_delay_min" : "10",
"initial_delay_max" : "100",
"repetitions_base_delay" : "200",
"repetitions_max" : "3",
"ttl" : "3",
"cyclic_offer_delay" : "2000",
"request_response_delay" : "1500"
}
}
  • services: Services is the configuration related to your services, this contains the port “30509” and it uses UDP as it mentioned “unreliable”\

Host:1

To run the server application, run the following command,

cd ~/vsomeip-sample/server/build && \
VSOMEIP_CONFIGURATION=<path-to-the-config> VSOMEIP_APPLICATION_NAME=hello_world_service LD_LIBRARY_PATH=/usr/local/lib ./hello_world_service

Note: You have to specify the LD_LIBRARY_PATH to link vsomeip functions at runtime

Host: 2

To run the client application, run the following command,

cd ~/vsomeip-sample/client/build && \
VSOMEIP_CONFIGURATION=<path-to-the-config> VSOMEIP_APPLICATION_NAME=hello_world_client LD_LIBRARY_PATH=/usr/local/lib ./hello_world_client

You might be able to see the Client has received the response “Hello, World”

That brings us to the end of this blog, this shows the communication between two devices running on a EC2 machine communicating with each other using the SOME/IP.

Using SOME/IP to communicate between two EC2 instances (2024)
Top Articles
Latest Posts
Article information

Author: Tuan Roob DDS

Last Updated:

Views: 6226

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Tuan Roob DDS

Birthday: 1999-11-20

Address: Suite 592 642 Pfannerstill Island, South Keila, LA 74970-3076

Phone: +9617721773649

Job: Marketing Producer

Hobby: Skydiving, Flag Football, Knitting, Running, Lego building, Hunting, Juggling

Introduction: My name is Tuan Roob DDS, I am a friendly, good, energetic, faithful, fantastic, gentle, enchanting person who loves writing and wants to share my knowledge and understanding with you.