lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] netconn receive UDP via multicast address


From: Jens Nielsen
Subject: Re: [lwip-users] netconn receive UDP via multicast address
Date: Tue, 9 Jan 2018 21:38:40 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

Hi

Are you using the driver and libraries from ST? Are you sure you're actually receiving the packets and handing them over to lwip? I'm guessing this has nothing to do with lwip but you need to enable the reception of multicast frames in the hardware. In my case (based on some old drivers for STM32F4) this was off by default

Best regards
Jens

On 2018-01-09 21:11, Maarten Roozendaal wrote:

Goodday,

 

I am working on an implementation of lwip netconn api in combination with FreeRTOS. I use lwip version 2.0.0 on an STM32F7 microcontroller with FreeRTOS V9.0.0

I want to use lwip to receive UDP packets from a mullticast adress. 239.0.0.0 in this case.

 

The system running lwip is assigned a static ip adress, being 192.169.123.109.

 

When sending UDP packets to 192.169.123.109 directly I can process them and echo them back. However, I need to be able to read UDP packets send to the multicast ip adress 239.0.0.0. To accomplish this I use the following task:

 

static void vUDPnetconnTask(void *pvParameters)

{

  static struct netconn *conn;

  static struct netbuf *buf;

  ip_addr_t DestIPaddr, OwnAddr;

  err_t err, recv_err;

 

  LWIP_UNUSED_ARG(pvParameters);

 

  netif_default->flags = NETIF_FLAG_UP | NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP | NETIF_FLAG_IGMP;

  

  IP4_ADDR(&MulticastIPaddr, 239, 0, 0, 0);

  IP4_ADDR(&OwnAddr, 192, 168, 123, 109);

   

  conn = netconn_new(NETCONN_UDP);

  if (conn!= NULL)

  {

    netconn_bind(conn, IP_ADDR_ANY, 60004);  // returns ERR_OK

    err = netconn_join_leave_group(conn, &MulticastIPaddr, &OwnAddr, NETCONN_JOIN); // returns ERR_OK

    if (err == ERR_OK)

    {

      while (1)

      {

        recv_err = netconn_recv(conn, &buf);

      

        if (recv_err == ERR_OK)

        {

            // process the packet

        }

      }

    }

    else

    {

      netconn_delete(conn);

    }

  }

 

}

 

So, I bind to IP_ADDR_ANY using port 60004 (this is the port that the multicast address receives UDP packets on) and I use the function netconn_join_leave_group() to subribe to the multicast address.

 

I do not get any error returns but I do not receive any UDP packets send to 293.0.0.0.

 

I have been trying for a long time to get this to work but feel like I am missing something fundamental. Is there a way to accomplish what I need?

 

Help is very much appriciated!

 

Greetings,

 

Maarten



_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

[Prev in Thread] Current Thread [Next in Thread]