0

in order to code a program, i need to know how the ping command is working.

I need to know, if a command ping -c1 "something" is executed, how many ipv4 packets and ethernet frames will be created ? considering that every cache is empty

thanks..

MisterPur
  • 29
  • 1
  • 9
  • Sounds like an X-Y problem, but you can do your research by reading the source for ping, which is widely available. The answer will be "some number of packets" and "some number of ethernet frames" depending on the system and implementation and arguments. –  May 09 '18 at 01:23

2 Answers2

0

The ping command uses ICMP packets. In order to code a ping command you need to be able to send and receive ICMP packets.

In windows, this is done using winsock raw socket support. Here is an example of a ping using raw sockets.

In Linux, you just need sockets support. Here is a stack overflow question about how to do ICMP packets in Linux.

Or you can find a library that implements this for you.

Shane Powell
  • 13,698
  • 2
  • 49
  • 61
0
Reply from 192.168.2.10: bytes=32 time<1ms TTL=128 - **Computer is on OS kernel still in memory**
Request timed out. - **OS is shutdown/Firewall blocking ICMP**
Reply from 192.168.2.10: Destination host unreachable. - **Computer powered off. Physical network active**

Here is the ping command explained for troubleshooting

techgloo
  • 1
  • 3