Documentation
¶
Index ¶
- Constants
- func Calc(res []byte, reqTs, resTs int64) (d int64, t int64)
- func GetT2T3Unix(ntpRes []byte) (int64, int64)
- func NewNtpV3Req() []byte
- func NtpTimestamp2Unix(ts uint64) int64
- func ParseTransmitTimestamp(ntpRes []byte) time.Time
- func SimpleNtpQuery(ntp_server_addr string) (now time.Time, cast time.Duration, err error)
- func TimeOfNtpServer(ntp_server_addr string) (now time.Time, cast time.Duration, err error)
- func UnixTimestamp2Ntp(uts int64) uint64
- type Ntp
Constants ¶
View Source
const (
UNIX_STA_TIMESTAMP = 2208988800
)
Variables ¶
This section is empty.
Functions ¶
func GetT2T3Unix ¶
从ntp响应报文中提取服务器回复时戳TransmitTimestamp
func ParseTransmitTimestamp ¶
从ntp响应报文中提取服务器回复时戳TransmitTimestamp
func SimpleNtpQuery ¶
ntp快速查询
func TimeOfNtpServer ¶
获取NTP服务器时戳及往返耗时
Types ¶
type Ntp ¶
type Ntp struct {
Li uint8 //2 bits 闰秒标志
Vn uint8 //3 bits NTP版本号,3或4
Mode uint8 //3 bits 3-客户端请求,4-服务器响应
Stratum uint8 //服务器时钟的层级,1最高
Poll uint8 //
Precision uint8 //服务器的时钟精度
RootDelay int32 //服务器与主时钟源的最大往返通讯时延/秒
RootDispersion int32 //服务器相对主时钟源的最大误差/秒
ReferenceIdentifier int32 //主时钟源标识
ReferenceTimestamp uint64 //服务器时钟最后一次校准的时间
OriginateTimestamp uint64 //客户向服务器发起请求的时间
ReceiveTimestamp uint64 //服务器收到客户请求的时间
TransmitTimestamp uint64 //服务器向客户发时间戳的时间
}
* NTP协议 http://www.ntp.org/documentation.html NTP报文-报文头总长度48字节
Click to show internal directories.
Click to hide internal directories.