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

How to choose network interface for DoIp client #44

Open
sylvtellier opened this issue Nov 3, 2023 · 2 comments
Open

How to choose network interface for DoIp client #44

sylvtellier opened this issue Nov 3, 2023 · 2 comments

Comments

@sylvtellier
Copy link

sylvtellier commented Nov 3, 2023

Hello everyone.

Many thanks for this package which works perfectly with udsoncan to connect to an ECU using DoIp.

However, I am encountering a problem choosing the network interface to use to create the DoIPClient client.

I have a classic internal network card and a USB/Ethernet adapter on my computer. My ECU supporting Doip is plugged to the usb/ethernet adapter. The network card is used for other communication.
When I simply create my client (as in this package's documentation : address, announcement = DoIPClient.get_entity()), the VehicleIdentificationRequest is sent by default to my internal ethernet card.

I would like this request to go to my usb/ethernet adapter.

If I deactivate the internal network card via the Windows control panel, the VehicleIdentificationRequest goes to my usb/ethernet adapter and I correctly receive the response from my ECU with its IP address, its port and its logical address.

How can we define the communication interface of the DoIP client?

Thanks for your help

@sylvtellier
Copy link
Author

sylvtellier commented Nov 3, 2023

re,

I just found my answer using your answer located here :
https://github.com/jacobschaer/python-doipclient/issues/33

I didn't understand your answer on first reading.
By modifying the line:
sock.bind(("", udp_port))
and replacing the "" by IP address of my usb/ethernet adapter, I solved the problem.
I also manually put this address in my interface settings.
My problem is solved now. On the other hand, it requires me to always use this address for all our adapters on different computers connected to the diagnostic gateway.

what bothers me is that I modified your package to achieve my ends. I don't know if it was the best thing to do.

Maybe you have an opinion or a better solution without modifying your package?

@jacobschaer
Copy link
Owner

The intention is that your network interface should be associated with an IP in the correct subnet so that the OS will deliver broadcast packets to it. If your NIC isn't in the correct subnet then I wouldn't expect get_entity() to work. For IPv6 with multicast, it's a little more complicated as IGMP requires specifying a source interface anyways hence we allow the user to pass in their desired interface. But in general it's better to let the OS handle such things.

An argument could be made to having get_entity() and await_vehicle_announcement() accept a client_ip specifically for IPV4 that defaults to None - if it's None use INADDR_ANY (""). It's somewhat confusing for IPV6 though as the source_interface and client_ip could potentially not match

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

No branches or pull requests

2 participants