Data link layer of computer network (full)

[Review Tips]

Wang Dao: This chapter is the focus of exams in previous years. On the basis of understanding the basic concepts and functions of the data link layer, it is required to focus on mastering the sliding window mechanism, three reliable transmission protocols, various MAC protocols, HDLC protocols and PPP protocols, especially the CSMA/CD protocol and Ethernet frame format. As well as the concepts of contention period and minimum frame length of LAN, and binary exponential backoff algorithm. In addition, the principles and differences of repeaters, network cards, hubs, bridges and LAN switches should also be mastered.

1. Functions of the data link layer

  • Provide services to the network layer
  • Link management
  • Frame delimitation, frame synchronization and transparent transmission
  • Flow control (control of sender)
  • error control

Note:

Provide services to the network layer

  1. Connectionless service without confirmation.
  2. Confirmed connectionless service.
  3. Confirmed connection-oriented services.​ 

Unacknowledged connectionless service means that the source machine sends independent frames to the target machine, and the target machine does not acknowledge these frames. No logical connection is established in advance and no logical connection is released afterwards. This type of service is very suitable whenthe error rate is very low, and the recovery task can be left to the layers above. This type of service is also very suitable for real-time communication because data lateness is less likely than data corruption in real-time communication Good. If a frame is lost due to noise on the line, the data link layer will not detect such frame loss and will not reply.

  • To prevent from frame loss during transmission, in a reliable data link layer protocol, the sender is responsible for each data sent The frame is designed with a timer. When the timer expires and the acknowledgment frame of the frame has not arrived, the sender willresend the frame.
  • To ensure that the receiver will not receive duplicate frames, each frame sent needs to be processedNumber;
  • Both Hamming codes and cyclic redundancy check codes are used for error control.
  • It is the function of the physical layer to conceal the details of physical transmission for terminal nodes. The data link layerdoes not need to considerhow to achieve undifferentiated bits. Transmission;

2. Framing

The purpose of framing is to resend only the erroneous frame when an error occurs, without having to resend all the data, thereby improving efficiency.

  • Character counting method (for example: first frame: 51239, second frame: 7123456...)
  • Head and tail delimiter method for character padding
  • The first and last marking method of zero bit padding (after encountering 5 "1"s, insert a "0")
  • Illegal coding method

 character counting

Illegal encoding method: When bit encoding is performed at the physical layer, the illegal encoding method is usually used. For example, the Manchester encoding method encodes the data bit "1" into a "high-low" level pair, the data bit "0" into a "low-high" level pair, and the "high-high" level pair and " The low-low" level pair is illegal (i.e. not used) in the data bits.

3. Error control

Actual communication links are not ideal. Bits may cause errors during transmission. 1 may become 0, and 0 may become 1. This is a bit error. Bit errors are one type of transmission errors. This section only discusses bit errors.

error detection coding 

  • Parity check code (after appending a check element, the number is an odd or even number)
  • Cyclic Redundancy Code (CRC)

CRC

Calculate the actual data sent:

1) Add 0 to the original data M0 (add r bits);

2) The original data after adding 0 is divided modulo 2 by the G(x) bit string;

3) Use the remainder of the result to replace the 0 added in 1); 

Check whether there are errors:

1) Divide the received binary sequence modulo 2 by the G(x) bit string;

2) If the remainder is 0, there is no error;

Forward example: Suppose G(x)=1101 (i.e. r=3), Data to be transmitted M=101001 (i.e. m=6)

101001000 

The data sent is: 101001001, with a total of m+r bits.

Reverse example: During the data transmission process, if the binary bit sequence received by the receiver is10110011010, the generator polynomial used by both receiving parties isG(x)=x^4+x^3+1, then the binary bit sequence is Was there an error in the transmission? If no error occurs, what are the bit sequences of the sent data and the bit sequence of the CRC check code?

 G(x)=1*x^4+1*x^3+0*x^2+0*x^1+1*x^0

error correction coding 

  •  Hamming code

Number of bits of effective information: n,

Number of check digits: k,

n+k≤2^k-1 (If you want to detect two-bit errors, you need to add 1 more check bit, that is, k+1 bits)

Hamming distance: The number of bits with different corresponding bit values ​​of two legal codes (codewords) is called the difference between the two codewordsCode distance (for example, the code distance between 001 and 000 is 1)

To detect D dislocation, the code distance D+1 is required

Error correction D bit requires code distance 2D+1

Generally speaking, data transmission errors are caused by noise. Noise in communication channels can be divided into two categories: thermal noise and impact noise. Thermal noise is generally inherent to the channel, and the errors caused are random errors, which can be reduced by increasing the signal-to-noise ratio. Its impact on data transmission. Impact noise is generally caused by external electromagnetic interference, and the errors caused are sudden errors. It is the main cause of transmission errors and cannot be avoided by improving the signal-to-noise ratio.

4. Flow control and reliable transmission mechanism

  • stop-wait flow control
  • Sliding window flow control
  • Reliable transmission mechanism 

Stop-wait flow control: Every time the sender sends a frame, it must wait for a response signal from the receiver before sending the next frame;

In the continuous ARQ protocol, the size of the sending window ≤ total number of windows -1.

Sliding window flow control:

  • Stop-wait protocol: send window size=1, receive window size=1.
  • Backoff N frames protocol (GBN): sending window size > 1, receiving window size = 1.
  • Select retransmission protocol (SR): sending window size > 1, receiving window size > 1.
  • When the size of the receiving window is 1, orderly reception of frames can be guaranteed.
  • Sending window + receiving window ≤ frame sequence number

Reliable transmission mechanism:

  • confirm
  • Retransmission

Example question of maximum channel utilization: The data transmission rate of a channel is 4kb/s, and the one-way propagation delay is 30ms. If you stop - wait for the maximum channel utilization of the protocol reaches 80%, then the required data frame length is at least ().
(L/C) / (L/C+ 2R)= L/(L+ 2RC)= L/(L + 2x30msx4kb/s)= 80%, resulting in L = 960bit.

GBD
  • GBN generally uses cumulative acknowledgment. If an acknowledgment is received for frame No. 5, it means that the receiver has received frames No. 1 to 5, so the sender only needs to retransmit the subsequent frames.
  • In the protocol of backing off N frames, the number of sequence numbers is not less than MAX_ SEQ+ 1. The size of the sending window in the question is 32, so the number of sequence numbers is at least 33
  • In the ARQ protocol with backoff N frames, the transmission window WT≤(2^n)-1.
SR
  • In the selective retransmission protocol, if n bits are used to number the frame, in order to prevent the new window
    from overlapping with the old window after the receiving end moves the window forward, The maximum size of the receive window should not exceed half of the sequence number range, that is, WR≤2^(n-1)
  • The data link layer uses the Selective Retransmission Protocol (SR) to transmit data. The sender has sent data frames No. 0~3 and has received the confirmation of frame No. 1. However, frames No. 0 and No. 2 have timed out in sequence. Then the number of frames that need to be retransmitted at this time is (2). Retransmit 0 and 2

5. Media access control 

Certain measures are taken so that the communication between the two pairs of nodes does not interfere with each other.

Channel partitioning media access control (statically assigned channels)

  • Frequency Division Multiplexing/FDM (similar to parallel)
  • Time Division Multiplexing/TDM (similar to concurrency)
  • Wavelength Division Multiplexing/WDM (Frequency Division Multiplexing of Light)
  • Code Division Multiplexing/CDM (mainly used in wireless communication systems, especially mobile communication systems.)

No code division multiplexing

 Compared with FDM, TDM has strong anti-interference ability and can be regenerated and shaped step by step to avoid the accumulation of interference. Moreover, digital signals are easier to realize automatic conversion, so according to the working principles of FDM and TDM, < a i=1>FDM is suitable for transmitting analog signals, and TDM is suitable for transmitting digital signals.

 Random access medium access control (dynamic allocation of channels)

All users can send random messages. All bandwidth is used when sending information.

  • ALOHA Agreement
  • CSMA protocol
  • CSMA/CD protocol
  • CSMA/CA protocol 
  • Polling access: token passing protocol (whoever has the token is the boss)
ALOHA Agreement
  • Pure ALOHA protocol
  • Slotted ALOHA protocol.
CSMA protocol
  • 1-Adhere to CSMA (after monitoring that the channel is busy, continue to monitor the channel; after monitoring that the channel is idle, the probability of sending a frame is 1, that is, send immediately Send data.)
  • Non-persistent CSMA (when a node wants to send data, it first listens to the channel; if the channel is idle, then the data is sent immediately; if the channel is busy, then it gives up monitoring and waits for a random and then repeat the above process.)
  • p-Adhere to CSMA(p,1-p,p,1-p)

CSMA/CD protocol
  • Suitable for bus network and half-duplex network
  • "Listen first and then transmit, listen and transmit at the same time, stop transmitting due to conflict, and re-transmit randomly."
  • Collision detection (Collision Detection) is Monitor while sending. If a collision is detected, data sending will be stopped immediately, wait for a random period of time, and then try to send data again.
  • The collision detection time (i.e.Dispute Period) defined in the CSMA/CD protocol means that the signal is between the two farthest endpoints. Round trip transfer time.
  • The minimum frame length is equal to the number of bits sent during the contention period. Therefore, when the transmission rate increases, the length of the cable medium can be reduced(so that the contention period time is reduced, that is, the end-to-end delay of Ethernet is reduced) , orincrease the minimum frame length.
  • Minimum frame length = bus propagation delay x data transfer rate x 2
  • The CSMA/CD protocol has been successfully applied to LANs using wired connections
 CSMA/CD Agreement  
  • Widely used in wireless LAN

Ethernet's binary backoff algorithm: Generally speaking, after the i-th (i<10) collision, the station will randomly select a number M between 0 and 2^i-1, and then wait for M times of contention Send data again later. After reaching 10 conflicts, the random number interval is fixed at the maximum value of 1023 and will not increase in the future. If there are more than 16 consecutive conflicts, then discard.

CSMA/CD and CSMA/CA major divisions:
  • CSMA/CD can detect conflicts, but cannot avoid them; CSMA/CA cannot detect whether there are conflicts on the channel while sending data. The absence of conflicts at this node does not mean that there will be no conflicts at the receiving node, and it can only be avoided as much as possible.
  • The transmission media are different. CSMA/CD is used for bus line Ethernet, and CSMA/CA is used for wireless LAN 802.11a/b/g/n, etc.
  • The detection methods are different. CSMA/CD detects through voltage changes in the cable; while CSMA/CA uses energy detection, carrier detection and energy-carrier hybrid detection to detect channel idleness.
  • Summary: The basic idea of ​​the CSMA/CA protocol is to first broadcast to inform other nodes when sending data, so that other nodes should not send data within a certain period of time to avoid collisions. The basic idea of ​​the CSMA/CD protocol is to monitor before sending, monitor while sending, and stop sending immediately once a collision occurs.

6. LAN

basic concepts

The main features of LAN are as follows:

  • Owned by a unit and limited in geographical scope and number of sites.
  • All sites share a higher total bandwidth (i.e. a higher data transfer rate).
  • Lower latency and lower bit error rate.
  • Each station has an equal relationship rather than a master-slave relationship.
  • Can perform broadcast and multicast.

Common topologies of LAN:

  • ①Star structure;
  • ②Ring structure;
  • ③Bus-shaped structure;
  • ④ Composite structure that combines star and bus shapes.

Three special LAN topologies are implemented as follows:

  • Ethernet (currently the most widely used local area network). The logical topology is a bus-shaped structure, and the physical topology is a star or extended star structure.
  • Token Ring (Token Ring, IEEE 802.5). The logical topology is a ring structure, and the physical topology is a star structure.
  • FDDI (Fiber Distribution Digital Interface, IEEE 802.8). The logical topology is a ring structure, and the physical topology is a double-ring structure.

Ethernet and IEEE 802.3

The IEEE802.3 standard is abaseband bus type local area network standard that describes the MAC sublayer of the physical layer and data link layer implementation method.

Ethernet adopts two measures to simplify communication: ①Adoptconnectionless working mode, which does not number the data frames sent and does not The receiver is required to send a confirmation, that is, the Ethernet does its best to deliver the data and provides unreliable services. The correction of errors is completed by the higher layer; ②The data sent uses Manchester encodingManchester encoding For the signal a>, a voltage conversion occurs in the middle of each symbol. The receiving end uses this voltage conversion to easily extract the bit synchronization signal.

1. Ethernet transmission media and network card

There are four commonly used transmission media in Ethernet: thick cable, thin cable, twisted pair and optical fiber.

2. Ethernet MAC frame 
  • The MAC protocol of Ethernet providesconnectionless and unreliable service
  • Every network card in the world has a unique code called a Media Access Control (MAC) address when it leaves the factory. This address is used to control the host's data communication on the network.
  • 12 hexadecimal numbers, such as 02-60-8c-e4-b1-21, the high 24 bits are the manufacturer code, and the low 24 bits are assigned by the manufacturer.
  • Address: Usually a 6-byte (48bit) address (MAC address) is used.
  • Type: 2 bytes, indicating which protocol entity the data carried in the data field should be handed over for processing.
  • Data: 46~1500 bytes, including high-level protocol messages. Due to the limitations of the CSMA/CD algorithm, the Ethernet frame must be full 
  • Padding: 0~46 bytes, when the frame length is too short, pad the frame to make it reach the minimum length of 64 bytes.
  • Check code (FCS): 4 bytes. The check range is from the destination address segment to the end of the data segment. The algorithm uses a 32-bit cyclic redundancy code (CRC). It not only needs to check the data part of the MAC frame, but also the destination address. , source address and type fields, but the preamble is not verified.

 3. High-speed Ethernet

Fast Ethernet still uses the CSMA/CD protocol, which uses the method of (keeping the shortest frame length unchanged) and reducing the maximum cable length to 100m to increase the data transmission rate of Ethernet to 100Mb/s.

Ethernet with a rate reaching or exceeding 100Mb/s is called high-speed Ethernet.

  • (1) 100BASE-T Ethernet (Ethernet is transmitted over twisted pair cables100Mb/s star topology of baseband signals Fabric Ethernet)
  • (2) Gigabit Ethernet
  • (2) 10 Gigabit Ethernet (fiber optic)
Whether to work in full duplex Whether to work in half-duplex speed Whether to use CSMA/CD
100BASE-T Ethernet 100Mb/s Used in half-duplex mode (not required in full-duplex mode)
Gigabit Ethernet 1Gb/s Used in half-duplex mode (not required in full-duplex mode)
10 Gigabit Ethernet  × 10Gb/s Need not

There are two standards for the physical layer of Gigabit Ethernet: IEEE 802.3z and IEEE 802.3ab. The former uses Fiber Channel and the latter uses 4 pairs of UTP Category 5 lines.​ 

IEEE802.11 Wireless LAN

1. Composition of wireless LAN

Fixed infrastructure wireless LAN

  • CSMA/CA protocol
  • Wi-Fi
  • The diameter of the basic service area of ​​wireless LAN generally does not exceed 100m.
  • 802.11 uses a star topology, with the center called the Access Point (AP).

Mobile self-organizing network without fixed infrastructure

  •  ad hoc network
  • No AP
  • The status of each node is equal, and the intermediate nodes are all forwarding nodes, so they all have the function of routers.
  • The network topology composed of mobile stations may change rapidly over time. Therefore, some routing protocols that are effective in fixed networks are no longer applicable to mobile ad hoc networks and require special attention.
2.802.11 MAC frame of LAN
  • 1) MAC header, 30 bytes in total. The complexity of the frame is all in the MAC header.
  • 2) The frame body, that is, the data part of the frame, does not exceed 2312 bytes. It is much longer than the maximum length of Ethernet.
  • 3) The frame check sequence FCS is the tail, a total of 4 bytes.

 VLAN-virtual local area network

 There are generally three methods of dividing VLANs

  • ① Based on ports, divide several ports of the switch into a logical group. This method is the simplest and most effective. If the host leaves If you change the original port, you may enter a new subnet.
  • ②Based onMAC address, some hosts are divided into a logical subnet by MAC address. When the physical location of the host is moved from a switch When going to another switch, it still belongs to the original subnet.
  • Based on IP address, based onnetwork layer address Or a protocol divides VLANs so that VLANs can be extended across routers to connect hosts on multiple LANs together.

 VLAN is based on switching technology and implements logical grouping and management through software. Computers in VLAN are not restricted by physical location . When a computer is moved from one VLAN to another, it is simply configured through software without having to change its physical location on the network. Computers in the same VLAN are not necessarily connected to the same physical network segment. They can be connected to the same switch or to different LAN switches. on, as long as these switches are interconnected.

Wan

  • WAN is not the same as the Internet. The Internet can connect to different types of networks (both local area networks and wide area networks), usually using routers< /span>) instead of using a router to connect to the network. Node switches forward packets in a single network, while routers forward packets in an Internet composed of multiple networks. router node switches to connect each host (or is a single network, usually using WAN to connect.
  • The communication subnet of the WAN mainly uses packet switching technology to interconnect LANs or computer systems distributed in different regions
    to achieve the purpose of resource sharing.
  • The transmission method used by WAN is (store and forward).
  • The TCP/IP protocol family mainly includes TCP, IP, ICMP, IGMP, ARP, RARP, UDP, DNS, FTP, HTTP, etc.
     

PPP Agreement 

The PPP agreement has three components:

1) Link Control Protocol (LCP). An extended link control protocol used to establish, configure, test, and manage data links.
2) Network Control Protocol (NCP). The PPP protocol allows the use of multiple network layer protocols at the same time. Each different network layer protocol
must be configured with a corresponding NCP to establish and configure logical connections for the network layer protocols.
3) A method of encapsulating IP datagrams onto a serial link. The IP datagram is its information part in the PPP frame. The length of this information part is limited by the maximum transmission unit (MTU).

PPP is a byte-oriented protocol. All frame lengths are integer bytes, and a special character filling method is used to complete data filling.

Characteristics of PPP agreement: 

1) PPP provides error detection but not error correction, and only guarantees error-free reception (CRC check through hardware). It is an unreliable transport protocol and therefore does not use sequence numbers and acknowledgment mechanisms.
2) It only supports point-to-point link communication and does not support multipoint lines.
3) PPP only supports full-duplex links.
4) Both ends of PPP can run different network layer protocols, but can still use the same PPP for communication.
5) PPP is byte-oriented. When the information field appears with a bit combination consistent with the flag field, PPP has two different processing methods: If PPP is used on asynchronous lines (default), The character filling method is used; if PPP is used on synchronous lines such as SONET/SDH, the protocol stipulates that hardware is used to complete bit filling (the same as HDLC).

Data link layer equipment

Switch (that is, a multi-port bridge)

  • In terms of propagation delay: Router > Switch > Hub
  • The main functions implemented by LAN switches are at the physical layer and data link layer. 
  • The switch can isolate conflict domains and work in a full-duplex state, allowing multiple pairs of nodes in the network to communicate at the same time (supporting simultaneous communication by multiple users), which improves network utilization. This is the advantage of the switch.
  • For a switch, for a 10Mb/s half-duplex port, the port bandwidth is 10Mb/s; if the port rate remains unchanged, the full-duplex port bandwidth is 20Mb/s.
  • When using an Ethernet switch (working in full duplex by default) to connect these hosts, although the bandwidth from each port to the host is still 10Mb/s, because one user is exclusive during communication rather than sharing the transmission medium with other network users bandwidth, so the total capacity of a switch with N ports is Nx10Mb/s.
  • If it is a half-duplex switch, the total capacity of a half-duplex switch with N pairs of 10Mb/s ports is Nx 10Mb/s, where N =24/2=12, and the total capacity is 120Mb/s 

Guess you like

Origin blog.csdn.net/weixin_53197693/article/details/133990742