I am using C# .net framework 4.7. My application is trying to join a multicast group that's a few routers (hops) away. As a result, I am trying to send the IGMP packet with TTL > 1. Currently, I am using UdpClient.JoinMulticastGroup() with the TTL parameter set to 3, but when I examine the IGMP packet with Wireshark, the TTL stays at 1.
Here is my code
UdpClient udpClient = new UdpClient();
// Creates an IPAddress to use to join and drop the multicast group.
IPAddress multicastIpAddress = IPAddress.Parse("239.192.16.107");
udpClient.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.IpTimeToLive, 10);
udpClient.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 10);
udpClient.Ttl = 10;
// The packet dies after 10 router hops.
udpClient.JoinMulticastGroup(multicastIpAddress, 10);
The several posts online seems to suggest that IGMP is meant for local network, so TTL is always 1; however, if that's true, why would JoinMulticastGroup allow us to set the TTL? but on the other side, why would TTL not change when I set TTL to 3?
Could someone confirm if the multicast join packet (IGMP) can have a TTL value other than 1? If it can, then is there something missing in my code?
Update: I set TTL to 10, and Wireshark still shows TTL=1
The specified TTL only applies to outgoing multicast packets. From the Microsoft Docs under Remarks:
The timeToLive parameter specifies how many router hops will be allowed for a multicasted datagram before being discarded.
IGMP messages will always have a TTL of 1, as they only need to be received by the local router. The router will then send its own messages to other routers as necessary. See https://networkengineering.stackexchange.com/questions/9636/why-ttl-value-1-in-igmp for more details.