Computer Networks Essentials / Data Link Layer

Medium Access Control (MAC)

๐Ÿค” What is Medium Access Control (MAC)?

In a network, many devices share the same communication medium (like a cable or wireless channel).

๐Ÿ“Œ Example:

  • Many computers connected to the same Ethernet cable

  • Many devices connected to the same Wi-Fi

๐Ÿ‘‰ Who gets to send data first?

๐Ÿ‘‰ What if two devices send data at the same time?

๐Ÿ’ก The answer is Medium Access Control (MAC).


๐Ÿง  Simple Definition

๐Ÿ“Œ Medium Access Control (MAC) is a sublayer of the Data Link Layer that controls how multiple devices access and share a common transmission medium.


๐Ÿงฉ Position of MAC in OSI Model

The Data Link Layer is divided into:

  • ๐Ÿ”น LLC (Logical Link Control)

  • ๐Ÿ”น MAC (Medium Access Control)

๐Ÿ“Œ MAC deals with who can transmit and when.


๐Ÿšจ The Core Problem: Multiple Access Problem

๐Ÿคฏ What is the Multiple Access Problem?

If:

  • Two devices transmit at the same time

  • Their signals collide

๐Ÿ“Œ This collision causes:

  • Data corruption โŒ

  • Retransmission โŒ

  • Wasted bandwidth โŒ

๐Ÿ‘‰ MAC protocols exist to avoid or handle collisions.


๐Ÿง  Real-Life Analogy

๐ŸŽค Group Discussion Example

  • If everyone speaks at once โ†’ noise โŒ

  • If rules exist โ†’ smooth discussion โœ…

๐Ÿ‘‰ MAC protocols are the rules of speaking for network devices.


๐Ÿงญ Types of MAC Techniques

MAC techniques are broadly classified into three categories:

1๏ธโƒฃ Random Access Protocols

2๏ธโƒฃ Controlled Access Protocols

3๏ธโƒฃ Channelization Protocols

Weโ€™ll understand each category clearly ๐Ÿ‘‡


๐ŸŽฒ 1. Random Access Protocols

๐Ÿ“Œ Devices transmit randomly, but follow rules to handle collisions.

๐Ÿ”น a) ALOHA

๐Ÿง  How ALOHA Works

  • Device sends data whenever it wants

  • If collision occurs โ†’ retransmit after random time

๐Ÿงฉ Types of ALOHA

๐Ÿ”ธ Pure ALOHA

  • Transmit anytime

  • Very high collision rate โŒ

๐Ÿ”ธ Slotted ALOHA

  • Time divided into slots

  • Transmit only at slot start

  • Fewer collisions โœ”๏ธ

โŒ Limitations

  • Very inefficient

  • Rarely used today

๐Ÿ”น b) CSMA (Carrier Sense Multiple Access)

๐Ÿง  Core Idea

Listen before you talk

๐Ÿ“Œ Device checks if medium is free before sending.

๐Ÿงฉ Types of CSMA

๐Ÿ”ธ CSMA/CD (Collision Detection)

๐Ÿ“Œ Used in wired Ethernet

๐Ÿง  How It Works

1๏ธโƒฃ Sense channel

2๏ธโƒฃ If free โ†’ transmit

3๏ธโƒฃ If collision detected โ†’ stop

4๏ธโƒฃ Wait random time โ†’ retransmit

โœ… Advantage

  • Efficient for wired LANs

โŒ Disadvantage

  • Not suitable for wireless


๐Ÿ”ธ CSMA/CA (Collision Avoidance)

๐Ÿ“Œ Used in wireless networks (Wi-Fi)

๐Ÿง  How It Works

  • Tries to avoid collisions before they happen

  • Uses acknowledgments and waiting times

โœ… Advantage

  • Suitable for wireless

โŒ Disadvantage

  • Slight delay


๐Ÿ›‚ 2. Controlled Access Protocols

๐Ÿ“Œ Devices take turns to transmit.

๐Ÿ” a) Token Passing

๐Ÿง  How It Works

  • A special packet called token circulates

  • Only device with token can send data

โœ… Advantages

  • No collision

  • Fair access

โŒ Disadvantages

  • Token loss stops network

  • Delay if many devices

๐Ÿ“Œ Used in Token Ring networks.


โœ‹ b) Polling

๐Ÿง  How It Works

  • Central device asks each device one by one

  • Device sends data when polled

โŒ Limitations

  • Slow

  • Central device failure breaks network


๐Ÿงฎ 3. Channelization Protocols

๐Ÿ“Œ Channel divided into smaller logical channels.

๐Ÿ”น a) FDMA (Frequency Division Multiple Access)

  • Channel divided by frequency

  • Each device gets different frequency band


๐Ÿ”น b) TDMA (Time Division Multiple Access)

  • Time divided into slots

  • Each device gets fixed time slot


๐Ÿ”น c) CDMA (Code Division Multiple Access)

  • Each device uses unique code

  • All transmit simultaneously


๐Ÿ“Š Comparison Table

Protocol

Collision

Usage

ALOHA

High

Old networks

CSMA/CD

Detects

Wired Ethernet

CSMA/CA

Avoids

Wireless

Token Passing

None

Token Ring

FDMA

None

Cellular

TDMA

None

GSM

CDMA

None

3G


โญ One-Line Summary

๐Ÿ”น MAC ensures fair, efficient, and collision-free access to a shared communication medium.