Search code examples
c++socketsudpipautosar

How to read data from SOME/IP protocol in C++


Currently I read some data using boost udp socket. I created socket like this

read_socket = new udp::socket(read_socket_service, udp_listener_endpoint);

where

boost::asio::io_service read_socket_service();
udp::endpoint udp_listener_endpoint(some_ip, some_port);

Then I take data

 read_socket->receive_from(boost::asio::buffer(*buffer), senderEndpoint);

where

udp::endpoint senderEndpoint;
buffer = std::make_unique<std::array<char, 100>>;

This method works if communication between packet generator and packet receiver is solved using UDP.
However now I have real device which communicates using SOME/IP protocol. I see in Wireshark some packets movement from device to my application environment, but I completely don't know how to get data from those packets.
When I use boost udp it shows me connection was established but buffer is still empty.
I found something like this https://github.com/GENIVI/vsomeip and icluded this into my project but I really don't know how to use it because documentation even don't indicates how to connect to th specific IP.
Or maybe int this case I shouldn't use any IP and port?


Solution

  • One of the possible solution is use of libtins library
    It allows you to extract raw UDP data from network traffic.
    Here is more detailed tutorial: libtins sniffing tutorial
    Of course later you will have to extract data from such package. This may be more complex work than reading it because all data must be decoded form binary.
    Here is Some/IP documentation: AUTOSAR Some/IP

    I hope in the future this will give some starting point to somebody.