Skip to content
Author: Tianle Yuan

Data Link Layer⚓︎

picture 1

Definition⚓︎

Demand?

The bitstream can cause errors (see physical layer's cons) when it is transmitted on a medium. We need a new layer that provides high-quality (error free) data transfer services to topper layers (such as network layer).

graph LR
    A[Network Layer] -- packets --- B[Data Link Layer]
    B -- "frames (bit-by-bit)" --- C[Physical Layer]
For?

Data Link Layer has below functions:

  1. Framing.
  2. Addressing.
  3. Transparent Transmission.
  4. Error Detection
  5. Error Correction
  6. Flow Control

Abstracting⚓︎

From physical layer to data link layer

We know that in the physical layer, information is communicated with bit stream through cable or WIFI.

To abstract the data link Layer, we classify the "communication channel" in this layer into two types:

  1. Point-to-point communication channel (use P2P protocol).
  2. Broadcast communication channel (use CSMA/CA protocol).

picture 9

Notice!

To understand the data link layer better, we think about the case of broadcasting first.

LAN (local area network) is a computer network that has the broadcasting function.

Furthermore, from all the LAN products, we peak Ethernet, which fllow the standard of DIX Ethernet V2 or IEEE 802.3.

Anatomy⚓︎

Dissect the data link layer

In order to make the data link layer more suitable for various LAN standards, the 802 committee divided the data link layer into two sub-layers:

picture 1

Let's go to check them one by one! 🛸🛸 Drink some coffee first! picture 11

1. MAC Sublayer⚓︎

Mac address⚓︎

MAC Address?

MAC Address is also called as the physical Address of a network device. MAC Address is used by the MAC sublayer. MAC Address is worldwide unique (since millions of network devices exist, we need to uniquely identify each).

picture 3

Functions of MAC Sublayer⚓︎

1.1 Framing⚓︎

Framing?

Transfer network data (a stream of bits) into frames, which is discernible blocks of information.

Frame?

Transferred protocol data units (PDUs) in the data link layer.

Types of Framing

picture 2

There are two types of Framing:

  • Fixed-size Framing:

    The frame is of fixed size. No need to add delimiters.

    Con

    When the data size is smaller than the fixed frame size, the frame itself will suffer internal fragmentation. We need to pad it.

  • Variable-size Framing:

    The frame needs to indicate the begin and end to be distinguished.

    Ways to implement
    1. Length field : define the length in the frame.

      • e.g. Ethernet (802.3)Ethernet frame.
      • Cons: Length field may get corrupted sometimes.
    2. ED (End Delimeter) : add end delimiter (like Period in English).

Schematic Diagram of Ethernet frame

Here below is the Ethernet frame format:

picture 4

  1. The Preamble area is used by the receiving interface’s circuitry to determine when a frame arrives and the amount of time between encoded bits (called clock recovery).

  2. The SFD and Preamble area indicates when the frame start.

  3. The Basic Frame (/Frame) field starts from the Destination (DST) and Source (SRC) address fields.

  4. Both DST (destination) and SRC (source) areas are all MAC addresses or known by other names such as:

    • Link-layer address
    • 802 address
    • Hardware address
    • Physical address
  5. The Type/Lenth area identifies the type of data that follows the header. It is for layer three using layer two frames. It indicates which layer three's protocol is used. Popular values used with TCP/IP networks include:

    • IPv4 (0x0800)
    • IPv6 (0x86DD)
    • ARP (0x0806).
  6. The DST, SRC, and Type/Lenth are composed as the MAC header.

  7. In the MAC Client Data field, we ignore the optional parts and only focus on the Payload area, which is the data the frame carries from source to destination. The Payload data is encapsulated by the layer three.

  8. The FCS (frame check sequence) is used to identify any errors in the frame.

1.2 Addressing⚓︎

As we know, MAC address is unique for each device. Thus, we can encapsulate the unique MAC address -- the source (SRC) and destination (DST) address in the header of each frame to ensure node-to-node delivery.

1.3 Transparent transmission⚓︎

What is the transparent transmission?

It describes a phenomenon of data transmission without error. It's as if the transmission itself doesn't exist.

Why?
  • If the data transmitted is printable characters (95 in total) in ASCII code, everything is okay.
  • However, if the data transmitted contains unprintable characters, errors will show up.
How?

Remember Variable-size Framing? Besides using the length field to implement frame, we can also refer the ED (End Delimeter) method! Here we use Byte Stuffing(or Character Stuffing) 🐤.

Implement Byte Stuffing

picture 7

As the diagram shows above, we give the following explanations:

  1. Flag can be SOH or EOT.
  2. SOH is the head part of the frame. We can use the Preamble+SFD areas as an example.
  3. EOT is the tail part of the frame. We can use the Carrier Extension areas as an example.
  4. When the MAC Client Data field exists unprintable characters such as Flag (SOH or EOT) OR ESC, we can add an extra escape character -- ESC to diminish ambiguation.

1.4 Control physical medium access⚓︎

No more explanations here; just know it as literal meaning.

2. LLC Sublayer⚓︎

Functions of LLC Sublayer⚓︎

LLC sublayer is responsible for:

  1. Error Detection
  2. Error Correction
  3. Flow Control

2.1 Error Detection⚓︎

What Error?

When data is transmitted, ,0 can possibly be changed into 1, which we call it as bit errors. It can be caused by: - Noise - Interference - Distortion - Bit synchronization errors

BER (Bit Error Rate)

BER (Bit Error Rate): The percentage of incorrect transmitted bits to the total number of transmitted bits.

\(BER = \frac{Error\;Bits}{Transmitted\;Bits}\)

How to detect?

CRC (Cyclic redundancy check) is the method we use for error detection.

Below diagram shows the idea of CRC:

picture 10

A good link for checking the methods for Error Detection: Error Detection in Computer Networks

Unreliable Transmission Protocols

Generally, on the transmission link with poor communication quality (errors exists), we will add the acknowledgement and retransmission mechanisms to make sure the correctness of frame data.

Without the two mechanisms we call the protocol an unreliable transmission protocol, such as:

  • PPP (for Point-to-point communication)
  • CSMA/CD (for Broadcast communication)
  • UDP (for the third layer, we will mention it later)

2.2 Error Correction⚓︎

Just for simple knowing:

Error Correction Techniques:

  1. Backward Error Correction (Retransmission) − If the receiver detects an error in the incoming frame, it requests the sender to retransmit the frame. It is a relatively simple technique. But it can be efficiently used only where retransmitting is not expensive, as in fiber optics and the time for retransmission is low relative to the requirements of the application.

  2. Forward Error Correction − If the receiver detects some error in the incoming frame, it executes the error-correcting code that generates the actual frame. This saves the bandwidth required for retransmission. It is inevitable in real-time systems. However, if there are too many errors, the frames need to be retransmitted.

2.3 Flow Control⚓︎

It is about processing the frame flow when transmitting. Details about the concepts see in Flow Control in Data Link Layer. There are basically two type of methods:

picture 12

Finally, let's check some devices used in the Data Link Layer.

Network Interface Card (NIC)

picture 13

Computer output data, through the Network Interface Card (NIC / Ethernet Card), will become Ethernet frames. Network card will also complete some broadcast link management (CDMA/CD implementation).

Network bridge

A bridge can be used to: - Interconnect two LANs together. - Separate network segments, which is a section of a network separated by bridges, switches, and routers.

picture 14

Ethernet switches

Picture first: 👀 picture 15

If you have ever traveled to any computer room before, you must have seen the sightseeing below: picture 16

Roughly, we can use Hub, Switch, and Router for Ethernet switches. picture 17

But what is the difference?

Hub

Hub is a type of device that’s commonly used as a connection point for various devices in a Local Area Network (LAN).

  • It works by receiving packets that arrive at one of its multiple ports, copying the packets, and sending them to its other ports so that all LAN segments can see the data.
Watch out!

Hub cannot handle the transmit collision. Once the collision happens, the collision will repeat and impact all the devices it connects to. That's why we should use Switch.

Switch (switching hub)

Switch is a more efficient, more intelligent version of a hub.

  • It uses packet switching to receive and forward data to its intended destination within a network.

  • Rather than blindly passing along data to all devices in a network as Hub, a switch records and "learn" the addresses of the connected devices.

  • Thus, switch can isolated conflict domains (which refers to the range that only one device can send information at a time).

picture 18

Router

Router is the most intelligent and complex of the three network connection devices. Router is the device in the network layer.

  • Rather than just forwarding data packets to other devices in a single network, routers are designed to forward data packets between two or more networks. It also directs traffic between those networks.

  • Router's function = Switch + Hub + More.

  • Thus, router can isolated broadcast domain (which refers to the range when the site sends out a broadcast signal, all the devices can receive the signal).

Okay, no more knowledge today! Enough details! Cheers the coffee ☕☕ coffee2

References⚓︎

Picture Resource 1

Picture Resource 2

Picture Resource 3

Picture Resource 4

Picture Resource 5

Picture Resource 6

Picture Resource 7

Error Detection and Correction in Data link Layer

Picture Resource 8

Picture Resource 9

Picture Resource 10

Networking Fundamentals: OSI 7 - Layer 2 - the data link layer - Part 2

THE DIFFERENCE BETWEEN A HUB, SWITCH, & ROUTER

Comments