Python-based network stress testing tool — generate TCP/UDP/ICMP/DNS/raw packets, run predefined scenarios (SYN flood, UDP flood, HTTP load, DNS stress, mixed floods), or craft custom tests. WARNING: Only test networks/systems you own or have explicit permission to test. Misuse is illegal and unethical.
The Network Stress Tester is a Python tool using Scapy to craft and send packets for stress and resilience testing. It supports interactive and CLI modes, multiple protocols, rate control (token bucket), multithreading, real-time monitoring, and logging.
-
Multiple protocols: TCP, UDP, ICMP, DNS, and raw packets.
-
Predefined test scenarios:
- SYN Flood (TCP)
- UDP Flood
- ICMP Flood (Ping)
- HTTP Load Test
- DNS Stress Test
- Mixed Protocol Flood (TCP + UDP + ICMP)
-
Customizable parameters: target, port, protocol, duration, packet rate, threads, payload size.
-
Token-bucket rate control for precise PPS (packets per second).
-
Multi-threaded sending for higher throughput.
-
Real-time monitoring: packets sent, current rate, elapsed time.
-
Logging:
network_tester.logstores test metadata and errors. -
Input validation and clear ethical warnings.
-
Python 3.6+
python3 --version
-
Scapy
pip install scapy
-
Root privileges (required for raw sockets / packet crafting): run with
sudo. -
Optional:
tcpreplayfor high-speedsendpfast(Debian/Ubuntu example):sudo apt-get install tcpreplay
-
Save the script as
network_tester.py. -
Make executable (optional):
chmod +x network_tester.py
-
Run with
sudowhen sending raw packets:sudo python3 network_tester.py
Run without arguments to open the menu-driven interface:
sudo python3 network_tester.pyMenu options typically include:
- Quick Test (minimal required inputs)
- Advanced Test (choose a predefined scenario)
- Custom Test (full parameter control)
- Stop Test
- Exit
Run tests directly from CLI:
sudo python3 network_tester.py [target] [options]Command-line options
target: Target IP address or hostname (required for CLI mode)
-p, --port Target port (defaults to protocol-specific)
-t, --protocol Protocol: tcp | udp | icmp | dns | raw (default: tcp)
-d, --duration Duration in seconds (default: 10)
-r, --rate Packets per second (default: 100)
-n, --threads Number of threads (default: 3)
-s, --size Payload size in bytes (default: 64)
-a, --advanced Run predefined scenario: syn-flood, udp-flood, icmp-flood,
http-load, dns-test, mixed-flood
--json Output results in JSON format
--html Generate an HTML report
-o, --output Output filename prefix (for reports/logs)
syn-flood— TCP SYN flood (example default: 5000 pps, 60s)udp-flood— UDP floodicmp-flood— ICMP ping floodhttp-load— simulate many HTTP requests (requires HTTP payload/method)dns-test— DNS query stress to port 53mixed-flood— mixes TCP/UDP/ICMP (example default: 3000 pps, 60s)
Run a SYN Flood:
sudo python3 network_tester.py 192.168.1.1 -a syn-flood
# runs: TCP SYN flood at 5000 pps for 60 seconds (default)Custom DNS test:
sudo python3 network_tester.py 192.168.1.1 -p 53 -t dns -d 60 -r 1000 -n 5 -s 128
# DNS packets to port 53, 1000 pps, 60s, 5 threads, 128B payloadMixed protocol flood:
sudo python3 network_tester.py 192.168.1.1 -a mixed-flood
# Mix of TCP/UDP/ICMP at 3000 pps for 60s (default)- Console: real-time progress (packets sent, instantaneous/average rate, elapsed time).
- Log file:
network_tester.log— recorded test configuration, start/stop times, totals and errors. - Reports: optional JSON or HTML report generation (if flags provided).
- Uses a token bucket algorithm to control packet send rate precisely across threads.
- Threads pick from a shared bucket of tokens; token refill aligned to desired PPS.
- High packet rates may be CPU- or NIC-limited; consider
tcpreplay/sendpfastfor very high throughput and pcap-based replay. - Multithreading increases throughput but also increases host load — monitor CPU and NIC utilization during tests.
READ BEFORE USING:
- Authorized Use Only. Run tests only on networks/devices you own or have written permission to test.
- Unauthorized testing can cause outages and expose you to legal action (e.g., CFAA in the U.S. or local equivalents).
- Prefer controlled lab or VM environments for development/testing.
- Obtain written permission from stakeholders and schedule tests to minimize impact.
Root Privileges Error
-
Ensure you run the script with
sudo:sudo python3 network_tester.py
Scapy Not Found
-
Install Scapy:
pip install scapy
-
Test import:
python3 -c "import scapy; print(scapy.__version__)"
Invalid IP/Hostname
-
Verify the target is reachable and resolvable:
ping -c 3 example.com
High CPU Usage
- Reduce
-r(rate) or-n(threads). Usehtop/topto monitor CPU. Considertcpreplayfor very high rates.
Permission / Firewall Issues
- Ensure local firewall or IDS/IPS doesn't block crafted packets. Use a lab environment to avoid production disruptions.
2025-09-28 18:30:45,123 - INFO - Starting TCP test to 192.168.1.1:80, Duration: 60s, Rate: 5000 pps, Threads: 3, Payload size: 64 bytes
2025-09-28 18:31:45,456 - INFO - Test completed. Sent 299850 packets, Average rate: 4997.5 pps, Duration: 60.02s
- Add packet capture and automatic analysis of target responses (pcap + analysis).
- Graphical visualization: packet rate over time, CPU/NIC utilization charts.
- Batch sending using
sendpfast+tcpreplayintegration for extreme throughput. - Support additional application-level protocols and more realistic traffic (e.g., full HTTP(S) transactions with TLS).
- Distributed testing mode (coordinated clients) with centralized result aggregation.
Provided as-is, without warranty. Use responsibly and at your own risk.This project is licensed under the MIT License. See LICENSE for details.
If you find bugs, have suggestions, or want to contribute, open an issue or contact the developer listed in the project repository.
Always get written permission before testing a target. Unauthorized testing can have serious legal and ethical consequences.