Protocols

In this section you will find a general overview of the TCP and UDP transmission protocols and a link to the corresponding PLC libraries that are required to integrate the protocols. Both transmission protocols are part of the Internet Protocol Suite and are therefore of great importance for our everyday communication, e.g. via the Internet.

Transmission Control Protocol (TCP)

The TCP protocol is a connection-oriented transmission protocol (OSI Layer 4), comparable to a telephone connection, in which callers must first establish a connection before data can be transmitted. Data streams (bytes) can be reliably transferred on request via TCP, which is why it is also referred to as a "data stream-oriented transfer protocol" in this context. The TCP protocol is used in networks where the data sent by a client or server requires confirmation from the other party. The TCP protocol is well suited for transferring large amounts of data or data streams without a defined start/end identifier. For the transmitter this is not a problem since he knows how many data bytes are transmitted. However, the receiver is unable to detect where a message ends within the data stream and where the next data stream starts. A read call on the receiver side only supplies the data currently in the receive buffer (this may be less or more than the data block sent by the other device). The transmitter has to specify a message structure that is known to the receiver and can be interpreted. In simple cases the message structure may consist of the data and a final control character (e.g. carriage return). The final control character indicates the end of a message. A possible message structure, which is often used for the transmission of binary data with a variable length, can be defined as follows: A special control character (a so-called start delimiter) and the data length of the subsequent data are entered in the first data bytes. This enables the receiver to detect the start and end of the message.

TCP/IP Client

A minimum TCP/IP client implementation within the PLC requires the following function blocks:

TCP/IP server

A minimum TCP/IP server implementation within the PLC requires the following function blocks:

The instances of the function blocks FB_SocketAccept and FB_SocketReceive are called cyclically (polling), all others as required.

User Datagram Protocol (UDP)

UDP is a connection-less protocol, i.e. data is sent between network devices without an explicit connection. UDP uses a simple transmission model without implicitly defining workflows for handshaking, reliability, data ordering or congestion control. Even though the above description suggests that UDP datagrams arrive unsolicited or duplicated or cause congestion on the data line, the protocol is preferred over TCP in some cases, especially for real-time communication, as TCP features require more computing power and therefore more time. The UDP protocol is well suited to sending small amounts of data due to its connection-less nature. UDP is a "packet-oriented/message-oriented transport protocol", i.e. the sent data block is received on the receiver side as a complete data block.

The following function blocks are required for a minimum UDP client/server implementation:

The instances of the function block FB_SocketUdpReceiveFrom are called cyclically (polling), all others as required.

See also: Samples