Finished CreatePacket function to allocate packet memory