Skip to content

rory-cd/ping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Python ICMP Ping Utility

Overview

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).

Key Features

  • Manual Packet Construction: Uses struct.pack to build ICMP Echo Request headers (Type 8) with a 16-bit identifier based on the current Process ID.
  • Checksum Implementation: Includes a custom calc_checksum function 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.

Technical Requirements

  • 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.

Installation & Usage

  1. Clone the repository:

    git clone [https://github.com/rory-cd/ping.git](https://github.com/rory-cd/ping.git)
  2. Navigate to the directory:

    cd python-ping-utility
  3. Run the application:

     # Linux/macOS
     sudo python3 ping.py
    
     # Windows (Run as Admin)
     python ping.py

About

Low-level ICMP Ping implementation in Python using raw sockets and binary packet packing with struct. Built from scratch for Deakin unit SIT323.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages