Giter VIP home page Giter VIP logo

sntp's People

Contributors

btfak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sntp's Issues

格式有点疑问

// generate
/*
Field Name Request Reply
----------------------------------------------------------
LI 0 or 3 0
VN 1-4 copied from request
Mode 3 4
Stratum ignore 1
Poll ignore copied from request
Precision ignore -log2 server significant bits
Root Delay ignore 0
Root Dispersion ignore 0
Reference Identifier ignore source ident
Reference Timestamp ignore time of last radio update
Originate Timestamp ignore copied from transmit timestamp
Receive Timestamp ignore time of day
Transmit Timestamp (see text) time of day
*/
func generate(req []byte) []byte {
var second = unix2ntp(time.Now().Unix())
var fraction = unix2ntp(int64(time.Now().Nanosecond()))
var res = make([]byte, 48)
var vn = req[0] & 0x38
res[0] = vn + 4
res[1] = 1
res[2] = req[2]
res[3] = 0xEC
res[12] = 0x4E
res[13] = 0x49
res[14] = 0x43
res[15] = 0x54
copy(res[16:20], int2bytes(second)[0:])
copy(res[24:32], req[40:48])
copy(res[32:36], int2bytes(second)[0:])
copy(res[36:40], int2bytes(fraction)[0:])
copy(res[40:48], res[32:40])
return res
}

44-48这几个字节数放的是纳秒数,为什么通过函数unix2ntp增加一个时间呢,40-44保存了秒数,44-48保存纳秒不就可以了么?
func int2bytes(i int64) []byte 这个函数把int64 8个字节的数据放在4个字节的byte数组里面放得下么?
还有就是这个库现在稳定么?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.