A Python-based network connectivity tester that uses the scapy library to send ICMP (ping) requests to a list of hosts, measure the round-trip time, and log the results. It also plots the ping test results over time and uses matplotlib library to display the results in a functional graph after the run.
Make sure you have Python 3.x installed. Then, install the required Python modules using the following command:
pip install scapy matplotlib--hosts: Comma-separated list of hosts to ping (e.g., '8.8.4.4,1.0.0.1'). Default is8.8.8.8,1.1.1.1.--duration: Test duration in seconds. Default is30.--interval: Ping interval in seconds. Default is1.--packet_size: Packet size in bytes. Default is32.--ttl: TTL (Time to Live). Default is64.--nolog: Skips the creation of a logfile.
-
Running with defaults (8.8.8.8, 1.1.1.1):
python network_tester.py
-
Running with custom hosts and other arguments:
python network_tester.py --hosts "8.8.4.4,1.0.0.1" --duration 10 --interval 2 --packet_size 64 --ttl 128 --nolog
-
Windows Native Raw Sockets Error: On Windows, raw sockets require administrator privileges. You may encounter the following error:
Error pinging 8.8.8.8: Windows native L3 Raw sockets are only usable as administrator !Solution:
- Run the Script as Administrator:
- In Windows, raw sockets (which are used to send ICMP pings) require administrator privileges.
- If you are using Command Prompt, VSCode or any other software to run the code. Run the software elevated then try running the script again.
- Run the Script as Administrator: