The main function of the data link layer

The most basic service data link layer is the network layer destination computer reliable data source computer to the network layer is transmitted to the adjacent node. For this purpose, the data link layer must have a series of corresponding functions are: how to combine the data into data blocks (data block in which the data link layer is referred to in the frame, the frame is the data link layer the transfer unit); how to control the transmission physical channel frame, including how to deal with transmission errors, how to adjust the transmission rate so as to match the reception isotropic; providing a data link between two network access entities established, maintenance and release management. These features embodied in the following aspects.

Three basic problems data link layer
1. encapsulated in a frame
in order to provide service to the network layer, data link layer must use the services provided by the physical layer. And we know the physical layer, it is transmitted bit stream, the bit stream does not guarantee that there is no error in the data transmission process, the number of bits received may be less than, equal to or more than the number of bits transmitted. But they may have different values, then the data link layer in order to achieve effective error control data, on the use of a "frame" of data block transmission. And to adopt a frame format for transmission, there must be a corresponding frame synchronization, which is the data link layer "framing" (also referred to as "frame synchronization") function.

Encapsulated in a frame (framing): header and trailer is added before and after each piece of data, this constitutes a frame. After receiving the receiving side physical layer bitstream turned over, it can be labeled in accordance with the header and tail to identify the beginning and end of the frame received from the bitstream.
An important concept of packet switching: that all data transmitted over the Internet are based on the packet (ie, IP datagram) to transfer unit.
IP network layer datagram is transmitted to the data link layer becomes part of the data frame. 'S first portion and a tail are added in front of and behind the data portion of the frame, constitutes a complete frame.
Frame length equal to the data length plus the length of the frame header portion and a frame portion of the tail, the header and the tail is an important role for frame delimiter (i.e., determining the boundaries of the frame).
Header and trailer further comprising a plurality of control information necessary when the transmission frame is transmitted from the frame header starts.
Various data link layer protocol must have clearly defined the format of the frame header and frame tail.
In order to improve the efficiency of the transmission frame, the data should be made as part of the frame length greater than the length of the header and trailer. However, each of the link layer protocol have a predetermined maximum length of the data portion of the frame - maximum transmission unit MTU (Maximum Transfer Unit).

When the data is a text file in ASCII printable composition, the frame delimitation can use special frame delimiter.
Control characters SOH (Start Of Header) on the front one, showing the head start of the frame. Another control character EOT (End Of Transmission) indicates the end of the frame. They hexadecimal encoding are 01 (binary is 00000001) and 04 (binary is 00000100).

The advantage of using frame-transfer is found when a data transmission error, there will simply re-transmits frame errors, bit stream without the need for retransmission of all the data, which will greatly improve the transmission efficiency. But then quickly returned to normal, and then again from the beginning frame just finished sending unsent. Since a frame delimiter, at the receiving end knows the received preceding data frame in an incomplete (only the first portion the SOH, there is no end of transmission character the EOT), it must be discarded. The received data frame delimiter followed by a significant (SOH and the EOT), so this is a complete frame, should accept.
But also it brings two problems: (1) how to identify the start and end frames; (2) the inclusion in the data frame transmission focus, the recipient receives the retransmitted data frame is identified as a new data frame, or recognized as a retransmission frame has been passed to frame it? This depends on a variety of data link layer "frame synchronization" technique identified. "Frame sync" technique can enable the recipient to the beginning and end of each frame is separated from the above is not entirely accurate bitstream ordered regions, but can also identify the retransmission frames.

2. transparent transmission
in the above-mentioned data link layer encapsulation and framing transparent transmission, to the use of escape characters. Under the premise of not using escape characters Suppose we analyze the problems:

Since the start and end of frame marker is specified using special control character, so a combination of the transmitted data bits in any 8-bit encoding certain control characters and does not allow the same frame delimiter used, otherwise there will be Framing error delimited.
When using a text file transfer frames consisting of (a text file is a character input from the keyboard), which apparently does not occur as part of the data SOH or EOT such frame delimiting control character. Visible matter what character input from the keyboard can be placed in such a frame transmission in the past, so this transmission is the transparent transmission.
PROBLEM: When a non-data portion of the ASCII text files (such as a computer program or a binary image, etc.), the situation is different, if the data of a character or binary code exactly SOH and EOT such as control characters, the data link layer mistakenly find the frame boundary, the portion of the frame accept (mistaken for a complete frame), while the remaining portion of the data is discarded (this part can not find the frame delimiting control character SOH). Such a transmission frame is clearly not transparent transmission.

 

Analysis: In order to solve the problem of transparent transmission, we must try to make the data control characters that may appear in "SOH" and "EOT" at the receiving end is not interpreted as a control character.
Solution: transmitting side data link layer control character appears in front of "SOH" and "EOT" is inserted into an escape character "ESC" (hexadecimal code is 1B) in the data. At the receiving end of the data link layer to delete the escape character is inserted before the data is sent to the network layer. This is called fill bytes (byte stuffing) or fill character (character stuffing). If the escape character which also appear in the data, then the solution is still insert an escape character in front of the escape character. Thus, when the receiver receives two consecutive escape characters, wherein in front of a delete.

3. The error detecting
transmission errors: can be divided into two categories, one bit error is the most basic, the other is not a frame received bit errors, but there has been loss of frame, frame repetition or frame out of sequence.

Bit errors: that bit errors may occur during transmission, i.e. 0,0 1 may become 1 may become. Is a bit errors in transmission errors.
Three frames: [# 1] - [# 2] - [# 3], it is assumed that the case received by the receiver there may arise:
(1) frame is lost: receive [# 1] - [# 3] (missing [# 2]).
(2) a frame repetition: receive [# 1] - [# 2] - [# 2] - [# 3] (received two [# 2]).
(3) frame out of sequence: receive [# 1] - [# 3] - [# 2] (hereinafter, but the first frame sent has reached the receiving end, which is not the same as the general concept of transmission data link layer).
BER BER (Bit Error Rate): is a period of time, as a percentage of transmission error bits total number of bits transmitted. For example, the bit error rate of 10 ^ (-10), the average transmission 10 ^ represents 10 bits of a bit error occurs. Bit error rate and signal to noise ratio of a great relationship, if we raise the signal to noise ratio, bit error rate can be reduced.
Problem: The actual communication link is not ideal, it is impossible to make the error rate down to zero.
Analysis: In order to ensure reliability of data transmission, when the computer network to transmit data must be used to detect a variety of measures.
Solution: currently widely used in the data link layer of the cyclic redundancy check CRC (Cyclic Redundancy Check) detection technology.
Note: Using the data link layer CRC test, can achieve very special transmission errors, but this is not reliable transmission.

He added:
the OSI view is the data link layer must be made reliable transmission. Therefore, based on the CRC check, the frame number increases, acknowledgment and retransmission. Receive the correct frame will send an acknowledgment to the transmitting end. The sender within a certain period of time if it does not receive an acknowledgment, it is considered an error has occurred, so it is retransmission until an acknowledgment is received.
This approach may have played a great role in history. But now the quality of the communication line has been greatly improved, the probability of poor quality caused by a communication link error has been greatly reduced.

The data link layer protocols of the Internet is widely used not apply acknowledgment and retransmission mechanism that does not require the data link layer provides reliable transport services (because this price to be paid is too high, does not pay) to the upper layers. If in addition an error and needs to be corrected at the data link layer to transmit data, then the error correction task done by the upper layer protocol (e.g., TCP transport layer protocol). Experiments show that this can increase communication efficiency.

MAC address
which is the main function of the MAC sublayer in the data link layer. Here the word "address" and "IP address Addressing" is completely different, because here are looking for the address is the MAC address of the computer network card, also known as the "physical address", "hardware address" instead of the IP address. In Ethernet using media access control (Media Access Control, MAC) address addresses, MAC address burned into each Ethernet network card. This is necessary in the case of multi-point connection, such as a communication network in the multi-point connection, to ensure that each frame can accurately be sent to the correct address, the receiver should know which a sender station.

Link layer provides services to the network layer
designed to target the data link layer is to provide a variety of services needed for a network layer. The actual service with the system vary, but in general, the data link layer provides three types of services to the network layer:

1. unacknowledged connectionless service
"unacknowledged connectionless service" refers to a separate source computer to transmit frames to the target computer, the target computer does not confirm the frames. This service, in advance without having to establish a logical connection, and afterwards they do not explain the logical connection. For this reason, if on the line caused due to a frame of data is lost, the data link layer and will not detect the loss of such frames, these frames can not be restored. Consequences of this situation can be imagined, of course, in the error rate is very low, less demanding or completeness of the data situation (such as voice data), this service is very useful, because such a simple errors can be handed over to OSI layers above to recover. Most LAN services such as the data link layer is used by the connectionless unacknowledged service.

2. Confirm connectionless service
in order to solve the above "unacknowledged connectionless service" insufficient to improve the reliability of data transmission, the introduction of the "confirmation of connectionless service." In this connection service, the source host data link layer frames to be transmitted for each numbered data, the data link layer destination host must each received data frame acknowledgment. If the source host data link layer acknowledgment is not received the data frame is transmitted within a predetermined period of time, then it needs to retransmit the frame. In this way the sender know each frame has reached the other side correctly. Such services are used largely unreliable channel, such as a wireless communication system. "Confirmation of connection-oriented service" which will be described below with the exception that it does not require prior to establishing a data link frame transmission, and do not release the data link after the end of the frame.

3. confirmation of connection-oriented service
most data link layer are used to provide a connection-oriented service to the network layer acknowledgment. With this service, the source and destination computers before transmitting the data need to establish a connection with each frame sent on that connection are also numbered, the data link layer ensures every frame is received. And each frame to ensure that it is only received once normal sequence. This is exactly the connection-oriented services with the introduction of the previous "confirmation connectionless service" distinction, in the absence of confirmation of service connection, if no acknowledgment is detected, the system that the other side did not receive, then retransmits the data, and because it is not connected, so this data may recur several times, you may also receive several times, causing data errors. This type of service is present three stages, namely: the data link establishment, data transfer, the data link release phase. Each frame is transmitted are numbered to ensure the correctness of the contents of the order of frame transmission. Data link layer subnetworks most WAN connection-oriented service confirmation.
----------------
Disclaimer: This article is CSDN blogger "lzcWHUT 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/jinjiniao1/article/details/90633477

Guess you like

Origin www.cnblogs.com/hll16/p/11943047.html