Protocolo de datagrama do usuário: IOT Parte 30

User Datagram Protocol: IOT Part 30

The TCP/IP protocol, despite being the most common protocol stack on the Internet, is not very suitable for IoT applications due to the high overhead. It is best suited for applications where reliable data delivery with high available bandwidth is required. IoT applications generally have limited bandwidth and require fast transfer of small data packets. In this case, the UDP/IP stack is much better than TCP/IP.
User Datagram Protocol (UDP) is the simplest transport layer protocol mainly used to establish low-latency, loss-tolerant connections between applications in the communication network. Both TCP and UDP run on top of the Internet Protocol (IP), which is why they are called TCP/IP and UDP/IP.
Protocolo de datagrama de usuário (UDP)
UDP is a connectionless protocol, which means the sender just transmits the data without waiting for the receiver to connect. It is an unreliable protocol when compared to TCP. There is no error checking mechanism or correction mechanism involved in data transmission which results in less bandwidth being used. The UDP protocol only sends packets (or datagram). There is no guarantee of confirmation of the packet received at the other end. It allows for less data overhead and delays.
For increased performance, the protocol allows individual packets to be dropped (without retries) and UDP packets to be received in a different order than they were sent, as determined by the application.
UDP Features –
The UDP protocol stack has the following features –
1) UDP can be used when acknowledging the data has no meaning.
2) It's great for one-direction data flow.
3) It is a connectionless protocol.
4) It does not provide any congestion control mechanism.
5) It is a protocol suitable for streaming applications such as video conferencing applications, computer games, etc.
UDP datagrams –
UDP traffic works through packets called datagrams, with each datagram consisting of a single message unit. The header details are stored in the first eight bytes, but the rest is what holds the actual message. The UDP datagram header can be divided into four parts, each two bytes long. These parts are as follows –
1) Source port – This 16-bit (2 bytes) information is used to identify the sender port that will send the data. A valid UDP port number ranges from 0 to 65535.
2) Destination port – This 16-bit information is used to identify the receiver port on which data will be received. A valid UDP port number ranges from 0 to 65535. This field identifies the receiver port and is required.
3) Length – The length field specifies the total length of the UDP packet (UDP header and UDP data). This individual field is a 16-bit field. The minimum length of the Length field is 8 bytes in case there is no UDP data.
4) Checksum – This field stores the checksum value generated by the sender before sending the data to the recipient. UDP checksums protect message data from corruption. The checksum value represents an encoding of the datagram data calculated first by the sender and then by the receiver. In UDP, checksum is optional, unlike TCP where checksum is mandatory.
Advantages of UDP –
UDP/IP has the following advantages over the TCP/IP stack –
1) It is better than TCP for applications that require constant flow of data, bulk data and that require speed rather than reliability.
2) For multicast and broadcast purposes, UDP is more suitable because it supports point-to-multipoint transmission method. The sender does not need to keep track of retransmitting data to multiple receivers, in contrast to TCP/IP, where the sender needs to take care of each packet.
3) There is a small packet header overhead in UDP (only 8 bytes), while TCP has 20 bytes of header.
In the next tutorial – Client Server Communication over UDP Protocol, an ESP8266 module is configured as a UDP server and a laptop is configured as a UDP Client. The UDP Client sends some data to the server and the server recognizes this by turning on an LED.

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.