generate_packets.py: clean up general helper functions
Part of #43927. Remove without() function (obsolete with filter() or appropriate set operations), and clean up and move prefix() to the appropriate spot in the file.
Part of #43927. Remove without() function (obsolete with filter() or appropriate set operations), and clean up and move prefix() to the appropriate spot in the file.