Steps to implement the micro-IPv6 protocol stack

Source: Internet
Author: User

We have learned a lot about the IPv6 protocol stack, and we also mentioned the specific knowledge about the embedded simplified IPv6 protocol stack, now let's present the IPv6 protocol stack implementation steps to everyone. For more information, see the following section.

IPv6 protocol stack design and implementation

During the design of the protocol stack, we design and implement an operating system simulation Layer Based on the embedded operating system to implement basic clock, message management, process synchronization, and other basic operating system functions. In terms of Protocol processes, all protocol stacks are encapsulated into individual processes, and applications can reside in them or act as separate processes. This achieves separation from the operating system, it also avoids inter-layer switching. For memory management, the class BSDbuf structure is used to link static buffers with dynamic buffers.

IPv6 protocol

The IPv6 protocol stack module is used to process received IPv6 data packets, construct IPv6 data packets to be sent, and send them to the underlying layer. When a packet is received, the network device driver calls the ip_input function to check its IP header, including its version number, packet length, load length, destination node address, and next header, after checking that the headers are correct, the headers are submitted to different processing modules based on the types of the next headers. When sending data, you must know the next hop IPv6 address of the sent packet and the corresponding MAC address of the address. ip_route) function is designed to implement this function, it obtains the processing process of the next hop IPv6 address and its corresponding MAC address. The destination cache is used to store the relationship between a series of recent packets and the corresponding next hop IP address, the prefix list stores the relationship between a series of subnet prefixes and other address prefixes and their corresponding next-hop IP addresses. If no matching record is found between the two, then, select the default router from the prefix list as the next hop IPv6 address for transmission.

After the next hop IPv6 Protocol address is obtained, the data enters the transmission phase. The transmission phase is controlled by ip_outputif) function, ip_output) function fills in the header, and selects the sending network interface, then, enable the sending network interface to send data.

ICMPV6

ICMPV6 is responsible for receiving, interpreting, and sending ICMPV6 packets. After receiving the packet, if it is a neighbor information packet, it is transferred to the neighbor discovery module. If it is a diagnostic packet, it is handed to the ICMPV6 diagnosis module. The ICMPV6 module only responds to the reply packet, and the destination cannot reach the packet. When processing incoming IP packets, if the next header is neither TCP nor UDP nor ICMPV6, it indicates that the protocol stack on the embedded device has reached the IP layer and the port is not reachable, the destination inaccessible message is sent. When an ICMPV6 response message is received, a response message is sent. The format is similar to that of the request message. Based on the received request message, the packet type is changed and the checksum is re-calculated, in the IP header, you can reverse the source address.

Neighbor Discovery

Neighbor Discovery is the core protocol for streamlining the IPv6 protocol stack. It uses the exchange of neighbor request messages and neighbor announcement messages to implement address interpretation, address repeatability detection, and automatic address configuration. No router request/router announcement messages or redirection messages are implemented.

◆ Neighbor Request Message

The type value is 135. The source address domain of the packet IP header is the address of the interface for sending neighbor requests or is not specified, the target address is the multicast address of the requested node associated with the requested target address, or the target address itself. The target address field in the ICMPV6 header field is the requested target address. The option field can contain the source link layer address option, which is used to tell the recipient to send the MAC address of the Request node. This option must be included when the source address is the specified address.

◆ Neighbor announcement message

The type value is 136, which is used to respond to neighbor request packets, or to notify the node of its link layer address change. The source address of the packet IP header is the interface address for sending neighbor announcement packets, the destination address is the unicast address that sends the neighbor request, or the multicast address that is used to announce the change to the link layer address of all neighbor nodes. The destination address is the interpreted IPv6 address, or the IPv6 Protocol address to be used in the address uniqueness verification. Address Explanation means that when a node only knows the IP address of a neighbor node, the node obtains the link layer address of the corresponding node by sending the neighbor request message and receiving the neighbor announcement message, it is the most important function module in the Neighbor Discovery module of the IPv6 protocol stack.

Node A knows the link IPv6 Protocol address of Node B.

FEC0: 0: 0: 1: B, but do not know the link layer address 00-10-5C-F7-5C-96 of Node B. Along the arrow, A sends A neighbor request message, the destination address of the IP domain is the destination address FEC0: 0: 0: 1: B. After receiving the neighbor request message, Node B checks that the target address belongs to the local host, and sends A unicast neighbor announcement message to, the destination link layer address option of the neighbor announcement message contains the link layer address 00-10-5C-F7-5C-96 of Node B. In this way, node A knows the link layer address of Node B and the address interpretation process is complete.

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.