Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

join igmp_group not working in lightwight IP (lwip)

I'm new to lwip, and I want to create a multicast receiver with lwip. My steps are as follow: 1. Enable LWIP_IGMP; 2. Set NETIF_FLAG_IGMP in low_level_init(); 3. Join multicast group, create and bind pcb; 4. udp_connect to remote_ip (or multicast IP address? Both are tried but failed)

Joining group returns success, and everything looks fine when program executing this. However the multicast receiver doesn't work, no multicast data comes into network interface. Seems I don't actually join my receiver to the igmp group, although the joining process looks fine. Does any one know what I'm missing?

I found "netif->igmp_mac_filter != NULL" in igmp_joingroup(), but this callback is set as NULL and not implemented. Do I need to implement it by myself to set the MAC filter or it is OK just leave it as NULL?

Thanks a lot for your help!

Ryan

like image 748
user3567175 Avatar asked Apr 24 '14 04:04

user3567175


4 Answers

When you join a multicast group the netif->igmp_mac_filter callback is typically called to configure a MAC filter in your Ethernet controller to accept packets with the multicast MAC address corresponding to the group. So, depending on the Ethernet H/W that you are using you may need to implement the callback.

like image 191
stathisv Avatar answered Nov 01 '22 16:11

stathisv


The hardware needs to be configured to receive multcast MAC frames, otherwise it will simply discard all frames with multicast destination address. There is probably an option to accept all incoming multicast frames. Enable that in low_level_init() and you should be able to see the incoming multicast frames. You shouldn't need to implement any filter.

like image 28
Fredrik Möller Avatar answered Nov 01 '22 16:11

Fredrik Möller


I had the same problem. I solved it removing the ETH Multicast Frame filter in the init of the MAC interface. To test, you can also set the interface in promiscuous mode, check if the multicast packet are received an then remove the promiscuous mode and set an appropriate Multicast Frame Filtering mode according to your needs.

like image 32
peregrinus Avatar answered Nov 01 '22 16:11

peregrinus


I set the code for Multicast Frame Filter as follows:

/* USER CODE BEGIN PHY_PRE_CONFIG */
  ETH_MACFilterConfigTypeDef FilterConfig;

  FilterConfig.PromiscuousMode = 1;
  FilterConfig.PassAllMulticast = 1;

  HAL_ETH_SetMACFilterConfig(&heth, &FilterConfig);

/* USER CODE END PHY_PRE_CONFIG */
like image 1
JongOk Baek Avatar answered Nov 01 '22 17:11

JongOk Baek