This adds a counter here to only loop to a maximum number of iterations. Now we avoid situations in which we would be stuck processing packets here. This also adds some other meaningful defines