Download as pdf or txt
Download as pdf or txt
You are on page 1of 80

The Medium Access Sublayer

The Medium Access Sublayer


Local Area Networks
• Switched networks are characterized by point-to-point
communications (as in WANs)
• Next we will look at broadcast communication networks (LANs)
The Medium Access Sublayer
Broadcast Networks
In broadcast networks:
• Each station is attached to a transmitter/receiver which
communicates over a medium shared by other stations
• Transmission from any station is received by all other stations
• There are no intermediate switching nodes

Examples of broadcast networks:


The Medium Access Sublayer
MAC Sublayer and Multi-access
• The key issue is how to determine who gets to use the channel
when there is competition for it.
• Broadcast channels are sometimes referred to as multi-access
channels or random access channels.
• If more than one station transmits at a time on the broadcast
channel, a collision occurs
• Multi-access problem: How to determine which station can
transmit?
• The protocols used to determine who gets next on a
multi-access channel belong to a sublayer of the data link layer
called the MAC (Medium Access Control) sublayer.
The Medium Access Sublayer
The Channel Allocation Problem

Static Channel Allocation in LANs and MANs


FDM: Frequency Division Multiplexing
• If there are N users, the bandwidth is divided into N
equal-sized portions, each user being assigned one portion
• No interference between users
• Suitable for fixed number of users with constant traffic
• e.g. a telephone trunk

Disadvantage: when the number of users is large and continuously


varying, or the traffic is bursty, FDM presents some problems.
The Medium Access Sublayer
The Channel Allocation Problem
Static Channel Allocation in LANs and MANs
A simple queuing theory calculation
For a channel of capacity C bps, with an arrival rate of λ
frames/sec, each frame having a length drawn from an
exponential probability density function with mean 1/μ
bits/frame, the mean time delay

Now let us divide the single channel up into N independent


subchannels, each with capacity C/N bps. The mean input rate on
each of the subchannel will now be λ/N. Recomputing T, we get
The Medium Access Sublayer
The Channel Allocation Problem

Static Channel Allocation in LANs and MANs


TDM: Time Division Multiplexing
• Same arguments (as in case of FDM) apply to TDM

• Each user is statically allocated every Nth time slot


• If a user does not use the allocated slot, it just lies fallow

None of the traditional static channel allocation methods work


well with bursty traffic, so dynamic methods must be explored
The Medium Access Sublayer
The Channel Allocation Problem
Dynamic Channel Allocation in LANs and MANs

Five key assumptions:


1. Station Model. The model consists of N independent
stations, each with a program or user that generates frames for
transmission.

The probability of a frame being generated in an interval of


length Δt is λΔt, where λ is a constant (the arrival rate of new
frames).

Once a frame has been generated, the station is blocked and


does nothing until the frame has been successfully
transmitted.
The Medium Access Sublayer
The Channel Allocation Problem
Dynamic Channel Allocation in LANs and MANs

Five key assumptions:


2. Single Channel Assumption. A single channel is available
for all communication. All stations can transmit on it and all
can receive from it.

As far as the hardware is concerned, all stations are


equivalent, although some protocol software may assign
priorities to them.
The Medium Access Sublayer
The Channel Allocation Problem
Dynamic Channel Allocation in LANs and MANs

Five key assumptions:


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.

All stations can detect collisions. A collided frame must be


transmitted again later. There are no errors other than those
generated by collisions.
The Medium Access Sublayer
The Channel Allocation Problem
Dynamic Channel Allocation in LANs and MANs

Five key assumptions:


4a. Continuous Time. Frame transmission can begin at any
instant. There is no master clock dividing time into discrete
intervals.

4b. Slotted Time. Time is divided into discrete intervals (slots).


Frame transmissions always begin at the start of a slot. A slot
may contain 0, 1, or more frames, corresponding to an idle
slot, a successful transmission, or a collision, respectively.
The Medium Access Sublayer
The Channel Allocation Problem
Dynamic Channel Allocation in LANs and MANs

Five key assumptions:


5a. Carrier Sense. Stations can tell if the channel is in use
before trying to use it. If the channel is sensed as busy, no
station will attempt to use it until it goes idle.

5b. No Carrier Sense. Stations cannot sense the channel


before trying to use it. They just go ahead and transmit.
Only later can they determine whether or not the
transmission was successful.
The Medium Access Sublayer
Multi-Access Protocols
• Protocols that solve the resolution problem dynamically are
called Multiple Access (Multi-access) Protocols

• Different types of multi-access protocols


✔ Contention protocols resolve a collision after it occurs.
These protocols execute a collision resolution protocol after
each collision
✔ Collision-free protocols ensure that a collision can never
occur
The Medium Access Sublayer
Evolution of Contention Protocols
The Medium Access Sublayer
Contention Protocols
• ALOHA Protocols
✔ (Pure) Aloha
✔ Slotted Aloha

• CSMA (Carrier Sense Multiple Access)


✔ Persistent CSMA
✔ Non-persistent CSMA
✔ CSMA/CD – Carrier Sense Multiple Access with Collision
Detection (=Ethernet)

• There are many more


The Medium Access Sublayer
Multiple Access Protocols
ALOHA
Pure ALOHA
the first
ALOHA of U. of Hawaii
multiple-access
protocol: a
method for
sharing a
transmission
channel by Computer
enabling the Center
transmitter to
access the 413MHz at 9600bps
channel at 407MHz at 9600bps
random times
The Medium Access Sublayer
Multiple Access Protocols
(Pure) ALOHA
Topology:
All stations send frames to a central node, which broadcasts the frames to all
stations

Aloha Protocol:
• Whenever a station has data, it transmits
• Stations transmit frame of fixed length on a common channel
•When two transmissions overlap, they garble each other (collision)
•Sender finds out whether transmission was successful or experienced a
collision by listening to the broadcast from the central node
•The central node acknowledges the correct frames it receives
•When a node does not get an acknowledgment within a specific timeout, it
assumes that its frame collided
•When a frame collides, the transmitting node schedules a retransmission after a
random delay
The Medium Access Sublayer
Multiple Access Protocols
(Pure) ALOHA

Pure ALOHA Frames are transmitted at completely


arbitrary times.
The Medium Access Sublayer
Multiple Access Protocols
(Pure) ALOHA

Collisions in Pure ALOHA


The Medium Access Sublayer
Multiple Access Protocols
(Pure) ALOHA
Collisions and vulnerable period

• A frame (red frame) will be in a collision if and only if another transmission


begins in the vulnerable period of the frame
• Vulnerable period has the length of 2 frame times
The Medium Access Sublayer
Multiple Access Protocols
ALOHA
nodes
S collision?
new frame channel
G No
S
old frame
Yes
The Medium Access Sublayer
Multiple Access Protocols
Slotted ALOHA

The Slotted Aloha Protocol:


• Slotted Aloha - Aloha with an additional constraint
• Time is divided into discrete time intervals (=slot)
•A station can transmit only at the beginning of a slot

As a consequence:
•Frames either collide completely or do not collide at all
•Vulnerable period = 1
The Medium Access Sublayer
Multiple Access Protocols
Slotted ALOHA

Collisions in Slotted ALOHA


The Medium Access Sublayer
Multiple Access Protocols: ALOHA
The Medium Access Sublayer
Multiple Access Protocols: ALOHA
The Medium Access Sublayer
Multiple Access Protocols: ALOHA
The Medium Access Sublayer
Multiple Access Protocols: ALOHA
The Medium Access Sublayer
Multiple Access Protocols: ALOHA
The Medium Access Sublayer
Multiple Access Protocols: ALOHA
The Medium Access Sublayer
Multiple Access Protocols: ALOHA
The Medium Access Sublayer
Multiple Access Protocols
ALOHA
Using S = GP0, we
get
For pure ALOHA: S = G e-2G
For slotted ALOHA: S = G
e-G
To find the maximum value:
The Medium Access Sublayer
Multiple Access Protocols
Comparison of ALOHA and S-ALOHA
The Medium Access Sublayer
Multiple Access Protocols
ALOHA
In slotted ALOHA, the best we can hope for is 37% success, 37%
slots empty, and 26% collisions. Operating at higher values of G
reduces the number of empties but increases the number of
collisions exponentially.
Consider the transmission of a test frame:
success: e-G, failure: 1-e-G, success for k attempts:

Expected number of transmissions:

As a result of the exponential dependence of E upon G, small


increases in the channel load can drastically reduce its performance.
The Medium Access Sublayer
Multiple Access Protocols
Carrier Sense Multiple Access Protocols

With slotted ALOHA the best channel utilization that can be


achieved is 1/e. This is hardly surprising, since with stations
transmitting at will, without paying attention to what other
stations are doing, there are bound to be many collisions.

In local area networks, however, it is possible for stations to


detect what other stations are doing, and adapt their behavior
accordingly.

Protocols in which stations listen for a carrier (i.e. a


transmission) and act accordingly are called carrier sense
protocols.
The Medium Access Sublayer
Multiple Access Protocols
CSMA - Carrier Sense Multiple Access

Improvement to ALOHA protocol:


• If stations have carrier sense capability (stations can test the
broadcast medium for ongoing transmission), and
• if stations only transmit if the channel is idle,
• then many collisions can be avoided.

Caveat: This improves ALOHA only if the ratio

is small. Why?
The Medium Access Sublayer
Multiple Access Protocols
CSMA - Carrier Sense Multiple Access

CSMA protocol:
• A station that wishes to transmit listens to the medium for an
ongoing transmission
• Is the medium in use?
✔ Yes: Station back of for a specified period
✔ No: Station transmits
• If a sender does not receive an acknowledgment after some
period, it assumes that a collision has occurred
• After a collision a station backs off for a certain (random) time
and retransmits
The Medium Access Sublayer
Multiple Access Protocols
CSMA - Carrier Sense Multiple Access

CSMA protocol:
• There are a number of variations of CSMA protocols
• Each variant specifies what to do if the medium is found busy:
✔ Non-persistent CSMA
✔ 1-persistent CSMA
✔ p-persistent CSMA
The Medium Access Sublayer
Multiple Access Protocols
CSMA - Carrier Sense Multiple Access

Non-persistent CSMA Protocol:


1. If the medium is idle, transmit immediately
2. If the medium is busy, wait a random amount of time
and repeat Step 1

• Random back-off reduces probability of collisions


• Wasted idle time if the back-off time is too long
• May result in long access delays
The Medium Access Sublayer
Multiple Access Protocols
CSMA - Carrier Sense Multiple Access

1-persistent CSMA Protocol:


1. If the medium is idle, transmit immediately
2. If the medium is busy, continue to listen until medium
becomes idle, and then transmit immediately

• Too selfish: there will always be a collision if two stations


want to retransmit
The Medium Access Sublayer
Multiple Access Protocols
CSMA - Carrier Sense Multiple Access

p-persistent CSMA Protocol:


1. If the medium is idle, transmit with probability p, and
delay for one time unit with probability (1 - p) [time unit
= length of propagation delay]
2. If the medium is busy, continue to listen until medium
becomes idle, then go to Step 1
3. If transmission is delayed by one time unit, continue
with Step 1

• Can be a good trade-off between non-persistent and 1-persistent


CSMA
The Medium Access Sublayer
Multiple Access Protocols
CSMA - Carrier Sense Multiple Access

How to select probability p?


• Assume that N stations have a packet to send and the medium is
busy
• Expected number of stations that will attempt to transmit once
the medium becomes idle is given by Np
• If Np > 1, then a collision is expected to occur (which results in
retransmission, which, in turn, results in more collisions)

• Therefore: Network must make sure that Np < 1, where N is


the maximum number of stations that can be active at a time
The Medium Access Sublayer
Multiple Access Protocols
CSMA: Summary
1-persistent CSMA: the station transmits with a probability of 1
whenever it finds the channel idle, if the channel is busy, it waits
until it becomes idle

non-persistent CSMA: the station transmits if the channel is idle,


if the channel is busy, it waits a random time and tries again

p-persistent CSMA (slotted): the station transmits with a


probability of p whenever it finds the channel idle, with a
probability of 1-p, it waits until the next slot. If another station
has begun transmitting, it acts as if there had been a collision. It
waits a random time and starts again.
The Medium Access Sublayer
Multiple Access Protocols
Comparison of CSMA Strategies
The Medium Access Sublayer
Multiple Access Protocols
Comparison of ALOHA and CSMA: Load vs Throughput
Assumption: propagation delay << transmission delay
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD

Improvement to CSMA protocol:


• Carrier Sense Multiple Access with Collision Detection

• Widely used for bus topology LANs (IEEE 802.3, Ethernet)

• Only works if propagation delay is small relative to


transmission delay (in other words, a must be small)
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD

CSMA has an inefficiency:


• If a collision has occurred, the channel is unstable until
colliding packets have been fully transmitted

CSMA/CD overcomes this as follows:


• While transmitting, the sender is listening to medium for
collisions. Sender stops if collision has occurred

Note:
• CSMA: Listen Before Talking
• CSMA/CD: Listen While Talking
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD

Generic CSMA/CD protocol:


• Use one of the CSMA persistence algorithm (non-persistent,
1-persistent, p-persistent) for transmission

• If a collision is detected during transmission, cease


transmission and transmit a jam signal to notify other stations
of collision

• After sending the jam signal, back off for a random amount of
time, then start to transmit again
The Medium Access Sublayer
Multiple Access Protocols
Carrier Sense Multiple Access Protocols

CSMA with collision detection (CSMA/CD):

Abort a transmission as soon as they detect a collision. Quickly


terminating damaged frames saves time and bandwidth.

After a station detects a collision, it aborts its transmission,


waits a random period of time, and then tries again, assuming
that no other station has started transmitting in the meantime.
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD

Question: How long does it take to detect a collision?


Answer: In the worst case, twice the maximum propagation
delay of the medium
The Medium Access Sublayer
Multiple Access Protocols
Collision Detection in CSMA/CD
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD
maximum collision detection time
A B
1.A starts t=0
transmitting 3. A reaches B 2.B starts
transmitting
5.B reaches A PROP

2PROP 4.B detects collision,


transmits JAM, stops

6.A detects collision,


transmits JAM, stops
The maximum collision detection time is equal to
twice the maximum end-to-end propagation delay.
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD
For this reason we will model the contention interval as a
slotted ALOHA system with slot width 2a (a is the end to end
delay). On a 1-km long coaxial cable, a≈5μsec.

It is important to realize that collision detection is an analog


process. The station’s hardware must listen to the cable while
it is transmitting. The signal encoding must allow collisions to
be detected (e.g., a collision of two 0-volt signals may well be
impossible to detect). For this reason, special encoding is
commonly used.
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD

Restrictions of CSMA / CD:


• Packet should be twice as long as the time to detect a collision
(2 * maximum propagation delay)
• Otherwise, CSMA/CD does not have an advantage over CSMA

Example: Ethernet
• Ethernet requires a minimum packet size and restricts the
maximum length of the medium
• Question: What is the minimum packets size in a 10 Mbit/sec
network with a maximum length of 500 meters?
The Medium Access Sublayer
Multiple Access Protocols
CSMA/CD

Exponential Backoff Algorithm:


• Ethernet uses the exponential backoff algorithms to determine
when a station can retransmit after a collision
The Medium Access Sublayer
Multiple Access Protocols
Performance of CSMA/CD

• Parameters and assumptions:


✔ End-to-end propagation delay: a
✔ Packet transmission time (normalized): 1
✔ Number of stations: N

• Time can be thought of as being divided in contention intervals


and transmission intervals.

• Contention intervals can be thought of as being slotted with slot


length of 2a (roundtrip propagation delay).
The Medium Access Sublayer
Multiple Access Protocols
Performance of CSMA/CD

✔ Contention slots end in a collision


✔ Contention interval is a sequence of contention slots
✔ Length of a slot in contention interval is 2a
✔ We assume that the probability that a station attempts to transmit in a slot is P
The Medium Access Sublayer
Multiple Access Protocols
Performance of CSMA/CD

✔ Contention slots end in a collision


✔ Contention interval is a sequence of contention slots
✔ Length of a slot in contention interval is 2a
✔ We assume that the probability that a station attempts to transmit in a slot is P
The Medium Access Sublayer
Multiple Access Protocols
Performance of CSMA/CD

• Derivation of maximum throughput of CSMA/CD:


• Let A be the probability that some station can successfully
transmit in a slot. We get:

• In the above formula, A is maximized when P=1/ N. Thus:


The Medium Access Sublayer
Multiple Access Protocols
Performance of CSMA/CD

• Prob [contention interval has a length of j slots] =


Prob [1 successful attempt] x Prob [ j-1 unsuccessful attempts] =

• The expected number of slots in a contention interval is then


calculated as:
The Medium Access Sublayer
Multiple Access Protocols
Performance of CSMA/CD

• Now we can calculate the maximum efficiency of CSMA/CD


with our usual formula:
The Medium Access Sublayer
Multiple Access Protocols
Collision-Free Protocols
Although collisions do not occur with CSMA/CD once a station
has unambiguously seized the channel, they can still occur
during the contention period. These collisions adversely
affect the system performance, especially when the cable is
long and the frames are short. As very long, high bandwidth
fiber optic networks come into use, the combination of large τ
and short frames will become an increasingly serious problem.
In the protocols to be described, we make the assumption that there
are N stations, each with a unique address from 0 to N-1 “wired”
into it.
The Medium Access Sublayer
Multiple Access Protocols
Collision-Free Protocols
A bit-map protocol

Protocols like this in which the desire to transmit is broadcast


before the actual transmission are called reservation protocols.
The Medium Access Sublayer
Multiple Access Protocols
Collision-Free Protocols
Performance of bit-map protocol

Assuming contention slot: 1 slot, data slot: d slots


Low-numbered stations must wait on the average 1.5N slots
and high-numbered stations must wait on the average 0.5N
slots before starting to transmit, the mean for all stations is N
slots.
Channel efficiency at low load: d/(N+d)

Channel efficiency at high load: Nd/(N+Nd)=d/(d+1)


The Medium Access Sublayer
Multiple Access Protocols
Collision-Free Protocols
Binary Countdown

A dash
Station’s binary indicates
address silence.
The Medium Access Sublayer
Multiple Access Protocols
Collision-Free Protocols
Binary Countdown

The channel efficiency of this method is d/(d+lnN). If,


however, the frame format has been cleverly chosen so that
the sender’s address is the first field in the frame, even these
lnN bits are not wasted, and the efficiency is 100%.

Variations: Use virtual station numbers. The successful


station being circularly permuted after each transmission.
Stations C H D A G B E F
Priority 7 6 5 4 3 2 1 0 if D transmits
Priority 7 6 0 5 4 3 2 1 others are promoted
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols

Two important performance measures for channel acquisition


strategies: delay at low load and channel efficiency at high
load
channel
delay efficiency
Light load Heavy load

Contention protocol good bad


Contention-free protocol bad good
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols

Obviously, it would be nice if we could combine the best


properties of the contention and collision-free protocols,
arriving at a new protocol that used contention at low loads to
provide low delay, but used a collision-free technique at high
load to provide good channel efficiency.

Such protocols will be called limited contention protocols.


The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols
Up until now the only contention protocols we have studied
have been symmetric, that is, each station attempts to acquire
the channel with some probability p, will all stations using the
same p.
Performance of the symmetric case: suppose that k stations are
contending for channel access, each has a probability p of
transmitting during each slot
The probability that some station successfully acquire the channel
is kp(1-p)k-1
Maximum occurs at p=1/k with Pr[success with optimal p]=
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols
As soon as the number of stations reaches even 5,
the probability has dropped close to it asymptotic
value of 1/e.
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols

Limited contention protocols decrease the amount of


competition by dividing the stations up into (not
necessarily disjoint) groups. Only the members of group 0
are permitted to compete for slot 0. If one of then succeeds, it
acquires the channel and transmits its frame.

If the slot lies fallow or if there is a collision, the members of


group 1 contend for slot 1, etc. by making an appropriate
division of stations into groups, the amount of contention for
each slot can be reduced, thus operating each slot near the
left end of Fig. 4-8.
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols
The adaptive tree walk protocol
Slot 0
Depth first search
for all ready
Slot 1 (if collision) stations
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols
When the load on the system is heavy, it is hardly worth the
effort to dedicate slot 0 to node 1, because that makes sense
only in the unlikely event that precisely one station has a frame
to send. Similarly, one could argue that nodes 2 and 3 should
be skipped as well for the same reason.

Put in more general terms, at what level in the tree should the
search begin?
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols
Assume that each station has a good estimate of the number of
ready stations, q, for example, from monitoring recent traffic.
Assume the root (node 1) is at level 0. Each node at level i has a
fraction 2-i of the stations below it.
If the q ready stations are uniformly distributed, the expected
number of them below a specific node at level i is just 2-iq.
Intuitively, we would expect the optimal level to begin
searching the tree as the one at which the mean number of
contending stations per slot is 1, that is, the level at which
2-iq=1. Solving this equation we find that i=log2q.
The Medium Access Sublayer
Multiple Access Protocols
Limited-Contention Protocols

Improvements:

For example, consider the case of stations G and H being


the only ones waiting to transmit.
Probe node 1: collision
Probe node 2: idle
Probe node 6: idle
Probe G Node 3 and node 7 can be
Probe H skipped. Why?
The Medium Access Sublayer
Multiple Access Protocols
Wireless LAN Protocols

The hidden terminal problem

When A transmits to B and C also transmits to B


simultaneously, the frames will be collided at B. Since A
and C can not see each other.
The Medium Access Sublayer
Multiple Access Protocols
Wireless LAN Protocols

The exposed terminal problem

When C hears B’s transmission intended for A, it may


falsely conclude that it can not send to D now.
The Medium Access Sublayer
Multiple Access Protocols
Wireless LAN Protocols

MACA (Multiple Access with Collision Avoidance)

MACA: basis for IEEE802.11 wireless LAN standard


The basic idea behind it is for the sender to simulate the
receiver into outputting a short frame, so stations nearby can
detect this transmission and avoid transmitting themselves
for the duration of upcoming (large) data frame.
The Medium Access Sublayer
Multiple Access Protocols
Wireless LAN Protocols
MACA (Multiple Access with Collision Avoidance)

RTS (30 bytes) and CTS contains the data length that will eventually
follow.
The Medium Access Sublayer
Multiple Access Protocols
Wireless LAN Protocols

MACA (Multiple Access with Collision Avoidance)

Any station hearing the RTS is clearly close to A and must


remain silent long enough for the CTS to be transmitted back
to A without conflict.

Any station hearing the CTS is clearly close to B and must


remain silent during the upcoming data transmission, whose
length it can tell by examining the CTS frame.
The Medium Access Sublayer
Multiple Access Protocols
Wireless LAN Protocols

MACA (Multiple Access with Collision Avoidance)

Despite these precautions, collisions can still occur. For


example, B and C could both send RTS frames to A at the same
time. In the event of a collision, an unsuccessful transmitter
(I.e., one that does not hear a CTS within the expected time
interval) waits a random amount of time and tries again later.
The algorithm used is binary exponential backoff.

You might also like