Server ping

Created at 27 Nov 2017, 16:20
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
EN

enrico.pedersini

Joined 23.11.2017

Server ping
27 Nov 2017, 16:20


On my local machine I have the ping showed by ctrader always aroun 10-15 ms. Usicng connect API, if I ping the server with the Ping net class I have the same ping shown in the cTrader platform. If I send a ping message and read the ping response, calculating the milliseconds elapsed from the send message, I have a ping around 180-200 ms. What is the best way to calculate how much time keep a message sent from my app to arrive on the server?
Thank you, regards.


@enrico.pedersini
Replies

PanagiotisCharalampous
27 Nov 2017, 16:32

Hi Enrico,

The latency showed in cTrader is the one way latency between cTrader -> cTrader Proxy -> cServer and is split into two parts, cTrader -> Proxy and Proxy->cServer. The way you have implemented it is that you measure the round trip of a message which will take definitely longer. It will be better to measure your latency by sending a ping message to the server and compare the timestamp of the request and the timestamp of the response.

Best Regards,

Panagiotis


@PanagiotisCharalampous

enrico.pedersini
27 Nov 2017, 18:10

Hi Panagiotis,
my first implementation was sending a ping request (filling the timestamp field with local ticks) with connect API and reading the ping response message. But I notice that the timestamp of the ping response is every time exactly the same i sent. Maybe i'm missing something...? I'll receck my code later this evening.

Thank you, regards.


@enrico.pedersini

PanagiotisCharalampous
28 Nov 2017, 09:08

RE:

enrico.pedersini said:

Hi Panagiotis,
my first implementation was sending a ping request (filling the timestamp field with local ticks) with connect API and reading the ping response message. But I notice that the timestamp of the ping response is every time exactly the same i sent. Maybe i'm missing something...? I'll receck my code later this evening.

Thank you, regards.

Hi Enrico,

Please check and let us know. If this is the case, we shall investigate further.

Best Regards,

Panagiotis


@PanagiotisCharalampous

enrico.pedersini
28 Nov 2017, 15:44

RE: RE:

Panagiotis Charalampous said:

enrico.pedersini said:

Hi Panagiotis,
my first implementation was sending a ping request (filling the timestamp field with local ticks) with connect API and reading the ping response message. But I notice that the timestamp of the ping response is every time exactly the same i sent. Maybe i'm missing something...? I'll receck my code later this evening.

Thank you, regards.

Hi Enrico,

Please check and let us know. If this is the case, we shall investigate further.

Best Regards,

Panagiotis

Hi Panagiotis,
sorry for the delay but I made some deeper tests. Anyway... I use the following c# code (firs part for sending and second part for receving:
 

var msg = MsgFactory.CreatePingRequest(DateTime.Now.Ticks);
Console.WriteLine(String.Format("SendPingRequest() Message sent: {0}", OpenApiMessagesPresentation.ToString(msg)));
SendMessage(msg.ToByteArray());
[...]
case (int)ProtoOAPayloadType.OA_PING_RES:
                    var pingMsg = MsgFactory.GetPingResponse(rawData);
                    Console.WriteLine(String.Format("PingResponse() Message received: {0}", pingMsg.Timestamp));

The code produce the following output:

SendPingRequest() Message sent: ProtoMessage{PingRequest{timestamp:636474769871789838}}
PingResponse() Message received: 636474769871789838

The timestamp of the ping response seems to be always the same time stamp sent.. Am I doing something wrong?
regards.


@enrico.pedersini