About Store Forum Documentation Contact
Donations:
215$/mo



Post Reply 
Getting latency and simulate high latency?
Author Message
SamNainocard Offline
Member

Post: #1
Getting latency and simulate high latency?
Hi everyone, I'm still at Network coding.

I have 2 questions about getting and simulate latency.

1. How can I get latency to server?
Is there a better way then send Latency Checking code to determine.
PHP Code:
ClientSendCheckPing(CS_LATENCYServer);
//...
Server.received(0); // ping-pong 
It seems to overload the server.

2. How can I simulate high latency to server?
I want to test and possibly optimize my network code for 300+ ms to simulate oversea or poor connection.
Is there a better way then increase delay before sending command?
PHP Code:
ServerUpdatePos-=Time.ad();
if (
ServerUpdatePos<=0)
{
   
ServerUpdatePos=0.1f;  // 100 ms?



Thank you in advance.
(This post was last modified: 12-06-2013 06:22 AM by SamNainocard.)
12-06-2013 06:21 AM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #2
RE: Getting latency and simulate high latency?
The proper way to simulate latency is to have a latency generator in the network between your clients and your server. I happen to have an expensive network latency generator appliance (running on a linux box) in a test network, but for those who do not have access to such devices, you can download some (semi) free software that you install on the server that mimics certain latent conditions by working with the server's nic. A simple google search will yield you several options, but as an example, you can download NetLimiter (I've tried it myself) which has a free trial period but you can opt to purchase it.
12-06-2013 03:15 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #3
RE: Getting latency and simulate high latency?
I think a good question is: why are your pings overloading the server? I'd guess Esenthel uses 32 byte pings, which would take a LOT to overload even a pc from 1997. Are you trying to ping every frame? If so, you should limit pings to a limited number per second.
12-06-2013 10:08 PM
Find all posts by this user Quote this message in a reply
Fex Offline
Bronze Supporter

Post: #4
RE: Getting latency and simulate high latency?
I think it is important to average the ping, I still don't have a ping solution I am happy with, packet loss is also important to measure, but I have no idea how to do that.
12-06-2013 10:41 PM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #5
RE: Getting latency and simulate high latency?
Pings overloading the server? I thought he was asking how to get a latency measurement and how to create/simulate latency?
12-07-2013 02:49 AM
Visit this user's website Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #6
RE: Getting latency and simulate high latency?
Well, I'm using wrong words for the 1st question. (I got distracted when posting pfft)
I mean, is there a simpler way to get latency than manually sending and receiving, which is kind of over-used for latency checking.

Thanks again. smile
(This post was last modified: 12-07-2013 03:07 PM by SamNainocard.)
12-07-2013 03:05 PM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #7
RE: Getting latency and simulate high latency?
Latency testing is done by sending a message out and seeing how long before the reply is received. You already have basics there. You can use UDP or TCP in EE. UDP is preferred because it is closer to how a typical latency test works (using icmp by ping which is connectionless). But you can still use TCP but the latency you will see is relevant only to tcp connections because tcp negotiates back and forth 4-6 times before you may see the reply to see how long a full round trip took. As far as I know, there isn't a native latency check in EE, but it doesn't need to have it natively, you can write it (like you are) and can tailor it based on whatever protocol you expect to use.
12-07-2013 03:30 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #8
RE: Getting latency and simulate high latency?
(12-06-2013 10:41 PM)Fex Wrote:  I think it is important to average the ping, I still don't have a ping solution I am happy with, packet loss is also important to measure, but I have no idea how to do that.

If you send 100 pings and only get 90 back, you have 10% packet loss. It's really that simple.
If you want a true test of actual effective latency, send the server a message with Time.curTimeMS() in it; when the client gets it back, subtract from the current Time.curTimeMS() value.
12-07-2013 05:07 PM
Find all posts by this user Quote this message in a reply
Fex Offline
Bronze Supporter

Post: #9
RE: Getting latency and simulate high latency?
(12-07-2013 05:07 PM)Rubeus Wrote:  
(12-06-2013 10:41 PM)Fex Wrote:  I think it is important to average the ping, I still don't have a ping solution I am happy with, packet loss is also important to measure, but I have no idea how to do that.

If you send 100 pings and only get 90 back, you have 10% packet loss. It's really that simple.
If you want a true test of actual effective latency, send the server a message with Time.curTimeMS() in it; when the client gets it back, subtract from the current Time.curTimeMS() value.

Hmm I use TCP, is there some way to see how many of the TCP packets failed (the message is always returned, but it oculd have taken multiple tries), or would I have to send and received UDP just to see the PL?
12-22-2013 02:19 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #10
RE: Getting latency and simulate high latency?
(12-22-2013 02:19 AM)Fex Wrote:  
(12-07-2013 05:07 PM)Rubeus Wrote:  
(12-06-2013 10:41 PM)Fex Wrote:  I think it is important to average the ping, I still don't have a ping solution I am happy with, packet loss is also important to measure, but I have no idea how to do that.

If you send 100 pings and only get 90 back, you have 10% packet loss. It's really that simple.
If you want a true test of actual effective latency, send the server a message with Time.curTimeMS() in it; when the client gets it back, subtract from the current Time.curTimeMS() value.

Hmm I use TCP, is there some way to see how many of the TCP packets failed (the message is always returned, but it oculd have taken multiple tries), or would I have to send and received UDP just to see the PL?

Using TCP, you can assume packet loss by the average latency of the packet. If your returns look something like 10ms 10ms 10ms 30ms 10ms 10ms, you can assume the 30 was a lost packet and had to be resent.
12-23-2013 09:27 AM
Find all posts by this user Quote this message in a reply
Post Reply