So first of all, please use [code][/code] tags to enclose code so it is at least readable.
I am not sure that with the provided input this code was ever going to work.
On a quick look I see that end_time variable is only ever set when at least $7 == tcp. The problem here is that the string 'tcp' is not in the input at all??
Also the seqno is never any bigger than 0 so the loops in END related to this will only ever loop once.
Combining the above means that by the time you get to the following line:
n_to_n_delay = n_to_n_delay/count;
You will receive 0/0 which in itself is not going to work.
So we either need better data to look at or you need to rethink some of the logic.