fix the packing issue
calculate the number of packets