I'm porting mdns into my embedded device(in C), it's not using socket but some raw packet tx.
And want to test it with avahi, so I run a virtualbox ubuntu, and build avahi so I can add debug message.
The device and ubuntu are on same local network, and able to ping each others.
The problem is avahi seems not receiving packets from device, I add messages just after avahi recvmsg(), so it's not even about if packet content is legit.
I can see my device sending mdns packets(224.0.0.251:5353), both on ubuntu tcpdump, and the host win10 wireshark (and those packets looks fine, at least wireshark shows no error columns).
On the other hand, avahi actually receives other mdns packets from same local network.
What's the potential problem of this?
So I finally found the problem.
Because I have to build packets from raw, and I made mistakes when calculating IP header checksum, the value is incorrect.
After fixing this bug, avahi socket can receive those packets.
Because wireshark default disable IP header checksum validation, so it shows no error at first glance.
And for some reason, tcpdump will also accept such packets.