UDP
UDP uses socket communication without connection (datagram), compared to TCP wich is a connected protocol.
In the RemnodeUDP-object you specify the name and ip-address of the node to communicate with
as well as the port-numbers for both ends. The local port-number needs to be unique on your node
not to conflict with other communications.
As default, all messages are sent with a special header that is not included in the user data buffer.
This header is added at the beginning of the message. The purpose for the header is to give information
about the message that is sent. This helps identifying what type of message that is received and to which buffer
the data will be unpacked. The header looks like:
char RemId1; /* STX (Hex 02) */
char RemId2; /* ETB (Hex 0F) in data message without acknowledge
ENQ (Hex 05) in data message with acknowledge
ACK (Hex 06) in acknowledge message */
short int Length; /* Number of bytes in message including this header */
short int MessId1; /* Message identity part 1 */
short int MessId2; /* Message identity part 2 */
All of the integers in the header will be sent as big endian values, which means the most significant byte first
in the datagram. The user data is the responsibility of the user to switch, if he wants integers to be sent
with big endian. Intel (x86), VAX and Alpha all use little endian! To send messages without headers, the
attribute DisableHeader should be set to TRUE. When communicating between two ProviewR-systems the header
should be kept on. MessId1 and MessId2 are fetched from attributes RemTrans.Address[0] and RemTrans.Address[1].
Through the header it is also possible to request an acknowledge of a sent message. If there is no
acknowledge the message will be resent with a cyclicity specified by the RetransmitTime-attribute in the
remtrans-object.
Since UDP/IP is a connectionless protocol there is a possibility to watch the connection using
keepalive-messages. This is set through the attribute UseKeepalive.
Sending messages
The transport will send a message to the remote port, consisting of header + data.
MessId in the header is taken from RemTrans.Address[0,1], byte-switched to send as big endian.
If MaxBuffers in remtrans-object > 0, the message is sent with type "want acknowledge" and is stored
in the retransmit queue for the remnode. When a corresponding acknowledge message is received, the
message is deleted from the retransmit queue. This is done automatically by the transport process.
Receiving messages
When we receive a buffer, we first check the header to see that this is a correct RemTrans message.
Then we search for RemTrans.Address[0,1] that matches the byte-switched MessId. If the data object for
this message is big enough to contain the message, the message will be stored, and the
DataValid flag will be set.
If the Remnode is marked to be used without header (DisableHeader-attribute set) then a RemTrans marked as a
receiving remtrans with a enough large buffer will be searched.