Encode the timeout option
01EDNS(0), the Extension Mechanisms for DNS, carries options inside an OPT pseudo-record. The keepalive option carries a server-selected idle timeout for an existing TCP connection.
Zero requests that the connection be closed after outstanding answers arrive. Hexadecimal ff ff represents 65535 units = 6553.5 seconds, the field’s encoding ceiling rather than a recommended policy.
Source for this drawing: RFC 7828 · Read RFC section 3.1 ↗
New to this? Start hereA quick picture + helpful background
A message needs an address.
Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
Use code 11 and count timeout units correctly.
- OPTION-CODE is 11. OPTION-LENGTH counts only the option data: 0 when TIMEOUT is omitted, 2 when the two-byte TIMEOUT is present.
- Clients MUST use length 0 and omit TIMEOUT. Servers including this option MUST specify the TIMEOUT currently associated with the TCP session.
- TIMEOUT is an unsigned two-byte value in network byte order, measured in units of 100 milliseconds: ten units make one second. The drawings show this option alone, not a complete DNS message or TCP length prefix.
Hexadecimal bytes use digits 0–9 and a–f. Network byte order places the high byte first. A timeout of 600 is a chosen example, not an RFC default. The maximum encoded value is 65535 units, or 6553.5 seconds; zero has a distinct close-request meaning. This option is carried with ordinary DNS traffic; it does not specify periodic TCP probe packets.
Read the RFC section ↗