In reply to desperadorocks:
Two approaches people take depending on what you plan to do with these fields
- Use dynamic unpacked arrays of bit or byte. Use the streaming operators to pack into your packet.
- Use fixed size fields with a maximum width. That maximum could be parameterized by the packet size. Then declare field width variables that can be randomized and then used to help mask your field values, and manual packing of fields.