views:

78

answers:

2

I'd like to create various network errors during testing. I'm using the Berkely sockets API directly in C++ on Linux. I'm running a mock server in another thread from within Boost.Test which listens on localhost.

For instance, I'd like to create a timeout during connect. So far I've tried not calling accept in my mock server and setting the backlog to 1, then making multiple connections, but all seem to successfully connect. I would think that if there wasn't room in the backlog queue I would at least get a connection refused error if not a timeout.

I'd like to do this all programatically if possible, but I'd consider using something external like IPchains to intentionally drop certain packets to certain ports during testing, but I'd need to automate creating and removing rules so I could do it from within my Boost.Test unit tests.

I suppose I could mock the various system calls involved, but I'd rather go through a real TCP stack if possible.

Ideas?

A: 

When I did some intensive protocol testing recently I used the click modular router. The advantage is it's quite powerful and relatively easy accessible. If you install click as a kernel module on a linux machine, you can easily reach network elements parameters for both setting and reading them. So you can for example change the loss rate of a drop element from 0 to 100%. While it is a little bit more difficult to get started with, you can simulate quite complex things with it. I personally used it (for example) this way to simulate varying bandwidth and packet loss circumstances to test an RTP video stream.

KillianDS
A: 

There was another question similar to this. My recommendation would be to use a network traffic generator like the IXIA. It will allow you to do many possible combinations of protocol testing in a repeatable way.

jcsf
I think you need http://www.ixiacom.com/ as an url :)
KillianDS
Yep, thanks. I fixed the link.
jcsf