Jump to content

The Long Overdue @ping command


Pancake

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  49
  • Reputation:   17
  • Joined:  02/06/12
  • Last Seen:  

I, and Pekkle were speaking about this in #rathena-dev. And we need your help.

Here is the chat log if you wish to view it:

<Pancake> Who wants to help me code a new atcommand?

<Pancake> @ping

<Pancake> I feel like its long overdue

<Pancake> The easiest way would be a simple

<Pancake> pong response

<&Pekkle> it will make the server ping client? or client ping server? or server-side just does some timing to attempt to measure ping

<Pancake> Server should ping the client

<Pancake> then display the ping in MS

<Pancake> Im not sure if we could get the client to ping the server

<&Pekkle> ok. so it'll only work if their computer/router responds to ping

<&Pekkle> yea i wasn't sure if we could either

<Pancake> Pekkle are there really computers and routers that dont respond to a ping on port 80?

<Pancake> This might open an easily usable ddos exploit come to think of it

<Pancake> Need to remember to limit it to one per 15 seconds per account

<&Pekkle> yea, ex: Netgear router you have to check the box "Respond to Ping on Internet WAN Port"

<&Pekkle> (it's unchecked by default)

<Pancake> Thats wierd

<Pancake> im on a netgear router now

<Pancake> and if you ping my ip

<Pancake> my computer responds

<&Pekkle> ah i see. is your computer setup as the DMZ?

<Pancake> Im actually on motel wifi

<Pancake> I live in a motel

<Pancake> :(

<Pancake> Anyway

<&Pekkle> oh xD

-> -Pekkle- 173.197.76.38

<Pancake> ping me

<Pancake> see if it works

<&Pekkle> k

<&Pekkle> "Request timed out." on my end

<Pancake> Ah you are right

<Pancake> ):

<Pancake> Hmm

<Pancake> Is there any other way we can test latency?

<&Pekkle> also if i remember correctly, in XP Windows Firewall is not set to respond to ping. You have to enable it

<Pancake> Wow thats terrible

<Pancake> Hrm

<Pancake> I guess maybe a simple

<Pancake> @ping

<Pancake> Server: pong!

<Pancake> would suffice

<&Pekkle> Control Panel > Windows Firewall > Advanced tab > ICMP Settings

<&Pekkle> and check "Allow incoming echo request"

<Pancake> Pekkle the problem is now that people arent going to do that just to ping

<Pancake> :)

<&Pekkle> yea

<&Pekkle> i wonder if there are any client-server packets where if the server sends a packet to the client, it just immediately responds

<&Pekkle> if there is a packet like that, the server could send that, measure the time (server-side), divide by 2 to get an approximate ping

<Pancake> I wouldnt know, I havent checked in a very long time

<Pancake> er

<Pancake> I havent checked into packets and such

<Pancake> in a long time

<Pancake> Shall we turn to the forums to ask someone?

<Pancake> Or is there some sort of tool we can use

<Pancake> that will send random packets to our client

<Pancake> Then we can check the logs and see which ones respond, and how they do it :)

<&Pekkle> maybe someone in here knows xD

<Pancake> I could make all their IRC clients light up

<Pancake> but i feel that theyd get angry

<Pancake> and thats counter productive

<&Pekkle> yea. i guess just post on forums or wait for someone to say something

<Pancake> Ill post our conversation in a code box if you are alright with that.

<&Pekkle> https://rathena.svn.sourceforge.net/svnroot/rathena/trunk/src/char/char.c line 3778 could that be something?

<&Pekkle> yea sounds good to me

<Pancake> Can you give me something to ctrl+f

<Pancake> to see line 3778

<&Pekkle> client keep-alive packet (every 12 seconds)

<Pancake> Ohhh

<Pancake> That seems like

<Pancake> exactly what we need

<Pancake> It looks like it returns a response

<&Pekkle> yea hopefully :P

Here is the important stuff:

<&Pekkle> https://rathena.svn.sourceforge.net/svnroot/rathena/trunk/src/char/char.c  line 3778 could that be something?
<&Pekkle> client keep-alive packet (every 12 seconds)

Does anyone have any suggestions, or help they can provide?

  • Upvote 3
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  169
  • Topics Per Day:  0.04
  • Content Count:  1260
  • Reputation:   750
  • Joined:  11/19/11
  • Last Seen:  

there are existent client-server functions that could be used to measure such thing -- perhaps we could make it a built in feature.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  49
  • Reputation:   17
  • Joined:  02/06/12
  • Last Seen:  

That was my hope. It seems like a small, but very useful addition, but I lack the skills necessary to do a legitimate @latency command.

But as Pekkle said, it would be as easy as.

@Latency

Server Sends Packet--(lag)-->Client Responds--(lag)-->Divide by 2.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

That was my hope. It seems like a small, but very useful addition, but I lack the skills necessary to do a legitimate @latency command.

But as Pekkle said, it would be as easy as.

@Latency

Server Sends Packet--(lag)-->Client Responds--(lag)-->Divide by 2.

So it does not work like this:

Client uses Command--(lag)-->Server Reponds--(lag)-->Divide by 2?

Both seems legit, now we have to analyze the packet with which this is possible.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  1315
  • Reputation:   372
  • Joined:  12/10/11
  • Last Seen:  

Purely cosmetical, isn't it better to call it @ping instead of @latency?

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  49
  • Reputation:   17
  • Joined:  02/06/12
  • Last Seen:  

Purely cosmetical, isn't it better to call it @ping instead of @latency?

it would actually be more accurate to call it @ping.

That was my hope. It seems like a small, but very useful addition, but I lack the skills necessary to do a legitimate @latency command.

But as Pekkle said, it would be as easy as.

@Latency

Server Sends Packet--(lag)-->Client Responds--(lag)-->Divide by 2.

So it does not work like this:

Client uses Command--(lag)-->Server Reponds--(lag)-->Divide by 2?

Both seems legit, now we have to analyze the packet with which this is possible.

The client would have to do the math, and we would have to modify decompiled client source(which there are many different versions of), the method I mentioned above would mean that the emulator calculates the ping, and sends a notice to the client, like a broadcast in the chat window. (Which would give the same accuracy)

Let me rephrase my previous post.

Server receives command, and returns with the special packet --(lag)-->Client sees packet, and returns a packet--(lag)-->Server divides the time spent from sending packet, until receiving packet, by 2, giving an accurate representation of ping.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  49
  • Reputation:   17
  • Joined:  02/06/12
  • Last Seen:  

Initially only to check your own lag.

But on another end, #ping player, is he lagging? ( A lot of players will claim WPE, or endless spam, on lag. Now we can check if its true )

Its just something basic, that comes in handy everywhere. If you've ever played an FPS, or MOBA you check your ping every game/match.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

...why do we need such a command? o.O

So we can be like

@ping

0 ms

"my test server (127.0.0.1) has amazing ping!" :(

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  386
  • Reputation:   15
  • Joined:  11/17/11
  • Last Seen:  

...why do we need such a command? o.O

So we can be like

@ping

0 ms

"my test server (127.0.0.1) has amazing ping!"

Yes, that's also nice idea BrianL :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  49
  • Reputation:   17
  • Joined:  02/06/12
  • Last Seen:  

...why do we need such a command? o.O

So we can be like

@ping

0 ms

"my test server (127.0.0.1) has amazing ping!" :)

I feel like you'd still have like 3-4 ms ping :)

But yes, has anyone made any progress at all with this? I know there is a new tool for dealing with packets.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  130
  • Reputation:   43
  • Joined:  12/11/11
  • Last Seen:  

Doesn't this has anything to do with pings? (clif.c)

void clif_parse_TickSend(int fd, struct map_session_data *sd)

Might be way off tho.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  47
  • Reputation:   8
  • Joined:  12/06/11
  • Last Seen:  

The client (as for 2006) already calculates the average ping.

It sends PACKET_CZ_REQUEST_TIME and stores the current client time. By the time PACKET_ZC_NOTIFY_TIME is received, the current client time is subtracted from the previously stored client time, calculating the time it takes to send and receive a packet (ping time + pong time).

It also sends a different packet to the char-server (PACKET_PING).

Character Server Packet Information (PACKET_PING)

struct PACKET_PING {
 /* this+0x0 */ short PacketType;
 /* this+0x2 */ unsigned long AID;
}

 HEADER_PING =  0x187,

Zone Server Packet Information (PACKET_CZ_REQUEST_TIME & PACKET_ZC_NOTIFY_TIME)

struct PACKET_CZ_REQUEST_TIME {
 /* this+0x0 */ short PacketType
 /* this+0x2 */ unsigned long clientTime
}

struct PACKET_ZC_NOTIFY_TIME {
 /* this+0x0 */ short PacketType
 /* this+0x2 */ unsigned long time
}

 HEADER_CZ_REQUEST_TIME =  0x7e,
 HEADER_ZC_NOTIFY_TIME =  0x7f,

To accomplish what you need, you need a packet sent by the server which is instantly replied by the client without any additional action.

This could be done with some dummy packets such as HEADER_ZC_REASSEMBLY_CERTIFY and CZ_REASSEMBLY_IDENTITY. In the decompiled client from 2006, it does nothing (although it appears to be a check on whether the client's Import Address Table is modified or not, an anti-cheat feature) and it's safe to send it.

struct PACKET_CZ_REASSEMBLY_IDENTITY::<unnamed-type-ImportAddressTableModify> {

 /* this(bf)+0x0:0x0 len(0x1) */ unsigned char Winsock
 /* this(bf)+0x0:0x1 len(0x1) */ unsigned char GDI32
 /* this(bf)+0x0:0x2 len(0x1) */ unsigned char Debugging
 /* this(bf)+0x0:0x3 len(0x1) */ unsigned char ClientCheckSumError
 /* this(bf)+0x0:0x4 len(0x4) */ unsigned char Unused
}

struct PACKET_CZ_REASSEMBLY_IDENTITY {
 /* this+0x0 */ short PacketType
 /* this+0x2 */ unsigned short PacketLength
/* this+0x4 */ struct PACKET_CZ_REASSEMBLY_IDENTITY::<unnamed-type-ImportAddressTableModify> ImportAddressTableModify

}

struct PACKET_ZC_REASSEMBLY_CERTIFY {
 /* this+0x0 */ short PacketType
 /* this+0x2 */ unsigned short PacketLength
}

  HEADER_ZC_REASSEMBLY_CERTIFY =  0x308,
 HEADER_CZ_REASSEMBLY_IDENTITY =  0x332,

So...

Store current time → Send ZC_REASSEMBLY_CERTIFY → Receive CZ_REASSEMBLY_IDENTITY → Calculate ping+pong from (current time - stored time)

Edited by Vianna
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  49
  • Reputation:   17
  • Joined:  02/06/12
  • Last Seen:  

Store current time → Send ZC_REASSEMBLY_CERTIFY → Receive CZ_REASSEMBLY_IDENTITY → Calculate ping+pong from (current time - stored time)

I have no experience with C so I can't write this, now we just wait for someone to make a quick code.

Does anyone here know if currtime() works in C, like it does in C#?

Also bump. Its been a while.

Edited by Arcenciel
Link to comment
Share on other sites


  • Group:  Development Manager
  • Topic Count:  56
  • Topics Per Day:  0.01
  • Content Count:  732
  • Reputation:   525
  • Joined:  12/13/11
  • Last Seen:  

Why not just use gettick()? It is a lot cleaner and is counted in milliseconds.

Edited by Aleos
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...