This project is a custom-built implementation of the standard Ping network utility. Developed for Deakin unit SIT323, it demonstrates low-level network programming by constructing and parsing Internet Control Message Protocol (ICMP) packets manually.
Unlike basic implementations that call system-level ping commands, this application utilizes Python raw sockets to interface directly with the network layer (OSI Layer 3).
- Manual Packet Construction: Uses
struct.packto build ICMP Echo Request headers (Type 8) with a 16-bit identifier based on the current Process ID. - Checksum Implementation: Includes a custom
calc_checksumfunction that performs 16-bit word summation and one's complement folding as per RFC 792. - Header Parsing: Extracts TTL from the IP header and unpacks ICMP fields (Type, Code, ID, Sequence) using
struct.unpack. - Validation Logic: Rigorously validates incoming replies by comparing Request IDs and Sequence numbers to ensure response integrity.
- RTT Calculation: Measures round-trip time in milliseconds with 3-decimal precision, implementing a 1-second interval between successive pings.
- Python 3.x
- Administrative/Root Privileges: Because this application uses Raw Sockets (
socket.SOCK_RAW), it must be executed with elevated privileges:- Windows: Run PowerShell/CMD as Administrator.
- macOS/Linux: Prefix the execution command with
sudo.
-
Clone the repository:
git clone [https://github.com/rory-cd/ping.git](https://github.com/rory-cd/ping.git)
-
Navigate to the directory:
cd python-ping-utility -
Run the application:
# Linux/macOS sudo python3 ping.py # Windows (Run as Admin) python ping.py