Quick and Dirty Python UDP Stress Test
Description:
This is a pair of scripts that serve to do a rough 'stress test' of UDP capacity between two points on the network. The output is in kilobits per second.
Platform:
Should work anywhere that Python works.
Output:
Client:
C:\Python24>python udp_stress_client.py ---------------------------------------- udp_stress_client.py Updates and documentation (if any) at http://www.elifulkerson.com ---------------------------------------- Starting client end. Control-C to quit. Our target: udp_stress_server.py running on localhost port 8105 Enter number of bytes to send and the number of times to send them: (for instance '100 10' to send 10 bursts of 100 bytes each) % 10000 10 * * * * * * * * * * Done. %
Server:
C:\Python24>python udp_stress_server.py ---------------------------------------- udp_stress_server.py Updates and documentation (if any) at http://www.elifulkerson.com ---------------------------------------- Starting UDP receive server... control-break to exit. Waiting for data... Rcvd: 1 bytes, 1 total in 5.67876503857 s at 0.0014087570001 kbps Reset recieved, clearing statistics. Rcvd: 10000 bytes, 10000 total in 0.00103365092491 s at 77395.5675676 kbps Rcvd: 10000 bytes, 20000 total in 0.00237320665057 s at 67419.3290171 kbps Rcvd: 10000 bytes, 30000 total in 0.00382031794544 s at 62821.9963437 kbps Rcvd: 10000 bytes, 40000 total in 0.00508528318543 s at 62926.682415 kbps Rcvd: 10000 bytes, 50000 total in 0.00636784842766 s at 62815.5654997 kbps Rcvd: 10000 bytes, 60000 total in 0.00769818510453 s at 62352.3588329 kbps Rcvd: 10000 bytes, 70000 total in 0.00895029954924 s at 62567.7383108 kbps Rcvd: 10000 bytes, 80000 total in 0.0102228076473 s at 62605.110267 kbps Rcvd: 10000 bytes, 90000 total in 0.0114995062222 s at 62611.3840099 kbps Rcvd: 10000 bytes, 100000 total in 0.0127552524134 s at 62719.2605896 kbps
Caveats:
- This isn't extremely scientific or tuned. It measures simply by shoving a lot of UDP traffic through the network and seeing how much gets through.
- In actual use, I was seeing a lot of dropped UDP packets. For instance, on my Cisco Pix, I would send 2000 bursts and only 800 or so would get through. The reporting end of the utility doesn't care, it just measures what did get through and how long it took.
- No attempt was made to calculate the overhead of Python itself. (For instance, printing to the console takes time, which this utility doesn't take into account
- In situations where lots of UDP is dropped, the initial "reset" packet (1 byte sent once) might not make it to the server. You will be able to identify this if the test claims to take a lot longer than it should have. You will have to run it again in this case.
- No randomization of data occurs, the UDP data is just 'XXXXXX....' etc. This is a poor test if you are testing data compression rates, as it should all compress very well.
Download:
(You will need both)
udp_stress_server.py
udp_stress_client.py