WIZnet Developer Forum

Is it possible to send Multicast UDP without Joining a group?

In my application, I need to receive multicast UDP from one multicast group, and send multicast UDP on another multicast group. I want to send Multicast UDP without joining the group it is being sent to (receiving is OK). I was following the instructions at wizwiki.net/wiki/doku.php?id=pro … #multicast where it says:

[quote]In the W5500, IGMP processing to register the multicast-group is internally (automatically) processed. When the user opens the Socket n with multicast mode, the “Join” message is internally transmitted… [/quote]which implies you don’t have control over the IGMP requests. For reference, I’ve been using Wiznet’s ioLibrary with the W5500. I first tried using the receive socket to send to a different multicast group, which didn’t work (it sends it to the currently joined multicast group). I then made two different sockets, one for receiving and one for sending. The code to open the socket is like this:

//open the socket in UDP mode, with flag set to enable multicasting (RECV SOCKET) setSn_DHAR(sn, test_mac); setSn_DIPR(sn, test_ip); setSn_DPORT(sn, PD_DESTINATION_PORT); ret = socket(sn, Sn_MR_UDP, PD_DESTINATION_PORT, SF_MULTI_ENABLE); //check for errors //open another port to reply on (SEND SOCKET) setSn_DHAR(tx_sn, tx_mac); setSn_DIPR(tx_sn, tx_multi_ip); setSn_DPORT(tx_sn, PD_DESTINATION_PORT); ret = socket(tx_sn, Sn_MR_UDP, PD_DESTINATION_PORT, SF_MULTI_ENABLE); //check for errors

 //recv function call
 if(getSn_RX_RSR(sn); > 0)
 	int32_t ret = recvfrom(sn, send_recv_buffer, size, test_ip, (uint16_t*)&destport);
 
 //send function call
 while(sentsize != tos_reply_size) {
 	int32_t ret = sendto(tx_sn, send_recv_buffer+sentsize, reply_size-sentsize, tx_multi_ip, PD_DESTINATION_PORT); 
	 sentsize += ret;
 }

I also tried making a “normal” socket without the “SF_MULTI_ENABLE” flag and sending to a multicast group, but it gave an error when sending (timeout I think). I’ll investigate this further tomorrow.

My question is, is it possible send multicast packets on a group without joining that group on the w5500?. If not, is it possible to use the MACRAW mode (it says somewhere in the documentation you can’t use IPRAW mode to send UDP packets)? Hopefully I’m just misunderstanding something in how the multicast works.

edit: I just noticed the “SEND_MAC” option for UDP mode. I’ll try to manually configure the Sn_DHAR hardware address to the appropriate multicast MAC and send using “SEND_MAC” and see if it works tomorrow.

I enabled the “SEND_MAC” option by making a copy of the socket() function and changing the setSn_CR() call:

//Inside the socket(...) function, used to be setSn_CR(sn,Sn_CR_SEND); //Changed to setSn_CR(sn,Sn_CR_SEND_MAC);
This seems to have worked.

I think what was happening before was that it would try to ARP the multicast group as if it were a normal ip address? or something and time out. By using SEND_MAC and specifying the MAC address there is no ARP, so it gets sent successfully.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.