"TCP/IP Detailed Volume 2: implementation" Note--igmp:internet Group Management Protocol

Source: Internet
Author: User

IGMP communicates group membership information between hosts and routers on the local network, and routers periodically multicast IGMP queries to all host groups. Host multicast IGMP reporting messages

In response to the query.

From an architectural standpoint, IGMP is the Transport layer protocol located above IP. It has a protocol number (2), and its message is hosted by an IP datagram. With ICMP

, the process typically does not directly access IGMP, but the process can send and receive IGMP packets via IGMP sockets. This feature enables the multicast routing daemon to be

Implemented as a user-level process.

Is the overall structure of the IGMP protocol in NET/3:


The arrival of the IGMP query enables Igmp_input to initialize a decrement timer for each IN_MULTI structure, which is updated by Igmp_fastimo when each timer

When timed out, Igmp_fasttimo calls Igmp_sendreport.

When we create a new IN_MULTI structure, Ip_setmoptions calls Igmp_joingroup. Igmp_joingroup Call Igmp_sendreport to publish

New group member information so that the timer can schedule a second notification within a short time. Igmp_sendreport completes the format of the IGMP message and passes it to

Ip_output.


1.IGMP structure

IGMP packets are only 8 bytes long and are structured as follows:


The Igmp_type contains a 4bit version code and a 4bit type code, as shown in:


The IGMP message is constructed as follows:


NET/3 only uses version 1 of the message, the multicast router sends 1 classes of messages to all hosts on the local network requesting a membership report. The response to Class 1 IGMP packets is

A 2-class message from the host that reports their multicast member information. Class 3 Messages transmit multicast routing information between routers, and the host does not process 3 types of messages.


Structure of the 2.IGMP_PROTOSW

The PROTOSW structure of IGMP is as follows:


Three times trigger IGMP processing:

A local interface joins a new multicast group.

An IGMP timer timed out.

An IGMP query was received.

There are also two events that trigger local IGMP processing, but the results do not send any messages:

Receive an IGMP report.

A local interface leaves a multicast group.


3. Join a group: Igmp_joingroup function

When a new In_multi structure is created, In_addmulti calls Igmp_joingroup. Then the request to join the same multicast group only increases the IN_MULTI structure

The number of references, not calling Igmp_joingroup.

The approximate function is handled as follows:

If a new group is called when all host groups, or member relationships are requested, the timer is not required, and the function returns. Because each multicast host is all multicast groups

, no reporting is required. It is not necessary to send a group member report to the loopback interface because the local host is the only system on the loop network and it already knows its

Member status.

In other cases, the report of the new group is sent immediately (via the Igmp_sendreport function), and a random value is selected for the group timer based on the group's situation.

Igmp_fastimo Check this variable to avoid unnecessary processing. The 2nd Membership Report is published when the timer for the new group times out.


4.igmp_fasttimo function

Igmp_fasttimo function loops find each IN_MULTI structure, for each structure:

If the timer is 0, do nothing.

If the timer is not 0, it is decremented. If 0 is reached, an IGMP group Membership report is sent.


5.igmp_sendreport function

The Igmp_sendreport function constructs and sends an IGMP report message for a multicast group.

By creating a mbuf, then setting the corresponding value, finally constructing a ip_moptions structure and passing it along with the message to Ip_output.

The process-level multicast router must listen for the Membership report and always receive IGMP datagrams when the system is configured as a multicast router. Through the Transport Layer program

The Igmp_input and Pr_input functions of the messaging to IGMP.


6. Input Processing: igmp_input function

The multicast router receives all IGMP packets, but the multicast host receives only those IGMP packets that arrive at the destination multicast group members (that is, those that receive

Their interfaces are query and member management reports for group members.

The standard protocol is divided into the igmp_input of the received report. The approximate treatment of igmp_input is as follows:

1. Verify IGMP packets, package IGMP test, and so on.

2. According to the code within the Igmp_type processing the message, Igmp_type contains a version code and a type code, according to these two codes respectively processing.

3. The effective IGMP messaging to Rip_input is presented to all processes that monitor IGMP packets in the rip_input.


6.1. Member Relations query: Igmp_host_membership_query

RFC1075 recommended multicast routers publish at least one IGMP membership query every 120 seconds. Send the query to 224.0.0.1 groups (all host groups).

The processing of the Igmp_type is as follows:

Receiving a query message does not immediately cause an IGMP member report. Instead, Igmp_input sets a random value for each set of timers associated with the interface that receives the query,

When a set of timers times out, Igmp_fasttimo sends a member relationship report, while the host of all other queries does the same action. Once a

A random timer for a specific group on the host times out, as if the group multicast a report. This report will cancel the timers on other hosts to ensure that only one report is

Multicast on the network. The router, like other group members, receives the report. An exception to this situation is all host groups, which do not set timers or send

Report.


6.2. Member Relationship report: Igmp_host_memeber_report

The processing of the Igmp_type is as follows:

Reports sent to the loopback interface are discarded.

If the network or subnet portion of the source address is 0 (which is allowed if the host is starting), the source address is set to the subnet address, then the process-level multicast routing

The daemon can tell which subnet it came from.


7. Leave a group: Igmp_leavegroup function

When the reference counter in the In_multi structure jumps to 0 o'clock, In_delmulti calls Igmp_leavegroup. The function does not take any action.

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.