Packet buffer

Based on #1101, tests will follow.