Added packet generation function