Add SO_TIMESTAMP support for datagram channels#3475
Add SO_TIMESTAMP support for datagram channels#3475klaaspieter wants to merge 1 commit intoapple:mainfrom
Conversation
Lukasa
left a comment
There was a problem hiding this comment.
Thanks for this patch! This mostly looks really good, I've left a few notes in the diff.
da2bdbb to
c51e7d1
Compare
|
@Lukasa the API breaking change made sense because I changed a constructor. What is the best way to handle this? I can add a new constructor with the new argument, keeping the old one unchanged. I can also make the default value for |
You'll need to add a new |
Motivation: NIO supports ECN, packet info, and segmentation metadata but not timestamps. Userspace timestamps are imprecise due to scheduler latency between packet arrival and recvmsg. SO_TIMESTAMP captures the exact kernel receive time with microsecond precision via control messages, which is critical for accurate RTT measurements and latency monitoring. Modifications: - Add timestamp field to AddressedEnvelope.Metadata - Add TimestampOption channel option - Parse SCM_TIMESTAMP control messages in ControlMessageParser - Add init(ecnState:packetInfo:segmentSize:timestamp:) to Metadata - Add test coverage Result: Datagram channels can enable .receiveTimestamp to receive kernel timestamps in AddressedEnvelope.Metadata.timestamp as a Double (seconds since epoch with microsecond precision).
3cf4a1c to
4550653
Compare
Motivation:
NIO supports ECN, packet info, and segmentation metadata but not timestamps. Userspace timestamps are imprecise due to scheduler latency between packet arrival and recvmsg. SO_TIMESTAMP captures the exact kernel receive time with microsecond precision via control messages, which is critical for accurate RTT measurements and latency monitoring.
Modifications:
Result:
Datagram channels can enable .receiveTimestamp to receive kernel timestamps in AddressedEnvelope.Metadata.timestamp as a Double (seconds since epoch with microsecond precision).