How Does the UDP Header Work in Computer Networks?

695.5K views
April 24, 2018
by
Gate Smashers
YouTube video player
How Does the UDP Header Work in Computer Networks?

TL;DR

UDP sends data without establishing a connection and does not guarantee delivery or packet order. Its fixed 8-byte header contains source port, destination port, length, and checksum fields, while the length field permits a maximum segment size of 65,535 bytes. The checksum detects errors and is optional in IPv4 but mandatory in IPv6.

Transcript

Hello friends! Welcome to Gate Smashers The topic is UDP That is User Datagram Protocol In transport we have seen that two protocols are very important. That is TCP and UDP So we are talking about UDP in this video. That where we use User Datagram Protocol We'll discuss about UDP header. So first I want to tell you about UDP It is a connection less... Read More

Key Insights

  • UDP is a connectionless transport protocol, which means data is sent without first creating a connection between the communicating machines. The lecture compares this behavior to posting a letter, where the sender prepares the data and dispatches it directly to its destination.
  • UDP is described as unreliable because it does not respond when one or more transmitted packets are lost. Reliability mechanisms associated with establishing a connection and ensuring delivery are not provided, so an application using UDP cannot assume that every sent packet reached the receiver.
  • UDP provides no packet-ordering guarantee because its header does not include a sequence number. If packets numbered 1, 2, 3, and 4 are transmitted, packets 3 or 4 may arrive before packet 2, especially when packets travel across different network paths.
  • The UDP header contains four fields: source port, destination port, length, and checksum. Source and destination ports identify the sending and receiving applications, supporting the transport layer's responsibility for end-to-end delivery between processes rather than merely between machines.
  • Port numbers range from 0 to 65,535 because a port field uses 16 bits. Ports from 0 to 1,023 are identified as well-known ports, while later values include registered and ordinary ports that applications and operating systems can use.
  • The UDP length field is 16 bits and represents the total size of the segment, including both its header and payload. Its maximum represented segment size is 65,535 bytes, rather than 65,536, because the 16-bit numeric range begins at zero.
  • The UDP header is always 8 bytes, leaving a maximum payload of 65,527 bytes when the total segment reaches 65,535 bytes. Payload means the pure application-layer data placed after the compulsory header, and smaller payloads can also be transmitted.
  • The UDP checksum detects errors by calculating a hash-like value from the UDP header, payload, and IP pseudo header. The receiver performs the calculation again and compares the values. The field is optional with IPv4 but mandatory with IPv6.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What is UDP and why is it called connectionless?

UDP, or User Datagram Protocol, is a transport protocol that sends data without first establishing a connection between the client and server. Its operation is compared to postal service: a sender writes a letter, places it in an envelope, and posts it without creating a dedicated connection. The data can therefore be dispatched directly to another machine.

Q: Why is UDP considered an unreliable protocol?

UDP is considered unreliable because it does not ensure that every transmitted packet reaches its destination. If one or two packets are lost from a larger transmission, UDP does not take responsibility for that loss. Its connectionless operation also allows packets to follow different network paths, which creates opportunities for packets to be lost before reaching the receiver.

Q: Does UDP guarantee that packets arrive in order?

UDP does not guarantee packet ordering because it does not use a sequence-number field. When packets 1, 2, 3, and 4 are sent, the receiver might obtain packet 3 first, packet 4 next, and packet 2 later. Packets can follow different paths through different networks, so their arrival sequence may differ from their transmission sequence.

Q: What fields are included in a UDP header?

A UDP header contains four fields: source port, destination port, length, and checksum. The source and destination port fields identify the applications at both ends of the communication. The length field records the total segment size, while the checksum field can detect whether an error affected the header or data during transmission.

Q: What are source and destination ports in UDP?

The source port identifies the application sending the data, while the destination port identifies the receiving application or service. The operating system can assign a port when an application such as a browser connects to the internet. Port numbers range from 0 to 65,535, and values from 0 to 1,023 are categorized as well-known ports.

Q: What does the UDP length field represent?

The UDP length field is 16 bits and represents the total size of the complete UDP segment, including both the header and payload. A 16-bit value covers numbers from 0 to 65,535, so the maximum total segment size is 65,535 bytes. The field does not mean that the segment itself is only 16 bits long.

Q: What is the maximum UDP payload described in the lecture?

The maximum UDP payload described is 65,527 bytes. The total UDP segment can be at most 65,535 bytes, and the compulsory UDP header always occupies 8 bytes. Subtracting the 8-byte header from the maximum total length leaves 65,527 bytes for payload, which is the pure data received from the application layer.

Q: How does the UDP checksum detect transmission errors?

The UDP checksum is calculated from three components: the UDP header values, the payload data, and the IP pseudo header. The sender transmits the resulting hash-like value with the data. The receiver calculates the value again from the same components. Matching values indicate no detected error, while different values indicate that the transmitted data contains an error.

Q: Is the UDP checksum mandatory in IPv4 and IPv6?

The UDP checksum field is optional when UDP operates with IPv4, so communication can still function without using it. With IPv6, the checksum field is mandatory. Although UDP remains unreliable and does not recover lost or unordered packets, the checksum can identify data errors by comparing the sender's calculated value with the receiver's independently calculated value.

Summary & Key Takeaways

  • UDP is a connectionless transport protocol that sends data without first establishing a path between the client and server. It resembles postal service because a sender can dispatch data directly. This approach provides no assurance that every packet will arrive, and UDP does not recover packets that are lost during transmission.

  • UDP does not maintain packet ordering because its header has no sequence-number field. Packets may travel through different network paths and reach the receiver in a different order. Unlike the many options available in a TCP header, the UDP header contains only source port, destination port, length, and checksum fields.

  • The UDP header has a fixed size of 8 bytes. Its 16-bit length field describes the total segment size, including both header and payload, with a maximum value of 65,535 bytes. The checksum detects data errors by using the UDP header, payload, and selected unchanging fields from the IP pseudo header.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from Gate Smashers 📚