1

I have a windows 8 PC, I am testing a beta program for network socket error handling. One of the ones I am having problem simulating for it to test is host unreachable and network unreachable errors. How can I simulate these conditions to know if the program is handling them correctly.

user3346931
  • 139
  • 1
  • 7

4 Answers4

3
  • Try connecting to an IP address that isn't being used.
  • Unplug your network connection at the point you want to simulate a failure
  • Unplug the other end of the conversation from your switch (or disconnect your internet if it is remote). This one tests what it does when your PC's connection is still up, which might be different from what it does when your network cable is disconnected.
Grant
  • 17,859
  • 14
  • 72
  • 103
3

For network unreachable errors, you can use route delete and remove all your routes. You should be able to get lots of network unreachable errors then.

william
  • 146
  • 4
1

While one could go about unplugging wires or deleting routes in your routing table, the kind of error conditions using these techniques is fairly limited. Instead, you could use a network simulator that will allow you to configure a virtual network then test your application against that.

This approach gets you several things:

  • Test scenarios can be repeated easily.
  • Test scenarios can be tested automatically.
  • You can test many different (and difficult) network setups without having to invest in hundred or hundreds of thousands of dollars in networking equipment.
  • Because you don't rely on physical proximity to network hardware, you can test anywhere that you write code.

There are several open source alternatives such as Cloonix, CORE Network emulator and others.

Green
  • 171
  • 1
  • 2
  • 9
0

you could also use the native firewall of Windows 8 to block the connection of your program.

DevOps
  • 720
  • 5
  • 16