Closed MultiName90 closed 1 year ago
DoIP used broadcast for the announcement, which is an IPv4 only concept. I would have to check, but I don't recall the spec describing using multicast for the the announcement messages. If it is multicast then yes, you need to "join" the group using socket.IP_ADD_MEMBERSHIP Or socket.IPV6_JOIN_GROUP
I expect that binding to the mcast address will probably also work on Linux as you found.
Ah, ok. That's not as awful as I thought:
8.DoIP-125 APP In the case of a vehicle announcement (not vehicle identification response), the UDP message shall always be sent with the target IPv4 address set to the limited broadcast address.
8.DoIP-155 APP In the case of a vehicle announcement (not the vehicle identification response), the UDP message shall always be sent with the target IPv6 address set to the link-local scope multicast address (FF02 16 ::1) as described in IETF RFC 2375.
In that case, if it's IPv6 we need to always join the ff02::1 group. If it's IPv4, still leave it up to the OS since it will be broadcast. The bummer about multicast is that it gets kind of painful on multi-homed computers. For IPv4 we just blindly use INADDR_ANY and, so long as the user setup their network masks properly, ultimately any broadcast messages that are decipherable as DoIP messages on any NIC will be handled.
So, I guess we need another optional parameter for "interface". If it's None, use the default and hope it's the same one as the ECU is connected to (unlikely, but it could happen). Otherwise, if it's an interface name use socket.if_nametoindex to get the index and subscribe.
Try the https://github.com/jacobschaer/python-doipclient/tree/multicast_vehicle_discovery
Branch and see. I don't have access to an IPv6 ECU.
Was this branch not sufficient to solve the Windows issues? I haven't had a chance to regression test for ipv4 yet, just curious if you had any luck.
at least for mi it was not working, meanwile im ussing a pyshark librarie to get this announcement msg
With pyshark are you running your python as an administrator? I feel like I'd still be suspicious of the firewall. But if you want to drop a pcap it might be useful. I'm really not sure why you're having no luck - maybe try with my most recent release.
On Windows its not read the multicast address ff02::1, and on Linux I have to bind the socket to the interface to recvfrom works