Detecting packet loss in realtime

Is it possible to detect packet loss in realtime programmatically? For example, I believe that PLI and NACK indications of packet loss might be written to an ‘xml cdr’ file in realtime, which would mean that a process that continually parses such a file could detect high packet loss.

Our FS instances have generated such files, but it’s not clear where such info is encoded in them and how soon after the PLIs and NACKs that the info is recorded.

And is such info available only for tracks leaving FS or also for those arriving?