0% found this document useful (0 votes)
2 views

Lecture#27-32 Media Access Control (MAC) Layer

The document discusses the Media Access Control (MAC) sublayer, detailing its responsibilities, protocols, and channel allocation methods. It covers various MAC protocols including contention-based, contention-free, and random access protocols like Aloha and CSMA/CD, along with their efficiencies and operational mechanisms. Additionally, it explains the structure of Ethernet frames and the process of collision detection and handling in CSMA/CD networks.

Uploaded by

aryanrajjpsps03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lecture#27-32 Media Access Control (MAC) Layer

The document discusses the Media Access Control (MAC) sublayer, detailing its responsibilities, protocols, and channel allocation methods. It covers various MAC protocols including contention-based, contention-free, and random access protocols like Aloha and CSMA/CD, along with their efficiencies and operational mechanisms. Additionally, it explains the structure of Ethernet frames and the process of collision detection and handling in CSMA/CD networks.

Uploaded by

aryanrajjpsps03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Media Access Control Sub Layer

Lecture#27-32

Dr. Sanjeev Patel


Asst Professor, CSE Dept.
NIT Rourkela
4/14/2024 Media Access Control Sub Layer 1
Outline
• MAC Protocol
• Contention-free and contention-based protocol
• Random access protocol
• Aloha Protocol
• CSMA protocol
• Ethernet
• CSMA/CD
• Polling
• Reservation
4/14/2024 Media Access Control Sub Layer 2
Responsibility of MAC Layer
❑ Responsibility of MAC Layer
– decide when a node accesses a shared medium
– resolve any potential conflicts between competing
nodes
– correct communication errors occurring at the
physical layer
– perform other activities such as framing,
addressing, and flow control
❑ Second layer of the OSI reference model (data
link layer)
4/14/2024 Media Access Control Sub Layer 3
The Channel Allocation Problem [2]
• How to allocate a single broadcast channel among competing
users
• Static Channel Allocation in LANs and MANs
• The traditional way of allocating a single channel, such as a
telephone trunk, among multiple competing users is
Frequency Division Multiplexing (FDM).
• If there are N users, the bandwidth is divided into N equal-
sized portions, each user being assigned one portion.
• Dynamic Channel Allocation in LANs and MANs
• Random allocation of the channel under following
assumptions

4/14/2024 Media Access Control Sub Layer 4


Dynamic Channel Allocation in LANs and MANs

1.Station Model- The model consists of N independent stations


2.Single Channel Assumption- A single channel is available
for all communication
3.Collision Assumption- If two frames are transmitted
simultaneously, they overlap in time and the resulting signal is
garbled. This event is called a collision.
4.(a) Continuous Time- Frame transmission can begin at any
instant
(b) Slotted Time.
5.(a) Carrier Sense- If the channel is sensed as busy, no station will
attempt to use it until it goes idle.
(b) No Carrier Sense.
4/14/2024 Media Access Control Sub Layer 5
MAC Protocols

4/14/2024 Media Access Control Sub Layer 6


MAC Protocols: a taxonomy
Three broad classes:
• Channel Partitioning
– divide channel into smaller “pieces” (time slots, frequency, code)
– allocate piece to node for exclusive use
• Random Access
– channel not divided, allow collisions
– “recover” from collisions
• “Taking turns”
– Nodes take turns, but nodes with more to send can take longer
turns

4/14/2024 Media Access Control Sub Layer 5-7


Channel Partitioning MAC protocols: TDMA

TDMA: time division multiple access


• access to channel in "rounds"
• each station gets fixed length slot (length = pkt trans time)
in each round
• unused slots go idle
• example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle

4/14/2024 Media Access Control Sub Layer 5-8


Channel Partitioning MAC protocols: FDMA

FDMA: frequency division multiple access


• channel spectrum divided into frequency bands
• each station assigned fixed frequency band
• unused transmission time in frequency bands go idle
• example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6
idle
frequency bands

4/14/2024 Media Access Control Sub Layer 5-9


CDMA
• One channel occupies entire bandwidth of the
link(differs from FDMA)
• All stations can send data simultaneously(differs
from TDMA)
• One channel carries all transmission
simultaneously
• It is based on coding theory
• Each stations is assigned a code , which is a
sequence of numbers called chips
4/14/2024 Media Access Control Sub Layer 10
Rules for encoding
• Suppose we have a sequence of four chips
corresponding to each station

4/14/2024 Media Access Control Sub Layer 11


CDMA multiplexer [5]

4/14/2024 Media Access Control Sub Layer 12


CDMA demultiplexer [5]

4/14/2024 Media Access Control Sub Layer 13


Random Access Protocols
• When node has packet to send
– transmit at full channel data rate R.
– no a priori coordination among nodes
• two or more transmitting nodes ➜ “collision”,
• random access MAC protocol specifies:
– how to detect collisions
– how to recover from collisions (e.g., via delayed retransmissions)
• Examples of random access MAC protocols:
– slotted ALOHA
– ALOHA
– CSMA, CSMA/CD, CSMA/CA

4/14/2024 Media Access Control Sub Layer 5-14


Slotted ALOHA
Assumptions Operation
• all frames same size • when node obtains fresh
• time is divided into equal frame, it transmits in next slot
size slots, time to transmit • no collision, node can send
1 frame new frame in next slot
• nodes start to transmit • if collision, node retransmits
frames only at beginning of frame in each subsequent slot
slots with prob. p until success
• nodes are synchronized
• if 2 or more nodes transmit
in slot, all nodes detect
collision
4/14/2024 Media Access Control Sub Layer 5-15
Slotted ALOHA [6]

Pros Cons
• single active node can • collisions, wasting slots
continuously transmit at • idle slots
full rate of channel • nodes may be able to
• highly decentralized: only detect collision in less
slots in nodes need to be than time to transmit
packet
in sync
• clock synchronization
• simple
4/14/2024 Media Access Control Sub Layer 5-16
Slotted Aloha efficiency
Efficiency is the long-run • For max efficiency with N
fraction of successful slots nodes, find p* that
when there are many nodes, maximizes
each with many frames to send Np(1-p)N-1
• For many nodes, take limit
• Suppose N nodes with many of Np*(1-p*)N-1 as N goes
frames to send, each to infinity, gives 1/e = .37
transmits in slot with
probability p
• prob that node 1 has success At best: channel
in a slot = p(1-p)N-1 used for useful
• prob that any node has a transmissions 37%
success = Np(1-p)N-1 of time!

4/14/2024 Media Access Control Sub Layer 5-17


Pure (unslotted) ALOHA
• unslotted Aloha: simpler, no synchronization
• when frame first arrives
– transmit immediately
• collision probability increases:
– frame sent at t0 collides with other frames sent in [t0-1,t0+1]

4/14/2024 Media Access Control Sub Layer 5-18


Pure Aloha efficiency [6]
P(success by given node) = P(node transmits) .

P(no other node transmits in [t0-1,t0] .


P(no other node transmits in [t0, t0+1]
= p . (1-p)N-1 . (1-p)N-1

= p . (1-p)2(N-1)

… choosing optimum p and then letting n -> infty ...

Even worse !
= 1/(2e) = .18

4/14/2024 Media Access Control Sub Layer 5-19


Alternative Method
• Offered load is the average number of frames
transmitted per unit time.
• Arrival of frames or packets follow the Poisson
process.
• Therefore, probability of k arrival of frames in t
time : {(λt)^k exp(-λt)}/ k!
• Assume t= 1 frame transmission unit and λ=G,
– then Prob [k frames]= {G^k exp(-G)}/ k!

4/14/2024 Media Access Control Sub Layer 20


Alternative Method
• The probability that it will avoid a collision is e-G, that is the
probability that all the other users are silent in that slot
• Probability of success= Prob[k=0]= e-G
• Probability of (collision +empty )= Prob[k>0]= 1-e-G
• Efficiency of slotted Aloha is calculated as:
– Efficiency is offered load Χ Prob[success] = G*e-G
– At G=1, empty slot=37%, success=37%, collision=26%.
• For pure Aloha, vulnerable time is 2 slots
• Efficiency of pure Aloha is:
offered load Χ Prob[success] = G* e-2G
4/14/2024 Media Access Control Sub Layer 21
Throughput Comparison

4/14/2024 Media Access Control Sub Layer 22


Carrier Sense Multiple Access
• To minimize the no. of collision or maximize the
performance, we can use the concept of sensing
the medium
• It is based on the technique listen before talk
or sense before transmit
• But it can not eliminate all the collision
• It is able to reduce the collision and improve the
throughput

4/14/2024 Media Access Control Sub Layer 23


CSMA (Carrier Sense Multiple Access)

CSMA: listen before transmit:

If channel sensed idle: transmit entire frame


• If channel sensed busy, defer transmission

• Human analogy: don’t interrupt others!

4/14/2024 Media Access Control Sub Layer 5-24


Collision in CSMA [5]

4/14/2024 Media Access Control Sub Layer 25


Persistence Technique
• This is technique defined that what should we do
when medium is busy
• Non-persistence:
1. If the medium is idle ,transmit; otherwise ,
go to step 2
2. If the medium is busy , wait an amount of
time drawn from a probability
distribution(retransmission delay) and
repeat step 1

4/14/2024 Media Access Control Sub Layer 26


1-Persistence
• Algorithm:
1. If the medium is idle ,transmit; otherwise ,
go to step 2
2. If the medium is busy , continue to listen until
the channel is sensed idle; then transmit
immediately
• Still, there is a chance of collision, when two
stations senses the medium simultaneously

4/14/2024 Media Access Control Sub Layer 27


p-Persistence
• Algorithm:
1. If the medium is idle ,transmit with probability p, and
delay one time unit with probability (1-p) (The time
unit is typically equal to the maximum propagation
delay)
2. If the medium is busy, continue to listen until the
channel is idle and repeat step 1
3. If the transmission is delayed one time unit, repeat
step 1
• It shows the highest performance among the all
persistence technique
4/14/2024 Media Access Control Sub Layer 28
Throughput Comparison [2]

4/14/2024 Media Access Control Sub Layer 29


Ethernet Frame Structure
Sending adapter encapsulates IP datagram (or other network layer
protocol packet) in Ethernet frame

Preamble:
• 7 bytes and each byte has the pattern 10101010 followed by
one byte with pattern 10101011
• used to synchronize receiver, sender clock rates
Data:
• 46-1500 bytes

4/14/2024 Media Access Control Sub Layer 5-30


Ethernet Frame Structure [6]
• Addresses: 6 bytes
– if adapter receives frame with matching destination address, or with
broadcast address (eg ARP packet), it passes data in frame to net-layer
protocol
– otherwise, adapter discards frame
• Type: 2 bytes indicates the higher layer protocol (mostly IP but
others may be supported)
– permits Ethernet to multiplex network-layer protocols
– It also indicated length of data in IEEE 802.3
• CRC: checked at receiver, if error is detected, the frame is simply
dropped

4/14/2024 Media Access Control Sub Layer 5-31


Bit Stuffing
• Ethernet start and end flag has a pattern 01111110
• Delimit frame at both ends 01111110
• May close one frame and open another
• Receiver hunts for flag sequence to synchronize
• Bit stuffing used to avoid confusion with data containing
01111110
– 0 inserted after every sequence of five 1s
– If receiver detects five 1s it checks next bit
– If 0, it is deleted
– If 1 and seventh bit is 0, accept as flag
– If sixth and seventh bits 1, sender is indicating abort
4/14/2024 Media Access Control Sub Layer 32
Bit Stuffing
• Example with possible errors

4/14/2024 Media Access Control Sub Layer 33


CSMA/CD (Collision Detection)
CSMA/CD: carrier sensing, deferral as in CSMA
– collisions detected within short time
– colliding transmissions aborted, reducing channel
wastage
• collision detection:
– easy in wired LANs: measure signal strengths,
compare transmitted, received signals
– difficult in wireless LANs: receiver shut off while
transmitting

4/14/2024 Media Access Control Sub Layer 5-34


CSMA/CD collision detection

4/14/2024 Media Access Control Sub Layer 5-35


Ethernet uses CSMA/CD
• No slots
• Carrier sense-
– Adapter doesn’t transmit if it senses that some
other adapter is transmitting
• Collision detection –
– Transmitting adapter aborts when it senses that
another adapter is transmitting
• Random access –
– Before attempting a retransmission, adapter waits
a random time
4/14/2024 Media Access Control Sub Layer 5-36
Contd…
• Back-off-
– If there is a collision, the frame needs to be sent again.
– To reduce the probability of collision, the station waits up to the
back-off limit and increment by one corresponding to each
collision
– If station does not hears a collision until the whole frame has
been sent, the transmission is successful.
• Jamming signal-
– If the station hear the collision, it sends a jam signal to all to
alert them that a collision has occurred;
– all stations discard the part of the frame received.
– The station then increments the value of the back-off parameter
by 1
4/14/2024 Media Access Control Sub Layer 37
Ethernet CSMA/CD algorithm [6]
1. Adaptor receives datagram 4. If adapter detects another
from net layer & creates frame transmission while
2. If adapter senses channel idle transmitting, aborts and
for 96 bit times, it starts to sends jam signal of 48 bit
transmit frame. If it senses times.
channel busy, waits until 5. After aborting, adapter enters
channel idle plus 96 bit times exponential backoff: after the
and then transmits mth collision, adapter chooses
3. If adapter transmits entire a K at random from
frame without detecting {0,1,2,…,2m-1}. Adapter waits
another transmission, the K·512 bit times and returns to
adapter is done with frame ! Step 2

4/14/2024 Media Access Control Sub Layer 5-38


CSMA/CD procedure [5]

4/14/2024 Media Access Control Sub Layer 39


• Truncated Binary Exponential Backoff
– Attempts := 0;
– Attempt Limit is 16 and Backoff Limit 10.
While
{ (Frame NOT Transmitted Successfully)
AND (Attempts < Attempt Limit) }
K : = Min (Attempts, Backoff Limit)
R : = Random (0, 2k-1)
delay : = R * SlotTime;
Wait (delay)
Increment Attempts;
End While
– This algorithm yields a "statistical fairness" in the
sharing of bandwidth.

4/14/2024 Media Access Control Sub Layer 40


CSMA/CD efficiency
• Tprop = max prop between 2 nodes in LAN
• ttrans = time to transmit max-size frame

1
efficiency =
1 + 5t prop / ttrans

• Efficiency goes to 1 as tprop goes to 0


• Goes to 1 as ttrans goes to infinity
• Much better than ALOHA, but still decentralized, simple,
and cheap

4/14/2024 Media Access Control Sub Layer 5-41


“Taking Turns” MAC protocols
channel partitioning MAC protocols:
– share channel efficiently and fairly at high load
– inefficient at low load: delay in channel access, 1/N
bandwidth allocated even if only 1 active node!
Random access MAC protocols
– efficient at low load: single node can fully utilize
channel
– high load: collision overhead
“taking turns” protocols (Controlled-access Protocol)
look for best of both worlds!
4/14/2024 Media Access Control Sub Layer 5-42
Controlled-access Protocols

• In this station consult one another to find which


station has right to send
• The asynchronous approach can be further
subdivided into many categories:
• Round robin and Reservation: Centralization
can be handled by
- Polling
- Token Passing
4/14/2024 Data Link Layer 43
Round Robin
• With round robin, each station in turn is given the
opportunity to transmit.
• During that opportunity, the station may decline to
transmit or may transmit subject to a specified upper
bound
• Usually expressed as a maximum amount of data
transmitted or time for this opportunity.
• When it is finished, relinquishes its turn, and the right to
transmit passes to the next station in logical sequence.
• Control of sequence may be centralized or distributed.
Polling is an example of a centralized technique
4/14/2024 Data Link Layer 44
Reservation
• A station needs to make a reservation before
sending data
• Time is divided into intervals
• A reservation frame precedes the data frames sent
in that interval
• If there are N stations in the system, there are
exactly N reservation minislots in the reservation
frame
• Each minislot belongs to a station and each station
makes a reservation in its own minislot
4/14/2024 Data Link Layer 45
Contd.
• For stream traffic, reservation techniques are well
suited.
• In this techniques, time on the medium is divided
into slots, much as with synchronous TDM.
• A station wishing to transmit reserves future slots
for an extended or even an indefinite period.
• Again, reservations may be made in a centralized
or distributed fashion.

4/14/2024 Data Link Layer 46


Reservation access method [5]

4/14/2024 Data Link Layer 47


Polling
• It involves two type of devices
• Primary Station: rule maker
• Secondary Station: follow the instructions
made by primary station
• Two operations are involved

4/14/2024 Data Link Layer 48


Select [5]

4/14/2024 Data Link Layer 49


Poll [5]

4/14/2024 Data Link Layer 50


Token Passing
• A token circulates around the ring, if no data
are being sent
• The station captures the token and sends one
or more frames
• It will keep capture till they have frame or
allocated time has not expired
• Finally release the token after used

4/14/2024 Data Link Layer 51


Token-passing network [5]

4/14/2024 Data Link Layer 52


Token-passing procedure [5]

4/14/2024 Data Link Layer 53


“Taking Turns” MAC protocols
(Controlled Access) [6]
Polling: Token passing:
• master node “invites” slave  control token passed from
nodes to transmit in turn one node to next sequentially.
• concerns:  token message
– polling overhead  concerns:
– latency  token overhead
– single point of failure  latency
(master)
 single point of failure (token)

4/14/2024 Media Access Control Sub Layer 5-54


Repeater, Hub, Bridge & Switch

Repeater [9]
“A repeater receives a signal, regenerates it, and passes it
on.
It can regenerate and retime network signals at the bit level
to allow them to travel a longer distance on the media.
It operates at Physical Layer of OSI
The Four Repeater Rule for 10-Mbps Ethernet should be
used as a standard when extending LAN segments.
This rule states that no more than four repeaters can be
used between hosts on a LAN.
This rule is used to limit latency added to frame travel by
each repeater.”
4/14/2024 Media Access Control Sub Layer 55
Repeater, Hub, Bridge & Switch

Hub [9]
“Hubs are used to connect multiple
nodes to a single physical device,
which connects to the network.
Hubs are actually multiport
repeaters.
Using a hub changes the network
topology from a linear bus, to a
star.
With hubs, data arriving over the
cables to a hub port is electrically
repeated on all the other ports
connected to the same network
segment, except for the port on
which the data was sent. “
4/14/2024 Media Access Control Sub Layer 56
Repeater, Hub, Bridge & Switch

Bridge [9]
“Bridges are used to logically separate
network segments within the same network.
They operate at the OSI data link layer (Layer
2) and are independent of higher-layer
protocols.
The function of the bridge is to make
intelligent decisions about whether or not to
pass signals on to the next segment of a
network.
When a bridge receives a frame on the
network, the destination MAC address is
looked up in the bridge table to determine
whether to filter, flood, or copy the frame
onto another segment. Broadcast Packets are
forwarded”
4/14/2024 Media Access Control Sub Layer 57
Repeater, Hub, Bridge & Switch

Switch [9]
“Switches are Multiport Bridges.
Switches provide a unique network segment on each port,
thereby separating collision domains.
Today, network designers are replacing hubs in their wiring
closets with switches to increase their network performance and
bandwidth while protecting their existing wiring investments.
Like bridges, switches learn certain information about the data
packets that are received from various computers on the
network.
Switches use this information to build forwarding tables to
determine the destination of data being sent by one computer to
another computer on the network. “
4/14/2024 Media Access Control Sub Layer 58
Repeater, Hub, Bridge & Switch

Switches: Dedicated Access [9]


A
“Hosts have direct connection to
switch C’ B
Full Duplex: No collisions
Switching: A-to-A’ and B-to-B’ switch
simultaneously, no collisions
Switches can be cascaded to
expand the network” C

B’ A’

4/14/2024 Media Access Control Sub Layer 59


Router and Gateway
• Router
– It is used to determine the routing decision of the incoming
packet using routing table stored in router
– It is responsible for receiving, analyzing and forwarding the
data packets to other networks and operated at network layer
• Gateways
– It regulates traffic between two dissimilar networks,
while routers regulate traffic between similar networks.
– It is responsible for the conversion of one protocol into the
other where networks have a different set of protocols
– It can be operated up-to application layer

4/14/2024 Media Access Control Sub Layer 60


References
1. William Stallings, “Data and Computer Communications”, Seventh
Edition, PHI 2004.
2. Andrew S. Tanenbaum, ”Computer Networks” 4th Edition PHI
3. B. A. Fourozan, “TCP/IP Protocol Suite”, 3rd Edition, Singapore,
McGrawHill, 2004.
4. L. L. Peterson and B. S. Davie, Computer Networks-A System
Approach, Elsevier.
5. B. A. Fourozan, “Data Communications and Networking”, 4th Edition,
Singapore, McGrawHill, 2004.
6. James F. Kurose, Keith W. Ross, “Computer Networking: A Top-Down
Approach Featuring the Internet”, 3rd Edition , Pearson Education 2009.
7. https://gaia.cs.umass.edu/kurose_ross/ppt.htm
8. PPT available for the respective books
9. http://home.iitk.ac.in/~navi/sidbinetworkcourse/

4/14/2024 Media Access Control


61 Sub Layer
Thank You

4/14/2024 Media Access Control Sub Layer 62

You might also like