3 ms·
The heartbeat extension was originally designed for DTLS, which is TLS over UDP. UDP datagrams don't arrive in a guaranteed order, or within any bounded time. I
by twic 13y ago
The heartbeat extension was originally designed for DTLS, which is TLS over UDP. UDP datagrams don't arrive in a guaranteed order, or within any bounded time. If heartbeat used a fixed message, then if you sent a request and receive a response using DTLS, you would have no way of knowing if that response was a response to that request, or to some other request you sent ten minutes ago, or what.
Allowing the request and response to carry a payload lets you mark each request with a unique identifier, so that you can recognise the resulting responses.
It's basically like an HTTP cookie. In reverse.
I have no idea why the payload is variable-sized, rather than being (say) a fixed 32 bits. I would guess the specifier didn't want to bake in assumptions about how much space a unique identifier would need.
- fulafel 13y ago> I have no idea why the payload is variable-sized For DTLS path MTU discovery (according to the heartbeat extension RFC).
- EvanAnderson 13y agoThat could have been accomplished with a fixed-length payload and variable-length padding, though.
- masklinn 13y ago> I would guess the specifier didn't want to bake in assumptions about how much space a unique identifier would need. Yep, although an up-to-64KB buffer seems like overkill you'd get a guy getting by on a byte, while the other one has a distributed system and wants UUID or something
- priomsrb 13y agoMakes sense. But 64k of data seems oddly large just to ID a message.
- tedchs 13y ago64k is the max value of a 2-byte unsigned int, as 2^16 - 1 = 65535; is that the size of the length prefix?
- stackcollision 13y agoI looked at the code and I'm pretty sure I saw that the payload size variable was a long int, so I was confused by this too.
- nollidge 13y agoI'm probably missing something, but if it's going to be of variable size, why not just a null-terminated string? Why does the size itself need to be specified along with the string? EDIT: Nevermind, this thread [0] has more discussion about it. [0] https://news.ycombinator.com/item?id=7572081 https://news.ycombinator.com/item?id=7572081