Add helper functions to slice packet and fill in various fields.
Replace slicing logic with function calls to modularize code.