SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

System design
How a Request Crosses a NetworkIPTCPUDP Routing, streams, and datagramsDNSHTTP Requests and Responses From a hostname to an HTTP response
Networking

UDP

Choose a delivery policy for missing, duplicate, and late datagrams.

Lesson goal

Trace two game-state updates and decide which datagrams the application should use, ignore, or recover.

Before you begin — TCP.

UDP (User Datagram Protocol) sends individual messages called datagrams. A game can send each position snapshot as soon as it is ready. If tick 1 is lost, a receiver that gets the complete snapshot for tick 2 can apply it immediately. The tick numbers and the decision to advance belong to the game.

The first game-state datagram is lost. The receiver applies the second snapshot without waiting for the first.

Decide what each datagram means

Each datagram carries its own payload and port information. UDP preserves message boundaries and lets a sender transmit without a transport handshake. A datagram can be lost, duplicated, or delivered after a later datagram. If the application needs acknowledgements, retransmissions, or ordering, it must supply that behavior or choose a protocol that does.

UDP datagrams can go missing or arrive out of order. UDP provides no automatic retransmission.

The game can attach an increasing tick number to every complete position snapshot. Suppose snapshots 1 and 3 arrive, then snapshot 2 arrives late. After applying 3, the receiver discards 2. Applying it would move the player back to an older position. This works because snapshot 3 contains everything needed to place the player. An update expressed only as a change from snapshot 2 would have a different recovery requirement.

Give real-time media a deadline

Suppose an audio frame is missing at its playback deadline. The application can conceal the gap and play the next frame. A playback buffer gives late frames more time to arrive, at the cost of additional delay before the listener hears the audio.

An application using UDP can request a retransmission while it would still be useful. It also needs to respond to network congestion. The actual delay depends on conditions along the path and on the application’s recovery policy. UDP usage guidelines

Check your understanding

A game sends a position snapshot and a purchase request. Could it discard either message as soon as a newer message arrives?

Compare your reasoning

A newer complete snapshot can supersede an older position. A purchase represents a lasting action. It needs a way to confirm the outcome and to handle a retry without charging the player twice.

Key Takeaways

  • Datagrams preserve individual messages and can be sent without a UDP connection handshake.
  • Sequence numbers and deadlines let an application decide whether an update is still useful.
  • Recovery depends on what a missing message means for the application. Complete snapshots and purchases call for different policies.

Take the quiz · Routing, streams, and datagrams

How is this lesson?

Previous lessonTCPNext lesson Routing, streams, and datagrams
Edit on GitHubReport on GitHub
On this page
%

On this page

Decide what each datagram meansGive real-time media a deadlineCheck your understandingKey Takeaways