In Siemens PLC Open User Communication, whether using TCP or UDP protocols, the TCON function is required to establish a connection. Thoughtful readers might ask: Isn't UDP a connectionless protocol? Why is TCON needed to establish a communication connection? This article will answer that question.
Let's compare the TCP and UDP protocols. First, let's clarify the conclusion: TCP is a connection-oriented protocol; UDP is a connectionless protocol. Here, "connection" refers to a dedicated data transmission channel established at the protocol layer between the communicating parties.
The TCP protocol has a real data transmission channel, and its operation is very similar to making a phone call. To call someone, you first dial a number. Once the other person answers, a dedicated communication channel is established between them. If the connection is lost, you need to redial to re-establish the connection and continue the call. The TCP transmission process is similar: the initiator must establish a connection with the receiver to communicate. If the connection is interrupted, you need to re-request to establish a connection. TCP transmission has an acknowledgment mechanism, making it reliable and secure. Of course, it is relatively slower.
The UDP protocol, however, is different. It doesn't require establishing a real communication channel between two communication partners; its execution process is similar to writing a letter. The sender writes the recipient's name and address on an envelope and then drops the letter into a mailbox. Whether the letter successfully reaches the recipient or is lost en route is completely irrelevant. The UDP protocol lacks an acknowledgment and retransmission mechanism and doesn't require establishing a communication connection between communication partners, hence it's called a "connectionless" protocol. Its advantage is its faster transmission speed.
Okay, so here's the question. Since UDP is a connectionless protocol, why is it necessary to call the TCON function to establish a "connection" before using UDP transmission in Siemens PLC's Open User Communication (OPC)?
In fact, the TCON function can be used for both TCP and UDP connections. When used for TCP communication, it actually establishes a connection between the communication partners; while for UDP communication, it only configures communication parameters (such as the IP address and port number of the communication partner). The user program passes the UDP communication parameters to the PLC's operating system by calling the TCON function, and then the system handles the rest. The operating system is responsible for sending this information out in the form of UDP packets. Therefore, in UDP communication, the TCON function establishes a "connection" between the user program and the operating system, not a connection with the communication partner; this "connection" is not the same as the other kind of "connection."
The image below is a block diagram of the TCON function in the Portal environment: