views:

57

answers:

1

I am connected via ethernet to a simple I/O hardware device which is controlled by a very old, inflexible .NET driver. I've used WireShark to peek at the packets and they are very small, simple packets containing the name of the driver and a few bytes for data (unencrypted). Each packet receives a success packet from the hardware device with a few bytes of confirmation data. There doesn't appear to be any persistence with the connection, it seems to be very trasnsactional.

I would like to fashion my own driver for this device, and send it my own packets to eliminate the junky driver. I understand struct layouts and how to format them explicitly, my question is what the slickest, most modern method of sending data to this network device would be.

Just looking for some info to get me started. Any ideas?

+1  A: 

Avoid thinking in terms of "driver", true operating system drivers cannot be written in a .NET language. The original code no doubt used a simple Socket. So can you. The only hard part is figuring out the exact protocol, the meaning of each individual byte.

Use Reflector on the original .NET assembly, you can probably reverse-engineer it. Do first check if your license agreement allows this, it isn't exactly common.

Hans Passant
Thanks Hans, I loosely (incorrectly) use the word "Driver" to mean any software that controls an external hardware device. Bad habit. Anyways, when you speak of Simple Socket -- are you referring to System.Net.Sockets? Is this the best way to do a transactional style packet sending? What about the return packet. I'm obviously kind of a noob with networking.
bufferz
Not so sure what 'transactional' means here, TCP guarantees delivery.
Hans Passant
By transactional I mean that there doesn't appear to be any persistence of the connection between explicit data sending. There is no activity going back and forth between the two devices maintaining any sort of state.
bufferz
Not sure why any state should be exchanged. It is pretty normal for programs to maintain their own state and just exchange messages. Avoid comparing this to ASP.NET session state where a session need to bolted on top of a server implementation that is stateless. Yes, it is probably a very simple protocol, as you observed.
Hans Passant
Hans, I see that you don't waste words, but your answer+comments gave me just enough information to find my own answer, so for that -- thank you on several levels!
bufferz