originateTimestamp equals 0 in returned packet
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 28
- Fork
- 8
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Running the slightly modified example
```js
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.
```js
Packet {
leapIndicator: 0,
version: 4,
mode: 4,
stratum: 2,
pollInterval: 6,
precision: 233,
referenceIdentifier: ,
referenceTimestamp: 1577013057260.7312,
originateTimestamp: 0,
receiveTimestamp: 1577013390216.6448,
transmitTimestamp: 1577013390216.6702,
rootDelay: ,
rootDispersion: ,
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:
```diff
--- 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();
};
```
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in index.js, in NTP.createPacket, e riproduci il problema con l’esempio mostrato nel report. Confronta il pacchetto costruito con il comportamento citato di RFC 2030, quindi verifica che i timestamp restituiti rendano utilizzabili il ritardo di andata e ritorno e l’offset dell’orologio di sistema.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100