SSDP on W5500

Hello there, I am using the W5500 chip in a project where i need to implement SSDP device discovery. It appear that I have trouble receiving the neccesary Multicast frames on the W5500.
I am working with the standard Wiznet driver and other functionality i tested so far is fine.
To receive the multicast frames i opened a normal UDP socket after setting SIPR and SHAR to the relevant addresses. I first tried the multicast IP and MAC reserved for SSDP (MAC 01:00:5E:FF:FF:FA and IP 239.255.255.250. ), but no luck there. Subsequently i did the exact same test with addresses from a example from the forum (MAC 01:00:5E:01:01:0B and IP 211.1.1.11. ). This works correctly. So my question is: how can i listen to the specific multicast address for SSDP? Regards and thanx in advance.

In my earlier post I gave an erroneous MAC. It should be 01:00:5E:7F:FF:FA. That is the one I actually used. As said: it doesn’t work. Any help would be appreciated.
I also found a post telling me to write the multicast addresses to DHAR and DIPR. Also tried that, though it seems an odd thing to do for setting up frame reception. Anyway, that too does not work. Calling the recv_from function just locks the processor up. It probably gets stuck in a loop. Please advise…

Did you enable multicasting?
please refer to image.
you should enable multicasting before open the socket.

Yes I did, and i read back the Sn_MR register to be shure of it’s contents, being 0x82.

And I also did this before opening the socket.

Code looks like this (using standard Wiznet driver):

initialization:

for (i=0;i<6;i++) {NetInfo.mac[i] = src_mac_addr[i];} // set SHAR
for (i=0;i<4;i++) {NetInfo.ip[i] = src_ip[i];} // set SIPR
for (i=0;i<4;i++) {NetInfo.sn[i] = subnet[i];}
for (i=0;i<4;i++) {NetInfo.gw[i] = gateway[i];}
for (i=0;i<4;i++) {NetInfo.dns[i] = dns_srv[i];}
NetInfo.dhcp = NETINFO_STATIC;

wizchip_setnetinfo(&NetInfo); //

sdata2 = socket(1, Sn_MR_UDP, 3000, (SF_MULTI_ENABLE)); // UDP multicast

receive data in loop:

Rlength = recvfrom(1, Rbuf, 200, src_ip, RecPort); //

       if ((0 < Rlength) && (Rlength < 1500))       
            {  
            uint8_t i;
            
            for (i=0;i<Rlength;i++) 
                {
                sdata2 = Rbuf[i];
                putchar(sdata2);  
                }
                
            putchar(Rlength); 
            Rlength = 0;  
            
            sdata2 = *RecPort & 0x00FF;
            putchar(sdata2);
            sdata2 = ((*RecPort & 0xFF00) >> 8);        
            putchar(sdata2);
            }

Sloppy programming caused me to use the variable src_ip to store the incoming ip address in the recvfrom function, sorry for that; it works becaue this variable is not reused after initialization, but after creating a seperate variable forthe incoming ip address it should be:

//receive data in loop:

Rlength = recvfrom(1, Rbuf, 200, inc_ip, RecPort); //

       if ((0 < Rlength) && (Rlength < 1500))       
            {  
            uint8_t i;
            
            for (i=0;i<Rlength;i++) 
                {
                sdata2 = Rbuf[i];
                putchar(sdata2);  
                }
                
            putchar(Rlength); 
            Rlength = 0;  
            
            sdata2 = *RecPort & 0x00FF;
            putchar(sdata2);
            sdata2 = ((*RecPort & 0xFF00) >> 8);        
            putchar(sdata2);   
            
            sdata2 = inc_ip[0];   putchar(sdata2);  
            sdata2 = inc_ip[1];   putchar(sdata2);
            sdata2 = inc_ip[2];   putchar(sdata2);
            sdata2 = inc_ip[3];   putchar(sdata2);

            }

But still no clue on how to receive SSDP multicast frames…
Maybe a code example based on your driver?

Hi Becky,

i still have no clue on how to receive SSDP multicast messages with the W5500. As far as i can tell, the chip will perfectly receive regular UDP messages, but any attempt to receive something in the specific multicast IP ranges will not work. I posted the code i used (departing from the Wiznet driver) on the forum and asked for a reaction, but got no reaction so far. I have set the multicast bit in the socket mode register but to no avail.

Please take a look and comment on my approach. I can find no other sources from users that actually used the designated multicast IP ranges.

Is it possible at all in the W5500?

Merry Xmas by the way…

Hello,

As you said you should set Sn_DIPR and Sn_DPORT for multicast.
I think you need set Sn_DIPR and Sn_DPORT.
Sn_DIPR is a Multicast group IP Address.

wiz_NetInfo defaultNetInfo = { .mac = {0x00,0x08,0xdc,0xff,0xee,0xdd},
							.ip = {192,168,0,130},
							//.ip = {222,98,173,241},
							.sn = {255,255,255,0},
							.gw = {222,98,173,254},
							//.dns = {168, 126, 63, 1},
							.dns = {8, 8, 8, 8},
							.dhcp = NETINFO_STATIC};
uint8_t multicast_ip[4]={239,255,255,250}
uint16_t multicast_port=1900;
wizchip_setnetinfo(&defaultNetInfo);

setSn_DIPR(0, multicast_ip);
setSn_DPORT(0, multicast_port);
socket(sn, Sn_MR_UDP, port, Sn_MR_MULTI)


There are my test code and serial capture.
I guess you’re having trouble because set the multicast address to source ip address.
Please refer to GitHub - WIZnet-ioLibrary/W5x00-Multicast: The Multicast Example for W5X00 using ioLibrary

Thankyou

Hi Becky,

i have set up the chip for multicast traffic in the way you indicated. I can read back the DIPR, DHAR, PORT and DPORT values after opening the socket, as well as the correct snMR value for UDP multicast.

I have tried to read incoming multicast messages using the recvfrom function that comes with the Wiznet driver, but any call of this function will lock up the firmware immediately. It appears that everything gets stuck in the recvfrom function, probably in a loop.

Is the recvfrom function suitable for receiving multicast data? I figured this would be the case because this particular function is the normal way to receive UDP data.

I also re-evaluated the example from WizWiki: http://wizwiki.net/wiki/doku.php?id=products:w5500:application:udp_function#multicast

This doesn’t work either, but if I write the addresses to SHAR and SIPR instead of DHAR and DIPR, reception is normal. I think that in this particular example the given IP address is outside the normal multicast IP range. If i try the same trick with the multicast addresses for SSDP, it won’t work.

Can you please elaborate on how to actually read incoming data in multicast mode? As far as i can see, the recvfrom function is not the way to do it.

Thanks, Ruud.

Thanx Becky. I had missed the code example on Github, so please ignore my last question. I will have time to play with this by the end of the week and i will keep you informed