vexed
Joined: 27 Oct 2013 Posts: 2
|
Posted: Wed Dec 16, 2015 6:58 am Post subject: Why should ttl be defaulted to 2? |
|
|
For upnpDiscover() there is a ttl parameter that the code comments say to use 2 as a default.
However, looking at the specs for IP_MULTICAST_TTL, all the documentation I have seen say that this should be 1.
Quote: |
6.2 IP_MULTICAST_TTL.
If not otherwise specified, multicast datagrams are sent with a default value of 1, to prevent them to be forwarded beyond the local network. To change the TTL to the value you desire (from 0 to 255), put that value into a variable (here I name it "ttl") and write somewhere in your program:
u_char ttl;
setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
The behavior with getsockopt() is similar to the one seen on IP_MULTICAST_LOOP.
|
This applies for both Windows & linux.
Quote: |
TTL Scope
----------------------------------------------------------------------
0 Restricted to the same host. Won't be output by any interface.
1 Restricted to the same subnet. Won't be forwarded by a router.
<32 Restricted to the same site, organization or department.
<64 Restricted to the same region.
<128 Restricted to the same continent.
<255 Unrestricted in scope. Global.
|
So, why do the code docs say the default should be 2?
Oh, and also, a value of 0 should throw an error/warning, since, as seen above, it won't go anywhere. |
|