Basic concepts of Data link layer three basic issues
Package into frame: Before and after a piece of data with the first and the tail, and then constitute the frame, the role of the first and the end is to define the frame;
Transparent transfer: When the transmitted data contains headers and trailing characters, it needs to be escaped (resolved with a byte fill, and the escape character is filled in front of the special characters in the data);
Error control: The transmission process may produce bit errors, 1 to 0, 0 to 1 and so on, in a period of time, the transmission error of bits accounted for the total number of transmitted bits is called BER, bit error rate and signal-to-noise ratio has a great relationship;
In order to ensure the reliability of the data transmission, in the process of computer transmission, it is necessary to use various error test measures (cyclic redundancy test CRC). After the FSC is CRC, the frame test sequence FSC refers to the data appended with redundant code (FSC), cyclic redundancy test CRC and frame test sequence FCS is not equivalent ;
CRC: Is a common method of error detection;
FSC: Is the redundant code added in the back of the data, FSC can be obtained by CRC, and CRC is not the only way to obtain the FSC;
The data link layer in two cases uses the data link layer of the point-to-point channel
Now the most used Data Link layer protocol in the world is the PPP protocol, when users use dial-up telephone line to access the Internet, it is generally a point-to-date protocol;
Requirements that the PPP protocol should meet |
The PPP protocol does not need to meet the requirements |
Encapsulating into frames Transparency Multiple network layer protocols Multiple types of links Error checking Detecting Connection Status Maximum Transmission Unit Network Layer Address negotiation Data compression negotiation |
Error correcting Flow control Serial number Multi-point line Half-duplex or single-work link |
The composition of the PPP protocol:
1. Data Link layer protocol can be used for asynchronous serial or synchronous serial media;
2. It uses LCP (Link Control Protocol) to establish and maintain a data link connection;
3. The Network Control Protocol (NCP) allows multiple network protocols to be used on point-to-page connections;
PPP Protocol frame format:
The Flag field F (flag) in the header, specified as 0x7e (symbol 0x indicates that the character following it is in hexadecimal.) The hexadecimal 7E binary representation is 01111110), and the Flag field represents the beginning of a frame.
The Address field A in the header is set to 0xFF (that is, 11111111).
The control field C in the header is specified as 0x03 (that is, 00000011).
The 2-byte protocol field in the header:
(1) When the Protocol field is 0x0021, the information fields for PPP frames are IP datagrams.
(2) When the Protocol field is 0xc021, the information fields of the PPP frame are the data of the PPP Link Control protocol LCP.
(3) When the Agreement field is 0x8021, the information fields of the PPP frame are the control data of the network layer.
The information field portion of the PPP frame, the length of the information field is variable, not exceeding 1500 bytes.
Trailing of PPP frames
The first field in the trailer (2 bytes) is an FCS that uses a CRC frame to verify the sequence.
The Flag field F (flag) in the tail is specified as 0x7e (symbol 0x means that the character following it is in hexadecimal.) The hexadecimal 7E binary representation is 01111110), and the Flag field represents the end of a frame.
Note: The flag field is the delimiter for PPP frames. Only one flag field is required between consecutive two frames. If two consecutive flag fields appear, this is an empty frame and should be discarded.
Implementation of transparent transmission in PPP protocol
When a bit (0x7E) combination of the same as the Flag field appears in the Information field, some steps must be taken to make the bit combinations of this form and the Flag field statement do not appear in the information field.
1-byte padding--ppp using asynchronous transport
When PPP uses asynchronous transport, it defines the transfer character as 0x7d and uses a byte fill.
RFC1662 Specifies the following filling methods:
(1) Convert each 0x7e byte that appears in the Information field to a 2-byte sequence (0x7d,0x5e).
(2) If a 0x7d byte appears in the Information field (that is, the same bit combination as the escaped character), the escape character 0x7d is converted to a 2-byte sequence (0x7d,0x5d).
(3) If the control character of the ASCII code appears in the Information field (that is, a character with a value less than 0x20), a 0x7d byte is added before the character, and the encoding of the character is changed. For example, the occurrence of 0x03 (in the control word "transmit end" ETX) turns it into a 2-byte sequence (0x7d,0x31).
Because of byte padding on the sending side, the number of bytes of information transmitted over the link exceeds the original number of bytes of information. However, the receiver can recover the original information correctly after receiving the data and then making the opposite transformation to the sender's byte fill.
20-bit fill--ppp using synchronous transfer
When PPP uses synchronous transmission, a 0-bit padding is used.
Specific methods for 0-bit padding:
(1) First scan the entire information field on the sending side (usually hardware implementation, but can also be implemented in software, but slower).
(2) If 5 consecutive 1 are found, fill in a 0 immediately.
(3) The receiver receives a frame, first find the Flag field F to determine the bounds of the frame, and then use the hardware to scan the bit stream, each time the discovery of 5 consecutive 1 o'clock, 5 consecutive 1 after the deletion of a 0, to restore the original information bit stream.
So with this zero-bit padding, you can guarantee that there will be no 6 consecutive 1 in the Information field.
Data link layer using broadcast channel
1. Broadcast channels are used in the data link layer of the LAN
The topology types of LAN are bus type, ring type, star type
The mode of shared channel of LAN is the multi-point connection for the total Linetype network.
Divided into the following two kinds
Random access: That is, the channel is not fixed to a certain host but each host can send information at any time, but the problem here is that if there are multiple users at the same time to send information, it will cause collisions, so it will fail, so there must be a collision resolution agreement
Controlled access: Controlled access is characterized by the user not being able to send information at any time, but is subject to certain controls, such as giving each user a token, or polling
2. Adapter
The adapter, also known as the NIC, is connected to the CPU via the I/O bus, which contains the computer's unique MAC address.
Today's adapters are powerful, and sending and receiving frames can be implemented on their own without the CPU, which saves CPU time. In addition, the adapter can also be error detection.
The adapter has the filter function, can not belong to the site of the received, does not belong to the frame of the site discarded
Usually there are three kinds of frames in the LAN
1 Tan (one-to-one), the MAC address of the received frame is the same as the native hardware address
2 broadcast frames (pair of all), all frames sent to the local area network (address is all 1)
3 Multicast frames (one-to-many), sent to a part of the LAN host
The adapter can also be set to work in promiscuous mode, that is, receiving all the frames on the LAN, so that you can listen to other people's information, this way is not good
3. CSMA/CD Agreement
Ethernet is the total line structure, so when a computer sends confidence, all the computer can be listening to, so that need to have a MAC address to well-known destination address.
Only the MAC address is the same as the MAC address of the header of the data frame when it is discarded in other cases.
In order to simplify the communication Ethernet using a non-connected operation, that is, when sending information is not necessary to establish a connection, error retransmission and other high-level protocols such as TCP.
Main contents of the CSMA/CD agreement
Multipoint access: Description is the total Linetype network
Carrier monitoring: Because each computer can send information at any time, so that in order to prevent information failure, the use of carrier monitoring, if there are other computers in the channel is transmitting information itself does not send
Collision detection: That is, the side of the transmission edge detection, carrier monitoring when there will be a time difference, that is, when a host is sent, the transmission of the other host is required, so that if a host is sent, other hosts did not detect (because of the time difference), then other hosts may also send
That would have the potential to cause a collision. Therefore, collision detection is required, and if a collision occurs, it stops sending and then waits for a period of time to resend.
Computer network Overview---Data link layer