Download as odp, pdf, or txt
Download as odp, pdf, or txt
You are on page 1of 69

MAC Sublayer

COMPUTER NETWORKS
Data-link Layer
(The Medium Access Control Sublayer)

MAC Sublayer

Questions to be answered ?
In broadcast networks, How the
channel is divided between competing
users?
What is Medium Access Control

(MAC)?
What protocols are used for
allocating a multiple access
channel ? Computer Networks
2

MAC Sublayer

the need for determine who


gets to use the channel
- When there are two or more users
trying to use a shared single
channel there should be an algorithm
to control this access.
- This problem occurs in broadcast
networks which are known as
multiaccess channels.
Computer Networks

MAC Sublayer

What is MAC?
- Medium Access Control (MAC) is a
sublayer of the Data-link layer.
- The protocols used to determine who goes
next on a multiaccess channel belongs to a
MAC sublayer.
- MAC is important in LAN which use a
multiaccess channel as the basis for
communication.
Computer Networks

MAC Sublayer

The Channel Allocation Problem

There are two schemes to allocate


a single channel among competing users:
1) Static Channel Allocation.
2) Dynamic Channel Allocation

Computer Networks

Types of
MAC
Control:
Distributed.
Centralized.

How they coordinate medium access:


Round-robin.
Scheduled-access.
Contention-based.

Computer Networks

Contention-Based MAC

No control.
Stations try to acquire the medium.
Distributed in nature.

Computer Networks

MAC Protocols
Contention-based
ALOHA and Slotted ALOHA.
CSMA.
CSMA/CD.
Round-robin : token-based protocols.
Token bus.
Token ring.

Computer Networks

MAC Sublayer

Static Channel Allocation:


In this scheme a Frequency Division
Multiplexing (FDM) is used for allocating a
single channel among competing users.
Example
if we have N users, the bandwidth will be
divided into N equal-size portions.
++ FDM is a simple and efficient allocation
mechanism.
- - Waste of resources when the traffic is
bursty, or the channel is lightly loaded.
Computer Networks

MAC Sublayer

Dynamic Channel Allocation:


Before the discussion of algorithms used for
dynamic allocation we need to consider the
following assumptions.
1) Station Model: N independent stations
generate frames for transmission.
(Generate >Block >Transmission)
2) Single channel Assumption: Single
channel is available for all communication.
3) Collision Assumption
4) Continuous Time, or Slotted Time
5) Carrier Sense, or No Carrier sense
Computer Networks

10

MAC Sublayer

Multiple Access Protocols:


- ALOHA is a system proposed for solving
the channel allocation problem.

- there are two versions of ALOHA:


1) Pure ALOHA; 2) Slotted ALOHA
The basic difference with respect to
timing is:
Pure ALOHA does not require global
time synchronization;
Slotted ALOHA does
Computer Networks

11

Pure ALOHA

In pure ALOHA, frames are transmitted at completely


arbitrary times.

MAC Sublayer

Pure ALOHA
The system is working as follows:
1- let users transmit whenever they
have data to be sent.
2- expected collisions will occur.
3- the collided frames will be
destroyed.
4- using a feedback mechanism to
know about the status of frame.
5- retransmit the destroyed frame.
Computer Networks

13

Pure ALOHA (2)

Vulnerable period for the shaded frame.

MAC Sublayer

Pure ALOHA
The main disadvantage of Pure
ALOHA is a low channel utilization.
This is expected due to the feature that
all users transmit whenever they
want.

Computer Networks

15

ALOHAs
Let S represents the
number of good transmissions per
Performance

frame time, and G represents the total number of attempted


transmissions per frame time, then we have:
S = G (Probability of good transmission)

S = G e-2G, where S is the


throughput (rate of successful
transmissions) and G is the
offered load.
S = Smax = 1/2e
= Networks
0.184 for G=0.5.
Computer
16

The maximum throughput occurs at G = 0.5, with S = 1/2e, which


is about 0.184.
In other words, the best we can hope for is a channel
utilization of 18 percent.
This result is not very encouraging, but with everyone
transmitting at will, we could hardly have expected a 100 percent
success rate.

Computer Networks

17

MAC Sublayer

Slotted ALOHA
In this method the proposal was to divide the
time into discrete intervals each interval
corresponding to one frame.
In Slotted ALOHA, a computer can not send
anytime, instead it is required to wait for
the beginning of the time slot.
The big advantage of Slotted ALOHA is the
increase in channel utilization.
Computer Networks

18

Slotted ALOHA
Assumptions
all frames same size
time is divided into equal
size slots, time to transmit
1 frame
nodes start to transmit
frames only at beginning
of slots
nodes are synchronized
if 2 or more nodes
transmit in slot, all nodes
detect collision

Operation
when node obtains fresh
frame, it transmits in next
slot
no collision, node can send
new frame in next slot
if collision, node retransmits
frame in each subsequent
slot with prob. p until
success

Computer Networks

19

Pros

single active node can


continuously transmit at full
rate of channel
highly decentralized: only
slots in nodes need to be in
sync
simple

Cons
collisions, wasting slots
idle slots
nodes may be able to detect
collision in less than time to
transmit packet
clock synchronization

Computer Networks

20

SLOTTED
ALOHAs
Performance
Doubles performance
of ALOHA.
Frames can only be transmitted at beginning of
slot: discrete ALOHA.
Vulnerable period is halved.
S = G e-G.
S = Smax = 1/e = 0.368 for G = 1.

Computer Networks

21

Pure ALOHA (3)

Throughput versus offered traffic for ALOHA


systems.

MAC Sublayer

Slotted ALOHA
There is a limit for the best channel utilization
using Slotted ALOHA.
To reduce the chance of collisions the
station should be able to detect what
other stations are doing.
In LAN networks this is possible, therefore
they can achieve better utilization than
Slotted ALOHA.
Carrier Sense Protocols are protocols in
which stations listen for a carrier.
Computer Networks

23

MAC Sublayer

Carrier Sense Multiple Access


(CSMA) Protocols
There are several versions of carrier sense
protocols:
- 1-persistent CSMA
- Non-persistent CSMA
- P-persistent CSMA
- CSMA with Collision Detection (CSMA/CD)
Computer Networks

24

MAC Sublayer

Carrier Sense Multiple Access


(CSMA) Protocols
- In 1-persistent CSMA, a station prior to
send data it listen to the channel to see if
anyone else is transmitting at that moment.
- if the channel is busy, the station waits
until it becomes idle.
- If the channel is idle, the station transmits
a frame.
- If a collision occurs, the station waits a
random amount of time and starts all over
again.
Computer Networks
25

MAC Sublayer

Carrier Sense Multiple Access


(CSMA) Protocols
- Although this protocol has disadvantages,
it is better than ALOHA and Slotted
ALOHA
-1) Its performance depends on the
propagation delay.
-2) There is a chance when two
stations start transmission at the same
time.
Computer Networks

26

MAC Sublayer

Carrier Sense Multiple Access


(CSMA) Protocols
- In Non-persistent CSMA a station makes
conscious attempt to sense the channel.
- After the first attempt, if the channel is idle,
it sends, however, if the channel is already
in use, it waits a random period of time and
repeats the algorithm.
- (+ -)This algorithm has better utilization
but longer delays than 1-persistent
CSMA. Computer Networks
27

MAC Sublayer

Carrier Sense Multiple Access


(CSMA) Protocols
- In p-persistent CSMA a station transmits
if the channel is idle with a probability p
and with probability q=1-p it waits until the
next slot.

Computer Networks

28

MAC Sublayer

Carrier Sense Multiple Access


(CSMA) Protocols
- The main advantage of persistent and
non-persistent over ALOHA is that they
ensure no station begins to transmit when
it senses the channel busy.

Computer Networks

29

MAC Sublayer

CSMA with Collision Detection


- It is important that stations should
terminate transmission as soon as they
detect a collision.
- This protocol is called CSMA/CD.
- It is widely used on LANs in the MAC
sublayer.
- It is the basis of the popular Ethernet
LAN.
Computer Networks

30

CSMA with Collision Detection

CSMA/CD can be in one of three states: contention,


transmission, or idle.

worst-case scenario
Let the time for a signal to propagate between the two farthest stations be
. At t0, one station begins transmitting. At - , an instant before the
signal arrives at the most distant station, that station also begins
transmitting.

At time almost - , node As


message has almost arrived

Node A starts
transmission at time t0

Computer Networks

Node B starts
transmission at time
- ,

33

Of course, it detects the collision almost instantly and stops,


but the little noise burst caused by the collision does not get back to
the original station until time 2 - . In other words, in the worst
case a station cannot be sure that it has seized the channel until
it has transmitted for 2 without hearing a collision. For this
reason we will model the contention interval as a slotted ALOHA
system with slot width 2.
On a 1-km long coaxial cable, 5 sec. For simplicity we will
assume that each slot contains just 1 bit. Once the channel has
been seized, a station can transmit at any rate it wants to, of
course, not just at 1bit per 2 sec.
Computer Networks

34

MAC Sublayer

CSMA with Collision Detection


- Collision detection is an analog process.
Therefore, special encoding is commonly
used.
- A sending station must continually
monitor the channel, listening for noise
bursts that might indicate a collision. For
this reason, CSMA/CD with a single
channel is inherently a half-duplex system.

Computer Networks

35

Description of CSMA/CD

Binary exponential backoff refers to a collision resolution mechanism

1
2
3
4
5

used in random access MAC protocols. This algorithm is used in Ethernet (IEEE
802.3) wired LANs.
In Ethernet networks, this algorithm is commonly used to schedule retransmissions
after collisions.
After a collision, time is divided into discrete slots whose length is equal to 2,
where is the maximum propagation delay in the network.
The reason for this choice is that 2 is the minimum amount of time a source needs
to listen to the channel to always detect a collision.
The stations involved in the collision randomly pick an integer from the set {0,1}.
This set is called the contention window. If the sources collide again because they
picked the same integer, the contention window size is doubled and it becomes
{0,1,2,3}. Now the sources involved in the second collision randomly pick an integer
from the set {0,1,2,3} and wait that number of slot times before trying again. Before
they try to transmit, they listen to the channel and transmit only if the channel is idle.
This causes the source which picked the smallest integer in the contention window to
succeed in transmitting its frame.

Ethernet Cabling

The most common kinds of Ethernet cabling.

Ethernet Cabling (2)

Three kinds of Ethernet cabling.


(a) 10Base5, (b) 10Base2, (c) 10Base-T.

10BaseT, 10Base2, and 10Base5


alike in many ways.

They are all Ethernet (IEEE-802.3)


They all use Carrier Sense Multiple
Access/Collision Detection (CSMA/CD).
They all rely on MAC addresses to indicate
source and destination nodes.
They all use Baseband technology.
They use identical packet structures.

Transceiver
That part of the network interface that
transmits and receives the data signal.
The interface to the media.
It places 1s and 0s on the media and picks
up 1s and 0s from the media.

10Base5 External Transceiver


Vampire
Tap

In most modern networking


equipment the Transceiver is
part of the NIC.
Transceiver

NIC

Ethernet Cabling (3)

Cable topologies. (a) Linear, (b) Spine, (c) Tree, (d)


Segmented.

Ethernet Cabling (4)

(a) Binary encoding, (b) Manchester encoding,


(c) Differential Manchester encoding.

Limitations of Bus
Technologies

10Base5
o
o

500 Meters per segment


100 Nodes per segment

10Base2
o
o

185 Meters per segment


30 Nodes per segment

Repeater
Ethernet 2-Port Repeater

BNC-0

AUI-0

BNC-1

AUI-1

185 Meters (Max)

Ethernet 2-Port Repeater

Repeater

BNC-0

185 Meters (Max)

AUI-0

BNC-1

AUI-1

Repeaters, Hubs, Bridges, Switches,


Routers and Gateways

(a) Which device is in which layer.


(b) Frames, packets, and headers.

Physical Layer: Repeaters


Distance limitation in local-area networks
Electrical signal becomes weaker as it travels
Imposes a limit on the length of a LAN

Repeaters join LANs together


Analog electronic device
Continuously monitors electrical signals on each
LAN
Transmits an amplified copy

50

Physical Layer: Repeaters


Distance limitation in local-area networks
Electrical signal becomes weaker as it travels
Imposes a limit on the length of a LAN
Repeaters join LANs together
Analog electronic device
Continuously monitors electrical signals on each LAN

Transmits an amplified copy

Repeaters do not understand frames, packets, or headers. They understand


volts. Classic Ethernet, for example, was designed to allow four repeaters,
in order to extend the maximum cable length from 500 meters to 2500
meters.
51

The Repeater:

Takes the packets it receives from one


network segment,
Regenerates them,
Repeats them on another network segment.

Repeater

Benefits of the Repeater:


It can extend the length of a network.
It can increase the number of allowed nodes.
It can connect different types of cabling
together.
It can increase fault tolerance.

But Repeater does not manage


traffic; it merely repeats traffic.

Physical Layer: Hubs


Joins multiple input lines electrically
Do not necessarily amplify the signal
Very similar to repeaters

Disadvantages
Limited aggregate throughput due to shared link
hub
Cannot support multiple rates or formats
(e.g., 10 Mbps vs. 100 Mbps Ethernet)
Limitations on maximum # of
hub
hub
nodes and physical distance
54

The entire hub forms a single collision domain.


All the lines coming into a hub must operate at
the same speed. Hubs differ from repeaters in
that they do not (usually) amplify the incoming
signals and are designed to hold multiple line
cards each with multiple inputs, but the
differences are slight. Like repeaters, hubs do not
examine the 802 addresses or use them in any
way.

Limitations of Repeaters and Hubs


One large shared link
Each bit is sent everywhere
So, aggregate throughput is limited
E.g., three departments each get 10 Mbps
independently
and then connect via a hub and must share 10
Mbps

Cannot support multiple LAN technologies


Does not buffer or interpret frames
So, cant interconnect between different rates or
formats
56

Link Layer: Bridges


Connects two or more LANs at the link layer
Extracts destination address from the frame
Looks up the destination in a table
Forwards the frame to the appropriate LAN segment

Each segment can carry its own traffic


host

host

host

host

host

host

host

host

Bridge
host

host

host

host

57

The Bridge decides what to do


with the frame by looking at
the Destination Address.
006707 B1EE9B
Destination
Address

Source
Address

Data

CRC

Link Layer: Switches


Typically connects individual computers
A switch is essentially the same as a bridge
Supports concurrent communication

Cut-through switching
Start forwarding a frame while it is still arriving
switch/bridge
segment
hub

segment

segment

hub

hub

59

Link Layer: Switches


Typically connects individual computers
A switch is essentially the same as a bridge
though typically used to connect hosts, not LANs

Like bridges, support concurrent communication


Host A can talk to C, while B talks to D
B

C
switch

60

Dedicated Access and Full Duplex


Dedicated access
Host has direct connection to the switch
rather than a shared LAN connection

Full duplex
Each connection can send in both directions
Host sending to switch, and host receiving from
switch
E.g., in 10BaseT and 100Base T

Completely supports concurrent transmissions


Each connection is a bidirectional point-to-point link
61

Bridges/Switches: Traffic Isolation


Switch breaks subnet into LAN segments
Switch filters packets
Frame only forwarded to the necessary segments
Segments can support separate transmissions
switch/bridge
segment
hub

segment

segment

hub

hub

62

Advantages Over Hubs/Repeaters


Only forwards frames as needed
Filters frames to avoid unnecessary load on segments
Sends frames only to segments that need to see them

Extends the geographic span of the network


Separate segments allow longer distances

Improves privacy by limiting scope of frames


Hosts can snoop the traffic traversing their
segment
but not all the rest of the traffic

Can join segments using different technologies


63

Disadvantages Over Hubs/Repeaters


Delay in forwarding frames

Bridge/switch must receive and parse the frame


and perform a look-up to decide where to forward
Storing and forwarding the packet introduces delay
Solution: cut-through switching

Need to learn where to forward frames


Bridge/switch needs to construct a forwarding table
Ideally, without intervention from network
administrators
Solution: self-learning

Higher cost

64

Motivation For Cut-Through Switching


Buffering a frame takes time
Suppose L is the length of the frame
And R is the transmission rate of the links
Then, receiving the frame takes L/R time units

Buffering delay can be a high fraction of total


delay
Propagation delay is small over short distances
Making buffering delay a large fraction of total
Analogy: large group walking through NYC
A
B

switches

65

Cut-Through Switching
Start transmitting as soon as possible
Inspect the frame header and do the look-up
If outgoing link is idle, start forwarding the frame

Overlapping transmissions
Transmit the head of the packet via the outgoing link
while still receiving the tail via the incoming link
Analogy: different folks crossing different
intersections
A

B
switches

66

Hubs, Switches, and Routers


Hub/

Bridge/

Router

Repeater

Switch

Protocol layer

physical

link

networ
k

Traffic isolation

no

yes

yes

Plug and play

yes

yes

no

Efficient routing

no

no

yes

Cut through

yes

yes

no
67

Repeaters, Hubs, Bridges, Switches,


Routers and Gateways (2)

(a) A hub. (b) A bridge. (c) a switch.

TRANSPORT GATEWAY
Up another layer we find transport gateways. These
connect two computers that use different
connection-oriented transport protocols.
For example, suppose a computer using the
connection-oriented TCP/IP protocol needs to talk
to a computer using the connection-oriented ATM
transport protocol. The transport gateway can copy
the packets from one connection to the other,
reformatting them as need be.
69

APPLICATION GATEWAY
Finally, application gateways understand
the format and contents of the data and
translate messages from one format to
another.
An e-mail gateway could translate Internet
messages into SMS messages for mobile
phones, for example.
C
o
l
u
0 m
Ro
wn 3
Ro
w
1
3
2
1

70

You might also like