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

Pico W: Joining multicast group doesn't receive messages. #9105

Closed
jimmo opened this issue Aug 25, 2022 · 2 comments · Fixed by georgerobotics/cyw43-driver#25
Closed

Pico W: Joining multicast group doesn't receive messages. #9105

jimmo opened this issue Aug 25, 2022 · 2 comments · Fixed by georgerobotics/cyw43-driver#25
Labels

Comments

@jimmo
Copy link
Member

jimmo commented Aug 25, 2022

Originally reported in the forum: https://forum.micropython.org/viewtopic.php?f=21&t=12965

On the Pico W:

import struct, socket

def inet_aton(addr):
    return bytes(map(int, addr.split(".")))

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("", 5007))
s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, struct.pack(">4sI", inet_aton("224.1.1.1"), 0))
print(s.recvfrom(1024))

From a PC:

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
s.sendto(b'some data', ('224.1.1.1', 5007))
s.close()

This same code works fine when the receiving device is an ESP32. On the Pico nothing is received.

@jimmo jimmo added the bug label Aug 25, 2022
@felixdoerre
Copy link
Contributor

I can give an "explanation" for that, as I was just working on a similar issue: right now the cyw43-driver used for the network module only listens on its own mac address, the broadcast mac address, and one hardcoded one for mdns: https://github.com/georgerobotics/cyw43-driver/blob/main/src/cyw43_ll.c#L1888

For getting traffic directed to 224.1.1.1, you would need to listen to mac address 01:00:5e:01:01:01 which right now is not possible.

I've just added a PR to cyw43 (georgerobotics/cyw43-driver#24) to implement this mac filtering, together with ipv6 support.

For the v4 multicast, you'd probably also have to implement an igmp_mac_filter https://github.com/lwip-tcpip/lwip/blob/853258fff05badfe55ffd8f39a2a31b920310488/src/include/lwip/netif.h#L381, I'd imagine similar to the one I've implemented for ipv6: https://github.com/georgerobotics/cyw43-driver/pull/24/files#diff-64f03fc421199e03e0db4be6979491a5386b3463410d8e4eeb19517be3c5d4b9R131.

@jimmo
Copy link
Member Author

jimmo commented Aug 26, 2022

Thanks @felixdoerre !

I've done as you suggested and implemented the v4 side in georgerobotics/cyw43-driver#25
This fixes the original report from the forum. Thanks for the v6 PR!

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

Successfully merging a pull request may close this issue.

2 participants