It's nowhere near a perfect solution.
All it's doing is checking the ping every second. If the ping doesn't change (which could be due to an enormous amount of factors) it classifies it as client lag. If the ping does change, it classifies it as server lag.
I imagine the thought behind this is that:
If your client is able to update the interface, then it's clearly not a freezing issue, it's a network issue.
If your client is able to get different ping results, then that means the connection is still active, but for whatever reason (server possibly busy), packets aren't being sent.
If your client always has the same ping result, then that may be an indication that there's an issue connecting to the server. Which means your client cannot connect to it.
But that's just a maybe. Maybe the ping was actually just the same because the connection was stable for that second. Maybe the server shut down, lost it's connection, etc. That's not necessarily the client's 'fault', but it is still the client being unable to connect.