generate_packets.py: replace range(len(...)) with enumerate(...)
Part of #43927. Replace constructs of the form
for i in range(len(seq)): elem = seq[i] # loop body
for i, elem in enumerate(seq): # loop body
Part of #43927. Replace constructs of the form
with