Documentation ¶
Index ¶
- Constants
- Variables
- func AddrToSockaddr(ip netip.Addr, port int) unix.Sockaddr
- func ConnFd(conn *net.UDPConn) (int, error)
- func EnableHWTimestamps(connFd int, iface string) error
- func EnableHWTimestampsRx(connFd int, iface string) error
- func EnableSWTimestamps(connFd int) error
- func EnableSWTimestampsRx(connFd int) error
- func EnableTimestamps(ts Timestamp, connFd int, iface string) error
- func IPToSockaddr(ip net.IP, port int) unix.Sockaddr
- func NewSockaddrWithPort(sa unix.Sockaddr, port int) unix.Sockaddr
- func ReadPacketWithRXTimestamp(connFd int) ([]byte, unix.Sockaddr, time.Time, error)
- func ReadPacketWithRXTimestampBuf(connFd int, buf, oob []byte) (int, unix.Sockaddr, time.Time, error)
- func ReadTXtimestamp(connFd int) (time.Time, int, error)
- func ReadTXtimestampBuf(connFd int, oob, toob []byte) (time.Time, int, error)
- func SockaddrToAddr(sa unix.Sockaddr) netip.Addr
- func SockaddrToIP(sa unix.Sockaddr) net.IP
- func SockaddrToPort(sa unix.Sockaddr) int
- type Timestamp
Constants ¶
const ( // ControlSizeBytes is a socket control message containing TX/RX timestamp // If the read fails we may endup with multiple timestamps in the buffer // which is best to read right away ControlSizeBytes = 128 // PayloadSizeBytes is a size of maximum ptp packet which is usually up to 66 bytes PayloadSizeBytes = 128 )
const Unsupported = "Unsupported"
Unsupported is a string for unsupported timestamp
Variables ¶
var AttemptsTXTS = defaultTXTS
AttemptsTXTS is configured amount of attempts to read TX timestamp
var TimeoutTXTS = time.Millisecond
TimeoutTXTS is configured timeout to read TX timestamp
Functions ¶
func AddrToSockaddr ¶
AddrToSockaddr converts netip.Addr + port into a socket address
func EnableHWTimestamps ¶
EnableHWTimestamps enables HW timestamps (TX and RX) on the socket
func EnableHWTimestampsRx ¶
EnableHWTimestampsRx enables HW RX timestamps on the socket
func EnableSWTimestamps ¶
EnableSWTimestamps enables SW timestamps (TX and RX) on the socket
func EnableSWTimestampsRx ¶
EnableSWTimestampsRx enables SW RX timestamps on the socket
func EnableTimestamps ¶
EnableTimestamps enables timestamps on the socket based on requested type
func IPToSockaddr ¶
IPToSockaddr converts IP + port into a socket address Somewhat copy from https://github.com/golang/go/blob/16cd770e0668a410a511680b2ac1412e554bd27b/src/net/ipsock_posix.go#L145
func NewSockaddrWithPort ¶
NewSockaddrWithPort creates a new socket address with the same IP and new port
func ReadPacketWithRXTimestamp ¶
ReadPacketWithRXTimestamp returns byte packet and HW RX timestamp
func ReadPacketWithRXTimestampBuf ¶
func ReadPacketWithRXTimestampBuf(connFd int, buf, oob []byte) (int, unix.Sockaddr, time.Time, error)
ReadPacketWithRXTimestampBuf writes byte packet into provide buffer buf, and returns number of bytes copied to the buffer, client ip and HW RX timestamp. oob buffer can be reaused after ReadPacketWithRXTimestampBuf call.
func ReadTXtimestamp ¶
ReadTXtimestamp returns HW TX timestamp
func ReadTXtimestampBuf ¶
ReadTXtimestampBuf returns HW TX timestamp, needs to be provided 2 buffers which all can be re-used after ReadTXtimestampBuf finishes.
func SockaddrToAddr ¶
SockaddrToAddr converts socket address to a netip.Addr Somewhat copy from https://github.com/golang/go/blob/658b5e66ecbc41a49e6fb5aa63c5d9c804cf305f/src/net/udpsock_posix.go#L15
func SockaddrToIP ¶
SockaddrToIP converts socket address to an IP Somewhat copy from https://github.com/golang/go/blob/658b5e66ecbc41a49e6fb5aa63c5d9c804cf305f/src/net/udpsock_posix.go#L15
func SockaddrToPort ¶
SockaddrToPort converts socket address to an IP Somewhat copy from https://github.com/golang/go/blob/658b5e66ecbc41a49e6fb5aa63c5d9c804cf305f/src/net/udpsock_posix.go#L15
Types ¶
type Timestamp ¶
type Timestamp int
Timestamp is a type of timestamp
func (Timestamp) MarshalText ¶
MarshalText timestamp to byte slice
func (*Timestamp) UnmarshalText ¶
UnmarshalText timestamp from byte slice