Sensor Connection over TCP
In a range of systems, such as:
- Automation systems
- Perimeter protection systems
- Access and control systems
It s necessary to interconnect remote sensors with the software installed on the server.
The easiest and by most supported application communication is a TCP connection. In order to accomplish a TCP connection, two sides are needed:
Establishing and terminating of TCP connection is always initialized by the TCP client. BEWARE of the potential error!! When collecting data from remote sensors to a server with installed application, server (hardware) ≠ TCP server. TCP server is, in this case, represented by an IP converter at the sensor and the server (hardware) is from the TCP protocol point-of-view a TCP client.
Establishing a TCP Connection
Since TCP is a transport service, there must be a connection established between a TCP client and a TCP server. Establishing of connection is divided into three steps:
- SYN: the TCP client sends a datagram with a pre-set flag SYN and a randomly generated sequence number (x) to the TCP server.
- SYN-ACK: the TCP server sends a datagram with a pre-set flags SYN and ACK and the sequence number (x) incremented by +1 to a TCP client. At the same time, the TCP server generates a random number of its own sequence (y).
- ACK: the TCP client sends a datagram of a pre-set flag ACK and the sequence numbers (x) and (y) incremented by +1.
Both sides (TCP server and TCP client) remember both the number of their own sequences as well as the sequence number of the other side. These numbers are used in further communication to determine the order of packets. If the above mentioned three-way handshake is successfully completed the connection is established and will remain until its termination.
Terminating a TCP Connection
In order to terminate data transmission, the process of connection termination shall take place. It releases all allocated resources (TCP ports). To terminate the connection, datagrams with flags FIN and ACK are used. The termination of connection can be initiated by both sides. Example of termination initiated by a TCP client:
- The TCP client sends a datagram with a pre-set flag FIN
- The TCP server responds with a datagram with a pre-set flag ACK
- The TCP server sends a datagram with a pre-set flag FIN
- The TCP client responds with a datagram with a pre-set flag ACK
After these steps, TCP connection will be successfully terminated.
Support of TCP Connection in METEL Devices
METEL IP devices by default support TCP mode on RS485 and RS232 ports. Termination devices, in this case LAN-RING switches, monitoring units IPLOG or serial lines converters miniLAN shall be set to TCP server mode. After simple setting of TCP port and communication mode, it is possible to connect:
- Automation systems - sensors of temperature, humidity, speed, pressure.....
- Perimeter protection systems - perimetric sensors, evaluation unit of perimetric sensors
- Access control systems - readers
Setting of TCP Server Port
You can set the TCP server port for connection establishing here. In order to distinguish TCP connections, TCP protocol uses port numbers (so called TCP ports). In total 65535 TCP ports exist and they are categorized into three groups:
- Well-known TCP ports: in range 0 to 1023 are assigned by IANA and are typically used by system services. Examples: FTP (port 21 and 20), SMTP (port 25), DNS (port 53) and HTTP (port 80).
- Registered TCP ports: in range 1024 to 49151. Their use should be registered at ICANN.
- Private TCP ports: in range 49152 to 65535 are reserved for dynamic allocation and private use. They are not fixed for any applications.
To set a TCP port, it is necessary to select from so-called private ports.
Setting of Serial Line Mode
In the menu BUS select the correct mode of serial line. In TCP mode usually the following options are used:
- RS485 - standard RS485 port
- Peridect 485 - optimized for perimeter protection systems Peridect connected over RS485
- Cias - optimized for perimeter protection systems CIAS
Updated: 10. 03. 2020