Chapter 1 TCP/IP details-Link Layer

Source: Internet
Author: User
Tags rfc windows remote access


One day in a certain month, I wrote half a blog article on the WLW without CTRL + S to study "TCP/IP details volume 1"-link layer, suddenly, my roommate made a trip to the electric cooker with a great deal of cooking power, and there was a power outage! So for a long time, this relentless power failure was wiped out .. All you can do is start from scratch! The hierarchical encapsulation of TCP/IP makes each layer seem completely independent and exclusive, so that we can think that the data transmission at each layer between different hosts is directly transmitted at the same layer, this means that we can ignore all the intermediate processes and focus on the layers of our attention. For example, we only need to pay attention to this layer for frame transfer between two different hosts, so that there is no need to care about how the physical layer lines are transmitted. The link layer has three main functions:
(1) receive and send data from the IP layer; (2) receive and send ARP requests for the ARP module; (3) receive and send RARP requests for the RARP module;
ARP and RARP are two important address resolution protocols. Here, we first regard them as the same IP layer for sending or transmitting (Link Layer) Data downward at a protocol level, the corresponding link layer responds to the request. Since the link layer needs to send and receive data, it must process the data: encapsulate the data into conforming frames; when the link layer is more common in two processing protocols: SLIP protocol and PPP protocol. PPP is a familiar word. What I have been puzzled about is that the SLIP protocol, which is still widely used in most college computer network textbooks in China, is not mentioned. It may be just a so-called outline requirement .. Various protocols at the link layer follow three basic principles: encapsulation into frames, error detection, and transparent transmission. I will discuss in detail below. My article will not record each knowledge point in the order explained in the book, I don't know why the author of TCP/IP always puts forward many unknown terms in advance and adds them to reference them. In the subsequent chapters, MTU is a good example, it is explained almost at the end of this chapter, but it has been used many times before:
MTU (maximum transmission unit) each link layer protocol specifies its maximum transmission data segment length, which is MTU. The MTU values of Ethernet and RFC 802.3 are limited to 1500 bytes and 1492 bytes respectively (note that this does not mean that MTU can only be so large ), when the data segment transmitted from the IP layer or the data segment obtained from the underlying layer exceeds this length, this will cause Frame loss. Therefore, when the IP layer wants to transmit data at the lower layer, it must first partition the data. The specific sharding principles will be described in subsequent sections on the IP layer. Principle 1: The data is encapsulated into frames by means of sub-assembly into frames. That is, the first frame SOF and the last frame EOT are added before and after a piece of data to form a complete frame. As shown in (the actual frame structure is more complex than this. The three principles are simplified here, and the following two principles are not described ):
Note that MTU is not the maximum length of a frame. Generally, MTU is the maximum length of intermediate data outside the frame header and the end of the frame. Because the data has the start and end characters, if the transmission is interrupted suddenly, only the frame header has no end frame, in this case, when the data is transmitted to the next data link, the frame can be directly discarded because it is not a complete frame detected.
Principle 2: transparent transmission now assumes that the SOH and EOT encoding are both 0XEE, so if the part of the data to be transmitted has a 0XEE, the frame boundary error may occur, as shown in:
When the link layer processes data, it mistakenly regards the SOH (OXEE) of the data part as a delimiter for processing. As a result, the latter part of the SOH will be lost without transmission. In order to process this frame, the frame boundary occurs in part of the data, so a processing method similar to the intermediate meaning character in C language is introduced. The Escape Character in C is "\". Here we assume that ESC is used as this escape character, and the data part will be processed in the following format:
In this way, when the data is transferred to the next data link layer for processing, every time an ESC is read, The SOH after it will not be considered as a definer. What if there is a pure content ESC in the data segment? The processing method is similar, that is, add an ESC character directly before it. When the next data link layer receives two ESC characters, it will delete one. Principle 3: The actual frame structure of the error detection is more complex than the above one, and may be shown as follows (a volume of the original image ):
This is the frame structure defined in RFC 802.3. Apart from the data segment, it is not only as simple as the frame header and the end of the frame. Currently, we only need to care about the final CRC segment, which is represented by four bytes and is a verification code obtained through a CRC operation. The specific method for CRC operation is actually relatively simple, I will not elaborate on it here. You can check it out (here ). In essence, we perform MD5 encryption on some data at ordinary times, but the CRC calculation result must be 0. When the receiving end receives the data, it performs detection in the same way, if the result is 0, it indicates that there is no error in transmission. If the value is not 0, an error is certainly returned, and the current frame is discarded. In this case, we can see that the error transfer mechanism at the link layer ensures that the frames transmitted to the destination host are correct (because the frames with errors will be discarded ).
The usage of the SLIP Protocol is included in the first article. Baidu Baike interpreted it as "SLIP (Serial Line Internet Protocol, Serial Line Internet Protocol ), this protocol is an old industrial standard for Windows Remote Access. It is mainly used in Unix remote access servers and is still used to connect certain ISPs. Because the SLIP protocol is designed for low-speed serial lines, it can be used for dedicated lines or dial-up lines. The transmission rate of Modem is between 1200bps and 19200bps ". In fact, this is a simple protocol. Its basic structure is similar to the structure described in principle 2 above. The frame processing method is the same, but there is no target address or CRC segment, there is no type segment, so there are three disadvantages:
(1) There is no way to notify the other end of the IP address of the local end; (2) there is no way to perform frame verification, if some data values (Change 0 to 1 or 1 to 0) may be changed due to line noise during transmission, these verification tasks must also be completed at the upper layer of the link layer; (3) because there is no type segment, a line cannot simultaneously transmit SLIP and other types of link layer protocols (such as PPP), because different protocols have different encapsulation methods for frames, the same data transmission segment is encapsulated into different frames. If a line used for SLIP transmission transmits the SLIP and PPP frames simultaneously, after arriving at the link layer of the target host, it is parsed as the SLIP protocol's frame Encapsulation Format. The consequences are unimaginable.
CSLIP protocol (compressed SLIP protocol) if we need to transmit a byte data frame using the SLIP protocol, after processing by the upper layer (IP layer and transport layer, the final data arriving at the link layer will contain 40 bytes. In fact, we mainly add some protocol headers, which will be detailed in subsequent chapters. The CSLIP protocol compresses the SLIP protocol with a relatively small data segment into a very short frame through certain compression processing, thus greatly improving the transmission efficiency. Here, 40 bytes may be compressed into 3 to 5 bytes for transmission, which greatly improves the running efficiency. Currently, all SLIP products support the CSLIP protocol. Compared with all the disadvantages of SLIP, the PPP protocol has no disadvantages. This Protocol is usually used when we connect to an ISP (internet service provider, internet service provider, such as China Telecom) through dialing. The frame structure of the PPP protocol is as follows:
 
The start and end fields are SOF and EOT mentioned in principle 1, which are fixed to 0XFF. The CIDR blocks and control CIDR blocks are fixed with 0XFF and 0X03. The Protocol segment is usually used to specify the data segment type. 0X0021 indicates IP datagram, 0XC021 indicates link control data, and 0X8021 indicates network control data. Similarly, the PPP protocol follows Principle 2. Compared with SLIP, it has the following advantages: (1) due to the existence of the Protocol segment, it supports transmission of multiple protocols on a single serial line, (2) The CRC check ensures the correctness of data transmission. (3) similar to CSLIP, frames can be compressed;
The LookBack interface volume does not describe the principle of the loopback interface in detail, but simply describes the line principle it passes during data transmission. The loopback interface is usually a Virtual Interface (IP address). Because a vro has multiple interfaces, if one of the interfaces interrupts the connection, you can access the vro through other interfaces. If you select an interface for a vro as its unique identifier, and these physical interfaces may be DOWN at any time, you have to select an interface as its ID. The loopback interface is used to identify the unique ID of a vro and can be manually specified without changing the status of the physical interface. The reason why the loopback interface is put on the link layer is that its role is similar to a link layer. When the network layer transmits data to a loopback interface, the following three situations usually occur:
(1) data sent to the loopback address will be directly returned to the IP input queue, that is, it will be directly transmitted to the IP layer; (2) data transmitted to the broadcast or multicast address is usually copied to the loop interface (that is, transmitted to itself), because the broadcast or multicast definition itself contains the host itself; (3) any data sent to the current host IP address is sent to the loopback interface. In fact, if a host is transmitting data to itself, the data will never be transmitted to the network, because many Ethernet device drivers cannot send data back to them. This also requires a host to be able to process the data sent by itself. Link Layer. This is the end! The wind tonight is so cool ......
 

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.