Reassemble Out-of-Order Message Chunks Over a Lossy Link

Last updated: November 29, 2026

Quick Overview

Large chat messages are split into chunks that may arrive out of order, duplicated or not at all. Write a receiver that rebuilds whole messages, delivers them strictly in sequence, and reports which chunks to retransmit.

Meta
Software Engineering Fundamentals
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Large chat messages are split into chunks that may arrive out of order, duplicated or not at all. Write a receiver that rebuilds whole messages, delivers them strictly in sequence, and reports which chunks to retransmit.

WhatsApp and Messenger run over flaky mobile networks, and their protocols layer ordering and reliability on top of the transport for things like media and multi-part payloads. In a networking-basics round at Meta, the interviewer wants to see how you handle reordering, duplicates and gaps without unbounded buffering, which is the same thinking TCP's receive window encodes.

What the Interviewer Expects
  • Buffers partial messages keyed by sequence number and chunk index
  • Ignores duplicates, including chunks of messages already delivered
  • Delivers complete messages in order, holding later ones until gaps fill
  • Produces negative acknowledgements for gaps that have waited past a timeout
  • Bounds buffer memory and explains the backpressure behavior when it fills
Key Topics to Cover
reordering
duplicate suppression
selective retransmission
flow control
networking basics
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you tell the sender what has been received so it can stop retransmitting (cumulative ACK versus selective ACK)?
  • What if one message is permanently lost: do you block the conversation forever?
  • How would you protect against a malicious sender that claims a huge total chunk count?
  • Which of these guarantees does TCP already give you, and why does the app layer still need some of them?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Each chunk: (msg_seq, idx, total, payload). Message sequence numbers start at 0 and are contiguous per conversation.
  • Output: complete messages, in sequence order, each exactly once.
  • `nacks(now...
High-Level Design

Two buffers: partial maps a message sequence to its received chunks, and complete holds fully assembled messages that cannot be delivered yet because an earlier message is still missing. `next_to_...


Submit Your Answer
Markdown supported