Sending larger ICMP Echo Requests in ipicmp.c?

Sending larger ICMP Echo Requests in ipicmp.c?

Post by tsr.. » Tue, 31 Aug 1999 04:00:00

I'm using Thamer Al-herbish's ipicmp.c program from

It is working fine except I'm trying to modify it to
send ICMP Echo Requests of arbitrary size.

My approach was to define a larger buff[], which holds
not only the IP and ICMP headers, and, in addition, my
data payload. Then I write my data payload to buff[],
starting at the byte immediately following the ICMP
header. When I call sendto(), I use the length of the IP
and ICMP headers, plus the length of my payload.

Problem is, when I run snoop I always see 48 byte ICMP packets,
no matter what length I use for my data payload.

Any ideas on how I can get this code to send longer
ICMP packets?

Here are snippets of my code:

#define MY_MAXDATA 1518
#define BUFFSIZE (sizeof(struct ip) + sizeof(struct icmp) + MY_MAXDATA)

/*For example, use a 300 byte data payload*/
my_datasize =300;

/*Length of IP and ICMP headers, combined */
hdr_leng    = sizeof(struct ip)+sizeof(struct icmp);

/*Length of IP header, ICMP header and data payload, combined */
total_leng  = hdr_leng + my_datasize;

/*Now set all 300 data bytes to the value '5'*/
memset (buff+hdr_leng,'5',my_datasize);

/*Send the ICMP Echo Request...*/

if(sendto(sockd,(char *)buff, total_leng, 0x0,
                (struct sockaddr *)&mysocket, sizeof(mysocket)) < 0) {
  fprintf(stderr,"ERROR from sendto()\n");


Sent via
Share what you know. Learn what you don't.