Jump to content


Photo

39.dll lag issue


  • Please log in to reply
13 replies to this topic

#1 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 03 June 2012 - 11:18 AM

I have encountered strange issue with lag on 39.dll
When character moves, it send his x,y, when he stops , it doesn't send anything
Server gets characters x,y and send them to other clients in the map.
When both player moves, there is no lag, but ,for example, My character stops moving(I don't send any packets), then somehow packets come to me slower and I get other clients x y with lag.
But when I start moving(send my own x y), then other clients x y come to me faster.

In shortly issue is: When client stop sending packets, then it gets other packets slower. When it continuously sends its packets, then it gets other packets faster.

Client side code:
Alarm[1] event (on move):
clearbuffer();
writebyte(MSG_PLAYER_VAR);
writeushort(x);
writeushort(y);
sendmessage(global.server_socket);

Server side code:
... read of packet header
x =readushort();
y = readushort();

clearbuffer();
writeushort(x);
writeushort(y);
sendmessage(other clients);
  • 0

#2 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 03 June 2012 - 07:18 PM

bump
  • 0

#3 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 03 June 2012 - 09:47 PM

any ideas at all ?
  • 0

#4 zehevi

zehevi

    GMC Member

  • GMC Member
  • 637 posts
  • Version:GM8

Posted 03 June 2012 - 10:02 PM

1. Read rules, you cannot bump every few hours.
2. Might be a problem with the router rather then the client / host.
Have you port forwarded both client and host?
And does both the client and host running on the same computer?

By the way, when the server receive a packet it stores the value in x/y as you wrote above?
If so, get rid of it, GM uses x and y variables for calculations that you do not need, store those values in temporary variables instead.
  • 0

#5 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 03 June 2012 - 10:21 PM

1. Read rules, you cannot bump every few hours.
2. Might be a problem with the router rather then the client / host.
Have you port forwarded both client and host?
And does both the client and host running on the same computer?

By the way, when the server receive a packet it stores the value in x/y as you wrote above?
If so, get rid of it, GM uses x and y variables for calculations that you do not need, store those values in temporary variables instead.

1. sorry for the bumping
2. when on 1 PC no lag at all, when on different PC, then lag occurs for that client, which doesn't send any messages, but when both start send message continuously no lag occurs, its like if I made now alarm[0]=1 (location message), so it wouldn't be no lag. But I don't want to waste messages for nothing(if character is standing so why send its x and y continuously).
3. server is made not on gamemaker, so that's not the issue.
My own thoughts :
Maybe when 1 client sends its location , and other gets the message, maybe not everything in that message gets read, and when another location message comes then the reading part gets mixed, and when that client starts moving, it clears the buffer , then unread message part gets cleared.
So I will try fixing it by adding clearbuffer() after the reading location message on the client.
  • 0

#6 zehevi

zehevi

    GMC Member

  • GMC Member
  • 637 posts
  • Version:GM8

Posted 03 June 2012 - 10:53 PM

The reason I asked you if the server and client is port forwarded is because the router will not let an unknown incoming udp packets through,
unless you port forward or open a temporary port by sending a packet through the same port as the incoming udp port, this is called NAT traversal.

Try port forwarding,
you have to port forward for your server anyway.
  • 0

#7 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 03 June 2012 - 11:01 PM

The reason I asked you if the server and client is port forwarded is because the router will not let an unknown incoming udp packets through,
unless you port forward or open a temporary port by sending a packet through the same port as the incoming udp port, this is called NAT traversal.

Try port forwarding,
you have to port forward for your server anyway.


Thanks, but the thing is, I am using TCP not UDP, and yeah I understand that it wouldn't allow my packets to reach un-portforwarded port if I use UDP
but for TCP I just port forward the server PC, and the clients doesn't need to port forward.
  • 0

#8 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 04 June 2012 - 02:51 PM

My own thoughts :
Maybe when 1 client sends its location , and other gets the message, maybe not everything in that message gets read, and when another location message comes then the reading part gets mixed, and when that client starts moving, it clears the buffer , then unread message part gets cleared.
So I will try fixing it by adding clearbuffer() after the reading location message on the client.


it didn't helped.
Any other ideas would be appreciated.
Once again the problem is: When client doesn't send packets continuously , then he gets other packets slower.
When both clients send packets contentiously then no lag at all.
My question is why?
  • 0

#9 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 04 June 2012 - 08:45 PM

I've tested this not only with my application, but with others also.
I took example of "Doogie's 39.dll" more info here: http://gmc.yoyogames...pic=362963&st=0

His code contained:
Alarm[0]:

send_location(); //script that sends location 
alarm[0]=1; //so the location packet is sent continuously

What I had changed:
Removed the alarm[0]=1;
ant added in step event when movement keys are pressed then alarm[0]=1;

So I get the same result as in my application, when testing on 1 PC, the lag would not be seen at all,
But when other clients from other PC start to connect, the lag is seen to the one who is not moving(he receives packets slower).

So the reason is maybe because, when the internet line between 1 PC and other, is not continuously used, then the PC which does not send packets
gets other packets slower.

Quick lame fix for this issue that I thought would be:
make location packet to be sent continuously (adding alarm[0]=1, in alarm event).
Or to waste less recourse, create another packet with less size then location packet
and make it send when not moving(not sending location packet.)

So then again, please post any ideas, that you can think of, or other fixing solutions. It would be grateful.
  • 0

#10 zehevi

zehevi

    GMC Member

  • GMC Member
  • 637 posts
  • Version:GM8

Posted 05 June 2012 - 08:08 AM

You need to retain the connection,
send a packet with any size every few seconds, 4 sec is when most connections die, if I remember right.
Of course it depends on the connection type, router, firewall and many other things, but it should hold this way.

By the way,
The way I do that is sending a 2 way ping every 3-4 sec,
this way you can maintain connection and watch for connection problems.

Edited by zehevi, 05 June 2012 - 08:10 AM.

  • 0

#11 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 05 June 2012 - 02:47 PM

omg, I just tried my idea, when not moving send another packet that is less sized. But still I get the lag...

Now I'm confused. Why sending location packet contentiously doesn't lag, but why I replace packet that is less sized(just packet header 1 byte) , I get lag.
  • 0

#12 zehevi

zehevi

    GMC Member

  • GMC Member
  • 637 posts
  • Version:GM8

Posted 06 June 2012 - 08:11 AM

Can you post the client receive code?
  • 0

#13 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 06 June 2012 - 07:49 PM

Can you post the client receive code?


var temp_id,temp_x,temp_y,temp_spr,temp_img;
temp_id=readushort();
temp_x=readushort();
temp_y=readushort();
temp_spr=readushort();
temp_img=readbyte();
with(obj_player_other_parent)
{
    if (char_id==temp_id && sprite_exists(temp_spr))
    {
        x=temp_x;
        y=temp_y;
        sprite_index=temp_spr;
        image_index=temp_img;
    }
}

Edited by kirisaku, 06 June 2012 - 07:50 PM.

  • 0

#14 kirisaku

kirisaku

    GMC Member

  • GMC Member
  • 23 posts
  • Version:GM8

Posted 09 June 2012 - 02:27 PM

I believe the problem was that only the server had setnagle(false) , so now I will try to add this to client also.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users