int icmp_unpack(char* buf, int len)
{
int iphdr_len;
struct timeval begin_time, recv_time, offset_time;
int rtt; //round trip time
struct ip* ip_hdr = (struct ip )buf;
iphdr_len = ip_hdr->ip_hl*4;
struct icmp icmp = (struct icmp*)(buf+iphdr_len); //使指针跳过IP头指向ICMP头**
len-=iphdr_len; //icmp包长度
if(len < 8) //判断长度是否为ICMP包长度
{
fprintf(stderr, "Invalid icmp packet.Its length is less than 8\n");
return -1;
}