Data Link Layer - CSU359 - Shoolini University

Data Link Layer

OSI Model: Data Link Layer

The Data Link Layer is the second layer in the OSI Model, sitting just above the Physical Layer and below the Network Layer. Its primary role is to ensure reliable data transfer between two directly connected nodes over a physical medium. It is responsible for framing, error detection, flow control, and managing access to the shared medium.

1. Functions of the Data Link Layer

The Data Link Layer provides crucial functionalities for reliable communication:

2. Sub-layers of the Data Link Layer

The Data Link Layer is divided into two sub-layers:

2.1 Logical Link Control (LLC)

The LLC sub-layer is responsible for:

2.2 Media Access Control (MAC)

The MAC sub-layer is responsible for:

3. Framing in the Data Link Layer

Framing is the process of encapsulating data into units with defined boundaries. The structure of a frame includes:

3.1 Error Detection Using CRC

CRC is computed as follows:

  1. Divide the data bits by a predefined polynomial using modulo-2 arithmetic.
  2. Append the remainder to the original data to form the transmitted frame.
  3. The receiver performs the same calculation to verify the integrity of the frame.
def crc(data, generator):
                data += '0' * (len(generator) - 1)
                for i in range(len(data) - len(generator) + 1):
                    if data[i] == '1':
                        for j in range(len(generator)):
                            data = data[:i + j] + str(int(data[i + j] != generator[j])) + data[i + j + 1:]
                return data[-(len(generator) - 1):]
            

4. Medium Access Control Techniques

4.1 CSMA/CD (Carrier Sense Multiple Access with Collision Detection)

Used in wired Ethernet networks to avoid collisions:

4.2 CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance)

Used in wireless networks to minimize collisions:

5. Addressing at the Data Link Layer

The Data Link Layer uses MAC addresses for communication:

6. Protocols in the Data Link Layer

Common protocols include:

7. Challenges in the Data Link Layer

Some challenges include: