If you use the commMonitor module under GEM5 to log the statistics of some part of your system (like, to log total number of instructions executed by CPUs at every specific interval or …) at the end of simulation , you will end up a very big trace file.

Now you will encounter problems if you want to re-play the trace file using other tools , or move it and open it some where else.

This python script , opens a generated google protocol buffer trace file, and splits it into smaller files. The files have all the standard format of a trace file so even they can be used separately.

I count the number of packets to decide when a new split file should be generated.

This python script uses mainly, previously python functions to open the trace file, to read it and to write it back.

your code here