func (pinger *Pinger) PayloadSize() uint16 {
	pinger.payloadMu.RLock()
	defer pinger.payloadMu.RUnlock()
	return uint16(len(pinger.payload))
}
PayloadSize retrieves the current payload size.
package ping
import (
	"net"
	"os"
	"sync"
	"golang.org/x/net/icmp"
)
const (
	ProtocolICMP = 1
	ProtocolICMPv6 = 58
)
var sequence uint32
type Pinger struct {
	LogUnexpectedPackets bool  
	payload   Payload
	payloadMu sync.RWMutex
	requests map[uint16]request  
	mtx      sync.RWMutex        
	id       uint16
	conn4    net.PacketConn
	conn6    net.PacketConn
	write4   sync.Mutex  
	write6   sync.Mutex  
	wg       sync.WaitGroup
}
func New(bind4, bind6 string) (*Pinger, error) {
	conn4, err := connectICMP("ip4:icmp", bind4)
	if err != nil {
		return nil, err
	}
	conn6, err := connectICMP("ip6:ipv6-icmp", bind6)
	if err != nil {
		if conn4 != nil {
			conn4.Close()
		}
		return nil, err
	}
	if conn4 == nil && conn6 == nil {
		return nil, errNotBound
	}
	pinger := Pinger{
		conn4:    conn4,
		conn6:    conn6,
		id:       uint16(os.Getpid()),
		requests: make(map[uint16]request),
	}
	pinger.SetPayloadSize(56)
	if conn4 != nil {
		pinger.wg.Add(1)
		go pinger.receiver(ProtocolICMP, pinger.conn4)
	}
	if conn6 != nil {
		pinger.wg.Add(1)
		go pinger.receiver(ProtocolICMPv6, pinger.conn6)
	}
	return &pinger, nil
}
func (pinger *Pinger) Close() {
	pinger.close(pinger.conn4)
	pinger.close(pinger.conn6)
	pinger.wg.Wait()
}
func connectICMP(network, address string) (*icmp.PacketConn, error) {
	if network == "" || address == "" {
		return nil, nil
	}
	return icmp.ListenPacket(network, address)
}
func (pinger *Pinger) close(conn net.PacketConn) {
	if conn != nil {
		conn.Close()
	}
}
func (pinger *Pinger) removeRequest(seq uint16) {
	pinger.mtx.Lock()
	delete(pinger.requests, seq)
	pinger.mtx.Unlock()
}
func (pinger *Pinger) SetPayloadSize(size uint16) {
	pinger.payloadMu.Lock()
	pinger.payload.Resize(size)
	pinger.payloadMu.Unlock()
}
func (pinger *Pinger) SetPayload(data []byte) {
	pinger.payloadMu.Lock()
	pinger.payload = Payload(data)
	pinger.payloadMu.Unlock()
}