Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INFO]: Supporting multiple versions of the same service (PRS_SOMEIPSD_00512). #797

Open
zhaoxin39913 opened this issue Oct 26, 2024 · 28 comments
Labels

Comments

@zhaoxin39913
Copy link

vSomeip Version

v3.4.10

Boost Version

1.7.6

Environment

Ubuntu 20.04

Describe the bug

Hi vsomeip experts,

One issue I would like to check with you guys.
 
In order to support multiple versions of the same service (defined in SOME/IP SD spec PRS_SOMEIPSD_00512), there could be multiple services offered with the same serviceID and instanceID but different major versions within a network. Using API request_service(serviceId, instanceId, ANY_MAJOR) should be able to find all services with different major versions for a given serviceID/instanceID pair. Next are_available() API should be able to retrieve all those major versions.

The problem is how does availability_handler() get triggered when those services with different major versions are detected, since only the serviceID and instanceID is passing to the handler without major version.

This is one of our customer user case, what's the solution do you suggest to handle it in our application?

Reproduction Steps

N/A

Expected behaviour

N/A

Logs and Screenshots

N/A

@zhaoxin39913 zhaoxin39913 changed the title [BUG]: <title>Supporting multiple versions of the same service. [BUG]: <title>Supporting multiple versions of the same service (PRS_SOMEIPSD_00512). Nov 4, 2024
@zhaoxin39913 zhaoxin39913 changed the title [BUG]: <title>Supporting multiple versions of the same service (PRS_SOMEIPSD_00512). [BUG]: Supporting multiple versions of the same service (PRS_SOMEIPSD_00512). Nov 4, 2024
@zhaoxin39913 zhaoxin39913 changed the title [BUG]: Supporting multiple versions of the same service (PRS_SOMEIPSD_00512). [INFO]: Supporting multiple versions of the same service (PRS_SOMEIPSD_00512). Nov 4, 2024
@KareemLMR
Copy link

Hello,
Did you tried calling request_service API with setting major version?
image

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Nov 18, 2024

Hi @KareemLMR,

Yes, I have tested request_service() API for the same service-instances with different major versions, it works without any errors from the log. But I am not able to verify it using vsomeip server API since the offer_service() API doesn't support offering the same service-instances with different major versions within the same VLAN network which I mentioned in #809.

Due to the limitation I have to ask our customer to verify it. It seems like our customer is using a 3rd party SOME/IP stack to deloy the services on different ECUs, which can support PRS_SOMEIPSD_00512.

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Nov 21, 2024

Hi @KareemLMR ,

Even we can specify the versions in some client side APIs like request_service(), subscribe() and register_availability_handler()/unregister_availability_handler(), there are still some APIs don't support passing the versions, which means the serviceID-instanceID-majVersion is not fully manageable independently. Thus I think we need to have below changes to fully support PRS_SOMEIPSD_00512 on client side to make sure the version is present in pair.

virtual void release_service(service_t _service, instance_t _instance) = 0;
change to
virtual void release_service(service_t _service, instance_t _instance, major_version_t _major = ANY_MAJOR, minor_version_t _minor = ANY_MINOR) = 0;

virtual void unsubscribe(service_t _service, instance_t _instance, eventgroup_t _eventgroup) = 0;
change to
virtual void unsubscribe(service_t _service, instance_t _instance, eventgroup_t _eventgroup, major_version_t _major = DEFAULT_MAJOR) = 0;

And request_event()/release_event() shall all add the major version as input parameter as below:
virtual void request_event(service_t _service, instance_t _instance, event_t _event, const std::set<eventgroup_t> &_eventgroups, major_version_t _major = DEFAULT_MAJOR, event_type_e _type = event_type_e::ET_EVENT, reliability_type_e _reliability = reliability_type_e::RT_UNKNOWN) = 0;

virtual void release_event(service_t _service, instance_t _instance, event_t _event, major_version_t _major = DEFAULT_MAJOR) = 0;

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Nov 22, 2024

I tested the request_service() for the same instance but with different major versions, and it return error message as below:
[error] rm_base::request_service service property mismatch (0102): [1234.5678:18:878082192] passed: 34:4294967295

In my test I have two devices (A and B) in the network. First device B offers service 0x1234/5678 with majorVersion 0x12. Next device B request service 0x1234/5678 with majorVersion 0x12 and it works. Then device B request service 0x1234/5678 with majorVersion 0x22, it reported such error.

From the source code, it seems like the majorVersion is not taken into consideration when maintaining the service instances available in the network. See void routing_manager_base::request_service() in routing_manager_base.cpp

@zhaoxin39913
Copy link
Author

Hi @KareemLMR,

From my investigation, It seems like the PRS_SOMEIPSD_00512 in SOME/IP SD Spec is totally not supported in vsomeip library, can you confirm ?

@KareemLMR
Copy link

KareemLMR commented Nov 23, 2024

Hello @zhaoxin39913
There is something I doubt, but I need to check with you. Open the vsomeip source code and navigate to the file implementation/routing/src/routing_manager_base.cpp at this function routing_manager_base::offer_service to be specific
image
And add a log to this if condition marked by the red arrow:
if (!its_info->is_local()) {
return false;
}
and if you can add more logs throughout this function then recompile and reinstall the binaries and let me see the logs of your test. If the log you added in that if condition appeared, then there is an issue as you said. If not then it is something else we will see.

@zhaoxin39913
Copy link
Author

Hi @KareemLMR,

I have made below changes per as your request:

    if (!its_info->is_local()) {
        VSOMEIP_INFO << "rm_base::offer_service !its_info->is_local ("
                << std::hex << std::setfill('0')
                << std::setw(4) << _client << "): ["
                << std::setw(4) << _service << "."
                << std::setw(4) << _instance << ":"
                << std::dec
                << static_cast<std::uint32_t>(its_info->get_major()) << ":"
                << its_info->get_minor() << "] passed: "
                << static_cast<std::uint32_t>(_major) << ":"
                << _minor;
        return false;

And after change I have triggered "notify-sample" to offer the second service instance 0x1234/0x5678 with version 0xA (There is already a service instance 0x1234/0x5678 with version 0x12 offered by another device within the same network). And from the wireshark we can see that the first time notify-sample was successful to offer the service 0x1234/0x5678 version 0xA, but after call stop_offer() and then start_offer() in "notify-sample", it failed to offer the service again. Below are full log messages from notify-sample:

zhax@zhax-desktop:~/work/COVESA/src/vsomeip-3.4.10/build/examples$ VSOMEIP_APPLICATION_NAME=service-sample ./notify-sample
2024-11-28 14:44:42.707338 [info] Using configuration folder: "/home/zhax/work/COVESA/src/config".
2024-11-28 14:44:42.709307 [info] Parsed vsomeip configuration in 1ms
2024-11-28 14:44:42.709649 [info] Configuration module loaded.
2024-11-28 14:44:42.709911 [info] Security disabled!
2024-11-28 14:44:42.710142 [info] Initializing vsomeip (3.4.10) application "service-sample".
2024-11-28 14:44:42.711782 [info] Instantiating routing manager [Host].
2024-11-28 14:44:42.714633 [info] create_routing_root: Routing root @ /tmp/vsomeip-0
2024-11-28 14:44:42.716890 [info] Service Discovery enabled. Trying to load module.
2024-11-28 14:44:42.725771 [info] Service Discovery module loaded.
2024-11-28 14:44:42.726925 [info] Application(service-sample, 1277) is initialized (11, 100).
2024-11-28 14:44:42.727391 [info] offer_event: Event [1234.5678.9999] uses configured cycle time 0ms
2024-11-28 14:44:42.728266 [info] REGISTER EVENT(1277): [1234.5678.9999:is_provider=true]
2024-11-28 14:44:42.728753 [info] Starting vsomeip application "service-sample" (1277) using 2 threads I/O nice 255
2024-11-28 14:44:42.731711 [info] main dispatch thread id from application: 1277 (service-sample) is: ffffbc79f060 TID: 189214
2024-11-28 14:44:42.732672 [info] shutdown thread id from application: 1277 (service-sample) is: ffffbbf8f060 TID: 189215
2024-11-28 14:44:42.733317 [info] create_local_server: Listening @ /tmp/vsomeip-1277
2024-11-28 14:44:42.734978 [info] OFFER(1277): [1234.5678:10.0] (true)
2024-11-28 14:44:42.732532 [info] Client [1277] routes unicast:192.168.225.3, netmask:255.255.255.0
Setting event (Length=1).
2024-11-28 14:44:42.739600 [info] Watchdog is disabled!
Application service-sample is registered.
2024-11-28 14:44:42.741732 [info] io thread id from application: 1277 (service-sample) is: ffffbec44020 TID: 189210
2024-11-28 14:44:42.741929 [info] io thread id from application: 1277 (service-sample) is: ffffbaf6f060 TID: 189217
2024-11-28 14:44:42.743662 [info] vSomeIP 3.4.10 | (default)
2024-11-28 14:44:42.744930 [info] Network interface "eth0" state changed: up
2024-11-28 14:44:42.746798 [info] Route "default route (0.0.0.0/0) if: eth0 gw: 192.168.225.1" state changed: up
2024-11-28 14:44:42.748222 [info] udp_server_endpoint_impl: SO_RCVBUF is: 212992 (1703936) local port:30490
2024-11-28 14:44:42.748774 [debug] Joining to multicast group 224.0.0.1 from 192.168.225.3
2024-11-28 14:44:42.750352 [info] udp_server_endpoint_impl: SO_RCVBUF is: 212992 (1703936) local port:30509
2024-11-28 14:44:42.750775 [info] SOME/IP routing ready.
2024-11-28 14:44:42.750875 [info] udp_server_endpoint_impl<multicast>: SO_RCVBUF is: 212992 (1703936) local port:30490
2024-11-28 14:44:42.752166 [warning] Route "224.0.0.1/32 if: eth0 gw: n/a" state changed: up
2024-11-28 14:44:43.334512 [error] routing_manager_impl::add_routing_info: rejecting routing info. Remote: 192.168.225.2 is trying to offer [1234.5678.18.878082192] on port 12344 offered previously on this node: [1234.5678.10.0]
Setting event (Length=2).
Setting event (Length=3).
2024-11-28 14:44:45.339291 [error] routing_manager_impl::add_routing_info: rejecting routing info. Remote: 192.168.225.2 is trying to offer [1234.5678.18.878082192] on port 12344 offered previously on this node: [1234.5678.10.0]
Setting event (Length=4).
Setting event (Length=5).
2024-11-28 14:44:47.349538 [error] routing_manager_impl::add_routing_info: rejecting routing info. Remote: 192.168.225.2 is trying to offer [1234.5678.18.878082192] on port 12344 offered previously on this node: [1234.5678.10.0]
Setting event (Length=6).
Setting event (Length=7).
2024-11-28 14:44:49.357992 [error] routing_manager_impl::add_routing_info: rejecting routing info. Remote: 192.168.225.2 is trying to offer [1234.5678.18.878082192] on port 12344 offered previously on this node: [1234.5678.10.0]
Setting event (Length=8).
Setting event (Length=9).
2024-11-28 14:44:51.367642 [error] routing_manager_impl::add_routing_info: rejecting routing info. Remote: 192.168.225.2 is trying to offer [1234.5678.18.878082192] on port 12344 offered previously on this node: [1234.5678.10.0]
Setting event (Length=1).
2024-11-28 14:44:52.746252 [info] vSomeIP 3.4.10 | (default)
2024-11-28 14:44:52.748212 [info] STOP OFFER(1277): [1234.5678:10.0] (true)
2024-11-28 14:44:53.376311 [warning] process_offerservice_serviceentry: Remote offer type changed [1234.5678]
2024-11-28 14:45:02.748736 [info] vSomeIP 3.4.10 | (default)
2024-11-28 14:45:02.763922 [info] rm_base::offer_service !its_info->is_local (1277): [1234.5678:18:878082192] passed: 10:0
2024-11-28 14:45:02.764833 [error] routing_manager_impl::handle_local_offer_service: rejecting service registration. Application: 1277 is trying to offer [1234.5678.10.0]] already offered remotely
2024-11-28 14:45:02.765169 [info] offer_service (1277): [1234.5678:10.0] (true) not offering, returned from handle_local_offer_service!
Setting event (Length=2).
Setting event (Length=3).
Setting event (Length=4).
Setting event (Length=5).
Setting event (Length=6).
Setting event (Length=7).
Setting event (Length=8).
Setting event (Length=9).
Setting event (Length=1).
Setting event (Length=2).
2024-11-28 14:45:12.752146 [info] vSomeIP 3.4.10 | (default)
2024-11-28 14:45:12.778179 [info] STOP OFFER(1277): [1234.5678:10.0] (true)
2024-11-28 14:45:12.779683 [warning] stop_offer_service received STOP_OFFER(1277): [1234.5678:10.0] for remote service --> ignore
2024-11-28 14:45:22.755800 [info] vSomeIP 3.4.10 | (default)
2024-11-28 14:45:22.794124 [info] rm_base::offer_service !its_info->is_local (1277): [1234.5678:18:878082192] passed: 10:0
2024-11-28 14:45:22.795834 [error] routing_manager_impl::handle_local_offer_service: rejecting service registration. Application: 1277 is trying to offer [1234.5678.10.0]] already offered remotely
2024-11-28 14:45:22.796629 [info] offer_service (1277): [1234.5678:10.0] (true) not offering, returned from handle_local_offer_service!
Setting event (Length=3).
Setting event (Length=4).
Setting event (Length=5).
Setting event (Length=6).
Setting event (Length=7).
Setting event (Length=8).
Setting event (Length=9).
Setting event (Length=1).
Setting event (Length=2).
Setting event (Length=3).
2024-11-28 14:45:32.758869 [info] vSomeIP 3.4.10 | (default)
2024-11-28 14:45:32.809674 [info] STOP OFFER(1277): [1234.5678:10.0] (true)
2024-11-28 14:45:32.810830 [warning] stop_offer_service received STOP_OFFER(1277): [1234.5678:10.0] for remote service --> ignore
2024-11-28 14:45:42.762672 [info] vSomeIP 3.4.10 | (default)
2024-11-28 14:45:42.825814 [info] rm_base::offer_service !its_info->is_local (1277): [1234.5678:18:878082192] passed: 10:0
2024-11-28 14:45:42.831568 [error] routing_manager_impl::handle_local_offer_service: rejecting service registration. Application: 1277 is trying to offer [1234.5678.10.0]] already offered remotely
2024-11-28 14:45:42.832564 [info] offer_service (1277): [1234.5678:10.0] (true) not offering, returned from handle_local_offer_service!

@KareemLMR
Copy link

Ok, I see the log you added appeared. That's good. I saw what I wanted to see. Let me try a change at my side and send it to you to try when it is successful.

@zhaoxin39913
Copy link
Author

Hi @KareemLMR ,

Any updates for your patch ?

@KareemLMR
Copy link

Hi @zhaoxin39913
Unfortunately, the change was much larger than what I expected at the beginning as all data structures and searching functions in the code are set to deal with only service and instance and I had to change the strategy many times after starting to decrease the impact of the change but the good news I have decided the most suitable one and I am about to finish the implementation. I will send it once done.

@zhaoxin39913
Copy link
Author

Thanks @KareemLMR for sharing the update.

@KareemLMR
Copy link

KareemLMR commented Dec 20, 2024

You can try this change #829 I was able to offer 2 services with only different major versions through it but I need you to verify it. Here is the code examples:
service1.cpp:

#include <vsomeip/vsomeip.hpp>

#define SAMPLE_SERVICE_ID 0x1234
#define SAMPLE_INSTANCE_ID 0x5678

std::shared_ptr< vsomeip::application > app;

int main() {
vsomeip_v3::unique_version_t unique = vsomeip_v3::get_unique_version(SAMPLE_INSTANCE_ID, 10);
app = vsomeip::runtime::get()->create_application("Hello");
app->init();
app->offer_service(SAMPLE_SERVICE_ID, unique, 10, 0);
app->start();
}

service2.cpp:

#include <vsomeip/vsomeip.hpp>

#define SAMPLE_SERVICE_ID 0x1234
#define SAMPLE_INSTANCE_ID 0x5678

std::shared_ptr< vsomeip::application > app;

int main() {
vsomeip_v3::unique_version_t unique = vsomeip_v3::get_unique_version(SAMPLE_INSTANCE_ID, 11);
app = vsomeip::runtime::get()->create_application("World");
app->init();
app->offer_service(SAMPLE_SERVICE_ID, unique, 11, 0);
app->start();
}

Also for the json file, I supported adding "major" : "value" just as instance in your service definition so don't forget that.
Please tell me the results of your testing.

And in all other APIs you will pass unique instead of instance but also add major and minor if the API require it

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Dec 31, 2024

Hi @KareemLMR ,

Thanks for sharing the sample code. One question here, for client API request_service(), Do we still support setting ANY_MAJOR in unique_version_t parameter? Or we must pass a non-0xFF version ? And if ANY_MAYJOR is supported, how does the AvailabilityHandler get triggered if there are different majVersion instances in the network?

virtual void request_service(service_t _service, unique_version_t _unique,
            major_version_t _major = ANY_MAJOR,
            minor_version_t _minor = ANY_MINOR,
            bool _use_exclusive_proxy = false) = 0;

@KareemLMR
Copy link

Hello @zhaoxin39913
Unfortunately the current patch set in case of using unique version to use the new feature of offering multiple instances with different major versions you have to request the service specifically by its major version
Using 0xFF as major won't work as expected in the current version but I was planning to fix that in another patch set just after checking your test results to know if it is the only thing missing before committing another change.
Have you tested it with requesting the specific major version and the rest of APIs?

@zhaoxin39913
Copy link
Author

Hi @KareemLMR ,

Currently I am only testing the client APIs which request different major versions for the same instance ID. It's working fine so far. I will continue to test those server APIs and keep you updated once my test is done.

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Jan 14, 2025

Hi @KareemLMR,

Update some test results here for the patch(let's call it 3.5.3p). Now I confirmed the server app can offer two major version instances for the same service/instance ID successfully. And the client app can also detect different version instances when registering different major version availability handlers.

However the basic request-response and event notification don't work in the patch. Here are my test setup:

The server app running on device B offers service 0x238/0x1 with version 4.1 and always sends response with payload data "Version4.1: Reply Cnt=X" for any methods. In the meantime it periodically sends event 0x4465/0x8778 with payload data "Version4.1: Event Cnt=X“ every 5s.
The client app running on device A requests service 0x238/0x1 and subscribes event group 0x4465 with major version 4 and always send request every 1s. And registers message handler to receive both response and event from device B.

Test Case1 (No response and event received): Both client app and server app are running with vsomeip 3.5.3p. The client app log is as below:

2025-01-14 16:19:08.551257  [info] Using configuration file: "/home/zhax/work/COVESA/multiple_majVersion_patch_src/config/vsomeip.json".
2025-01-14 16:19:08.553718  [info] Parsed vsomeip configuration in 1ms
2025-01-14 16:19:08.554187  [info] Configuration module loaded.
2025-01-14 16:19:08.554483  [info] Security disabled!
2025-01-14 16:19:08.554704  [info] Initializing vsomeip (3.5.3) application "request-sample".
2025-01-14 16:19:08.555695  [info] Instantiating routing manager [Host].
2025-01-14 16:19:08.560971  [info] create_routing_root: Routing root @ /tmp/vsomeip-0
2025-01-14 16:19:08.567016  [info] Service Discovery enabled. Trying to load module.
2025-01-14 16:19:08.587358  [info] Service Discovery module loaded.
2025-01-14 16:19:08.591667  [info] Application(request-sample, 0103) is initialized (11, 100).
2025-01-14 16:19:08.592841  [info] REQUEST(0103): [0238.0001:4.4294967295]
2025-01-14 16:19:08.602663  [info] create_local_server: Listening @ /tmp/vsomeip-103
2025-01-14 16:19:08.607122  [info] REGISTER EVENT(0103): [0238.0001.8778:is_provider=false]
2025-01-14 16:19:08.608108  [info] SUBSCRIBE(0103): [0238.0001.4465:ffff:4]
2025-01-14 16:19:08.608728  [info] Starting vsomeip application "request-sample" (0103) using 2 threads I/O nice 0
2025-01-14 16:19:08.611914  [debug] Thread created. Number of active threads for request-sample : 1
2025-01-14 16:19:08.613286  [info] main dispatch thread id from application: 0103 (request-sample) is: ffff90f5f060 TID: 6430
2025-01-14 16:19:08.614579  [info] Client [0103] routes unicast:192.168.225.3, netmask:255.255.255.0
Service [238.1:4] is NOT available.
2025-01-14 16:19:08.614740  [info] shutdown thread id from application: 0103 (request-sample) is: ffff9074f060 TID: 6431
2025-01-14 16:19:08.621289  [info] Watchdog is disabled!
2025-01-14 16:19:08.623689  [info] io thread id from application: 0103 (request-sample) is: ffff92c05020 TID: 6427
2025-01-14 16:19:08.623910  [info] io thread id from application: 0103 (request-sample) is: ffff8f72f060 TID: 6433
2025-01-14 16:19:08.625012  [info] vSomeIP 3.5.3 | (default)
2025-01-14 16:19:08.630391  [info] Network interface "eth0" state changed: up
2025-01-14 16:19:08.635098  [info] Route "default route (0.0.0.0/0) if: eth0 gw: 192.168.225.1" state changed: up
2025-01-14 16:19:08.639554  [debug] Joining to multicast group 224.0.0.1 from 192.168.225.3
2025-01-14 16:19:08.641245  [info] SOME/IP routing ready.
2025-01-14 16:19:08.644673  [info] udp_server_endpoint_impl<multicast>: SO_RCVBUF is: 212992 (1703936) local port:30490
2025-01-14 16:19:08.647025  [warning] Route "224.0.0.1/32 if: eth0 gw: n/a" state changed: up
2025-01-14 16:19:10.713993  [info] endpoint_manager_impl::create_remote_client: 192.168.225.1:13501 reliable: 0 using local port: 0
2025-01-14 16:19:10.716441  [info] udp_client_endpoint_impl::connect: SO_RCVBUF is: 212992 (1703936) local port:0 remote:192.168.225.1:13501
2025-01-14 16:19:10.718382  [debug] routing_manager_stub::on_offer_service: ON_OFFER_SERVICE(0000): [0238.0001:4.1]
Service [238.1:4] is available.
2025-01-14 16:19:10.522534  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0001
2025-01-14 16:19:11.527970  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0002
2025-01-14 16:19:12.533606  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0003
2025-01-14 16:19:13.539502  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0004
2025-01-14 16:19:14.545933  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0005

Test Case 2 (Only response can be received): Client app is running with vsomeip 3.4.10, server app is running with vsomeip 3.5.3p. The client app log is as below:

zhax@zhax-desktop:~/work/COVESA/src/vsomeip-3.4.10/build/examples$ ./request-sample 
2025-01-14 16:24:54.412258 [info] Using configuration file: "/home/zhax/work/COVESA/src/config/vsomeip.json".
2025-01-14 16:24:54.415145 [info] Parsed vsomeip configuration in 1ms
2025-01-14 16:24:54.415730 [info] Configuration module loaded.
2025-01-14 16:24:54.416294 [info] Security disabled!
2025-01-14 16:24:54.416635 [info] Initializing vsomeip (3.4.10) application "request-sample".
2025-01-14 16:24:54.419252 [info] Instantiating routing manager [Host].
2025-01-14 16:24:54.427170 [info] create_routing_root: Routing root @ /tmp/vsomeip-0
2025-01-14 16:24:54.431621 [info] Service Discovery enabled. Trying to load module.
2025-01-14 16:24:54.445042 [info] Service Discovery module loaded.
2025-01-14 16:24:54.447214 [info] Application(request-sample, 0103) is initialized (11, 100).
2025-01-14 16:24:54.448103 [info] REQUEST(0103): [0238.0001:4.4294967295]
2025-01-14 16:24:54.453231 [info] create_local_server: Listening @ /tmp/vsomeip-103
2025-01-14 16:24:54.455711 [info] REGISTER EVENT(0103): [0238.0001.8778:is_provider=false]
2025-01-14 16:24:54.456332 [info] SUBSCRIBE(0103): [0238.0001.4465:ffff:4]
2025-01-14 16:24:54.457042 [info] Starting vsomeip application "request-sample" (0103) using 2 threads I/O nice 255
2025-01-14 16:24:54.461310 [info] main dispatch thread id from application: 0103 (request-sample) is: ffffaa0ff060 TID: 6790
2025-01-14 16:24:54.463216 [info] Client [0103] routes unicast:192.168.225.3, netmask:255.255.255.0
2025-01-14 16:24:54.463377 [info] shutdown thread id from application: 0103 (request-sample) is: ffffa98ef060 TID: 6791
2025-01-14 16:24:54.471103 [info] Watchdog is disabled!
Service [238.1:4] is NOT available.
2025-01-14 16:24:54.475108 [info] io thread id from application: 0103 (request-sample) is: ffffabd8e020 TID: 6787
2025-01-14 16:24:54.475271 [info] io thread id from application: 0103 (request-sample) is: ffffa88cf060 TID: 6793
2025-01-14 16:24:54.480181 [info] vSomeIP 3.4.10 | (default)
2025-01-14 16:24:54.483180 [info] Network interface "eth0" state changed: up
2025-01-14 16:24:54.488397 [info] Route "default route (0.0.0.0/0) if: eth0 gw: 192.168.225.1" state changed: up
2025-01-14 16:24:54.493667 [info] udp_server_endpoint_impl: SO_RCVBUF is: 212992 (1703936) local port:30490
2025-01-14 16:24:54.495813 [debug] Joining to multicast group 224.0.0.1 from 192.168.225.3
2025-01-14 16:24:54.497831 [info] SOME/IP routing ready.
2025-01-14 16:24:54.502629 [warning] Route "224.0.0.1/32 if: eth0 gw: n/a" state changed: up
2025-01-14 16:24:54.502423 [info] udp_server_endpoint_impl<multicast>: SO_RCVBUF is: 212992 (1703936) local port:30490
2025-01-14 16:24:54.281767 [info] endpoint_manager_impl::create_remote_client: 192.168.225.1:13501 reliable: 0 using local port: 0
2025-01-14 16:24:54.286428 [info] udp_client_endpoint_impl::connect: SO_RCVBUF is: 212992 (1703936) local port:0 remote:192.168.225.1:13501
2025-01-14 16:24:54.289344 [warning] sd::get_eventgroup_reliability: couldn't determine eventgroup reliability type for [0238.0001.4465] using reliability type:  0002
Service [238.1:4] is available.
[Version4.1: Reply Cnt=12.]
[Version4.1: Reply Cnt=13.]
[Version4.1: Reply Cnt=14.]
[Version4.1: Reply Cnt=15.]
[Version4.1: Reply Cnt=16.]
[Version4.1: Reply Cnt=17.]
[Version4.1: Reply Cnt=18.]

Test Case 3 (Both reponse and event can be received) : Both client app and server app are running with vsomeip 3.4.10. The client app log is as below:

zhax@zhax-desktop:~/work/COVESA/src/vsomeip-3.4.10/build/examples$ ./request-sample 
2025-01-14 16:30:45.157989 [info] Using configuration file: "/home/zhax/work/COVESA/src/config/vsomeip.json".
2025-01-14 16:30:45.161198 [info] Parsed vsomeip configuration in 1ms
2025-01-14 16:30:45.162387 [info] Configuration module loaded.
2025-01-14 16:30:45.163487 [info] Security disabled!
2025-01-14 16:30:45.164094 [info] Initializing vsomeip (3.4.10) application "request-sample".
2025-01-14 16:30:45.165984 [info] Instantiating routing manager [Host].
2025-01-14 16:30:45.172830 [info] create_routing_root: Routing root @ /tmp/vsomeip-0
2025-01-14 16:30:45.177416 [info] Service Discovery enabled. Trying to load module.
2025-01-14 16:30:45.188069 [info] Service Discovery module loaded.
2025-01-14 16:30:45.191270 [info] Application(request-sample, 0103) is initialized (11, 100).
2025-01-14 16:30:45.192110 [info] REQUEST(0103): [0238.0001:4.4294967295]
2025-01-14 16:30:45.196348 [info] create_local_server: Listening @ /tmp/vsomeip-103
2025-01-14 16:30:45.198136 [info] REGISTER EVENT(0103): [0238.0001.8778:is_provider=false]
2025-01-14 16:30:45.198676 [info] SUBSCRIBE(0103): [0238.0001.4465:ffff:4]
2025-01-14 16:30:45.199385 [info] Starting vsomeip application "request-sample" (0103) using 2 threads I/O nice 255
2025-01-14 16:30:45.203263 [info] Client [0103] routes unicast:192.168.225.3, netmask:255.255.255.0
2025-01-14 16:30:45.202861 [info] main dispatch thread id from application: 0103 (request-sample) is: ffff8f62f060 TID: 6955
2025-01-14 16:30:45.203508 [info] shutdown thread id from application: 0103 (request-sample) is: ffff8ee1f060 TID: 6956
2025-01-14 16:30:45.208354 [info] Watchdog is disabled!
Service [238.1:4] is NOT available.
2025-01-14 16:30:45.210771 [info] io thread id from application: 0103 (request-sample) is: ffff912c6020 TID: 6952
2025-01-14 16:30:45.210966 [info] io thread id from application: 0103 (request-sample) is: ffff8ddff060 TID: 6958
2025-01-14 16:30:45.214122 [info] vSomeIP 3.4.10 | (default)
2025-01-14 16:30:45.216152 [info] Network interface "eth0" state changed: up
2025-01-14 16:30:45.219214 [info] Route "default route (0.0.0.0/0) if: eth0 gw: 192.168.225.1" state changed: up
2025-01-14 16:30:45.221233 [info] udp_server_endpoint_impl: SO_RCVBUF is: 212992 (1703936) local port:30490
2025-01-14 16:30:45.221956 [debug] Joining to multicast group 224.0.0.1 from 192.168.225.3
2025-01-14 16:30:45.222951 [info] SOME/IP routing ready.
2025-01-14 16:30:45.224761 [warning] Route "224.0.0.1/32 if: eth0 gw: n/a" state changed: up
2025-01-14 16:30:45.224955 [info] udp_server_endpoint_impl<multicast>: SO_RCVBUF is: 212992 (1703936) local port:30490
2025-01-14 16:30:45.232804 [info] endpoint_manager_impl::create_remote_client: 192.168.225.1:13501 reliable: 0 using local port: 0
2025-01-14 16:30:45.240254 [info] udp_client_endpoint_impl::connect: SO_RCVBUF is: 212992 (1703936) local port:0 remote:192.168.225.1:13501
2025-01-14 16:30:45.244899 [warning] sd::get_eventgroup_reliability: couldn't determine eventgroup reliability type for [0238.0001.4465] using reliability type:  0002
Service [238.1:4] is available.
[Version4.1: Reply Cnt=0.]
[Version4.1: Reply Cnt=1.]
[Version4.1: Reply Cnt=2.]
[Version4.1: Event Cnt=1.]
[Version4.1: Reply Cnt=3.]
[Version4.1: Reply Cnt=4.]
[Version4.1: Reply Cnt=5.]
[Version4.1: Reply Cnt=6.]
[Version4.1: Reply Cnt=7.]
[Version4.1: Event Cnt=2.]
[Version4.1: Reply Cnt=8.]
2025-01-14 16:30:55.215905 [info] vSomeIP 3.4.10 | (default)
[Version4.1: Reply Cnt=9.]
[Version4.1: Reply Cnt=10.]

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Jan 14, 2025

Hi @KareemLMR ,

Here is the my client app source code:

#include <vsomeip/vsomeip.hpp>
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <chrono>
#include <thread>
#include "sample-ids.hpp"

class requestSample
{
    public:
        requestSample() :
            app_(vsomeip::runtime::get()->create_application("request-sample")),
            service2Available_(false),
            service4Available_(false),
            sender_(std::bind(&requestSample::run, this))
        {
        }

	void init()
        {
            app_->init();
            app_->register_message_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID,vsomeip::ANY_METHOD,
               std::bind(&requestSample::on_message, this, std::placeholders::_1));

            request_ = vsomeip::runtime::get()->create_request();
            request_->set_service(SAMPLE_SERVICE_ID);
            request_->set_instance(SAMPLE_INSTANCE_ID);
            request_->set_method(SAMPLE_METHOD_ID);
            request_->set_reliable(false);

            app_->request_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, 0x4);
            app_->register_availability_handler(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID,
                std::bind(&requestSample::on_availability, this, 0x4,
                          std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), 0x4);

            std::set<vsomeip::eventgroup_t> its_groups;
            its_groups.insert(SAMPLE_EVENTGROUP_ID);
            app_->request_event(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENT_ID, its_groups);
            app_->subscribe(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENTGROUP_ID, 0x4);
        }

	void start()
        {
            app_->start();
        }

        void run()
        {
            while(1)
            {
                if (service2Available_)
                {
                    request_->set_interface_version(0x2);
                    app_->send(request_);
                }

                if (service4Available_)
                {
                    request_->set_interface_version(0x4);
                    app_->send(request_);
                }

                std::this_thread::sleep_for(std::chrono::milliseconds(1000));
            }
	}

        void on_message(const std::shared_ptr<vsomeip::message> & _response)
        {
            std::shared_ptr<vsomeip::payload> payload = _response->get_payload();
            vsomeip::length_t length = payload->get_length();
            const vsomeip::byte_t* data = payload->get_data();
            std::string response_str(data, data + length);

            std::cout << response_str  << std::endl;     
	}

        void on_availability(uint8_t majver, vsomeip::service_t service, vsomeip::instance_t instance, bool is_available)
        {
            std::cout << "Service ["
            << std::hex << std::setfill('0') << std::setw(4) <<  std::setw(2) << service << "." << instance << ":" <<  +majver << "] is "
	    << (is_available ? "available." : "NOT available.") << std::endl;

            if (majver == 0x2)
	    {
               if (is_available)
               {
                   service2Available_ = true;
               }
               else
               {
                   service2Available_ = false;
	       }
               return;
            }

            if (majver == 0x4)
            {
               if (is_available)
               {
                   service4Available_ = true;
               }
               else
               {
                   service4Available_ = false;
               }
               return;
            }	    
        }

    private:
        std::shared_ptr<vsomeip::application> app_;
        std::shared_ptr<vsomeip::message> request_;
        bool service2Available_;
        bool service4Available_;
        std::thread sender_;
};

int main()
{
    requestSample client;
    client.init();
    client.start();
    return 0;
}

@KareemLMR
Copy link

Hello @zhaoxin39913
I think I found the issue. I will share a fix for that with you today.

@KareemLMR
Copy link

Thank you for the feedback
I believe this should fix the issue: https://github.com/KareemLMR/vsomeip
Please try the test again and tell me the results but this time you will need to set the major version of the request in your code like this:
request_->set_instance(major)
Also the message handler availability_state_handler_t is now of type:
typedef std::function< void (service_t, unique_version_t, availability_state_e) > availability_state_handler_t;
instead of:
typedef std::function< void (service_t, instance_t, availability_state_e) > availability_state_handler_t;

And don't forget to use unique_version_t in APIs that need them in the latest patch I just shared with you.

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Jan 15, 2025

Thank you for the feedback I believe this should fix the issue: https://github.com/KareemLMR/vsomeip Please try the test again and tell me the results but this time you will need to set the major version of the request in your code like this: request_->set_instance(major) Also the message handler availability_state_handler_t is now of type: typedef std::function< void (service_t, unique_version_t, availability_state_e) > availability_state_handler_t; instead of: typedef std::function< void (service_t, instance_t, availability_state_e) > availability_state_handler_t;

And don't forget to use unique_version_t in APIs that need them in the latest patch I just shared with you.

Hi @KareemLMR ,

Thanks for your quick response. However, this is existing way we must support. In other word we need to keep the vsomeip API backward compatible in the patch, otherwise we will encounter regression issue, eg. COMMON API proxy/stub code is still using the existing vsomeip API. If we always introduce new API for existing feature, the COMMON API won't work, all related things need to be considered as well, then it will be a very big impact.

@KareemLMR
Copy link

KareemLMR commented Jan 15, 2025

I believe it is backward compatible as I didn't change any API in the last patch I shared. I said that last line just to confirm with you that you correctly used it from the older patch. You can even try it and tell me what you have found

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Jan 15, 2025

I believe it is backward compatible as I didn't change any API in the last patch I shared. I said that last line just to confirm with you that you correctly used it from the older patch. You can even try it and tell me what you have found

Thanks @KareemLMR , that's great! What I expect is the old APIs are still working in the network only has single major version instance. And we can use the new APIs to handle multiple major version instances.

I will test the new patch and keep you updated.

@zhaoxin39913
Copy link
Author

zhaoxin39913 commented Jan 16, 2025

Hi @KareemLMR,

Tested the second patch (3.5.3p2) you shared with client app(server app is still using 3.4.10), still see the same error log on client side:

2025-01-14 16:19:10.716441  [info] udp_client_endpoint_impl::connect: SO_RCVBUF is: 212992 (1703936) local port:0 remote:192.168.225.1:13501
2025-01-14 16:19:10.718382  [debug] routing_manager_stub::on_offer_service: ON_OFFER_SERVICE(0000): [0238.0001:4.1]
Service [238.1:4] is available.
2025-01-14 16:19:10.522534  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0001
2025-01-14 16:19:11.527970  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0002
2025-01-14 16:19:12.533606  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0003
2025-01-14 16:19:13.539502  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0004
2025-01-14 16:19:14.545933  [error] Routing info for remote service could not be found! (0103): [0238.0001.0421] 0005 

git log :

commit 531ca1f7aadd89568e4be41f8b5484e58f0e8ec3 (HEAD -> master, origin/master, origin/HEAD)
Author: Kareem Ibrahim <[email protected]>
Date:   Tue Jan 14 21:41:49 2025 +0200

    change instance_t type in sync_handler to unique_version_t.

commit d7b01668cb415ea6de6b4f39393da978cf3243ab
Author: Kareem Ibrahim <[email protected]>
Date:   Tue Jan 14 19:45:47 2025 +0200

    Fix request/response issue.

commit 59c8bb5db2644bdf0125c24ef5f8e88cf3e16c10
Author: Kareem Ibrahim <[email protected]>
Date:   Fri Dec 20 02:11:23 2024 +0200

    Support handling multiple services with the same service and instance IDs but different major version.

@KareemLMR
Copy link

Hello @zhaoxin39913
Just a question, did you set the major version in the response as I said in my last comment request_->set_instance(major)?

@KareemLMR
Copy link

KareemLMR commented Jan 16, 2025

I tried to reproduce that issue of "[error] Routing info for remote service could not be found!". It only happened if I didn't set the major version in request : request_->set_major_version(major). When I set it, everything works fine. So I said you might forgot it as it was not in the old API but unfortunately this change in the API can't be avoided as the old API only takes service and instance but if we have multiple services with same instance but different major version, the send API won't work (how will it differentiate between them). So I believe it is impossible to implement this feature without this change, do you think of something different?

We can negotiate about that if you have a different opinion, but can you try setting the major version as I told you just to check everything is fine?

In my opinion, I believe this change is inevitable as I told you. However, I think I made some unnecessary changes to the rest of the APIs making the user forced to know the definition of unique_version_t. I think it is better to return the rest of the APIs like offer_service, request_service, ... and so on back to their original form of accepting instance and major and to add major version with a default value of 0 to the APIs that didn't take them originally like release_service, ..etc and then the unique_version to be constructed inside the vsomeip code NOT by the user so it will be 100% compatible with the old API. But I won't be able to do anything regarding the request_->set_major_version(major). It is unavoidable.

If you agree with me. I can make these changes in another patchset but after you test the current version by setting major version in the request_ as I told you.

Image

@zhaoxin39913
Copy link
Author

Hi @KareemLMR,

vsomeip already has message API set_interface_version() to do the same thing, which is duplicate with set_major_version(). Can you confirm ?

@zhaoxin39913
Copy link
Author

Hello @zhaoxin39913 Just a question, did you set the major version in the response as I said in my last comment request_->set_instance(major)?

Hi @KareemLMR ,

vsomeip already has message API set_interface_version() to do the same thing, which is duplicate with set_major_version(). Can you confirm ?

@zhaoxin39913 zhaoxin39913 reopened this Jan 18, 2025
@KareemLMR
Copy link

I was thinking of that too. However, in the vsomeip code intervace_version was never used as major_version. They even have different types although both are uint8_t (interface_version_t and major_version_t). I tried to check the SOME/IP Specification Document, it is defined as "major version of the service interface" but in some requirments like this one attached below seems diffrent from the fixed service major version. It seems more like session id or protocol version so I am not sure so I didn't use it fearing it might not be known globally by vsomeip users that they are the same. However, anyway this will not affect my change much if we made sure both interface version and major version are the same. I will just replace the call of my newely defined method with this one in the code and it will be fine, if you confirm it works fine with my method set_major_version()

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants