Why is it zero? Because no packets were received during that period.
In your code you periodically check throughput (every 1 sec). It could be that for a particular second the throughout of the particular flow you monitor is zero, for any reason (collisions, no traffic, scheduler etc).
What to change? Nothing in terms of why it is zero, but you should add checks so that you do not division with zero.
Also, I would recommend checking your calculations, duration negative?