Original link http://f0g.is-programmer.com/posts/5458.html
These two days have been overwhelmed by IGMP proxy, sometimes working, sometimes not working. Finally, I am very worried aboutCodeI finally found the problem and summarized it.
The principle of IGMP proxy is to receive IGMP Report on the downstream interface, and then broadcast it from the upstream interface. At the same time, add the corresponding Virtual Interface (vif) on the router) ). Finally, the multicast packet received from the upstream interface can be sent to the network corresponding to the downstream interface.
In the standard Linux kernel implementation, when the MFC (Multicast forward cache) Table is added, a hash value is generated by using the src ip and dest ip (that is, the Group IP) as the index. However, because the IGMP proxy must process all the SRC Ip's multicast packages (add the MFC entry), the hash method must be modified, for example, in my kernel, the Dest IP and interface index are used to generate the hash. Of course, you can also use other functions to ensure that the kernel corresponds to the app.
During the test, I found that there were too few test tools available. I only found a Microsoft tool on Windows. To facilitate future tests, I wrote another one myself. The tool is simple. It provides two functions: sending a multicast UDP packet and receiving a multicast UDP packet. Note that you must set ip_multicast_ttl to modify the TTL value of the IP package during packet sending. Otherwise, the default TTL of Linux is 1, and the router is lost. In addition, ethereal is untrusted and always tells me that the checksum error is actually good.
These two days have been overwhelmed by IGMP proxy, sometimes working, sometimes not working. Finally, I found the problem by turning out the code and finally finding out the problem.
The principle of IGMP proxy is to receive IGMP Report on the downstream interface, and then broadcast it from the upstream interface. At the same time, add the corresponding Virtual Interface (vif) on the router) ). Finally, the multicast packet received from the upstream interface can be sent to the network corresponding to the downstream interface.
In the standard Linux kernel implementation, when the MFC (Multicast forward cache) Table is added, a hash value is generated by using the src ip and dest ip (that is, the Group IP) as the index. However, because the IGMP proxy must process all the SRC Ip's multicast packages (add the MFC entry), the hash method must be modified, for example, in my kernel, the Dest IP and interface index are used to generate the hash. Of course, you can also use other functions to ensure that the kernel corresponds to the app.
During the test, I found that there were too few test tools available. I only found a Microsoft tool on Windows. To facilitate future tests, I wrote another one myself. The tool is simple. It provides two functions: sending a multicast UDP packet and receiving a multicast UDP packet. Note that you must set ip_multicast_ttl to modify the TTL value of the IP package during packet sending. Otherwise, the default TTL of Linux is 1, and the router is lost. In addition, ethereal is untrusted and always tells me that the checksum error is actually good.