Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

originateTimestamp equals 0 in returned packet

オープン
#3 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
javascript, node.js
領域
networking

調査の方向性

index.js の NTP.createPacket から始め、報告に示されている例で問題を再現してください。構築されたパケットを、引用されている RFC 2030 の動作と比較し、その後、返されたタイムスタンプによって往復遅延とシステムクロックのオフセットが利用可能になることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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();
 };
主要言語
JavaScript
スター
28
フォーク
8
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。