Movement Validation

How do I check if a player hasn’t modified the client’s movement speed/pixels per tick.
When the client moves it sends a UDP packet containing the updated position to the server. But doing this doesn’t allow me to check if the player is walking at normal speed because of packet loss.
I wanted to do this approach :
Client --> movement packet(newX,newY)
Server does Math.abs(oldx-newx) and checks if that number is greater than speed, if it is then send the correct position to that client.

But with UDP the server won’t receive all the packets so Math.abs(oldx-newx) can be bigger than speed while the client is not hacking.

Speed isn’t a change in position; it’s a change in position over time. Once you get a packet, take the time since the last packet into account. Due to variations in thetiming of the packets, you want to look at the average movement over a few updates and also possibly have a small error tolerance so the server isn’t overly picky.

How would I use the time since last packet, the player obviously doesn’t always move.
Say I walk for 1 second and then stand still for 5 and walk again. It would take 5 seconds in account while it shouldn’t.

Either have the player send updates regardless of moving (in many games the player is almost always moving anyway), or add some logic to cap it to 1-2 updates’ worth of movement or something like that.