This is a Python based implementation of ping that can send ICMP Echo Requests and receive ICMP Echo Responses and display helpful statistics. It supports both IPv4 and IPv6 and has a lot of configurable options like ping count, ttl, network interface and timeout.
- Send ICMP echo requests to a target IP address.
- Receive and process ICMP echo replies from the target.
- Calculate and display round-trip time (RTT) for each ICMP echo request-reply cycle.
- Provides statistics on:
- Packet loss
- Minimum RTT
- Maximum RTT
- Average RTT
- Standard deviation of RTT
- Provide options to configure the utility:
- Choose the network interface for sending packets.
- Set the Time-To-Live (TTL) value.
- Support both IPv4 and IPv6.
- Set No. of packets to send
- Set timeout value
- Handles keyboard interruptions (
Ctrl + C) gracefully to show intermediate statistics. - Error handling for invalid domain names or unreachable IPs.
- Provides extensive test cases and logging options.
git clone https://github.com/NetworkInCode/custom-ping-utility-new-Devaansh-Kumar custom_ping
cd custom_pingThe only dependency is to have Python 3 installed and Linux.
sudo python3 src/main.py google.comYou can also use Make to run the utility and set options
COUNT=5 TARGET=amazon.com make runusage: main.py [-h] [-c COUNT] [-t TTL] [-i INTERFACE] [--timeout TIMEOUT] [-6] destination
Custom Ping Utility
positional arguments:
destination Target hostname or IP address
options:
-h, --help show this help message and exit
-c COUNT, --count COUNT
Number of packets to send (default: 4)
-t TTL, --ttl TTL Time-To-Live (TTL) value for packets (default: 64)
-i INTERFACE, --interface INTERFACE
Network interface to use for sending packets (optional)
--timeout TIMEOUT Timeout in seconds for each packet (default: 1)
-6, --ipv6 Use IPv6 instead of IPv4 (defualt: false)- Basic IPv4 Ping
sudo python3 src/main.py google.com- Ping with 5 Packets and TTL 128
sudo python3 src/main.py google.com -c 5 -t 128- Use a Specific Network Interface (eth0)
sudo python3 src/main.py google.com -c 3 -i eth0- Ping Using IPv6
sudo python3 src/main.py google.com -6- Ping an IPv4 Address Explicitly
sudo python3 src/main.py 1.1.1.1- Ping an IPv6 Address
sudo python3 src/main.py 2606:4700:4700::1111 -6- Set Timeout Value
sudo python3 src/main.py google.com --timeout 2To run all tests and validate the utility use either one of:
sudo scripts/test.sh
make testTo run tests and log the output to a file:
make test-logsudo make clean