RFC5905 64-bit timestamp format中的fraction的精度为什么是232 picoseconds?

1、64bit的Timestamp Format   

The 64-bit timestamp format is used in packet headers and other places with limited word size.  It includes a 32-bit unsigned seconds field spanning 136 years and a 32-bit fraction field resolving 232 picoseconds.                  

    1秒 = 1000毫秒 (millisecond) = 1,000,000微秒(microsecond) = 1,000,000,000纳秒(nanosecond) = 1,000,000,000,000皮秒(picosecond)

2、为什么是232 piposeconds?

从时间单位上看,232picosecond 不到四分之一纳秒,为什么单位这么奇怪,不是微秒、纳秒的倍数?

答案隐藏在附录里:

get_time() 函数返回的tstamp是64-bit的timestamp:

    typedef unsigned long long tstamp;   /* NTP timestamp format */

gettimeofday() 获取的是4字节的秒、4字节微秒:

struct timeval{
    long int tv_sec;  /* 秒数 */
    long int tv_usec; /* 秒数 */
}

所以,U2LFP 直接将struct timeval转换成8字节的timestamp:

#define FRAC       4294967296.             /* 2^32 as a double */
#define D2LFP(a)   ((tstamp)((a) * FRAC))  /* NTP timestamp */
#define LFP2D(a)   ((double)(a) / FRAC)
#define U2LFP(a)   (((unsigned long long) \
                       ((a).tv_sec + JAN_1970) << 32) + \
                       (unsigned long long) \
                       ((a).tv_usec / 1e6 * FRAC))

关注tv_usec部分,tv_usec / 1e6 将微秒转换成秒,再乘以2^32得到64-bit timestamp。

以1微秒为例,转换成的Fraction是: 1 / 1e6 * FRAC = 4294.967296, 取整后 fraction = 4294.

公式反过来:

将Fraction转换成微秒:1 / FRAC * 1e6 = 0.00023283064365386962890625微秒,也就是0.2328纳秒,232.8皮秒。

因此,精度的来源是:将1秒分成2^32份,每份0.00000000023283064365386962890625秒,大约等于232皮秒。

3、5G Qos Monitoring的时间测量采用该64-bit timestamp format进行时延测量,精度 232皮秒。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值