Network interface layer

This article refers to "Computer Network" (seventh edition) edited by Xie Xiren, the blog post is for learning use only, used to record notes
The network interface layer includes the data link layer and the physical layer.
The physical layer considers how to transmit data bit streams on transmission media connected to various computers, rather than referring to specific transmission media . The role of the physical layer is to shield these differences in transmission media and communication methods as much as possible, so that the data link layer above the physical layer does not feel these differences. The main task of the physical layer is to determine some characteristics related to the interface of the transmission medium ( mechanical characteristics, electrical characteristics, functional characteristics, process characteristics ) and the conversion of the transmission mode (serial and parallel conversion).
The signal generated by the source is often called a baseband signal. The baseband signal often contains more low-frequency components or even DC components, and many channels cannot transmit such low-frequency components or DC components. In order to solve this problem, the baseband signal must be To be modulated. Modulation can be divided into two categories: coding (baseband modulation) and bandpass modulation . The encoding only transforms the waveform of the baseband signal. Common encodings are:

  • Non-return to zero system: positive level represents 1, negative level represents 0.
  • Return to zero system: positive pulse represents 1, negative pulse represents 0.
  • Manchester coding: the upward transition at the center of the bit period represents 0, and the downward transition at the center of the bit period represents 1
  • Differential Manchester coding: There is always a transition at the center of each bit, and there is a transition at the beginning of the bit to represent 0, and vice versa. 1.
    Insert picture description here
    The signal frequency generated by Manchester coding is higher than the non-return to zero system, but it has the ability to synchronize The clock frequency is extracted from the waveform) .
    Bandpass modulation requires the use of a carrier wave for modulation, moving the frequency range of the baseband signal to a higher frequency band and converting it to an analog signal. Common modulation methods include amplitude modulation, frequency modulation, and phase modulation. In fact, in order to achieve a higher information transmission rate, a technically more complex multi-system amplitude-phase hybrid modulation method, such as quadrature amplitude modulation QAM, will be used.
    Multiplexing is a basic concept in communication technology. Various multiplexing technologies are widely used for channels in computer networks. Common multiplexing technologies include frequency division multiplexing, time division multiplexing, and statistical time division multiplexing.
    Insert picture description here
    In frequency division multiplexing, after users are allocated to a certain frequency band, these frequency bands are occupied throughout the communication process. All users of frequency division multiplexing occupy different bandwidth resources at the same time. The disadvantage is that when the number of users is large, it cannot be guaranteed that all users can be allocated bandwidth.
    Time-division multiplexing divides time into segments of equal-length time-division multiplexing frames. Each time-division multiplexing user occupies a fixed time slot in each TDM frame. All users of time-division multiplexing are at different times. Occupy the same bandwidth.
    Insert picture description here
    However, the channel utilization of time division multiplexing is not high, because when the user has no data to send, the time slot allocated to the user in the time division multiplexing frame can only be idle, and other users cannot use it even if they have data to send all the time. These free time slots. Insert picture description here
    Statistical time-division multiplexing is an improved time-division multiplexing, which can significantly improve channel utilization. The user sends the data to the input buffer of the concentrator at any time, and then the concentrator scans the input buffer in sequence, puts the input data in the buffer into the statistical time-division frame, and skips over the buffer without data. Statistical time division multiplexing The number of time slots in each frame is less than the number of users connected to the concentrator, so if all users send data to the concentrator without stopping, then the concentrator must be unable to cope with it, and the internally set buffers will overflow .

data link layer

The channels used by the data link layer are mainly point-to-point channels and broadcast channels. Point-to-point channels use one-to-one point-to-point communication, while broadcast channels use one-to-many broadcast communication.
The difference between a link and a data link: a link is a physical line from a node to an adjacent node, without any other switching nodes in the middle; and a data link is a software used to implement data interaction at the link layer Hardware (hardware and software that controls data transfer protocols and communication links), the common is a network adapter.
Others divide the link into a physical link and a logical link. The physical link is the link mentioned above, and the logical link is the data link above, which is the physical link plus the necessary communication protocol.
When transmitting data on the data link layer, the data unit is a frame. When data is to be sent, the data link layer sends the data from the network layer to form a frame and sends it to the link; while receiving data, the received The data in the frame is taken out and handed over to the network layer. Each frame of data contains control information (frame header), which indicates which host this frame data is to be sent to and from which host. There is also a check code at the end of the frame to check whether this frame of data has changed during transmission.
There are many kinds of data link layer protocols, but there are three basic problems that are common: encapsulation and framing, transparent transmission, and error detection .

  • Encapsulation is to add header and trailer before and after a piece of data, thus forming a frame. An important role of the header and trailer is to delimit the frame (determine the boundaries of the frame). The maximum transmission unit refers to the upper limit of the data part length.

Insert picture description here
Insert picture description here

  • Transparency means that any data can be transmitted on the link layer of the two hosts.
  • Error detection is to detect whether errors occur during data transmission. At present, the cyclic redundancy check CRC is widely used in the data link layer.
    If the data received by the data link layer can pass the CRC check, it will continue to be transmitted to the upper layer, otherwise it will be directly discarded and no network resources will be wasted. The check here can only be the most basic bit error check, and for the frame loss, frame repetition and frame out-of-sequence, it needs the upper layer protocol to achieve .

Point-to-point protocol PPP.

Internet users usually have to connect to an ISP to access the Internet. The PPP protocol is the data link layer protocol used when the user's computer communicates with the ISP.
The PPP frame format is shown in the figure. The flag field F is specified as 0x7E, the flag field indicates the start or end of a frame, and the flag field is the delimiter of the PPP frame. A flag field is needed between two consecutive frames. If two consecutive flag fields appear, it indicates that this is an empty frame.
When the protocol field is 0x0021, the information field of the PPP frame is the IP packet. When it is 0xc021, it is the control protocol LCP data, and 0x8021 indicates that this is the control data of the network layer.
FCS is a frame check sequence using CRC.
Insert picture description here
Transparency PPP is used in asynchronous transmission (byte transmission), the escape character is defined as 0x7D, and use byte padding.
Convert the 0X7E bytes appearing in the information field to 2 bytes (0X7D, 0X5E), convert the 0X7D appearing in the information field to 2 byte order (0X7D, 0X5D), and convert the control characters in the ASCII code into 2 byte sequence (0x7D, 0X20 + original value).
The PPP protocol is used for synchronous transmission (a series of bits are continuously transmitted). The PPP protocol uses a zero-bit padding method to achieve transparent transmission. Scan the entire information field first when sending. If you find that there are 5 consecutive 1s, fill in a 0 immediately. You can ensure that there are no 6 consecutive 1s in the information field (6 consecutive 1s in 0x7E, so that it will not be wrong. Think of it as the delimiter of the frame).
PPP protocol workflow. When the user dials in to access the ISP, a physical connection is established from the user's computer to the ISP. At this time, the user computer sends a series of link control protocols LCP (negotiation of some configuration parameters) to the ISP in order to establish a data link connection. Then the network layer configuration is required, and the network control protocol NCP assigns a temporary IP address to the newly accessed user's personal computer. In this way, the user's personal computer becomes a host with an IP address on the Internet.
Insert picture description here

Use the data link layer of the broadcast channel.

The two standards of Ethernet: Ethernet V2 and 802.3 are different: 802.3 specifies that the third field of the MAC frame is "length / type". When the value of this field is greater than 0x6000, it means "type", which is exactly the same as Ethernet V2. When the length is lower than 0x6000, it indicates the length.
Insert picture description here

In order to make the data link layer better adapt to multiple LAN standards (such as 802.3, 802.4, 802.5, etc.), IEEE split the data link layer of the LAN into two sub-layers, namely logical link control and media access control MAC. The content related to the access to the transmission media is placed in the MAC sublayer, while the LLC has nothing to do with the transmission media, that is, the transmission media and the local area network of the MAC sublayer are transparent to the LLC sublayer.
Now that Ethernet has achieved a monopoly in the LAN market, the Ethernet V2 protocol is often used in the Internet rather than the LAN in the IEEE802.3 standard, so the role of LLC has disappeared.
Insert picture description here
The connection between the computer and the external LAN is through a communication adapter. The adapter has the function of data string and parallel conversion, and the adapter also has the ability to cache data.
Insert picture description here
CSMA / CD protocol The
early Ethernet connected many computers to a bus. When a host sends data, all computers on the bus can detect this data. In order to realize one-to-one communication on the bus, each computer adapter has a different address from other adapters. When sending a data frame, write the address of the receiving station at the head of the frame. The adapter can only receive this data frame if the destination address in the data frame matches the hardware address stored in the adapter ROM.
Ethernet adopts the following measures to ensure the normal communication of the device: it adopts a more flexible connectionless working method, and can directly send data without establishing a connection. The adapter does not number the data frames sent, nor does it require the other party to send back confirmation, that is, unreliable delivery ; as long as there is a computer on the bus sending data, the transmission resources of the bus are occupied, and only one can be allowed at a time The computer sends data, otherwise the computers will interfere with each other. Ethernet adopts CSMA / CD protocol, that is, carrier sense multipoint access / collision detection.
Ethernet sends data using Manchester encoding. The biggest advantage of using this encoding method is the ability to synchronize (can obtain synchronization signals), so that you know when the data will be transmitted.
Multipoint access in the protocol means that this is a bus network. Many computers are connected to a bus in a multipoint access mode; carrier monitoring is to detect whether other computers on the bus are also sending; collision detection is to send while sending. Monitor . Collision detection is to detect the change of the signal voltage on the channel in order to determine whether other stations are also sending data when sending data. When several stations send data on the bus at the same time, the amplitude of the signal voltage change on the bus will increase (superimposed on each other).
Bus-type Ethernet can only perform bidirectional alternating communication (half-duplex communication). Each station needs to monitor whether there is data being transmitted on the bus before sending data by itself in order to obtain the right to use; it also needs to monitor for a while while transmitting data to confirm that no other station is also using the bus at this time. When a collision is detected, the sending device suspends sending data and waits for a random time to send the data again. If retransmitting 16 times is unsuccessful, the frame is discarded and reported to the upper layer.
The agreement specifies that the basic backoff time is 2t for the contention period, and the specific contention period is 51.2us. For 10Mbit / s Ethernet, 512bit data, that is, 64 bytes, can be sent during the contention period. Therefore, any frame with a length less than 64 bytes is an invalid frame aborted due to collision . Upon receiving such an invalid frame, it should be discarded immediately. If the data transmitted by all network layers is less than 46 bytes (64 bytes-14 frame header-4 bytes FCS) bytes, it needs to be filled. At the same time, Ethernet also stipulates that the minimum interval between frames is 9.6us. This is to make the reception buffer of the station that has just received the data frame clear and prepare for the next frame .
The Ethernet using the hub is still a bus network logically, and each station shares the logical bus, using the CSMA / CD protocol.
The expansion of Ethernet includes hubs, bridges, and switches. Among them, the hub belongs to the physical layer extension, or the bus type, which is rarely used now; the bridge and the switch are both extended through the data link layer Ethernet, and the interactive machine is a multi-interface bridge. The switch has parallelism, that is, it can connect multiple pairs of interfaces at the same time, so that multiple pairs of hosts communicate at the same time.Hosts communicating with each other are exclusive transmission media, transmitting data without collision

Published 35 original articles · Like1 · Visits 1870

Guess you like

Origin blog.csdn.net/lzj_linux188/article/details/104138018