1

I have a small microcontroller device that I program via USB using Python. The device has an Ethernet connection, which can be configured either with DHCP or by manually setting the IP/Subnet via USB. The device is connected to my local LAN using a very simple unmanaged switch.

My understanding is that in order for UDP multicast to work, the device needs to have its IP set, even though it's simply listening to a multicast group/port. This may seem counterintuitive.

Is there a way for UDP clients to listen to a multicast group/port without setting their own IP?

Or alternatively, is there a way to communicate with the device via Ethernet before its IP is set?

12
  • Where did you see that UDP multicast requires an IP ?
    – harrymc
    Commented Jul 17, 2023 at 20:03
  • My device is based on an RP2040 which runs Python (Micropython) on bare metal, so no OS. Micropython just deals with the Ethernet controller drivers directly. Your point is still valid though. One could use sockets directly without relying on network interfaces I guess.
    – Miki
    Commented Jul 17, 2023 at 20:04
  • 1
    @Miki I believe you have to tell it what interface to use for broadcast traffic like tcpdump -i eth0 -n udp. You might also have to specify ether broadcast or ether multicast, but I'm pretty sure that's just for filtering out.
    – Cpt.Whale
    Commented Jul 17, 2023 at 20:44
  • 1
    Use the actual multicast address like: echo -n 1234567890| ncat -vu 224.4.4.4 4444. serverfault.com/a/1062886/411612
    – Cpt.Whale
    Commented Jul 18, 2023 at 15:47
  • 1
    At that point, it's probably down to the drivers/micropython itself requiring an IP (which I know nothing about). Does it work if you assign it a random ipv6 address? enp2s0 is a newer-style systemd/udev "predictable" name freedesktop.org/wiki/Software/systemd/…. Those can usually be disabled or customized.
    – Cpt.Whale
    Commented Jul 19, 2023 at 16:05

1 Answer 1

0

Multicast is a broadcast protocol that doesn't need a destination IP address, only a port number, and it is delivered to all computers.

Multicasting will send an identical message to every member of a group. A group is identified by a multicast address. A multicast address must use the following IP address range: 224.0.0.0 through 239.255.255.255. The server will send a message marked with this address and clients must join the group before they can receive any multicast messages. This address itself is not a valid IP that can normally be used by any one computer and is only used as a tag to identify the group.

You can see an example of a client program in Simple listener.c program for UDP multicast.

3
  • Why the downvote ?
    – harrymc
    Commented Jul 17, 2023 at 21:03
  • Can you provide an example of how you would send/receive UDP packets, maybe using python or netcat/tcpdump or similar? Can you also describe the local network configuration required?
    – Miki
    Commented Jul 19, 2023 at 13:22
  • Programming is rather for StackOverflow. I'm just saying here that for receiving multicast all you need is the right socket, as you can well see in the example program. Even the IP_ADD_MEMBERSHIP call in the example only tells the switch/router that there is a listener for that group on this interface (some switches will not multicast to interfaces without listeners).
    – harrymc
    Commented Jul 19, 2023 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .