func ReadPacketWithKernelTimestamp(conn *net.UDPConn) (ntp *Packet, kernelRxTime time.Time, remAddr net.Addr, err error) {
	buf := make([]byte, PacketSizeBytes)
	oob := make([]byte, ControlHeaderSizeBytes)
	_, _, _, sa, err := conn.ReadMsgUDP(buf, oob)
	if err != nil {
		return nil, time.Time{}, nil, err
	}
	ts := (*syscall.Timespec)(unsafe.Pointer(&oob[syscall.CmsgSpace(0)]))
	kernelRxTime = time.Unix(ts.Unix())
	packet, err := BytesToPacket(buf)
	return packet, kernelRxTime, sa, err
}
ReadPacketWithKernelTimestamp reads kernel timestamp from incoming packet
package ntp
import (
	"bytes"
	"encoding/binary"
	"net"
	"time"
	"unsafe"
	syscall "golang.org/x/sys/unix"
)
const PacketSizeBytes = 48
const ControlHeaderSizeBytes = 32
type Packet struct {
	Settings       uint8   
	Stratum        uint8   
	Poll           int8    
	Precision      int8    
	RootDelay      uint32  
	RootDispersion uint32  
	ReferenceID    uint32  
	RefTimeSec     uint32  
	RefTimeFrac    uint32  
	OrigTimeSec    uint32  
	OrigTimeFrac   uint32  
	RxTimeSec      uint32  
	RxTimeFrac     uint32  
	TxTimeSec      uint32  
	TxTimeFrac     uint32  
}
const (
	liNoWarning      = 0
	liAlarmCondition = 3
	vnFirst          = 1
	vnLast           = 4
	modeClient       = 3
)
func (p *Packet) ValidSettingsFormat() bool {
	settings := p.Settings
	var l = settings >> 6
	var v = (settings << 2) >> 5
	var m = (settings << 5) >> 5
	if (l == liNoWarning) || (l == liAlarmCondition) {
		if (v >= vnFirst) && (v <= vnLast) {
			if m == modeClient {
				return true
			}
		}
	}
	return false
}
func (p *Packet) Bytes() ([]byte, error) {
	var bytes bytes.Buffer
	err := binary.Write(&bytes, binary.BigEndian, p)
	return bytes.Bytes(), err
}
func BytesToPacket(ntpPacketBytes []byte) (*Packet, error) {
	packet := &Packet{}
	reader := bytes.NewReader(ntpPacketBytes)
	err := binary.Read(reader, binary.BigEndian, packet)
	return packet, err
}
func ReadNTPPacket(conn *net.UDPConn) (ntp *Packet, remAddr net.Addr, err error) {
	buf := make([]byte, PacketSizeBytes)
	_, remAddr, err = conn.ReadFromUDP(buf)
	if err != nil {
		return nil, nil, err
	}
	ntp, err = BytesToPacket(buf)
	return ntp, remAddr, err
}