Computer Network (Basic)-Data Link Layer

data link layer

Features

  • Encapsulated and framed
  • Transparent transmission
  • Error detection

Encapsulated and framed

  • Frame is the basic unit of data link layer data
  • The sender adds a specific mark before and after a piece of data at the network layer to form a "frame"
  • The receiving end recognizes the "frame" based on specific marks before and after
    Encapsulated and framed
  • The frame header and tail are specific control characters (specific bit stream)
    SOH: 00000001 (header)
    EOT: 00000100 (tail)

Question: What if these bit streams happen to be in the data?

  • Transparent transmission to solve

Transparent transmission

  • "Transparency" is a very important term in the computer field
  • Transparent transmission "that is, the control character is in the frame data, but it must be treated as if it does not exist"

Assuming that there is a tail control character in the frame data, the wrong frame will be parsed at the receiving end.
Insert picture description here
Transparent transmission solves this problem by adding escape characters to the control characters in the datagram.
Insert picture description here

Error detection

  • The physical layer just transmits the bit stream and cannot control whether there is an error
  • The data link layer is responsible for "error monitoring"

method

  • Parity check code
  • Cyclic Redundancy Check Code CRC

Parity check code

  • Assuming that the transmission data is 00110010, the data obtained by calculation is odd, and a bit of 1 is added after the data. If the transmission data is 00111010, the data obtained by calculation is an even number, and a bit of 0 is added after the data, and the data is received. After the calculation result is the same as the added bit, check whether the data is wrong
    Insert picture description here
  • However, this method has certain limitations. Assuming the transmission data is 00110010, the bit bit is increased by 1, the data transmission error, the third bit becomes 0, and the error is found after calculation. Assuming that both 3 and 4 bits are transmitted incorrectly, there is no comparison after calculation. found mistake
    Insert picture description here

Cyclic Redundancy Check Code CRC

  • A method for generating fixed-digit check codes based on transmitted or saved data
  • Detect errors that may occur after data transmission or saving
  • The generated numbers are calculated and appended to the data
  • The error detection ability of CRC is related to the order of the bit string

Division modulo "2"

  • Division modulo "2" is division in binary
  • Similar to arithmetic division, but division does not borrow bits, it is actually an "exclusive OR" operation
  • example
    • Binary XOR operation
      Insert picture description here
    • Division modulo "2"
      Insert picture description here

process

  • Select a polynomial G(x) for verification, and add r zeros at the end of the data

  • The data after adding r zeros is divided by the bit string of the polynomial using the modulo "2" division

  • The obtained remainder is filled in the position of r 0s in the original data to obtain a verifiable bit string

  • Example
    1. Example 1: Use CRC to calculate the checkable bit string of 101001

    • The first step (select a polynomial G(x) for verification, and add r zeros to the end of the data):
      select the polynomial G(x) as shown in the figure, the polynomial binary bit string is 1101, and the highest order is 3

Insert picture description here

  • Add 3 zeros at the end of the data
    Insert picture description here

  • The second step (the data after adding r zeros is divided by the bit string of the polynomial by the modulo "2" division):

    • The polynomial binary bit string 1101 is divided by modulo "2" on the data with zero added, the remainder should be 001, and the calculation on the picture is wrong
      Insert picture description here
  • The third step (the generated number is calculated and appended to the data):
    Insert picture description here
    the data received by the receiving end is divided by the bit string of G(x), and the error is judged according to the remainder
    Insert picture description here

MTU (Maximum Transmission Unit)

  • The data frame of the data link layer is not infinite
  • Data frames that are too large or too small will affect the efficiency of transmission
  • Ethernet MTU is generally 1500 bytes

Path MTU

  • Path MTU is determined by the minimum value of MTU in the link
    Insert picture description here

Ethernet protocol

  • Ethernet is a widely used local area network technology
  • Ethernet is a protocol applied to the data link layer
  • Use Ethernet to complete the data frame transmission of adjacent devices

MAC address

  • MAC address (physical address, hardware address)
  • Each device has a unique MAC address
  • The MAC address has a total of 48 bits, expressed in hexadecimal (30-B4-9E-ED-85-CA)

Ethernet protocol

Data Format

  • The picture shows the Ethernet protocol, the number represents the number of bytes occupied by each attribute
    Insert picture description here
  • If it is network layer IP data
    Insert picture description here
  • ARP request response
    Insert picture description here
  • RARP request response data

Insert picture description here

MAC address table

  • The address table is a mapping table between MAC address and hardware interface
    Insert picture description here
  • Example
    Assume that A data needs to be passed to C, the connection method is as shown in the figure, and the MAC address table is as shown
    Insert picture description here
    Insert picture description here
  • A sends data frames through the network card
  • When the data frame arrives at the router, the router takes out the first 6 bytes
  • The router matches the MAC address table and finds the corresponding network interface
    • Assume that there is no hardware interface information of C in the MAC address table
    • E checks the MAC address table and finds that there is no information about C
    • E will receive responses from B and C and record the address
  • The router sends data frames to the network interface

problem

  • The data link layer is only responsible for the transmission of adjacent physical nodes. Assuming the network topology shown in the figure, how does A
    transmit data to C across devices ?
    • Problems solved by the network layer
      Insert picture description here

Guess you like

Origin blog.csdn.net/DALAOS/article/details/114242377