networking code with latency prediction and correction