Replicate Application Network Behaviour
-
Well this is my third post resulting from this project I'm working on, which is taking me right out of my comfort zone! I'm trying to replicate the behaviour of a server application we have which controls various display screens around the building over the network. The application itself is overly complex for our admin staff to use and I want to make my own which replicates just one small function of the original with a very simple UI. I think the networking side is fairly simple but although I'm quite experienced with vb.net I've never delved into the networking side of things before and it's a whole new scary world. Up until now I've successfully got my version to broadcast a UDP packet with the required data, to which the display screens respond with an ICMP echo request. My server automatically replies to the echo (I didn't code that, the machine just does it). After that the client starts sending TCP packets in attempt to register itself with the server, and now that's where I'm stuck. The client is sending a packet which apparently has no data but does have the SYN flag set to 1 and contains various 'options' (I'm getting this from a packet sniffer). When the real application receives that packet it responds with its own packet with the SYN flag as 1 and the ACK flag as 1, as well as the same options. However, because I haven't got the real application running my server machine just responds with a TCP packet with ACK=1 and RST=1, and no options. My question is how do I code in vb.net the receipt of these packets from the client and respond with the correct flags and options? There are some good tutorials online for coding client/server communications using the Sockets class and I've got as far as I have by following these but none of them explain how to set flags and such. I suspect what I'm trying to do is at a lower level. Do I even need to manually create these packets? I'm a bit out of my depth so any help would be very gratefully received!
-
Well this is my third post resulting from this project I'm working on, which is taking me right out of my comfort zone! I'm trying to replicate the behaviour of a server application we have which controls various display screens around the building over the network. The application itself is overly complex for our admin staff to use and I want to make my own which replicates just one small function of the original with a very simple UI. I think the networking side is fairly simple but although I'm quite experienced with vb.net I've never delved into the networking side of things before and it's a whole new scary world. Up until now I've successfully got my version to broadcast a UDP packet with the required data, to which the display screens respond with an ICMP echo request. My server automatically replies to the echo (I didn't code that, the machine just does it). After that the client starts sending TCP packets in attempt to register itself with the server, and now that's where I'm stuck. The client is sending a packet which apparently has no data but does have the SYN flag set to 1 and contains various 'options' (I'm getting this from a packet sniffer). When the real application receives that packet it responds with its own packet with the SYN flag as 1 and the ACK flag as 1, as well as the same options. However, because I haven't got the real application running my server machine just responds with a TCP packet with ACK=1 and RST=1, and no options. My question is how do I code in vb.net the receipt of these packets from the client and respond with the correct flags and options? There are some good tutorials online for coding client/server communications using the Sockets class and I've got as far as I have by following these but none of them explain how to set flags and such. I suspect what I'm trying to do is at a lower level. Do I even need to manually create these packets? I'm a bit out of my depth so any help would be very gratefully received!
Without seeing anything else in those packets, I'm guessing that the client is opening a TCP connection with the server on a certain port.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
Without seeing anything else in those packets, I'm guessing that the client is opening a TCP connection with the server on a certain port.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...Yes, I think it is. But how do I get my application to respond in the same way as the one I'm copying does and allow the connection to be made? Once the server has returned a packet with the syn=1 flag it sends another packet telling the client that it was registered successfully.
-
Yes, I think it is. But how do I get my application to respond in the same way as the one I'm copying does and allow the connection to be made? Once the server has returned a packet with the syn=1 flag it sends another packet telling the client that it was registered successfully.
I have no idea. But, what you describe sounds exactly like the client opening a connection to the server using TCP. What port number is used would be in the packet. Without seeing the packet data, it's almost impossible to say what's going on. You really can't look at one or two packets, but at a group of packets in the conversion to figure out what is really happening.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
I have no idea. But, what you describe sounds exactly like the client opening a connection to the server using TCP. What port number is used would be in the packet. Without seeing the packet data, it's almost impossible to say what's going on. You really can't look at one or two packets, but at a group of packets in the conversion to figure out what is really happening.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...Alright, well it seems as if the TCP connection is being established now. The next packet that the client sends contains 26 bytes of data, which I've intercepted and read with a packet sniffer. My VB code receives this package and I've written it to display what's received, but it doesn't show the whole lot, for some reason. While the packet sniffer shows that the packet data contains the client name I only get the first four or five bytes of data displayed from my VB code. The rest seems to be ignored, even though a line I've written in to count the number of bytes indicates that the whole lot is being received. I've used a 'Do While' loop to make sure that the buffer is empty before displaying the data but still I only get those few bytes. Any idea why the packet sniffer is intercepting data in the packet which my application isn't receiving/displaying?