Subject: [core] DNS over CoAP: Caching and CoAP Max-Age vs DNS TTL

From: Martine Sophie Lenders <[email-masked]>
Date: Fri, 25 Mar 2022 12:55:59 +0100

Hi,

during today's meeting, I was asked to put the four discussion points I 
presented in my talk on DoC [1] on the list. Here is the discussion 
points on the implications of caching and the problem of Max-Age and DNS 
TTL (slides 10-12 of [2]).

When caching at a CoAP proxy, we face the issue that both CoAP's Max-Age 
option and the TTL value in DNS are expressed by means of a relative 
time frame: A caching proxy (which might not be aware of DoC) might 
update the Max-Age accordingly on Cache Hit, but not the TTLs. As such, 
to get the real time a record is valid, the DoC client need to adapt the 
DNS TTLs according the CoAP Max-Age.

I presented two options, already discussed in our GitHub PRs [3].

Option 1 [4] would basically take the DoH route and just use the minimum 
TTL min(TTLs) as the Max-Age and not further manipulate the DNS 
response. Consequently, the client would need to check the TTLs then 
again the Max-Age of the response and, if the Max-Age is lesser than the 
minimum TTL, adapt the TTLs accordingly, by doing

TTL_new = TTL_old - (min(TTLs) - Max-Age)

Option 2 [5] puts most of that workload on the server, which apart from 
using the minimum TTL min(TTLs) as the Max-Age then uses that value to 
adapt all TTLs within the DNS response by doing

TTL_new = TTL_old - min(TTLs)

The client then doesn't need to search the minimum TTL first and compare 
it to the Max-Age, but just can add the current Max-Age to all TTLs:

TTL_new = TTL_old + Max-Age

This option has the added bonus that it is also more robust against 
cache invalidation when using content-based ETags: The TTLs do not 
change in the CoAP response, even if different TTLs are reported from 
upstream (assuming they are still have the same differences to each 
other). The disadvantage is, that we add an explicit dependency of the 
application data on CoAP context.

So the questions are: Which Option should we go for? Is this even 
something that should be discussed in the draft?

Cheers,
Martine

[1] https://datatracker.ietf.org/doc/draft-lenders-dns-over-coap/
[2] 
https://datatracker.ietf.org/meeting/113/materials/slides-113-core-dns-queries-over-coap-doc-00
[3] https://github.com/anr-bmbf-pivot/draft-dns-over-coap/pulls
[4] https://github.com/anr-bmbf-pivot/draft-dns-over-coap/pull/17
[5] https://github.com/anr-bmbf-pivot/draft-dns-over-coap/pull/19