views:

37

answers:

2

During integration testing it is important to simulate various kinds of low-level networking failure to ensure that the components involved properly handle them. Some socket connection examples (from the Release It! book by Michael Nygard) include

  • connection refused
  • remote end replies with SYN/ACK but never sends any data
  • remote end sends only RESET packets
  • connection established, but remote end never acknowledges receiving packets, causing endless retransmissions

and so forth.

It would be useful to simulate such failures for integration testing involving web services, database calls and so forth.

Are there any tools available able to create failure conditions of this specific sort (i.e. socket-level failures)? One possibility, for instance, would be some kind of dysfunctional server that exhibits different kinds of failure on different ports.

EDIT: After some additional research, it looks like it's possible to handle this kind of thing using a firewall. For example iptables has some options that allow you to match packets (either randomly according to some configurable probability or else on an every-nth-packet basis) and then drop them. So I am thinking that we might set up our "nasty server" with the firewall rules configured on a port-by-port basis to create the kind of nastiness we want to test our apps against. Would be interested to hear thoughts about this approach.

+1  A: 

Take a look at the dummynet.

Nikolai N Fetissov
+1  A: 

You can do it with iptables, or you can do it without actually sending the packets anywhere with ns-3, possibly combined with your favourite virtualisation solution, or you can do all sorts of strange things with scapy.

Andrew McGregor