Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCP-IP over GPRS with Modbus

Status
Not open for further replies.

F_Ionut

Technical User
Feb 17, 2017
1
RO
Hello.
I am working to a project involving a GSM/GPRS module which role it is to connect clients with some devices over the internet using TCP-IP and Modbus protocol. Now I am studying the TCP connecting scheme.
As far as I understood , the GSM network automatically close a TCP connection if there is not any traffic on it for some time.
I want to detect and maintain TCP connection as reliable as possible. Also to detect half-open connections.
The connection procedure is as follows: my GSM module acts as a server, so it opens a socket on port 502 and wait for clients to read data. The client can read data periodically at 3 minutes or longer.
When a client connects with my module , it requests for some data, the module sends the requested data and wait for other requests, and keeps the connection open. Now if the connection gets broken for other reasons (due to power failures, GSM network etc) the client needs to be able to connect with the module again. The module must detect broken connection and must act so the client can reconnect to it again
In order to detect broken connection the module send periodically some dummy data to the client and check if that data was received by the client. If not, the tcp connection must be re-established.
The question is: how to interpret this "re-establishment" of the connection?
1. Should I close the current TCP connection, and open a new one, meaning listening to port 502 again?
2. Should I close the current TCP connection and trying to connect to the port and ip of the client as provided from the last valid TCP connection?

The point is that the module must be available as soon as possible to answer to client's requests; that it is why I need the TCP connection to be functional as soon as possible.

PS. The module supports just AT commands ( Quectel M95 module) so I don't have access to all functionalities of the TCP stack.
Thank you.
(I am new in TCP stack so I may have used technical terms with improper meaning)
 
Typically…
The Modbus TCP client will handle establishment of the sockets.
The Modbus TCP server (your end device) should handle closing the socket should it become hung.
The client will initiate a poll of the end device (server) which establishes the socket on port 502. Should the socket close, the client will reestablish the socket on the next poll. It should be inherent in the client Modbus TCP driver.
As a Modbus TCP server, your device will be listening on port 502. Should a socket become hung, there should be a timer set in the server to close the socket should no data be received for X number of seconds. This should be a setting/function in the server.
Given that the Quectel M95 is just the transport, I do not think it would have any TCP control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top