Skip to content

hheghine/ft_ping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ ft_ping

ft_ping is a custom reimplementation of the Unix ping command written in C. It sends ICMP Echo Request packets to a specified IPv4 address or hostname and measures round-trip time (RTT) for each response. Inspired by the behavior of ping from GNU inetutils-2.0, it handles basic options like -v and -?, provides error feedback, and reports network statistics while operating at the raw socket level.

what is ping and how it works

At its core, ping:

  • sends ICMP echo request packets to a target.
  • waits for ICMP echo reply packets.
  • measures the round-trip time (RTT).
  • reports statistics like packet loss, min/avg/max RTT.

ICMP (Internet Control Message Protocol) is used for diagnostics, not for regular data transfer like TCP/UDP.

ICMP (RFC 792) packet format

+--------------------------------+
|  type | code  |    checksum    |
+--------------------------------+
|       id      |  seq. number   |
+--------------------------------+
|             data               |
+--------------------------------+
FIELD LENGTH DESCRIPTION
type 1 byte 8 for echo request, 0 for echo reply
code 1 byte always 0 for echo messages
checksum 2 bytes 16-bit checksum of the ICMP message (header + data)
identifier 2 bytes identifies the request; often the process id
sequence number 2 bytes incremented with each request to match replies
data variable optional payload; must be echoed in the reply

About

[ 🚧 in progress ] custom reimplementation of the unix ping command written in c.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published