Follow ISO15118-2-2014,7.10.1.2 Supported ports
Baymax-Rob opened this issue · 0 comments
Baymax-Rob commented
The table 15-Supported UDP ports for SDP, the SDP client source port at the EVCC in the range of Dynamic ports(49152 - 65535).
I think it is necessary to add a line of code "sock.bind(("", randint(49152, 65535)))" in "evcc/transport/udp_clinet.py":
@staticmethod
def _create_socket(iface: str) -> socket.socket:
"""
This method creates an IPv6 socket configured to send multicast datagrams
"""
# Initialise the socket for IPv6 datagrams
# Address family (determines network layer protocol, here IPv6)
# Socket type (datagram, determines transport layer protocol UDP)
sock = socket.socket(family=socket.AF_INET6, type=socket.SOCK_DGRAM)
# Allows address to be reused
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# The socket needs to be configured with a time-to-live value (TTL)
# for messages to 1 so they do not go past the local network segment.
ttl = struct.pack("@i", 1)
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_HOPS, ttl)
# Restrict multicast operation to the given interface
# The IP_MULTICAST_IF or IPV6_MULTICAST_IF settings tell the socket
# which interface it shall send its multicast packets. It can be seen
# as the dual of bind(), in the server side, since bind() which controls
# interface(s) the socket receives multicast packets from.
interface_index = socket.if_nametoindex(iface)
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_IF, interface_index)
#Add
sock.bind(("", randint(49152, 65535)))