https://github.com/llefranc/42_ft_ping
School projet: reimplement ping internet utility, using a raw socket and IP/ICMP protocols.
https://github.com/llefranc/42_ft_ping
42 42born2code 42paris 42school ft-ping icmp icmp-ping ip ping
Last synced: 7 months ago
JSON representation
School projet: reimplement ping internet utility, using a raw socket and IP/ICMP protocols.
- Host: GitHub
- URL: https://github.com/llefranc/42_ft_ping
- Owner: llefranc
- Created: 2023-04-24T10:52:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-23T14:13:25.000Z (over 2 years ago)
- Last Synced: 2025-01-16T21:40:24.480Z (9 months ago)
- Topics: 42, 42born2code, 42paris, 42school, ft-ping, icmp, icmp-ping, ip, ping
- Language: C
- Homepage:
- Size: 1.3 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ft_ping (@42Paris)
> This project was code for Linux. Here is the [subject][1].
>
## About
ft_ping is a reimplementation in C of the ping utility based on the ping implementation from inetutils-2.0.
ft_ping uses a raw socket to send each second an ICMP Echo Request packet with a timestamp in its body.
It will also display a line of information for each received ICMP packet.It accepts a simple IPv4 address or hostname as a parameter, and supports both numerical IP addresses and hostnames.
> The program should be run with appropriate permissions, as sending ICMP Echo Request packets may require administrative privileges.
When receiving an ICMP packet, ft_ping will check:
- If the packet was correctly addressed to this process by checking the PID stored in the ID field of ICMP Echo Request.
- If it's an error packet or not.ft_ping will ping the targeted host until `Ctrl+C` is pressed. It will then display statistics about the received ICMP Echo Response packets.
ft_ping supports also the following options :
- `-h`: provides help information about the usage and command-line options of ft_ping.
- `-q`: enables quiet output, ft_ping will only display the end statistics.
- `-v`: enables verbose output and allows viewing the results in case of problems or errors related to the packets.*Example of error packet (packet filtered) with verbose output*

## Building and running the project
1. Download/Clone this repo
git clone https://github.com/llefranc/42_ft_ping
2. `cd` into the root directory and run `make`
cd 42_ft_ping
make3. Run `ft_ping` with appropriate permissions
sudo ./ft_ping 192.168.0.1
sudo ./ft_ping localhost
sudo ./ft_ping google.com -v## Sources
- [RFC of ICMP protocol][2]
- [RFC of IP protocol][3][1]: https://github.com/llefranc/42_ft_ping/blob/main/ft_ping.en.subject.pdf
[2]: https://www.rfc-editor.org/rfc/rfc792
[3]: https://www.rfc-editor.org/rfc/rfc791