If the payload has variable size to facilitate MTU discovery, then there is some logic to sending messages of varying sizes. An MTU can never exceed the 1500 of ethernet though, so this is weird stuff. What good can a payload of 64k really do? And MTU discovery doesn't involve any echoing by the receiving party. Either packets get blocked (at the IP layer) and error messages get returned (by the router blocking them) OR the packages arrive fully (or get reassembled) so this Heartbeat code won't know about any issues anyway. And the "echo" proves nothing. I really don't get this, what is the point...?
I think you said it yourself. So why argue when it's pointed out?
Clearly path discovery has nothing to do with keeping a connection open. Further, can't path discovery be done in an un-encrypted TCP or UDP channel with separate tooling and the results passed into tuning parameters of the encrypted protocol? (This is even assuming the security layer on top of TCP even needs to know MTU when TCP is handling it already)
Since when is THE secure protocol supposed to be the kitchen sink dumping ground of the internet?
To wit: TLS Heartbeats were originally intended for DTLS (in fact, the first draft was apparently DTLS-specific). Datagram protocols have a problem: if datagrams are too large, the IP protocol will need to fragment them. Fragmentation is calamitous for performance and reliability. So sizing datagrams is tricky. One technique for solving that is "path MTU discovery". The original use case for TLS Heartbeats was, as the RFC spells out clearly, PMTU discovery.
The payload/padding split exists so that one side of the protocol can send large messages, and the counterparty can reply with smaller ones, relying on the fact that the message includes discardable padding.
It's not a good protocol. The functionality is implemented at the wrong layer. And the inclusion of the extension into TCP TLS was a mistake, one (also) discussed on the mailing list. Unfortunately, the way standards work, it's easier to say "yes" to new features than "no", and it was easier to add the extension to both TCP TLS and DTLS than it was to hash out the argument of whether TCP TLS needed the feature.