Update: 2021-02-07

Beim Multicast muss die lokale IP-Adresse der Empfänger nicht bekannt sein.
Für Multicast ist in IPv4 der Adress-Bereich 224.0.0.0 bis 239.255.255.255 reserviert.
Die Adresse ist frei wählbar, muss aber auf allen Esp Boards welche die Nachricht empfangen sollen gleich sein.

Client und Server können im selben Webserversketch verwendet werden.

Esp8266 UDP Multicast senden als Arduino Tab.

MulticastClient.ino

// ****************************************************************
// Sketch Esp8266 UDP Multicast Client Modular(Tab)
// created: Jens Fleischer, 2021-02-03
// last mod: Jens Fleischer, 2021-02-03
// For more information visit: https://fipsok.de
// ****************************************************************
// Hardware: Esp8266
// Software: Esp8266 Arduino Core 2.7.0 - 2.7.4
// Getestet auf: Nodemcu, Wemos D1 Mini Pro
/******************************************************************
  Copyright (c) 2021 Jens Fleischer. All rights reserved.

  This file is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This file is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
*******************************************************************/
// Die Übergabe der Nachricht an "sendMulticast("Nachricht");" erfolgt als C-String.
/**************************************************************************************/


void sendMulticast(const char* message) {
  IPAddress multicastIP(230, 120, 10, 1);                  // Sendet an alle Netzwerkteilnehmer mit dieser Multicastadresse
  constexpr uint16_t PORT = 8266;                          // und diesem UDP Port.
  WiFiUDP Multicast;
  Multicast.beginPacketMulticast(multicastIP, PORT, WiFi.localIP());
  Multicast.print(message);
  Multicast.endPacket();
}

Der Aufruf der Funktion UDP senden ist nach ausführen von "Connect();" möglich.
Du kannst "sendMulticast();" überall in deinem Sketch einbinden.

Beispiel:

****************** UDP senden **********************

sendMulticast(localTime().c_str());                 // Datum und Uhrzeit
char str[8];
sendMulticast(itoa((millis() / 1000),str,10));      // Laufzeit des Esp... in Sekunden

Beispiel:

***************** UDP im Setup *********************

void setup() {
 Connect();
 .........
char str[43];
snprintf(str,sizeof(str), "Start Esp8266 mit der IP: %d.%d.%d.%d", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
sendMulticast(str);
 ......
}
Beispiel:

********** Esp8266 sendet Lebenszeichen ************

void loop() {
 ......
 .........
  static uint32_t previousMillis;
  constexpr uint32_t INTERVAL (1000UL * 5);                // Interval in Sekunden einstellen.
  if (millis() - previousMillis >= INTERVAL) {
    previousMillis += INTERVAL;
    const char* vivit = "Ich bin noch da!";
    sendMulticast(vivit);
  }
 ......
}

Esp8266 UDP Multicast empfangen als Arduino Tab.

MulticastServer.ino

// ****************************************************************
// Sketch Esp8266 UDP Multicast Server Modular(Tab)
// created: Jens Fleischer, 2021-02-17
// last mod: Jens Fleischer, 2021-02-20
// For more information visit: https://fipsok.de
// ****************************************************************
// Hardware: Esp8266
// Software: Esp8266 Arduino Core 2.6.1 - 2.7.4
// Getestet auf: Nodemcu, Wemos D1 Mini Pro
/******************************************************************
  Copyright (c) 2021 Jens Fleischer. All rights reserved.

  This file is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This file is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
*******************************************************************/
// Diese Version von UDP Multicast Server sollte als Tab eingebunden werden.
// #include <ESP8266WebServer.h> oder #include <ESP8266WiFi.h> muss im Haupttab aufgerufen werden
// Die Funktion "setupUdpMulticast();" muss im Setup eingebunden werden.
// Um zu empfangen muss die Funktion "multicastServer();" im loop(); aufgerufen werden.
// Die "WiFiUdp.h" wird durch "ArduinoOTA.h" im Webserver Tab includiert.
/**************************************************************************************/

#include <WiFiUdp.h>

WiFiUDP Multicast;

IPAddress multicastIP(230, 120, 10, 1);                        // Sendet an alle Netzwerkteilnehmer mit dieser Multicastadresse
constexpr uint16_t PORT = 8266;                                // und diesem UDP Port.
char multicastBuffer[255];                                     // Puffer für eingehendes Paket.

void setupUdpMulticast() {
  Multicast.beginMulticast(WiFi.localIP(), multicastIP, PORT);
}

void multicastServer() {
  uint16_t packetSize = Multicast.parsePacket();               // Eingehende UDP-Pakete empfangen.
  if (packetSize) {                                            // Prüfen ob UDP-Pakete empfangen wurden.
    Multicast.read(multicastBuffer, sizeof(multicastBuffer));  // Einlesen des UDP Paket in den Bufffer.
    multicastBuffer[packetSize] = 0;                           // String Ende hinzufügen.
    Serial.println(multicastBuffer);                           // Visualisierung des empfangenen Packets.
    // Optional eine Unicast Antwort senden das daß Paket empfangen wurde.
    if (unsigned (Multicast.destinationIP()[0] - 224) <= (239 - 224)) {
      Multicast.beginPacket(Multicast.remoteIP(), PORT);
      Multicast.print(WiFi.hostname() + " Multicast bekam das Packet!");
      Multicast.endPacket();
    }
  }
}