Sunday, September 5, 2010

Ping

Ping is a computer network administration utility used to test the reachability of a host on an Internet Protocol (IP) network and to measure the round-trip time for messages sent from the originating host to a destination computer. The name comes from active sonar terminology.

Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP response. In the process it measures the time from transmission to reception (round-trip time)[1] and records any packet loss. The results of the test are printed in form of a statistical summary of the response packets received, including the minimum, maximum, and the mean round-trip times, and sometimes the standard deviation of the mean.

The use of a ping utility is usually described as pinging a computer.

Ping may be run using various options (command line switches) depending on the implementation that enable special operational modes, such as to specify the packet size used as the probe, automatic repeated operation for sending a specified count of probes, time stamping options, or to perform a ping flood. Flood pinging may be abused as a simple form of denial-of-service attack, in which the attacker overwhelms the victim with ICMP echo request packets.
Contents
[hide]

* 1 History
* 2 ICMP packet
* 3 Sample ping test
* 4 Message format
o 4.1 Echo request
o 4.2 Echo reply
o 4.3 Other replies
* 5 Payload
* 6 In gaming
* 7 Other types of pinging
* 8 See also
* 9 References
* 10 External links

[edit] History
A server denying a ping request because of the request's size.

The ping utility was authored by Mike Muuss in December 1983 as a tool to troubleshoot problems in an IP network. He named it after the sound pulses of sonar, since its operation is analogous to that of sonar in submarines, whereby the sonar instrument directs a pulse of sound toward a target. The echo bounces from the target and is received by the operator.[1][2]

The usefulness of ping in assisting the diagnosis of Internet connectivity issues was impaired starting in 2003, when a number of Internet service providers began filtering out ICMP Type 8 (ICMP Echo Request) messages at their network boundaries.[citation needed] This was partly due to the increasing use of ping for target reconnaissance, for example by Internet worms such as Welchia that flood the Internet with ping requests in order to locate new computers to infect. Not only did the availability of ping responses leak information to an attacker, it added to the overall load on networks, causing problems for routers across the Internet.[citation needed]

However host discovery or ping scanning or ping sweep is still a part of network scanning tools like nmap, as it may give basic evidence about the existence of a remote machine.

Although RFC 1122 prescribes that any host must accept an echo-request and issue an echo-reply in return, this has been characterized as a security risk.[3]
[edit] ICMP packet
ICMP packet Bit 0 - 7 Bit 8 - 15 Bit 16 - 31
IP Header
(20 bytes) Version/IHL Type of service Length
Identification flags and offset
Time To Live (TTL) Protocol Checksum
Source IP address
Destination IP address
ICMP Payload
(8+ bytes) Type of message Code Checksum
Quench
Data (optional)

Generic composition of an ICMP packet[4]

* Header (in blue):
o Protocol set to 1 and Type of Service set to 0.
* Payload (in red):
o Type of ICMP message (8 bits)
o Code (8 bits)
o Checksum (16 bits), calculated with the ICMP part of the packet (the header is not used)
o The ICMP 'Quench' (32 bits) field, which in this case (ICMP echo request and replies), will be composed of identifier (16 bits) and sequence number (16 bits).
o Data load for the different kind of answers (Can be an arbitrary length, left to implementation detail. However must be less than the maximum MTU of the network[citation needed]).
* Data Transportation

Note that ICMP (and therefore Ping) resides on the Network layer (level 3) of the OSI (Open Systems Interconnection) model. This is the same layer as IP (Internet Protocol). Consequently, Ping does not use a port for communication.
[edit] Sample ping test

The following is a sample output of pinging en.wikipedia.org under Linux with the iputils version of ping:

admin@localhost# ping en.wikipedia.org
PING rr.pmtpa.wikimedia.org (66.230.200.100) 56(84) bytes of data.
64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=1 ttl=52 time=87.7 ms
64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=2 ttl=52 time=95.6 ms
64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=3 ttl=52 time=85.4 ms
64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=4 ttl=52 time=95.8 ms
64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=5 ttl=52 time=87.0 ms
64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=6 ttl=52 time=97.6 ms
--- rr.pmtpa.wikimedia.org ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 8998ms
rtt min/avg/max/mdev = 78.162/89.213/97.695/6.836 ms

The output shows the results of 10 pings to 66.230.200.100 with the results summarized at the end. The program is stopped by pressing ctrl-C.

* shortest round trip time was 78.162 milliseconds
* average round trip time was 89.213 milliseconds
* maximum round trip time was 97.695 milliseconds
* Standard deviation of the round-trip time was 6.836 milliseconds

[edit] Message format
[edit] Echo request

The echo request is an ICMP message whose data is expected to be received back in an echo reply ("ping"). The host must respond to all echo requests with an echo reply containing the exact data received in the request message.
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Type = 8 Code = 0 Header Checksum
Identifier Sequence Number
Data :::

* The Identifier and Sequence Number can be used by the client to match the reply with the request that caused the reply. In practice, most Linux systems use a unique identifier for every ping process, and sequence number is an increasing number within that process. Windows uses a fixed identifier, which varies between Windows versions, and a sequence number that is only reset at boot time.
* The data received by the Echo Request must be entirely included in the Echo Reply.

[edit] Echo reply

The echo reply is an ICMP message generated in response to an echo request, and is mandatory for all hosts and routers.
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Type = 0 Code = 0 Header Checksum
Identifier Sequence Number
Data :::

* Type and code must be set to 0.
* The identifier and sequence number can be used by the client to determine which echo requests are associated with the echo replies.
* The data received in the echo request must be entirely included in the echo reply.

[edit] Other replies

In case of error, destination host or intermediate router will send back an ICMP error message, i.e. host unreachable or TTL exceeded in transit. In addition these messages include the first 8 bytes of original message (in this case header of ICMP echo request, including quench value), so ping utility can match it to originating query.[citation needed]
[edit] Payload

The payload of the packet is generally filled with letters of the alphabet as this ASCII tcpdump shows

16:24:47.966461 IP (tos 0x0, ttl 128, id 15103, offset 0, flags [none],
proto: ICMP (1), length: 60) 192.168.146.22 > 192.168.144.5: ICMP echo request,
id 1, seq 38, length 40
0x0000: 4500 003c 3aff 0000 8001 5c55 c0a8 9216 E..<:.....\U....
0x0010: c0a8 9005 0800 4d35 0001 0026 6162 6364 ......M5...&abcd
0x0020: 6566 6768 696a 6b6c 6d6e 6f70 7172 7374 efghijklmnopqrst
0x0030: 7576 7761 6263 6465 6667 6869 uvwabcdefghi

Some of this payload includes timestamp when message was sent. This allows ping to compute round trip time in a stateless manner - ping doesn't need to remember what and when packets was sent, all the data needed will be contained in the returned message. In case of no answer and no error message, most implementation of ping displays nothing, or periodically prints notification about timeout.[citation needed]
[edit] In gaming
Main article: ping (video gaming)

In various network multi-player games, the server notes the time it requires for a game packet to reach a client and a response to be received. This round-trip time is usually reported as the player's 'ping'. It is used as an effective measurement of the player's latency, with lower ping times being desirable. Note that this style of ping typically does not use ICMP packets.
[edit] Other types of pinging

The term ping is commonly used to describe the transmission of an effectively content-less message that is used for a variety of purposes. For example, a ping may be sent using the User Datagram Protocol (UDP) to a device located behind a network address translator (NAT) to keep the port binding on the NAT translator from timing out and removing the forward mapping. Other examples are short or empty instant messages, emails, voice mails, or missed-call notification to indicate availability.

No comments:

Post a Comment