Design a packet reassembler API | Bloomberg
Back
|
Home
/
System Design
/
Bloomberg
Design a packet reassembler API
Bloomberg
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
System Design
0
0
Design a PacketAssembler API for Streaming Fragments
Context and Assumptions
You are building a small component that assembles packets from a byte stream.
Each packet begins with a 1-byte header that encodes the payload length N (0–255). The header byte is not part of the payload.
The stream may arrive fragmented arbitrarily; a single call may contain parts of a packet or multiple full packets back-to-back.
Example interaction:
packetit(0x04, 'a', 'b', 'c') -> no output (header 4 indicates a 4-byte payload; only 3 bytes arrived)
packetit('d') -> 'abcd' (completes the prior packet)
Requirements
Specify the class and method signatures of a PacketAssembler API.
Describe state management: buffering, expected size, and how fragments are handled.
Behavior when receiving multiple consecutive packets within one or many calls.
Handling of invalid headers and oversized input (e.g., header value exceeds a configured maximum).
Define when/how state resets after emission and on errors.
Thread-safety considerations and options.
Provide tests (unit-style examples) that exercise common and edge cases.
Analyze time and space complexity.
Solution
(Locked)
Login required
10 XP
Comments (0)
Sign in
to leave a comment
Loading comments...