According to VALVe:
Client hitboxes (red) versus rewound server hitboxes (blue). 200ms fakelag.
OR: This screenshot was taken on a listen server with 200 milliseconds of lag (using net_fakelag), right after the server confirmed the hit. The red hitbox shows the target position on the client where it was 100 milliseconds ago. Since then, the target continued to move to the left while the user command was travelling to the server. After the user command arrived, the server restored the target position (blue hitbox) based on the estimated command execution time. The server traces the shot and confirms the hit (the client sees blood effects).
http://developer.valvesoftware.com/wiki/Lag_compensation
EDIT: Basically, it gets the command, looks at time sent, then goes back to that time, calculates movement, bullet speed, then where it hits, then deals proper damage.
VALVe Dev Wiki 说:Lag compensation is the notion of the server calculating as best it can when a usercmd was sent, and rewinding time to that point when processing it. In combination with prediction, lag compensation can help to combat network latency to the point of almost eliminating it.
Client hitboxes (red) versus rewound server hitboxes (blue). 200ms fakelag.
OR: This screenshot was taken on a listen server with 200 milliseconds of lag (using net_fakelag), right after the server confirmed the hit. The red hitbox shows the target position on the client where it was 100 milliseconds ago. Since then, the target continued to move to the left while the user command was travelling to the server. After the user command arrived, the server restored the target position (blue hitbox) based on the estimated command execution time. The server traces the shot and confirms the hit (the client sees blood effects).
http://developer.valvesoftware.com/wiki/Lag_compensation
EDIT: Basically, it gets the command, looks at time sent, then goes back to that time, calculates movement, bullet speed, then where it hits, then deals proper damage.
