UDP is the preferable choice, if you do not need to implement a protocol that requires TCP (eg HTTP SMTP etc.) When a proper master slave structure is chosen, it is no big deal to make the UDP reliable. All you need is to implement a checksum and check if the master gets a correct answer on every command.

TCP (Transmission_Control_Protocol) and UDP (User Datagram Protocol) are protocols to send messages and datas over the internet.

limitations with LabVIEW embedded The TCP functions never time out. They can only be interrupted by a timed loop with higher priority. Therefore a complex framework has to be implemented The Zsystem targets cannot receive packets larger than 1480 bytes (Fragmented IP packets are not fully supported) Sending of larger data packets is no poblem.
packet order organized by the protocol must be organized by the application if required
protocol overhead moderate (~4 seconds to open a connection receive a message send a answer and close the connection again) The transmission is much faster when the connection is held open minimal
unknown packet size the packet size has to be sent first so that the receiver knows how many bytes will folllow entire packets are received

Wikipedia compares the two protocols as follows: (state: 25.01.2011)
TCP is a connection-oriented protocol, which means that it requires handshaking to set up end-to-end communications. Once a connection is set up user data may be sent bi-directionally over the connection.

  • Reliable – TCP manages message acknowledgment, retransmission and timeout. Multiple attempts to deliver the message are made. If it gets lost along the way, the server will re-request the lost part. In TCP, there's either no missing data, or, in case of multiple timeouts, the connection is dropped.
  • Ordered – if two messages are sent over a connection in sequence, the first message will reach the receiving application first. When data segments arrive in the wrong order, TCP buffers the out-of-order data until all data can be properly re-ordered and delivered to the application.
  • Heavyweight – TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control.
  • Streaming – Data is read as a byte stream, no distinguishing indications are transmitted to signal message (segment) boundaries.

UDP is a simpler message-based connectionless protocol. Connectionless protocols do not set up a dedicated end-to-end connection. Communication is achieved by transmitting information in one direction from source to destination without verifying the readiness or state of the receiver.

  • Unreliable – When a message is sent, it cannot be known if it will reach its destination; it could get lost along the way. There is no concept of acknowledgment, retransmission or timeout.
  • Not ordered – If two messages are sent to the same recipient, the order in which they arrive cannot be predicted.
  • Lightweight – There is no ordering of messages, no tracking connections, etc. It is a small transport layer designed on top of IP.
  • Datagrams – Packets are sent individually and are checked for integrity only if they arrive. Packets have definite boundaries which are honored upon receipt, meaning a read operation at the receiver socket will yield an entire message as it was originally sent.
udp_vs_tcp_ip.txt · Last modified: 2017/11/07 21:26 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki