Page 1 of 1
A lag detector

Posted:
Thu Sep 27, 2012 12:47
by CTMN
There should be something like a lag detector that shows if theres a lag(I mean the multiplayer server lags).
I lost lots of things in lags and Im tired of losing things again in lags.

Posted:
Thu Sep 27, 2012 19:57
by VanessaE
+1

Posted:
Thu Sep 27, 2012 21:20
by jordan4ibanez
well this would be quite interesting, there are multiple aways to detect this. What is lag anyways, you should ask yourself? The delay in communication between the client and the server? If that is your definition of lag then there should be a node that changes from black to white every second (serverwise) to show you what your client is recieving from the server.
Another way you could go about this is with a pingputer. A pingputer is a way to calculate the delay of time in between a client doing something and a server actually registering what happens. This could be really easy or really difficult depending on how in depth you want to go for detecting lag, but the simplest thing i can think of at the time of writing this is a white block with the word "Sleep" on it, and when you hit it, it turns black and has the word "Active" on it for aproximately 1 second. With that you'd be able to calculate how much a server is lagging based on the delay of time of you hitting the block and the block staying "active"
A different form of the pingputer could also be a simple forumspec, just one box where you can put your items in (kind of like a 1 slot chest) and see how long it takes for the server to register that you've put an item in the pingputer. now this should not eat your item because chests normally don't eat items if you have less than 10 different items in it, hence the 1 spot lag detection.
A ping command would be the simplest though, you could go /ping and the server could return "PONG!", this is used in minecraft bukkit servers and a lot of chat-encorperated multiplayer servers. BUT a more complex version of this could be a /calcspeed command. It could detect the delay clientside if that would even be possible, and tell the client what the lag is, or a connection speed on a scale of 1-10. So it would send back "Connection Speed: 6" or something.
Anyways that's my thoughts on that. Any better ideas out there?

Posted:
Thu Sep 27, 2012 23:25
by VanessaE
It need not be anything complicated since the server and client are in constant communication anyway. I don't know what all the server sends to the client, but surely you can take advantage of the existing packet flow:
Measure the time between adjacent packets in the server's "keep alive" stream (it does seem to have one if you look at the profiler graph while the client is idle). Keep variables indicating the current, minimum, and maximum times measured between packets of that type. Update these variables on every received packet.
Measure the elapsed time from the moment of the most recent player action to the moment the client receives the server's response to that action. Keep variables indicating the current, minimum and maximum times. Update these variables every time the client receives a server response to an action.
Add the two above minimum times. The result is your best packet time.
Add the two above maximum times. The result is your worst packet time.
Add the current received packet time to the current action response time.
Compute the difference between this summed current packet time and the summed minimum time.
Keep a running average of this difference, integrated over the last 5 or 10 seconds' worth of measurements. This is your lag time.
In the F5 "debug" output, display the current difference average as the amount of lag, in seconds, rounded to the nearest 1/10 second. Update the display once per second as long as it's visible.
Put all of the raw values into one of the F6 profiler pages.

Posted:
Thu Sep 27, 2012 23:39
by jordan4ibanez
VanessaE wrote:It need not be anything complicated since the server and client are in constant communication anyway. I don't know what all the server sends to the client, but surely you can take advantage of the existing packet flow:
Measure the time between adjacent packets in the server's "keep alive" stream (it does seem to have one if you look at the profiler graph while the client is idle). Keep variables indicating the current, minimum, and maximum times measured between packets of that type. Update these variables on every received packet.
Measure the elapsed time from the moment of the most recent player action to the moment the client receives the server's response to that action. Keep variables indicating the current, minimum and maximum times. Update these variables every time the client receives a server response to an action.
Add the two above minimum times. The result is your best packet time.
Add the two above maximum times. The result is your worst packet time.
Add the current received packet time to the current action response time.
Compute the difference between this summed current packet time and the summed minimum time.
Keep a running average of this difference, integrated over the last 5 or 10 seconds' worth of measurements. This is your lag time.
In the F5 "debug" output, display the current difference average as the amount of lag, in seconds, rounded to the nearest 1/10 second. Update the display once per second as long as it's visible.
Put all of the raw values into one of the F6 profiler pages.
build it, test it, save it, commit it, party

Posted:
Fri Sep 28, 2012 00:43
by RabbiBob
My mind goes right to the Valve
NetGraph.

Posted:
Fri Sep 28, 2012 01:03
by jordan4ibanez
RabbiBob wrote:My mind goes right to the Valve
NetGraph.
that's seeming to be a great idea, i have a strange, strange idea to base that on

Posted:
Fri Sep 28, 2012 01:15
by cornernote
You can just get a tree, put it in your craft area, and see how long it takes for wood to appear in the output box.
However, i think the OP wants an indicator to tell them the server is lagging without them having to check every 2 minutes.
When you press F5 twice, in red at the bottom is says "client received packets". If none are coming through then its lagging.

Posted:
Fri Sep 28, 2012 09:17
by Echo
I don't know if it could work, but is it possible to use "register_globalstep" get the current time (minetest.env:get_timeofday()) save the value for the next globalstep and detect the difference between both "timestamps"?
It wouldn't detect lags for client server communication, but if the server gets slow.

Posted:
Fri Sep 28, 2012 18:34
by irksomeduck
My suggestion is-
1. Look at the top bar of screen
2. Look at FPS clock
3. If it's under 10 FPS, you probably have lag
Sources- Personal experience

Posted:
Sat Sep 29, 2012 00:59
by Menche
I usually use /status to see if a server lags. A simple command like that should complete almost instantly, if it takes longer than half a second its lagging.

Posted:
Sun Sep 30, 2012 14:49
by CTMN
I know too that there are such methods, but I wanted a light that appears on tne screen and that blinks when the server changes the light. Or a symbol that shows if the server lags.
I have the problem that my server always sends messages and such things, but it doesn't see it if I remove or place a block. That's what means "lag" for me. I never saw a server sending NO packets, even during real lags(there are always red lines moving and there's always a number above 0).

Posted:
Sun Sep 30, 2012 19:15
by jordan4ibanez
Here, a lag tester
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_chatcommand("ping", {
params = "",
description = "Test the lag",
privs = {},
func = function(name, param)
minetest.chat_send_player(name, "Pong!")
end
})

Posted:
Tue Oct 02, 2012 10:16
by CTMN
Is it for the client or the server? I know plain NOTHING about Lua or the api.

Posted:
Tue Oct 02, 2012 10:36
by Calinou
irksomeduck wrote:My suggestion is-
1. Look at the top bar of screen
2. Look at FPS clock
3. If it's under 10 FPS, you probably have lag
Sources- Personal experience
Lag != slow performance.
Anyway (in reply to VanessaE's post), I think the current FPS count and ping time should be shown on the bottom right of the screen (so that you can see your FPS while you're in fullscreen).

Posted:
Tue Oct 02, 2012 12:53
by LazyJ
Calinou wrote:irksomeduck wrote:My suggestion is-
1. Look at the top bar of screen
2. Look at FPS clock
3. If it's under 10 FPS, you probably have lag
Sources- Personal experience
Lag != slow performance.
Anyway (in reply to VanessaE's post), I think the current FPS count and ping time should be shown on the bottom right of the screen (so that you can see your FPS while you're in fullscreen).
Yes, a small FPS/Ping indicator in fullscreen mode would be nice.