Cycle every payload pattern per packet and always run both directions

This commit is contained in:
flamingcow
2026-07-25 23:03:31 -07:00
parent 0f16edfe61
commit e77574712d
8 changed files with 75 additions and 104 deletions
+4 -11
View File
@@ -12,17 +12,14 @@ const (
hwtstampFilterAll = 1
)
// Read and written through the ifreq data pointer.
type hwtstampConfig struct {
flags int32
txType int32
rxFilter int32
}
// Hardware timestamping is a property of the interface, not the socket: the MAC
// has to be told to stamp on transmit and on receive before any socket can ask
// for the values. Receive stamping is filtered by protocol and ours is not PTP,
// so nothing narrower than "all" will see our frames.
// Receive stamping is filtered by protocol and ours is not PTP, so nothing
// narrower than "all" will see our frames.
func checkTimestamping(fd int, ifname string) checkResult {
res := checkResult{item: ifname + " hw timestamps"}
desc := func(c hwtstampConfig) string {
@@ -70,9 +67,6 @@ func checkTimestamping(fd int, ifname string) checkResult {
return res
}
// The socket asks for the values the MAC is now producing. Only the raw
// hardware clock is wanted; the software stamps would just be more control
// message to copy.
func enableTxTimestamps(fd int) error {
return unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_TIMESTAMPING,
unix.SOF_TIMESTAMPING_TX_HARDWARE|
@@ -85,9 +79,8 @@ func enableRxTimestamps(fd int) error {
unix.SOF_TIMESTAMPING_RX_HARDWARE|unix.SOF_TIMESTAMPING_RAW_HARDWARE)
}
// SCM_TIMESTAMPING carries three timespecs and the third is the raw hardware
// clock; the first two are software clocks we did not ask for and which arrive
// zeroed. A zero hardware stamp means the MAC did not produce one.
// Three timespecs, of which the third is the raw hardware clock. A zero there
// means the mac did not produce a stamp.
const scmTimestampingLen = 3 * int(unsafe.Sizeof(unix.Timespec{}))
func hwTimestamp(oob []byte) (int64, bool) {