Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simulate socket connection loss?

Tags:

c#

.net

sockets

In one of our client-server application, we need to test the behavior of application when socket connections are lost due to various reasons. For this test, we need to simulate a program that can forcefully break the connections on a specific port on server every few seconds. This way we can test the behavior of how the connected clients react to such connection breakages.

Please suggest me if I can do this in my code or I can use this with any free software.

EDIT: We know the port at which we need to block connections for few milliseconds or seconds.

like image 705
Faisal Avatar asked Oct 06 '22 01:10

Faisal


2 Answers

A daunting task!

  • First, grab the Microsoft Robotics SDK

  • Next, you'll need a programmable robot arm kit - there are a few of them reviewed here that look promising.

  • Now the tricky part - you'll need to code a series of actions that move the arm into position, close the hand (thus depressing the RJ45 release nubbin), then move laterally, so as to create an unplug/replug motion.

  • Once complete, position your robotic arm behind your system near the NIC ethernet port and call your methods to trigger the sequence!

like image 149
JerKimball Avatar answered Oct 10 '22 02:10

JerKimball


Assuming you are on Windows

NetStat Agent has a trial version where you can monitor connections and kill them automatically based on filter. Also you can kill them manually. The one thing it can not do is setup some delay before killing connection.

like image 24
David Goshadze Avatar answered Oct 10 '22 01:10

David Goshadze