UDP Multicast is a communication method that sends a single data packet to multiple receivers in a multicast group, using the network more efficiently than unicast or broadcast.
Key Features:
Efficient data distribution to multiple receivers.
No acknowledgment or retransmission (best effort).
Common Use Cases:
Streaming Media: Live video or audio broadcasting (e.g., IPTV).
Gaming: Real-time multiplayer game updates.
Financial Systems: Market data distribution.
IoT Systems: Device synchronization or firmware updates.
Disaster Alert Systems: Emergency notifications to multiple devices
IPv4 Multicast Address Range : 224.0.0.0 ~ 239.255.255.255 This range is reserved for multicast communication and can be divided as follows:
224.0.0.0 ~ 224.0.0.255: Local Network Multicast Limited to the same subnet and does not traverse routers.
239.0.0.0 ~ 239.255.255.255: Organization-specific Multicast Used within private networks and can be configured like unicast addresses.
Set up
In this WCC, the W55RP20-EVB-Pico will function as the UDP multicast sender, so several socket configurations will be made.
The receivers used include the W5500-EVB-Pico, W5100S-EVB-Pico, W5500-EVB-Pico2, and a smartphone.
Additionally, since the multicast will be performed within the local network, the TTL is set to 1,
setSn_TTL(SOCKET_ID, 1); // set TTL (1 : local)
and the address is configured in the 224.0.0.1 range.
static uint8_t multicast_ip[4] = {224, 0, 0, 6}; // multicast ip address
static uint16_t multicast_port = 29999; // multicast port
The multicast IP and port configured are set as the destination as follows.
setSn_DIPR(SOCKET_ID, multicast_ip); // destination IP 설정
setSn_DPORT(SOCKET_ID, multicast_port); // destination port 설정
Multicast differs from standard ARP(Address Resolution Protocol) usage in that a specific IP address is shared by multiple receivers. Since multicast IP addresses are directly converted to MAC addresses, ARP is not required.
Therefore, the MAC address is converted as follows
uint8_t multicast_mac[6] = {
0x01, 0x00, 0x5e, // First 3 bytes of the multicast MAC address
multicast_ip[2] & 0x7f, // Last 23 bits of the IP address(first 7 bits of 224~239 : 1)
multicast_ip[3], // Last 2 bytes of the IP address
0x00 // Remaining byte is set to 0
};
and configured accordingly.
// Set the MAC address (DHAR: Socket n Destination Hardware Address Register)
setSn_DHAR(SOCKET_ID, multicast_mac);
// Skip ARP (Address Resolution Protocol) and directly set the MAC address
setSn_CR(SOCKET_ID, Sn_CR_SEND_MAC);
The execution screen of the sender is as follows. When a rising edge is detected on a specific GPIO, the message is sent.
The UDP multicast receiver was implemented with reference to the code below, and the smartphone was connected to the same Wi-Fi network, using the tester app for testing.