XIV Dev Wiki
  • Welcome
  • Community Projects
  • Game Data
    • Visual Effects
      • AVFX Files
      • Global Parameters
      • Schedulers
      • Particles
      • Emitters
      • Timelines
      • Effectors
      • Binders
      • Object Life
    • File Formats
      • Excel
    • Character Data Files
      • Character Creator Preset
      • Character data folder
        • Chat Log (.log)
  • Data Files
    • ZiPatch
      • SQPK
    • SqPack
  • Network
    • Packet Structure
    • Channels
    • Ping
  • Game Internals
    • Actions
      • Animation Lock
    • World
      • Coordinate System
      • Weather
    • RSV
    • RSF
  • SqexArg
Powered by GitBook
On this page
  • Pseudocode
  • Remarks

Was this helpful?

Edit on GitHub
Export as PDF
  1. Network

Ping

Internal ping calculation

PreviousChannelsNextActions

Last updated 2 years ago

Was this helpful?

  1. The client uses to generate an arbitrary timestamp, which it converts roughly into milliseconds by dividing it by 10,000.

  2. An IPC message is sent by the client which includes the timestamp encoded as a 32-bit integer value.

  3. An IPC message is sent back by the server with the same timestamp.

  4. The client generates a new timestamp, divides it by 10,000, and then computes the difference between them to get the RTT for the connection.

Pseudocode

void SendPingRequest() {
    int64_t t;
    PingRequest req;
    QueryPerformanceCounter(&t);
    req.timestamp = (int32_t)(t / 10000);
    SendMessage(req);
}

int32_t HandlePingResponse(PingResponse resp) {
    int64_t currT;
    int32_t prevMs = resp.timestamp;
    QueryPerformanceCounter(&currT);
    int32_t currMs = (int32_t)(currT / 10000);
    return currMs - prevMs;
}

Remarks

Because the server copies the same timestamp into the response message as is in the request message, ping calculation can be done in a stateless manner with respect to the client.

QueryPerformanceCounter