From 3ea65aed7b16ab70f8ac2c29a8e309ad4c281fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lluc=20Sim=C3=B3?= Date: Thu, 5 Jun 2025 17:55:46 +0200 Subject: [PATCH] packet: fix parsing rootDelay and rootDispersion Values obtained now are the same as the ones I see in wireshark --- src/packet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packet.js b/src/packet.js index 65365a5..af65e8d 100644 --- a/src/packet.js +++ b/src/packet.js @@ -78,8 +78,8 @@ class NTPPacket { packet.stratum = parseInt(data[1]) || 2; packet.pollInterval = parseInt(data[2]) || 10; packet.precision = parseInt(data[3]); - packet.rootDelay = data.slice(4, 8).readFloatBE(0) / 2 ** 16; - packet.rootDispersion = data.slice(8, 12).readFloatBE(0) / 2 ** 16; + packet.rootDelay = data.readUInt32BE(4) / (2 ** 16); + packet.rootDispersion = data.readUInt32BE(8) / (2 ** 16); packet.referenceIdentifier = data.slice(12, 16); // Timestamps where the 4 first bytes are the