How to calculate round trip time for the communication between client and server in tcp connections.
Assuming you have control over both client and server, send a message to the server with a time-stamp on it and have the server merely return the timestamp back to the client.  When the client receives this back, it compares the current timestamp to the one in the payload and voila, the difference is the time it took for a round-trip.
Tcp round trip time calculation using python