Skip to main content

A powerful network connectivity analyzer with real-time system monitoring and IPv6 support

Project description

๐ŸŒ TCP Port and Ping Checker

A powerful, real-time network connectivity analyzer that performs both ping and TCP port checks with intelligent system resource management.

Python License Platform

๐Ÿš€ Features

  • ๐Ÿ” Dual Connectivity Check: Both ping and TCP port verification
  • ๐ŸŒ IPv6 Support: Full support for IPv4, IPv6, and domain names
  • โšก Real-time System Monitoring: CPU and RAM usage tracking
  • ๐Ÿค– Dynamic Resource Management: Auto-adjusting thread count and batch sizes
  • ๐Ÿ›ก๏ธ Intelligent Throttling: Automatic slowdown on high system load
  • ๐Ÿ“Š Comprehensive Reporting: Beautiful HTML and detailed TXT reports
  • ๐Ÿ”ง CLI Support: Flexible command-line interface
  • ๐ŸŽฏ Multi-format Input: Single IPs, comma-separated lists, or file-based
  • ๐Ÿงต Thread-safe Operations: Secure concurrent processing
  • ๐Ÿ“ˆ Performance Analytics: Real-time progress monitoring

๐Ÿ“ Project Structure

tcp-port-checker/
โ”œโ”€โ”€ main.py                 # Main application with CLI support
โ”œโ”€โ”€ config.py               # Configuration and IP loading
โ”œโ”€โ”€ network_checker.py      # Core network checking logic
โ”œโ”€โ”€ system_monitor.py       # Real-time system monitoring
โ”œโ”€โ”€ report_generator.py     # Report generation (TXT/HTML)
โ”œโ”€โ”€ ip_addresses.txt        # IP addresses list (auto-generated)
โ”œโ”€โ”€ requirements.txt        # Dependencies
โ””โ”€โ”€ README.md              # This file

๐Ÿ› ๏ธ Installation

Prerequisites

  • Python 3.6+ (recommended: Python 3.8+)

Quick Setup

# Clone the repository
git clone https://github.com/ismailTrk/tcp-port-checker.git
cd tcp-port-checker

# Install dependencies
pip install -r requirements.txt

# Run with default settings
python3 main.py

Dependencies

  • psutil>=5.8.0 - System resource monitoring

All other components use Python standard library.

๐Ÿš€ Usage

Basic Usage

# Check IPs from default file (ip_addresses.txt)
python3 main.py

# Quick single IP check
python3 main.py -ip 192.168.1.1

# Check specific port
python3 main.py -ip 192.168.1.1 -p 22

# Check IPv6 addresses
python3 main.py -ip "2001:4860:4860::8888,::1" -p 53

# Mixed IPv4, IPv6, and domains
python3 main.py -ip "8.8.8.8,2001:4860:4860::8888,google.com" -p 443

Advanced Usage

# Use custom IP file
python3 main.py -f /path/to/custom_ips.txt

# Custom timeout and workers
python3 main.py -ip 10.0.0.1 -t 5 --no-monitor -w 20

# Generate only specific report type
python3 main.py --txt-only -o scan_results

# Complex scan with custom settings
python3 main.py -f /var/network_ips.txt -p 9000 -t 10 -o network_audit

CLI Parameters

Parameter Description Example
-ip, --ip-address Single IP or comma-separated list -ip 192.168.1.1
-p, --port Target port to check -p 9000
-f, --file Custom IP list file -f /var/ips.txt
-t, --timeout Connection timeout (seconds) -t 5
-o, --output Output file prefix -o scan_results
--txt-only Generate only TXT report --txt-only
--html-only Generate only HTML report --html-only
--no-monitor Disable system monitoring --no-monitor
-w, --workers Worker thread count (static mode) -w 15

๐Ÿ“„ IP Address File Format

Create ip_addresses.txt or use custom files:

# TCP Port Checker - IP Addresses List
# Lines starting with # are comments

# Single IPs
192.168.1.1
10.0.0.1

# Comma-separated IPs
192.168.1.10, 192.168.1.11, 192.168.1.12

# Domain names
google.com
github.com

๐Ÿ“Š System Features

๐Ÿค– Dynamic Worker Management

  • Low Load (<30%): CPU_COUNT ร— 3 workers
  • Medium Load (30-60%): CPU_COUNT ร— 2 workers
  • High Load (60-80%): CPU_COUNT ร— 1 worker
  • Critical Load (>80%): CPU_COUNT รท 2 workers

๐Ÿ“ฆ Dynamic Batch Processing

  • High Load: Small batches (ร—0.4)
  • Normal Load: Regular batches (ร—1.0)
  • Low Load: Large batches (ร—1.4)

๐Ÿ›ก๏ธ Intelligent Throttling

  • >95% Usage: 2-second delays
  • >90% Usage: 1-second delays
  • >85% Usage: 0.5-second delays

๐Ÿ“ˆ Output Examples

Console Output

๐Ÿš€ Checking 5 hosts on port 52311
๐Ÿ’ป CPU:โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘(87.3%) | RAM:โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘(75.2%) | Workers:8 | Throttle:๐ŸŸข

IP ADDRESS      | PING     | PORT       | STATUS
----------------------------------------------------------------------
192.168.1.1     | PING โœ“   | TCP52311 โœ— | ๐ŸŸก PING OK, PORT CLOSED
10.0.0.1        | PING โœ“   | TCP52311 โœ“ | ๐ŸŸข FULL ACCESS
google.com      | PING โœ“   | TCP52311 โœ— | ๐ŸŸก PING OK, PORT CLOSED

Status Codes

  • ๐ŸŸข FULL ACCESS: Ping โœ“ + Port โœ“
  • ๐ŸŸก PING OK, PORT CLOSED: Ping โœ“ + Port โœ—
  • ๐ŸŸ  PING FAILED, PORT OPEN: Ping โœ— + Port โœ“
  • ๐Ÿ”ด NO ACCESS: Ping โœ— + Port โœ—

๐ŸŽจ Report Generation

TXT Report

  • Detailed statistics and analysis
  • Categorized results by status
  • Performance recommendations
  • Problem analysis and suggestions

HTML Report

  • Interactive web interface
  • Color-coded status indicators
  • Real-time filtering
  • Responsive design for all devices

โš™๏ธ Configuration

Edit config.py to customize:

DEFAULT_PORT = 52311                 # Default port to check
DEFAULT_TIMEOUT = 3                  # Connection timeout
MIN_WORKERS = 2                      # Minimum threads
MAX_WORKERS_LIMIT = 50               # Maximum threads
THROTTLE_CPU_THRESHOLD = 85          # CPU throttle threshold
THROTTLE_MEMORY_THRESHOLD = 85       # RAM throttle threshold

๐Ÿ”ง Development

Code Structure

  • Modular Design: Clean separation of concerns
  • PEP 8 Compliant: Professional Python standards
  • Thread-safe: RLock protection for shared resources
  • Error Handling: Comprehensive exception management
  • Type Hints: Enhanced code readability

Testing

# Test with minimal IPs
echo "127.0.0.1" > test_ips.txt
python3 main.py -f test_ips.txt

# Test CLI arguments
python3 main.py -ip 127.0.0.1 -p 22 --txt-only

๐Ÿ› Troubleshooting

Common Issues

IP file not found:

โŒ IP list file not found: ip_addresses.txt

Solution: The program will auto-create a sample file. Edit it and run again.

Permission denied for ping:

โŒ Ping command failed

Solution: On some systems, you may need sudo privileges for ping commands.

Invalid IP format:

โš ๏ธ Line 5: Invalid IP format skipped: 10.25.1.300

Solution: Fix IP addresses (values must be 0-255).

Performance Tips

  • Use --no-monitor for consistent performance on stable systems
  • Adjust -w (workers) based on your system capabilities
  • Use -t (timeout) appropriate for your network latency

๐Ÿ“‹ System Requirements

  • OS: Linux, Windows, macOS
  • Python: 3.6+ (recommended: 3.8+)
  • RAM: Minimum 256MB available
  • CPU: Any modern processor
  • Network: Ping command access, TCP socket permissions

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit pull requests.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

๐Ÿ“ License

This project is open source and available under the MIT License.

๐Ÿ†˜ Support

If you encounter any issues or have questions:

  • Open an issue on GitHub
  • Check the troubleshooting section
  • Review the example usage patterns

โšก Pro Tip: Start with python3 main.py -ip 127.0.0.1 to test the application quickly!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tcp_port_checker-1.0.2.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tcp_port_checker-1.0.2-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file tcp_port_checker-1.0.2.tar.gz.

File metadata

  • Download URL: tcp_port_checker-1.0.2.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for tcp_port_checker-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9ef20009a72cdebd26aa3fa5e2461fbdbdd37b60b3ea521bbbca94b6d70aad49
MD5 ad14e876a248a811e85fc65f6bd72526
BLAKE2b-256 2f32fb9361d74594997635a05a7138ca921e50f5117afbfcaf67c773de0f50e0

See more details on using hashes here.

File details

Details for the file tcp_port_checker-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tcp_port_checker-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9f8cbfc7dffaa9496ee812c4f9d3fa7c1a6060869b532472dc8e5ae61ed277
MD5 6fb1fca410ee392f281c0f12bafaf7d9
BLAKE2b-256 741b51eca63417aebda32055662af06cf7a2222f56af132e19248686b524d542

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page