# Listening for Multicast UDP packets

**URL:** <https://forums.freertos.org/t/listening-for-multicast-udp-packets/7894>\
**Category:** Kernel\
**Created:** [June 4, 2019, 8:05pm UTC](https://forums.freertos.org/t/listening-for-multicast-udp-packets/7894 "2019-06-04T20:05:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 4, 2019, 8:05pm UTC](https://forums.freertos.org/t/listening-for-multicast-udp-packets/7894/1 "2019-06-04T20:05:48Z")

</div>

**[larrydew](https://sourceforge.net/u/larrydew/)** wrote on [Tuesday, June 04, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/e717ebed84/#fd74):

How do I configure a socket to listen to a Multicast address range?

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [June 5, 2019, 1:06am UTC](https://forums.freertos.org/t/listening-for-multicast-udp-packets/7894/2 "2019-06-05T01:06:56Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Wednesday, June 05, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/e717ebed84/#e878):

Multicast is not yet available in FreeRTOS+TCP.

What it would need is a few changes:

Add some code in NetworkInterface.c to tell the NIC which multicast addresses you want to use. You will probably see code that allows the LLMNR multicast address 224.0.0.252 (01-00-5E-00-00-FC).  
Note that there are often two ways of filtering MAC-addresses: usually there is an array of e.g. 4 MAC-addresses. And sometimes there you can enter hash values (Multicast hash match).

Secondly: make sure that the library allows packets that have a multicast target address.  
This happens in `prvAllowIPPacket()`. Again you will see code that allow LLMNR traffic:

```auto
    #if( ipconfigUSE_LLMNR == 1 )
        /* Is it the LLMNR multicast address? */
        ( ulDestinationIPAddress != ipLLMNR_IP_ADDR ) &&
    #endif

```

And finally: the address resolution: when replying, make sure that the proper MAC address is found.  
Normally, MAC addresses are obtained in either of two ways: address couples are stored upon reception. So when you reply to a UDP message, the ARP table probably contains the IP-address of the peer.  
But when you’re the first one to send, an ARP request will be created to lookup the IP-address (and the first UDP packet will get lost). This will not work for Multicast. So that will need a change in the ARP lookup routine. You can read [here](https://networklessons.com/multicast/multicast-ip-address-to-mac-address-mapping) about IPv4 multicast address resolution.

After making the above changes, you can use an ordinary UDP socket to communicate.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 8, 2019, 3:55pm UTC](https://forums.freertos.org/t/listening-for-multicast-udp-packets/7894/3 "2019-06-08T15:55:05Z")

</div>

**[larrydew](https://sourceforge.net/u/larrydew/)** wrote on [Saturday, June 08, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/e717ebed84/#c00b):

Thanks
