originateTimestamp equals 0 in returned packet
还没有人认领这个 Issue。
评估
- 难度
- 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
antfu-collective/icones#398 ·
-
ECmail.com 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
wesbos/burner-email-providers#554 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
radiantearth/stac-browser#1023 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
components-web-app/docs#92 ·