# UDP length calculation · example 2

Subject: Computer Networks

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/cn/#tee/practice/transport/udp-size-2

Canonical: https://deep-learning-study-room.vercel.app/read/cn/tee/practice/transport--udp-size-2/

Optional extension · no matching calculation in the two supplied papers

**Optional worked extension.** This calculation format was not found in the supplied December 2025 final or February 2026 re-exam. The numbers and practice marks are authored. Study the core concept and actual-paper questions first; this is extra explanation, not a TEE prediction.

### Practice question. A UDP datagram carries 512 payload bytes. The IP header is 20 bytes with no additional extension headers. Find the UDP Length and complete IP packet size. [5 practice marks]

#### Answer

## Given

UDP payload=512 B; UDP fixed header=8 B; IP header=20 B.

## To find

UDP Length field and total packet bytes.

## Formula and why



$$
L_{UDP}=8+P,\quad L_{IP}=H_{IP}+L_{UDP}
$$



UDP Length includes its own header, but does not include the IP header.

## Step-by-step solution

#### Step 1. Include the UDP header

512+8=520 bytes.

#### Step 2. Include the IP header

520+20=540 bytes.

#### Step 3. Check layer boundaries

20 IP + 8 UDP + 512 data = 540 bytes.

**Final answer:** UDP Length=520 bytes; IP packet=540 bytes.

#### What this result means

Do not write the whole IP packet size into the UDP Length field. Link-layer overhead is excluded.
