A Python application to ping a specified host, log the results to a CSV file, and print statistics to the console. The project supports configurable packet sizes and optional CSV logging.
Why did I create this? Because I did'nt like the output format of the default Windows ping command. And, I felt like making a pinger, for fun. So, here we are.
- Ping a specified host with a configurable packet size.
- Log ping results to a CSV file.
- Print statistics to the console.
python main.py -H <host> -s <packet_size> [-f]<host>: The host to ping (default: 8.8.8.8)<packet_size>: The size of the ping packet in bytes (default: 32)-f: Enable logging to a CSV file (optional)
Example 1:
- Ping Google with 32-byte packets.
- Do not write output to CSV file, i.e. do not include the
-fargument. - Press [Ctrl+C] to exit program.
python main.py -H 8.8.8.8 -s 322025-07-18 23:06:28.664 Ping: "8.8.8.8" Packet Size: 32 bytes Delay: 5.5 ms Min: 5.5 ms Max: 5.5 ms Average: 5.5 ms Packets Sent: 1 Packets Lost: 0 (0.00%)
2025-07-18 23:06:29.671 Ping: "8.8.8.8" Packet Size: 32 bytes Delay: 5.5 ms Min: 5.5 ms Max: 5.5 ms Average: 5.5 ms Packets Sent: 2 Packets Lost: 0 (0.00%)
2025-07-18 23:06:30.677 Ping: "8.8.8.8" Packet Size: 32 bytes Delay: 5.5 ms Min: 5.5 ms Max: 5.5 ms Average: 5.5 ms Packets Sent: 3 Packets Lost: 0 (0.00%)
2025-07-18 23:06:31.684 Ping: "8.8.8.8" Packet Size: 32 bytes Delay: 5.4 ms Min: 5.1 ms Max: 5.5 ms Average: 5.4 ms Packets Sent: 4 Packets Lost: 0 (0.00%)Example 2:
- Ping local host with 128-byte packets.
- Write output to CSV file, i.e. Include the
-fargument.- The file name will looks simialr to this,
ping_log_20250718_230821_192_168_1_1_128.csv.
- The file name will looks simialr to this,
- Press [Ctrl+C] to exit program.
python main.py -H 192.168.1.1 -s 128 -f2025-07-18 23:08:21.122 Ping: "192.168.1.1" Packet Size: 128 bytes Delay: 2.8 ms Min: 2.8 ms Max: 2.8 ms Average: 2.8 ms Packets Sent: 1 Packets Lost: 0 (0.00%)
2025-07-18 23:08:22.125 Ping: "192.168.1.1" Packet Size: 128 bytes Delay: 2.7 ms Min: 2.5 ms Max: 2.8 ms Average: 2.7 ms Packets Sent: 2 Packets Lost: 0 (0.00%)
2025-07-18 23:08:23.129 Ping: "192.168.1.1" Packet Size: 128 bytes Delay: 2.6 ms Min: 2.5 ms Max: 2.8 ms Average: 2.6 ms Packets Sent: 3 Packets Lost: 0 (0.00%)
2025-07-18 23:08:24.133 Ping: "192.168.1.1" Packet Size: 128 bytes Delay: 2.7 ms Min: 2.5 ms Max: 3.0 ms Average: 2.7 ms Packets Sent: 4 Packets Lost: 0 (0.00%)from app_config import AppConfig
from application import Application
if __name__ == "__main__":
config = AppConfig().get_arguments()
app = Application(config)
app.run()- Python 3.x
-
Clone the repository:
git clone https://github.com/your-username/your-repo.git
-
Navigate to the project directory:
cd your-repo -
Create and activate the virtual environment using the provided batch files:
-
To create the virtual environment and activate it, run:
venv_create.bat
-
If you need to activate the virtual environment later, run:
venv_activate.bat
-
To deactivate the virtual environment, run:
venv_deactivate.bat
-
To delete the virtual environment, run:
venv_delete.bat
-
-
Install the required packages:
venv_install_requirements.bat
-
To save the current list of installed packages to
venv_requirements.txt, run:venv_save_requirements.bat
Contributions are welcome! Please follow the contribution guidelines.
- Fork the project.
- Create your feature branch (git checkout -b feature/AmazingFeature).
- Commit your changes (git commit -m 'Add some AmazingFeature').
- Push to the branch (git push origin feature/AmazingFeature).
- Open a pull request.
Distributed under the MIT License. See LICENSE for more information.
- Twitter: @rohingosling
- Project Link: https://github.com/your-username/your-repo