Recently, I went back to my textbook computer Networks in college to review the TCP/IP protocol and explore the principles of VPN. However, having not read this book for a long time, I was suddenly attracted by the knowledge of link layer. I felt that I had not learned anything at the beginning and could not remember the content of PPP protocol (ah, I love it!). So go on to “desire” the state of knowledge and take notes at the link layer.
1 Basic Introduction
As the next layer of the network layer, the link layer is mainly responsible for encapsulating and packaging data in the network layer, commonly known as IP packets, which can also be called packets or packets. Usually, the most well-known, or basic, is point-to-point channel (PPP), a transmission protocol called a frame. The “dot”, here is the meaning of two nodes, for example, two Ethernet cable connected computer, the communication between them is to point to point, if the two computer is out of the same local area network (such as the use under the same router, or switch), between them, it is not point to point, because among them there are other equipment (nodes). It can be said that at this time the computer to the router (switch) is point-to-point, so that a point-to-point channel, called a link. The other concept, data link, is not really a point-to-point link, and there are physical devices in the middle to implement the protocol, which can be said to be a logical link.
2 Basic problems at the link layer
The link layer frame, as a basic unit of encapsulation and transmission of upper layer data, naturally faces certain problems to deal with the problems faced by its own layer. It mainly includes frame encapsulation, transparent transmission and error detection.
2.1 Encapsulation into frames
We know that when downloading general files, the server is not directly the data of the file parsing out, directly sent over (of course, do not exclude you download the file is small enough), in a certain sense, this is a kind of space reuse idea. In the process of transferring a file, how can the client identify these scattered data? The link layer is responsible for identifying the packet data, and the reorganization takes place at the IP layer. Data link layer in the upper encapsulated into a frame, will be added at the end of the first and some data is used to frame and bound, in this way, the node at the time of received data, can isolates each frame, this data is called a frame delimiter, first the tail with SOH, EOT (say the name of the delimiter, essence is a binary) delimited. Obviously, the data between the head and tail is the data information encapsulated at the next level. With the design of the head and tail, and the maximum transmission unit between them, it is possible to distinguish between different frames based on the presence or absence of frame delimiters and discard invalid frames. The frame structure is shown below
2.2 Transparent Transmission
The term transparent transmission simply means the transmission of data “hidden” from the target object. At the link layer, the data that needs to be transmitted is the “frame delimiter” encapsulated in the data part of the frame, so that the node does not “discover” (mistakenly) that it is the frame delimiter. The frame delimiter is also a binary, but it’s not very common in the data, but it will inevitably appear in the data part of the same symbol, so you need to avoid the node to recognize it as SOH,EOT. The idea behind this design is the same as when we use “\” to escape character output or regular expressions in our code, that is, to add a binary before another binary, and so on. This behavior is called character padding.
Error detection
The environment on the network is “ever-changing”, which makes it hard to avoid errors in the transmission process of frames. Like TCP, the data link layer also detects errors on frames. However, because the links involved in the link layer are not as complex as TCP, it simply checks for errors, drops them directly, and makes sure that TCP does the retransmission (not always) — that is, the data link layer is unreliable in most cases. Error detection by the link layer is only for the bit error detection in a frame, it does not care about frame repetition, frame loss, frame out of order and so on. In fact, THIS is all DONE by TCP. The cyclic redundancy detection (CRC) algorithm is widely used in error detection. Let’s look directly at the description in the textbook:
This algorithm will not be described too much, but the general idea is that the number of zeros added after M is p-digit n minus one digit. The purpose of this method is that first, the quotient can always be represented by n-digit, and second, the FCS added with remainder will not change the original data of M.
3 the PPP protocol
As the most basic protocol in the link layer, PPP has its own more detailed rules on the “big definition” of the link layer (such as the three basic problem designs above).
Composition of 3.1
Learn from the above we know that the basic data transmission unit of data link layer is the frame, frame structure is composed of 01, actually the PPP protocol the frame can be grouped to send, this is asynchronous transmission, and the whole frame sent as synchronous transmission link control protocol (LCP), is used to establish, configure, and test data link negotiations. A set of network control protocols (NCP) used to support unused network layer protocols. These three components make up the content of THE PPP protocol, and they usually complement each other. Asynchronous transmission is mainly used for transmission with low timing requirements (such as scattered asynchronous messages).
3.2 Filling Method
PPP has two modes: asynchronous transmission and synchronous transmission. The two modes need to be distinguished. The classification of frame groups in asynchronous transmission adopts the idea of transparent transmission, using byte padding. The synchronous transmission is to avoid the node to mistake the characters used in byte filling as delimiters. Generally, it adopts the zero-bit filling method with five consecutive ones filling zeros.