Data Format - Application Protocol
The protocols TCP and UDP are used for the socket-based network communication. The data transmitted via these protocols is assembled based on a specific application protocol. Both peers must use the same application protocol for successful communication.
For this example application, an application protocol format has been defined. It allows the application to verify the received data and to create the suitable response if a request for information has been received.
This simple protocol contains the following information:
oTransmission ID
oLength of the text message
oText message which represents the request command or the information
The figure illustrates the data format of the application protocol:
The table provides further information on the elements:
Item of the protocol |
Datatype |
Description |
---|---|---|
Transmission ID |
UINT |
The transmission ID is randomly generated by the TCP client. It is sent back by the server in the response so that the client can verify the received data. |
Length of text message |
USINT |
Indicates the length of the text message in bytes (number of characters + 1). This allows the receiving site to verify the consistency of the data. |
Text message |
STRING[80] |
The text message contains the application data. |
The communication between client and server via TCP consists of the following steps:
oThe client sends a request with the text message GetTimestamp to the server.
oThe server responds to that request:
If the request was correct, the server responds by sending the same transmission ID and the system time as text STRING in ASCII format.
If the server cannot interpret the request message (because it differs from GetTimestamp), the response contains the text STRING UnknownCommand besides the transmission ID and the length of the text message.