func parseICMPEcho(b []byte) (*icmpEcho, error) {
	bodylen := len(b)
	p := &icmpEcho{ID: int(b[0])<<8 | int(b[1]), Seq: int(b[2])<<8 | int(b[3])}
	if bodylen > 4 {
		p.Data = make([]byte, bodylen-4)
		copy(p.Data, b[4:])
	}
	return p, nil
}
parseICMPEcho parses b as an ICMP echo request or reply message
body.
package fastping
import (
	"errors"
)
func ipv4Payload(b []byte) []byte {
	if len(b) < 20 {
		return b
	}
	hdrlen := int(b[0]&0x0f) << 2
	return b[hdrlen:]
}
const (
	icmpv4EchoReply     = 0
	icmpv4UnReach       = 3
	icmpv4SourceQuench  = 4
	icmpv4Redirect      = 5
	icmpv4EchoRequest   = 8
	icmpv4RouteAdvert   = 9
	icmpv4RouterSolicit = 10
	icmpv4TimeExceeded  = 11
	icmpv4ParamProb     = 12
	icmpv4Tstamp        = 13
	icmpv4TstampReply   = 14
	icmpv4IReq          = 15
	icmpv4IReqReply     = 16
	icmpv4MaskReq       = 17
	icmpv4MaskReply     = 18
	icmpv6EchoRequest   = 128
	icmpv6EchoReply     = 129
)
type icmpMessage struct {
	Type     int              
	Code     int              
	Checksum int              
	Body     icmpMessageBody  
}
type icmpMessageBody interface {
	Len() int
	Marshal() ([]byte, error)
}
func (m *icmpMessage) Marshal() ([]byte, error) {
	b := []byte{byte(m.Type), byte(m.Code), 0, 0}
	if m.Body != nil && m.Body.Len() != 0 {
		mb, err := m.Body.Marshal()
		if err != nil {
			return nil, err
		}
		b = append(b, mb...)
	}
	switch m.Type {
	case icmpv6EchoRequest, icmpv6EchoReply:
		return b, nil
	}
	csumcv := len(b) - 1  
	s := uint32(0)
	for i := 0; i < csumcv; i += 2 {
		s += uint32(b[i+1])<<8 | uint32(b[i])
	}
	if csumcv&1 == 0 {
		s += uint32(b[csumcv])
	}
	s = s>>16 + s&0xffff
	s = s + s>>16
	b[2] ^= byte(^s)
	b[3] ^= byte(^s >> 8)
	return b, nil
}
func parseICMPMessage(b []byte) (*icmpMessage, error) {
	msglen := len(b)
	if msglen < 4 {
		return nil, errors.New("message too short")
	}
	m := &icmpMessage{Type: int(b[0]), Code: int(b[1]), Checksum: int(b[2])<<8 | int(b[3])}
	if msglen > 4 {
		var err error
		switch m.Type {
		case icmpv4EchoRequest, icmpv4EchoReply, icmpv6EchoRequest, icmpv6EchoReply:
			m.Body, err = parseICMPEcho(b[4:])
			if err != nil {
				return nil, err
			}
		}
	}
	return m, nil
}
type icmpEcho struct {
	ID   int     
	Seq  int     
	Data []byte  
}
func (p *icmpEcho) Len() int {
	if p == nil {
		return 0
	}
	return 4 + len(p.Data)
}
func (p *icmpEcho) Marshal() ([]byte, error) {
	b := make([]byte, 4+len(p.Data))
	b[0], b[1] = byte(p.ID>>8), byte(p.ID)
	b[2], b[3] = byte(p.Seq>>8), byte(p.Seq)
	copy(b[4:], p.Data)
	return b, nil
}