This is the sixth day of my participation in Gwen Challenge

Zero. Significance of data link layer

The line of the physical layer consists of transmission medium and communication equipment, and there will certainly be errors when the bit stream is transmitted on the transmission medium. In this way, the data link layer is introduced on top of the physical layer to provide high-quality data transmission services to the network layer through error detection, error control and flow control.

For the network layer, the existence of the link layer does not need to care about the specific transmission medium and communication equipment used by the physical layer.

I. Functions of the data link layer

  • Link control. Responsible for establishing, maintaining and releasing data links. Primarily used for connection-oriented services.
  • Frame synchronization. The receiver determines the start and end positions of a frame in the received bit stream.
  • Error control. Causes the receiver to determine that the data received is the data sent by the sender
  • Transparent transmission. Any combination of data should be able to be transmitted over the link.
  • Flow control. In the OSI system, there is certainly flow control at the data link layer (the study is still in the data link layer). In the TCP/IP architecture, traffic control at the data link layer is moved to the transport layer and there is no need to set up traffic control at the data link layer.

Second, the group of frames

Meaning: If only bitstreams are transmitted, all bitstreams must be retransmitted in case the transmitted bit flows out incorrectly. And if the frame is wrong, only the wrong frame can be sent.

Added frame synchronization, frame demarcation, transparent transmission problems.

Four ways to group frames

  • Character counting method
  • Byte padding header and tail delimiter method
  • Beginning and end identification method for bit filling (0 bit filling method)
    • Start and end frames with 0111 1110
    • So whenever there are five consecutive ones, insert a zero after them.
  • Physical coding violation law

Third, error control

Error detection code: parity check code, cyclic redundancy code CRC

Error correction code: Hamming code

Flow control and reliable transmission mechanism

Flow control and reliable transport mechanisms are functions of the transport layer.

Traffic control is to control the rate at which the sender sends data so that the receiver can receive it in time. One basic approach is for the receiver to control the sender’s data flow.

There are two common ways of flow control:

  • Stop – Wait for flow control
  • Sliding window flow control

The data link layer only uses cyclic redundancy code check error detection technology and can only receive frames error-free. The data link layer is not required to provide “reliable transport” services to the network layer. Reliable transmission means that the receiver receives what the sender sends at the data link layer.

Transmission errors fall into two categories:

  • Bit errors (can be detected by CRC)
  • Transmission error: frame loss; Frame repetition; The frame disorder

Q: The IP used by the Internet is connectionless, so its transmission is unreliable. It is easy to feel that the Internet is unreliable. Why not design Internet transmission to be reliable?

  1. The Internet that transmits data has some drawbacks, such as causing bit errors or packet loss.
  2. Even if the network can achieve 100% error-free transmission, end-to-end data transmission can still go wrong.

In other words, the cost of making a communications network very reliable is not worth the cost of carrying computer data. Now that the terminal equipment has intelligence, we should put the network design simple point, so that intelligent terminals to complete the task of making transmission more reliable.

Computer networks employ a strategy that uses connection-oriented TCP at the transport layer to ensure reliable end-to-end transmission. As long as the TCP of host B finds an error in data transmission, it tells host A to retransmit the faulty part of data until THE part of data is correctly transmitted to host B.

If the data transmission provided by the Internet is unreliable, then the Internet here refers to the network excluding hosts (only the physical layer, the data link layer, and the network layer).

If the data transmission provided by the Internet is reliable, it indicates that the Internet has expanded to include the host transport layer.

Sliding window mechanism

The send window can only slide forward if the receive window slides forward (at the same time an acknowledgement is sent).

Reliable transmission mechanisms include stop-wait protocol, back N frame protocol and selective retransmission protocol. From the sliding window level, the three protocols differ only in the size of the sending window and the receiving window.

  • Stop-wait protocol: send window =1, receive window =1.
  • Back N frame protocol: send window >1, receive window =1.
  • Select retransmission protocol: Send window >1, receive window >1.

When the size of the receive window is 1, frames must be received in sequence.

Stop-wait protocol:

Reliable transmission means that the receiver receives what the sender sends. This is done by both acknowledgement (sending acknowledgement frames) and timeout retransmission. A strategy for reliable transport using these two mechanisms is also known as automatic request retransmission (ARQ).

Confirmation is divided into:

  • Piggyback confirmation: Piggyback the confirmation frame to a reply frame.

  • Cumulative confirmation

Protocol = technology + consider the downside. So stop-wait protocol = stop-wait flow control technology + disadvantage.

Back N frames (GBN) protocol

If n bits are used to number frames, the size W of the sending window must be 1<W<=2^n^-1, and the size W of the receiving window must be 1. If the send window is larger than 2^n^-1, the receiver cannot distinguish between old and new data frames.

If a frame is wrong, the receiver simply discards that frame and all subsequent frames.

Supports cumulative validation.

Select the retransmission (SR) protocol

If n bits are used to number frames, the maximum size of the sending window should not exceed half of the serial number range to avoid overlapping between the new receiving window and the old receiving window after the receiver moves the window forward: W<=2^n-1^

The retransmission protocol does not support cumulative confirmation.

Five, media control access

Background: In LAN, if there is competition when sharing channel, how can we better allocate channel right? Media control access is to solve this problem.

Media control access is divided into the following three categories:

  • Channel division media access control. Statically allocated channel
  • Random access media access control. Dynamically allocated channel
  • Polling access media access control. Dynamically allocated channel

Channel division

  • Frequency division multiplexing
  • Time division multiplexing
  • Wavelength division multiplexing
  • Code division multiplexing CDMA

Random access

ALOHA agreement

Pure ALOHA

In the”

CSMA protocol

CS carrier sense MA multiple access

  • 1- Adhere to CSMA: listen for idle, send data immediately
  • P – Adhere to CSMA: listen for idle, send data with probability P
  • Do not adhere to CSMA: when listening is idle, send data immediately. Otherwise, delay a random event and listen again

CSMA/CD protocol

Carrier sense multiple access protocol with collision detection.

For Bus-based Ethernet (wired)

Listen first and then send, listen while sending, conflict stop sending, random resend.

Contention period/collision window/collision window: Ethernet end-to-end round-trip delay 2τ. If no conflict is detected after this contention period, you can be sure that this send will not have a conflict.


The frame length b i t Data transfer rate b i t / s > = 2 Propagation delay ( namely 2 tau ) . Propagation delay = distance Signal velocity \frac{frame length bit}{data transmission rate bit/s} >= 2* propagation delay (i.e. 2τ). Propagation delay =\frac{distance}{signal propagation speed}

Therefore, Ethernet specifies a minimum frame length of 64B

There are two Ethernet working modes:

First, the full-duplex working mode. The network card cannot receive two requests for sending data at the same time, so there is no conflict and CSMA/CD collision detection is not used.

The second is the half duplex mode. Because sending and receiving use the same channel, you must use the CSMA/CD collision detection mechanism.

Retransmission timing: Truncate binary index type retreat algorithm:

The maximum number of retransmission times k is 10.

Discard the device 16 times.

CSMA/CA protocol

Mainly used in wireless LAN.

Conflict avoidance is added to CSMA.

The CSMA/CA protocol confirms the correctly received data frame.

Polling access

Mainly used in token ring Lans.

Token passing protocol.

There will be no conflict.

6. LAN

Ethernet

Generally called 802.3LAN for Ethernet, Ethernet now almost become synonymous with LAN.

MAC frames for Ethernet

Wireless LAN

The IEEE 802.11

Token ring network

The IEEE 802.5

Seven, wide area network

Point to point communication

OSI layer: three physical layers, data link layer, and network layer.

The protocols used are mainly at the network layer.

Routing and packet forwarding.

The Internet is the largest wide area network.

The PPP protocol

Peer-to-peer protocol.

PPP is a byte-oriented protocol.

Features not required for PPP: error correction, flow control, serial number, multi-point line, half duplex or simplex.

In HDLC protocol

Advanced Data Link Control (HDLC) protocol is a bit-oriented data link control protocol developed by ISO.

It applies to two basic configurations of links:

  • Unbalanced configuration
  • Equilibrium configuration

HDLC frame is divided into three types: information frame (I frame), supervision frame (S frame), unnumbered frame (U frame). No spies

Zero-bit filling method is adopted, that is, 5 consecutive ones are followed by 0.

PPP and HDLC frame format difference

  • PPP is byte oriented. HDLC is bit-oriented.
  • PPP frames have one more 2-byte protocol field than HDLC frames.
  • PPP does not use serial number and confirmation mechanism, but only ensures error-free acceptance (cyclic redundancy code check is performed by hardware), and end-to-end error detection is performed by high-level protocols. The HDLC protocol uses numbering and acknowledgement mechanisms for information frames.

Data link layer equipment

The bridge

A bridge has at least two ports, each connected to a network segment.

It can interconnect different physical layers, different MAC sub-layers, and Ethernet at different rates.

Classification of network Bridges:

  • Transparent bridge. The route is not optimal. The spanning tree algorithm is adopted.
  • Source diameter selection network bridge. I chose the best path.

LAN switch

LAN switches are essentially multi-port Bridges that work at the data link layer. Each port on a LAN switch is directly connected to a host or hub and typically operates in full-duplex mode.

The Ethernet switch monopolizes the bandwidth of the transmission media.

Total switch capacity calculation method: None The default value is half duplex.

  • Half-duplex: Number of ports x bandwidth of each port
  • Full-duplex: Number of ports x bandwidth of each port x 2

The biggest advantage of a switch is that not only does the bandwidth occupied by each port node not decrease with the increase of port nodes, but the total bandwidth of the switch increases with the increase of port nodes.

There are two switching modes of switches:

  • Straight-through interchange
  • Store-and-forward switching

Broadcast domain, conflict and summary of each layer device

Generally speaking, a network segment is a collision domain, and a LAN is a broadcast domain.

Physical layer device:

  • Repeater. Both amplifiers and Repeaters amplify, except that the amplifier amplifies the analog signal and the repeater amplifies the digital signal.

  • Hub: multi-port repeater.

  • Conflict domains cannot be isolated, nor can broadcast domains be isolated.

Data link layer device:

  • The bridge.
  • Switch: multi-port bridge. Each port on the switch is a conflicting and, that is, the switch can isolate conflicting and.

Network layer device:

  • Router: Sends data from one network to another. Conflict domains can be isolated. Each port of the router is a broadcast domain that can be isolated.

Hubs and switches work at the physical layer and the data link layer, respectively, and cannot connect to two different networks. Therefore, both hubs and switches need to send broadcast data to each port (because each port is still connected to the same network).

Routers can connect to different networks, and routers do not forward broadcast packets by default (because each port is connected to a different network). Each port of a router is a broadcast domain.