Linux ICMP Learning notes three ICMP related questions analysis __linux

Source: Internet
Author: User

In the analysis of the previous section, 3 questions were left:

Before parsing the ICMP packet processing process, I have the following questions:

1. Why to create a socket for each CPU only to send ICMP messages, do not use the socket can also send ICMP messages out.

2. What is the working principle of ping?

3. What is the working principle of traceroute?

1, for the first question, through the analysis of the previous section, there should be the following reasons

A lock access ensures that only one ICMP message can be sent at the same time. Because Socket->sk_lock.slock has a definition of a spin lock, using this spin lock, you can ensure that only one ICMP message is sent at the same time. And if it's not socket, we need to create a new structure to ensure that only one ICMP message is sent at the same time, and since there is already a ready-made structure in the code, there is no need to create a new structure

b in the Linux kernel, the ICMP, IGMP, TCP, UDP as a four-layer processing process to treat, and for TCP, UDP and other four-tier data, send and receive packets are used to achieve the socket, already has a relatively sound mechanism, including ip_append_data, Ip_push_pending_frames, so this set of mechanisms for ICMP is not necessary to create new mechanisms specifically for ICMP.

2, for the working principle of ping, mainly through echo_request, echo_reply to achieve.

Where Echo_request is implemented using the application layer, the following echo format, in the Linux implementation, is to set the identifier as the process ID of the ping request, while sequence is the requested count value, through the source, destination IP address, identifier, sequence can differentiate between different ping responses.

TYPE (8/0)

CODE (0)

Checksum

Identifier

Sequence

Option

3, for traceroute working principle, mainly according to Echo_request, Echo_reply, time_exceeded these 3 ICMP types of data packets implemented.

First, the traceroute process sends an ECHO Request packet with a TTL value of 1, 2, 3, 4, 5, 6, and the middle router site sends a time_exceed ICMP error message when it receives a packet with a TTL of 0. This traceroute process will know each of the site's IP address, and the destination address of the PC or router received echo_request type of packets, that will reply to the echo_reply type of packets, which traceroute workflow.

TYPE (11)

CODE (0-1)

Checksum

Not used (must set 0)

Option


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.