Computer Network-Link Layer

Data link layer services

the term

  • Hosts and routers: nodes
  • Communication channels connecting adjacent nodes: links
    • Wired links
    • Wireless links
    • Local Area Networks (LANs)
  • Link layer (layer 2) data packets: frames, encapsulating network layer datagrams

The data link layer is responsible for transmitting datagrams from one node to the adjacent nodes directly connected to another physical link through one link.

Link layer service

  • Framing
    • Encapsulated datagrams form data frames, plus header and trailer
    • Frame synchronization
  • Link access
    • If it is a shared medium, channel access needs to be resolved
    • "MAC" address in the frame header, used to identify the source and destination of the frame
    • Different from IP address!
  • Reliable delivery between adjacent nodes
    • It is rarely used on wired links with low bit error rate (such as optical fiber, some twisted pairs, etc.)
    • Wireless link: high bit error rate, which requires reliable delivery
  • Flow control
    • Pacing adjacent sending nodes and receiving
  • Error detection
    • Signal attenuation and noise can cause errors.
    • The receiving end detected an error:
      • Notify the sender to retransmit or drop the frame directly
  • Error correction
    • The receiver directly corrects bit errors
  • Full-duplex and half-duplex communication control
    • Full-duplex: the nodes at both ends of the link are transmitted in both directions simultaneously
    • Half-duplex: alternate bidirectional transmission of nodes at both ends of the link

The specific implementation of the link layer

  • Each host or router interface
  • The link layer is implemented in an "adapter" (ie, network interface card-NIC) or on a chip
    • Ethernet network card, 802.11 network card; Ethernet chipset
    • Implement link layer and physical layer
  • System bus connected to the host
  • Composed of hardware, software and firmware

Communication between network cards

Error coding


Parity code

Internet Checksum

Cyclic Redundancy Check Code (CRC)

  • Error coding with more powerful error detection capabilities
  • Treat data bits, D, as a binary number
  • Select a bit pattern with r + 1 bits (generate bit pattern), G
  • Goal: Choose r CRC bits, R, satisfy
    • <D, R> happens to be divisible by G (modulo 2)
    • Error detection at the receiving end: use G to divide <D, R>, the remainder is all 0, no error; otherwise, there is an error!
    • It can detect all errors with burst length less than r + 1 bits.
  • Widely used in actual networks (Ethernet, 802.11 WiFi, ATM)

Multiple access control (MAC)

  • Single shared broadcast channel
  • Simultaneous transmission of two or more nodes: interference
    • Conflict
      • The node receives two or more signals at the same time → failed to receive!
  • Multiple access control protocol
  • A distributed algorithm is used to determine how the nodes share the channel, that is, when the nodes can transmit data
  • Communication channels must share coordination information based on the channel itself!
    • No out-of-band channel for coordination

Ideal MAC protocol

MAC protocol classification

  • Three categories:
  • Channel partitioning (channel partitioning) MAC protocol
    • Multiplexing
    • TDMA、FDMA、CDMA、WDMA等
  • Random access (random access) MAC protocol
    • Channels are not divided, conflicts are allowed
    • Use conflict "recovery" mechanism
  • "Taking turns" MAC protocol
    • Nodes use channels in turn

Channel division MAC protocol: TDMA

  • TDMA: time division multiple access
  • "Periodic" access channel
  • Each station occupies a fixed-length time slot in each cycle (eg length = packet transmission time)
  • Unused time slot idle (idle)
  • For example: 6-site LAN, 1, 3, 4 transmission packets, 2, 5, 6 idle

Channel division MAC protocol: FDMA

  • FDMA: frequency division multiple access
  • The channel spectrum is divided into frequency bands
  • Each station is assigned a fixed frequency band
  • No transmission band idle
  • For example: 6 sites LAN, 1, 3, 4 frequency bands transmit data, 2, 5, 6 frequency bands are idle.

Random access MAC protocol

  • When the node wants to send a packet:
    • Use the full channel data rate R to send packets
    • No prior coordination between nodes
  • Two or more nodes transmit simultaneously: ➜ "Collision"
  • The random access MAC protocol needs to be defined:
    • How to detect conflicts
    • How to recover from conflict (eg, by delayed retransmission)
  • Typical random access MAC protocol:
    • Slotted ALOHA
    • ALOHA
    • CSMA, CSMA / CD, CSMA / CA

Slotted ALOHA protocol





CSMA protocol

  • Carrier sense multiple access protocol CSMA (carrier sense multiple access)
  • Before sending a frame, monitor the channel (carrier):
    • Channel idle: send a complete frame
    • Channel busy: postpone transmission
    • 1- Stick to CSMA
    • Non-adherent CSMA
    • P-stick CSMA
  • Conflict may still occur: signal propagation delay

CSMA / CD protocol



CSMA / CD efficiency

Rotate access to MAC protocol

  • Channel division MAC protocol:
    • When the network load is heavy, the shared channel is efficient and fair
    • When the network load is light, the shared channel efficiency is low!
  • Random access MAC protocol:
    • When the network load is light, the shared channel efficiency is high, and a single node can use the full bandwidth of the channel
    • When the network load is heavy, conflict overhead occurs
  • Rotating access to the MAC protocol: combining the advantages of both!

Polling:

  • The master node takes turns to "invite" the slave nodes to send data
  • Typical application: "dumb" slave device

Token passing:

  • Control tokens are passed from one node to the next in sequence.
  • Token: special frame

MAC protocol summary

  • Channel division MAC protocol: time, frequency band, chip division
    • TDMA 、 FDMA 、 CDMA
  • Random access MAC protocol:
    • ALOHA, S-ALOHA, CSMA, CSMA / CD
    • CSMA / CD applied to Ethernet
    • CSMA / CA application 802.11 wireless LAN
  • Rotate access to MAC protocol:
    • Main node polling; token passing
    • Bluetooth, FDDI, token ring network

Guess you like

Origin www.cnblogs.com/ygjzs/p/12740008.html