Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

311
Vistas
is ping measured in time to and from the server, or time between the request being made and the server receiving it?

look at the title

idk how to do specifically, a ping in javascript,

but I made this itty bitty snippet that returns

  • the time the request was made,
  • the time the server received the request, (done from server side)
  • and the time the server sent the response.
async function getResponseTimeOnce(){
  var times = {};
  times.beforeRequest = Date.now();
  await fetch("https://randobytes.yimmee.repl.co/ping").then((serverReceive)=>{
    serverReceive.json().then((serverReceive)=>{
      times.serverReceive = serverReceive;
    });
    times.afterRequest = Date.now();
  });
  return times;
}

all I'm asking, is, which values am I supposed to subtract to get the ping time?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

In standard ping programs, the latency measurement is always the round-trip-time (RTT). You should subtract beforeRequest from afterRequest to get the difference.

Source: https://developer.mozilla.org/en-US/docs/Glossary/Round_Trip_Time_(RTT)

$ ping example.com
PING example.com (216.58.194.174): 56 data bytes
64 bytes from 216.58.194.174: icmp_seq=0 ttl=55 time=25.050 ms
64 bytes from 216.58.194.174: icmp_seq=1 ttl=55 time=23.781 ms
64 bytes from 216.58.194.174: icmp_seq=2 ttl=55 time=24.287 ms
64 bytes from 216.58.194.174: icmp_seq=3 ttl=55 time=34.904 ms
64 bytes from 216.58.194.174: icmp_seq=4 ttl=55 time=26.119 ms
--- google.com ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 23.781/26.828/34.904/4.114 ms

For this particular application, you may also consider using the Performance API to get a high resolution timestamp.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Ping uses RTD/RTT (Round-trip delay/time). The RTD should be calculated from the time you sent the request to the time you receive the response.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda