calculate latency between client and controller

add code to calculate the latency between client and controller