Minimum TTL with and without Relays

I'm hoping someone can clarify something rather fundamental regarding TTL as I'm getting conflicting answers.

Imagine a simple scenario where we have 2 nodes and a gateway in a straight line such that node 1 is within range of the gateway and node 2 is within range of node 1 but out of range of the gateway.  Node 1 is set to be a relay. Node 2 is not a relay.

So something like this:

[Gateway] - - - - - - - - - - - - - - - - - - [node 1 (relay)] - - - - - - - - - - - - - - - - - - [node 2]

Messages from node 1 will go directly to the gateway. Messages from node 2 must be relayed via node 1.

My question is simple: what is the minimum TTL setting for messages originating at node 1 and messages originating at node 2? 


Node 1: My expectation is that since Node 1 is a single "hop" from the gateway, TTL should be set to 1. However, some references seem to imply it should be set to zero.

Node 2: Node 2 must use node 1 as a relay. Given that it is one "hop" from node 2 to node 1, and another "hop" from node 1 to the gateway, I would expect TTL to be 2. However, some references imply that a relay will only relay a message if TTL is greater than or equal to 2, so the message must have a TTL of 2 when it arrives at node 1, implying that it must start with TTL equal to 3.

What is the correct answer?

Parents
  • Hi Nicholas,

    I was a bit uncertain myself actually. It does sound right that a TTL of 1 would allow for one hop, but no, the code is right.

    The Mesh spec is the place to go when you are getting conflicting answers. TTL is described in a simple way in 3.4.4.4 "TTL":

    The TTL field is a 7-bit field. The following values are defined:

    • 0 = has not been relayed and will not be relayed

    • 1 = may have been relayed, but will not be relayed

    • 2 to 126 = may have been relayed and can be relayed

    • 127 = has not been relayed and can be relayed

    The initial value of this field is set by the transmitting layer (lower transport layer, upper transport layer, access, foundation model, model) or an application and used by the network layer when operating as a Relay node.

    The use of the TTL value of zero allows a node to transmit a Network PDU that it knows will not be relayed, and therefore the receiving node can determine that the sending node is a single radio link away. The use of a TTL value of one or larger cannot be used for such a determination.

    Btw, I see that you are using nRF5 SDK for Mesh. I would recommend you to switch to NCS if you can.

    Regards,

    Elfving

  • Hi Elfving,

    Thanks for your answer.

    For the sake of absolute clarity, what about a node that is within range of a gateway i.e. node 1 in my scenario ??

    Messages from node 1 do not need to be relayed,  but they do need to be transmitted. I would expect that if TTL was zero, the message simply would not go anywhere, but maybe that is not the case. 

    Can messages originating from node 1 have a TTL of zero? Or must they have a TTL of 1?

    Thanks for your help.

    P.s. We do plan on switching to NCS, but we want to get the current code/device shipped before we do add we suspect it will take some time. 

Reply
  • Hi Elfving,

    Thanks for your answer.

    For the sake of absolute clarity, what about a node that is within range of a gateway i.e. node 1 in my scenario ??

    Messages from node 1 do not need to be relayed,  but they do need to be transmitted. I would expect that if TTL was zero, the message simply would not go anywhere, but maybe that is not the case. 

    Can messages originating from node 1 have a TTL of zero? Or must they have a TTL of 1?

    Thanks for your help.

    P.s. We do plan on switching to NCS, but we want to get the current code/device shipped before we do add we suspect it will take some time. 

Children
  • NickN said:

    Messages from node 1 do not need to be relayed,  but they do need to be transmitted. I would expect that if TTL was zero, the message simply would not go anywhere, but maybe that is not the case. 

    As it says in the spec: The use of the TTL value of zero allows a node to transmit a Network PDU that it knows will not be relayed, and therefore the receiving node can determine that the sending node is a single radio link away.

    My understanding is that if a TTL of 0 was used, the messages would still be transmitted. So Node 1 could send a message with TTL of 0 to the gateway. They could also have a TTL of 1 and be used the same way, but with a TTL of 0 you get the additional feature of the Gateway knowing that it came from node 1. 

    NickN said:
    P.s. We do plan on switching to NCS, but we want to get the current code/device shipped before we do add we suspect it will take some time

    Understandable. Just checking.

    Regards,

    Elfving

  • So in conclusion:

    A node that is in range of the gateway can send messages with TTL=0 and they will be successfully transmitted to the gateway. In addition, the gateway will know which node the message came from because the message can only have made one "hop" to get there.

    A node that is out of range of the gateway and needs a message to be relayed must have a minimum value of TTL=2. More generally, the message must have a TTL>=2 at the last relay before the gateway. Messages arriving at a relay with TTL=1 or TTL=0 will not be relayed.

    So in the simplified system we started with, node 1 can send its own messages with TTL=0 and node 2 would need its messages to have TTL=2 to successfully reach the gateway.

    Thank you for the clarity!

  • No problem Nicholas, 

    Please let us know if there is anything else.

    Regards and happy holidays,

    Elfving

Related