Creating TCP network errors for unit testing

I want to create various network errors during testing. I use the Berkely Socket API directly in C ++ on Linux. I am running the server layout in another thread from Boost.Test that is listening on the local host.

For example, I would like to create a timeout during the connection. So far, I tried not to accept accept on my breadboard server and set the backlog to 1, and then make some connections, but everything seems to connect successfully. I would think that if there was no room in the backlog, I would at least get a refusal to refuse, if not a timeout.

I would like to do this all programmatically, if possible, but I would think about using something external, such as IPchains, to intentionally remove certain packages to certain ports during testing, but I would need to automate the creation and deletion rules so I can do this from my Boost.Test tests.

I suppose I could mock various system calls, but I would prefer, if possible, to use a real TCP stack.

Ideas?

+2
source share
2 answers

When I recently conducted intensive testing of the protocol, I used click modular router . The advantage is that it is quite powerful and relatively easy to access. If you installed a kernel module on a linux machine, you can easily reach the network element settings for configuration and reading. Thus, you can, for example, change the loss rate of the drop element from 0 to 100%. Although getting started is a little trickier, you can imitate pretty complex things. I personally used it (for example) in such a way as to simulate different bandwidth and packet loss in order to test the RTP video stream.

+1
source

There was a question similar to this one. My recommendation would be to use a network traffic generator like IXIA . This will allow you to perform many possible combinations of protocol testing in a repeatable manner.

0
source

All Articles