refactor: move packet i/o initialisation into one place