3

I am trying to simulate a scenario where connection to the server of one process is down while the connection to another server is up. Just pulling the network cable won't work in my case since I need another process connection to stay up.

Is there any tool for this kind of job? I am on Windows. Thanks!

Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
Gant
  • 29,661
  • 6
  • 46
  • 65

3 Answers3

3

There's a few layers which you can simulate this at. The easiest would be if your two servers listen on two distinct TCP ports. In that case, you could run two tcp proxies, and stop/pause one when you want to simulate a failure. For Windows I would suggest using tcpTrace to do this.

Another option would be to have the two servers bound to two virtual NICs, which are bridged to the physical NIC. Of course if you have two physical NICs, you could bind each server process to a different physical NIC.

At a lower level, you can ran a WAN simulator. Most simulators allow you to impair specific types of traffic or specific ports. One such simulator is Packetstorm.

One other method which I would suggest is attaching a debugger to one process, and halting all threads on the process with the debugger. Often, a process doesn't die, but gets stuck in garbage collection, or in a loop. As the sockets don't close, many 'high availability' solutions won't automatically failover.

brianegge
  • 29,240
  • 13
  • 74
  • 99
2

One approach would be to mock the relevant network connection code for the purposes of testing. In this case you would probably want to mock it returning whatever it usually would if the connection was down.

William
  • 13,332
  • 13
  • 60
  • 73
  • Thanks for the answer. But I don't have access to the process's source code so I cannot do the mocking in application level. – Gant Aug 28 '09 at 06:32
0

A poor man's approach if you can use sleep/hibernate mode on your machine :

  • Set an Outbound rule in the Windows Firewall to disallow connection for a particular Program.
  • Already connected sockets stay connected: put the machine in sleep/hibernate mode for a brief moment to force those sockets to disconnect.
  • When the system is restored, the program cannot establish new connections.
  • New connections are made possible as soon as you disable the firewall rule.

Note that it does not simulate network outage because each connection fails immediately with an permission error. But it prevents a process to establish connections.

Eric Boumendil
  • 2,318
  • 1
  • 27
  • 32