Closed kbssa closed 2 years ago
First, you have to understand Multicast and Multicast addresses by reading
Local subnetwork Addresses in the range of 224.0.0.0 to 224.0.0.255 are individually assigned by IANA and designated for multicasting on the local subnetwork only. For example, the Routing Information Protocol (RIPv2) uses 224.0.0.9, Open Shortest Path First (OSPF) uses 224.0.0.5 and 224.0.0.6, and Multicast DNS uses 224.0.0.251. Routers must not forward these messages outside the subnet from which they originate.
Some more examples how to use UDP Multicast
can be found in MDNS_Generic library
#define MDNS_SERVER_PORT (5353)
...
static IPAddress mdnsMulticastIPAddr = IPAddress(224, 0, 0, 251);
...
statusCode = this->_udp->beginMulticast(mdnsMulticastIPAddr, MDNS_SERVER_PORT);
Second, you have to at least follow the instructions when creating an issue, with critical information such as
because some Ethernet boards and libraries are not supporting Multicast at all.
Check UDP Multicast supported Ethernet modules / libraries
Without the necessary information, the vague issue will be ignored and deleted next time.
Good Luck,
Thanks for your fast reply.
Sorry about not providing the necessary information.
Board name and type - esp32 devkit v1 Ethernet board - W5500 Ethernet library - Ethernet
I made a mistake when I was typing the code here, the multicast address I placed is wrong, it is not 23,255,255,250, the correct is 239,255,255,250.
As I mentioned before, the multicast server is receiving all the packets, the problem is that it doesn't reply any message.
I have no idea on why it isn't working.
If you'd like to use UPnP / SSDP, try my UPnP_Generic library to be sure your system (router, network, etc.) is working OK.
https://github.com/khoih-prog/UPnP_Generic/blob/master/src/UPnP_Generic_Impl.h#L805-L852
#define UPNP_SSDP_PORT 1900
...
IPAddress ipMulti(239, 255, 255, 250); // multicast address for SSDP
...
bool UPnP::connectUDP()
{
#if UPNP_USING_ETHERNET
#if USE_BUILTIN_ETHERNET
#warning Using LAN8742A Ethernet and STM32Ethernet Lib in UPnP
// For STM32 built-in LAN8742A Ethernet using STM32Ethernet Lib
// initialize, start listening on specified port. IPAddress here must be local, not ipMulti address
// virtual uint8_t beginMulticast(IPAddress, uint16_t);
if (_udpClient.beginMulticast(Ethernet.localIP(), UPNP_SSDP_PORT))
{
return true;
}
#else
// initialize, start listening on specified port.
// virtual uint8_t beginMulticast(IPAddress, uint16_t);
if (_udpClient.beginMulticast(ipMulti, UPNP_SSDP_PORT))
{
return true;
}
#endif
#elif UPNP_USING_WT32_ETH01
if (_udpClient.beginMulticast(ipMulti, UPNP_SSDP_PORT))
{
return true;
}
#else
#if defined(ESP8266)
if (_udpClient.beginMulticast(WiFi.localIP(), ipMulti, UPNP_SSDP_PORT))
{
return true;
}
#else
if (_udpClient.beginMulticast(ipMulti, UPNP_SSDP_PORT))
{
return true;
}
#endif
#endif //UPNP_USING_ETHERNET
//UPNP_LOGINFO(F("UDP connection failed"));
UPNP_LOGINFO0(F("F"));
return false;
}
Hello,
I am trying to make the UdpSendReceive example work in Multicast mode, it receive all the packets I send, but it never sends the reply message.
The unicast mode works as it should.
I just changed the line Udp.begin(localPort); to Udp.beginMulticast(IPAddress(23,255,255,250),1900);
Is there something missing in the code to make the multicast works ?