Question

Is there any way (preferably in C#) how to regularly measure connection layer latency (roundtrip) without changing the application protocol and without creating separate dedicated connection - e.g. using some similar SYN-ACK trick like tcping do but without closing/opening connection?

I'm connecting to the servers via given ASCII based protocol (and always using TCP_NODELAY). Servers send me large amount of discrete messages and I'm regularly sending 'heartbeat' payload (but there is no response payload to the heartbeat). I cannot change the protocol and in many cases I also cannot create more than one physical connection to the server.

Was it helpful?

Solution

Keep in mind that TCP does windowing, so this could cause issues when trying to implement an elegant SEQ/ACK solution. (you would want sequence, not synchronize)

[EDIT: Snipped a very overcomplicated and confusing explaination.]

I'd have to say the best way is to use a simple stopwatch method of starting a timer, making a very thin request or poll, and measure the time back from it. If that query really is the lightest you can make it, then that should give you the minimum amount of time you can reasonably expect to wait, which sometimes more valuable than the ping (which can be misleading).

If you really absolutely need just the network time to machine and back, just use an ICMP ping.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top