Ping在線檢測工具

域名或IP地址

Ping次數

Ping時間間隔


關於Ping在線檢測工具:

這個在線ping工具從Linux服務器返回ping結果. 您可以選擇ping域名的次數,以及兩次ping查詢之間的時間間隔.

comic ping

Ping域名需不需要加www.前綴?

對於一部分網站,您必須加www前綴,例如www.microsoft.comwww.quora.com .如果ping檢測失敗,請實施在域名之前加www.前綴.這是因為一些域名所有者設置DNS沒有使用默認的設置.

為什麼需要使用Ping檢測?

你有沒有在Skype對話中經歷過長時間延遲?您是否對在線遊戲時感受延遲?你應該檢測從你家到網站的延遲時間.

Ping檢測計算從您家到任何具有公共IP地址或域名的Web服務器的往返時間(從您單擊從Web服務器返回內容的鏈接). 它還會告訴您有多少數據包已傳輸,已接收的數據包數以及已丟失的數據包數.

對於在線遊戲,遊戲服務器的ping延遲應保持在100ms之下,如果ping延遲超過200ms則體驗無法忍受.對於常規的Web瀏覽活動,ping延遲對上網體驗影響較小. ping延遲和Internet速度是2個不同的概念,高延遲並不意味著你只能忍受480p分辨率的Netflix,雖然ping延遲和Internet速度是經常體現為正相關.

有幾種方法可以降低ping延遲,大互聯網流量會對ping延遲產生負面影響,因此夜間的互聯網速度更快,包裹丟失率低於白天.

更多關於ping檢測的鏈接:

維基百科(ping): https://en.wikipedia.org/wiki/Ping_(networking_utility)

RFC 792 (ping): https://tools.ietf.org/html/rfc792

Linux系統中的ping檢測(Ubuntu): https://linux.die.net/man/8/ping

Windows系統中的ping檢測: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ping

Linux系統中的ping檢測命令:

NAME
       ping - send ICMP ECHO_REQUEST to network hosts

SYNOPSIS
       ping  [-aAbBdDfhLnOqrRUvV46] [-c count] [-F flowlabel] [-i interval] [-I interface] [-l preload]
       [-m mark] [-M pmtudisc_option] [-N nodeinfo_option] [-w deadline] [-W timeout] [-p pattern]
       [-Q tos] [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp option] [hop ...] destination

root@instance-1:/var/log/apache2# ping -c 4 -i 1 facebook.com
PING facebook.com (157.240.22.35) 56(84) bytes of data.
64 bytes from edge-star-mini-shv-01-sjc3.facebook.com (157.240.22.35): icmp_seq=1 ttl=52 time=19.1 ms
64 bytes from edge-star-mini-shv-01-sjc3.facebook.com (157.240.22.35): icmp_seq=2 ttl=52 time=18.6 ms
64 bytes from edge-star-mini-shv-01-sjc3.facebook.com (157.240.22.35): icmp_seq=3 ttl=52 time=18.9 ms
64 bytes from edge-star-mini-shv-01-sjc3.facebook.com (157.240.22.35): icmp_seq=4 ttl=52 time=18.7 ms

--- facebook.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 18.697/18.857/19.102/0.189 ms
    

用Python進行ping IP地址或域名(用package socket):

import socket
import time


def ping(ip_or_domain, count):
    for i in range(1, count):
        try:
            start_time = time.time()
            socket.gethostbyname(ip_or_domain)
            end_time = time.time()
            total_time = round((end_time - start_time) * 1000, 2)
            print('{0} is reachable: icmp_seq={1} time={2}ms'.format(ip_or_domain, i, total_time))
        except socket.herror:
            print('{0} is NOT reachable'.format(ip_or_domain))


if __name__ == "__main__":
    # ping ip address
    ping("93.184.216.34", 4)
    # ping domain
    ping("coding.tools", 2)

-------------------
93.184.216.34 is reachable: icmp_seq=1 time=19ms
93.184.216.34 is reachable: icmp_seq=2 time=31ms
93.184.216.34 is reachable: icmp_seq=3 time=15ms
93.184.216.34 is reachable: icmp_seq=4 time=13ms
coding.tools is reachable: icmp_seq=1 time=14ms
coding.tools is reachable: icmp_seq=2 time=7ms
    

用Java進行ping IP地址或域名(用package java.net.InetAddress):

import java.io.IOException;
import java.net.InetAddress;

public class Ping {
    public static void ping(String ip_or_domain, int count) throws IOException {
        InetAddress remote_host = InetAddress.getByName(ip_or_domain);
        // send ping request "count" times in total
        for (int i = 1; i <= count; i++) {
            // Sending ping request
            long start_time = System.currentTimeMillis();
            boolean is_reachable = remote_host.isReachable(5000);
            long end_time = System.currentTimeMillis();
            long total_time = end_time - start_time;
            if (is_reachable)
                System.out.println(ip_or_domain + " is reachable: icmp_seq=" + i + " time=" + total_time + "ms");
            else
                System.out.println(ip_or_domain + "is NOT reachable");
        }
    }

    public static void main(String[] args) throws IOException {
        // ping ip address
        ping("93.184.216.34", 4);
        // ping domain
        ping("coding.tools", 2);
    }
}

-------------------
93.184.216.34 is reachable: icmp_seq=1 time=19ms
93.184.216.34 is reachable: icmp_seq=2 time=19ms
93.184.216.34 is reachable: icmp_seq=3 time=15ms
93.184.216.34 is reachable: icmp_seq=4 time=14ms
coding.tools is reachable: icmp_seq=1 time=8ms
coding.tools is reachable: icmp_seq=2 time=3ms