Unable to compare ping times on fly

前端 未结 3 1137
不知归路
不知归路 2021-01-28 00:22

I tried the following command unsuccessfully

sdiff <(ping www.nato.int) <(ping www.reuters.com)

Is there any way to have a real-t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-28 01:07

    You could do this using say perl/python/php/otherlang and time how long it takes to open a connection to say port 80 for instance. You can store this into a variable and then use this for mathematical analysis.

    Something like this in psuedo-code:

    $site1_start = get_timestamp();
    $sock = opensocket($someAddress,$required_port);
    if($sock) { $sock->close(); };
    $site1_end = get_timestamp();
    $site1_round_trip = $t2 - $t1
    
    $site2_start = get_timestamp();
    $sock = opensocket($someAddress);
    if($sock) { $sock->close(); };
    $site2_end = get_timestamp();
    $site2_round_trip = $t2 - $t1
    
    // now we can perform some stuff on the round trips
    

提交回复
热议问题