IGMP小结(2)

20190831

以前写过一个小结关于LWIP的IGMP阶段性小结。这次呢,当然希望更深入一些。

(1)在lwipopts.h里面加上

#define LWIP_IGMP             1
#define LWIP_RAND             lwip_rand

然后建立一个lwip_rand函数

(2)添加igmp_init函数

(3)添加 

if ((localtime - IGMPTimer) >= IGMP_TMR_INTERVAL)
  {
    IGMPTimer =  localtime;
        igmp_tmr();
  }

(4)在low_level_init函数里面添加

netif->flags |= NETIF_FLAG_IGMP;

(5)在ETH_MACDMA_Config函数里面把

ETH_InitStructure.ETH_MulticastFramesFilter = ETH_MulticastFramesFilter_Perfect;改为

ETH_InitStructure.ETH_MulticastFramesFilter = ETH_MulticastFramesFilter_None;

为什么要改?在文档AN3411里面有

在这里也有相关https://stackoverflow.com/questions/23259594/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

3 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.

----------------------------------------------------------

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.

----------------------------------------------------------------------------------

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.

 

 



 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值