lsongdev / lsongdev/node-ntp

originateTimestamp equals 0 in returned packet

Abierto
#3 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
JavaScript
Estrellas
28
Forks
8
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Running the slightly modified example

const ntp = require('..');

ntp(function(err, response){
  if(err) return console.error(err);
  console.log(response);
});

originateTimestamp === 0 is returned which renders roundtrip delay d and system clock offset t unusable.

Packet {
  leapIndicator: 0,
  version: 4,
  mode: 4,
  stratum: 2,
  pollInterval: 6,
  precision: 233,
  referenceIdentifier: <Buffer c0 35 67 6c>,
  referenceTimestamp: 1577013057260.7312,
  originateTimestamp: 0,
  receiveTimestamp: 1577013390216.6448,
  transmitTimestamp: 1577013390216.6702,
  rootDelay: <Buffer 00 00 01 d5>,
  rootDispersion: <Buffer 00 00 07 07>,
  destinationTimestamp: 1577013390262,
  time: 2019-12-22T11:16:30.216Z,
  d: 1577013390261.9746,
  t: 788506695085.6575
}

According to https://tools.ietf.org/html/rfc2030#section-6

In unicast and anycast modes, the Receive Timestamp and Transmit Timestamp
fields are set to the time of day when the message is sent and the
Originate Timestamp field is copied unchanged from the Transmit
Timestamp field of the request. It is important that this field be
copied intact, as a NTP client uses it to avoid replays. In multicast
mode, the Originate Timestamp and Receive Timestamp fields are set to
0 and the Transmit Timestamp field is set to the time of day when the
message is sent.

I suppose that client and server operate in unicast/ anycast mode. If this is the case I would like to change:

--- a/index.js
+++ b/index.js
@@ -63,7 +63,7 @@ NTP.prototype.time = function (callback) {
 NTP.createPacket = function () {
   const packet = new Packet();
   packet.mode = Packet.MODES.CLIENT;
-  packet.originateTimestamp = Date.now();
+  packet.transmitTimestamp = Date.now();
   return packet.toBuffer();
 };

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza en index.js, en NTP.createPacket, y reproduce el problema con el ejemplo mostrado en el informe. Compara el paquete construido con el comportamiento citado de RFC 2030 y, a continuación, verifica que las marcas de tiempo devueltas permitan utilizar el retraso de ida y vuelta y el desfase del reloj del sistema.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
networking
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.