Merge writePacket and splitPacket into one function
No longer need to do header calculation for writePacket