How to test how an application handles thousands of TCP connections

stress-testingtcp

We're attempting to track down an issue a client is having with injecting large quantities of mail to our gateway, and somewhere along the line, his connections are being rejected. Unfortunately, beyond that, the client has not provided much useful data other than that he doesn't seem to be getting SYN ACK messages back.

We're looking to do some testing of our service and establish just how many TCP connections it can establish (and later, messages we can inject) before it chokes. Are there any utilities which I could use to establish thousands of simultaneous TCP connections to a target? No payload is necessary.

Ideally, this tool would give us a rundown of how many connections it was able to establish, or how rapidly, etc.

Any thoughts are highly appreciated!

Best Answer

You could use hping to generate the traffic. But you'd be better off trying to actually replicate the real-world load.

hping Examples

Send TCP SYN packets to port 0 on host example.com (note that hping will increment the source port by 1 for each packet sent):

hping example.com -S -V

Send TCP SYN packets to port 443 on host example.com:

hping example.com -S -V -p 443

Send TCP packets to port 443 on host example.com with the SYN + ACK flags set:

hping example.com -S -A -V -p 443

Send TCP packets to port 443 on host example.com with the SYN + ACK + FIN flags set:

hping example.com -S -A -F -V -p 443

Send TCP SYN packets every 5 seconds to port 443 on host example.com:

hping example.com -S -V -p 443 -i 5

Send TCP SYN packets every 100,000 microseconds (i.e. every 0.1 second or 10 per second) to port 443 on host example.com. Note that verbose has been removed:

hping example.com -S -p 443 -i u100000

Send TCP SYN packets every 10,000 microseconds (i.e. every 0.01 second or 100 per second) to port 443 on host example.com:

hping example.com -S -p 443 -i u10000

Send TCP SYN packets every 10,000 microseconds (i.e. every 0.01 second or 100 per second) to port 443 on host example.com. Stop after 500 packets:

hping example.com -S -p 443 -i u10000 -c 500