You are on page 1of 38

Switched Networks

Chapter 3 Medium Access Control Sublayer

Dr.-Ing. Torben Weis


University Duisburg-Essen

Channel Allocation Problem (1)

Multiple stations access one channel Two different approaches What do we expect?
Static Simple Dynamic Efficient
Institut fr Informationstechnik

How to avoid collisions?

Static Channel Allocation Dynamic Channel Allocation

Torben Weis

Channel Allocation Problem (2)


Example:

Human protocols:

Cocktail party many people gather in a large room Broadcast medium = air Give everyone a chance to speak Dont speak until you are spoken to Dont monopolize the conversation Raise your hand if you have a question Dont interrupt when someone is speaking Dont fall asleep when someone else is talking

Institut fr Informationstechnik

Torben Weis

Channel Allocation Problem (3)


If more than 2 users send at the same time collision All collided packets are lost waste of bandwidth Ideally, the MAC protocol for a broadcast channel with R bit/sec should satisfy:

If only 1 node is sending than the throughput is R When M nodes have data to send than the throughput is R/M Decentralized protocol, i.e. no master Simple & inexpensive to implement
Institut fr Informationstechnik Torben Weis 4

Protocol Layer
Layer Layer55 Layer Layer44 Layer Layer33 Layer Layer22 Layer Layer11
Network Layer Data Link Layer Physical Layer Application Layer Transport Layer

Layer Layer55 Layer Layer44


Network Layer Data Link Layer Physical Layer

Layer Layer33 Layer Layer22 Layer Layer11

Layer Layer33 Layer Layer22 Layer Layer11

Layer Layer33 Layer Layer22 Layer Layer11

Data Link Layer puts frames on the wire What happens if multiple stations want to put frames on the medium (wire) at the same time? => Medium Access Control (MAC) is required
Institut fr Informationstechnik Torben Weis 5

Medium Access Control Sublayer


Layer Layer55 Layer Layer44 Layer Layer33 Layer Layer22 MAC MAC Layer Layer11
Physical Layer Network Layer Data Link Layer Application Layer Transport Layer

Layer Layer55 Layer Layer44


Network Layer Data Link Layer

Layer Layer33 Layer Layer22 MAC MAC Layer Layer11

Layer Layer33 Layer Layer22 MAC MAC Layer Layer11

Layer Layer33 Layer Layer22 MAC MAC

Physical Layer

Layer Layer11

MAC is not part of the OSI Model MAC is a sublayer of the Data Link Layer
Institut fr Informationstechnik Torben Weis 6

Static Channel Allocation


Frequency Division Multiplexing (FDM) Time Division Multiplexing (TDM)

Institut fr Informationstechnik

Torben Weis

Frequency Division Multiplexing (1)


Uses static allocation Channel has a bandwidth of H n stations are connected to the cable Idea

Result

Divide the bandwidth in H/n frequency bands Assign one band to one station No collisions possible Delay increased by factor n

Institut fr Informationstechnik

Torben Weis

Frequency Division Multiplexing (2)

(a) The original bandwidths (b) The bandwidths raised in frequency (b) The multiplexed channel
Institut fr Informationstechnik Torben Weis 9

Time Division Multiplexing (1)


Uses static allocation Channel transfers B bit/sec n stations are connected to the cable Idea
Allocate n time slots of length t Round robin Each station transfers B*t bits per slot No collisions possible Delay increased by factor n
Institut fr Informationstechnik Torben Weis 10

Result

Time Division Multiplexing (2)

Institut fr Informationstechnik

Torben Weis

11

Dynamic Channel Allocation (1)


Station Model

n independent stations Each station wants to send frames is the constant arrival rate Probability of sending a frame in time t is t

Institut fr Informationstechnik

Torben Weis

12

Dynamic Channel Allocation (2)


Single Channel Assumption

All stations connected to the same channel All stations are equivalent Every station can send/receive Optional
Priorities can be assigned to stations

Institut fr Informationstechnik

Torben Weis

13

Dynamic Channel Allocation (3)


Collision Assumption
Two stations sending at overlapping time intervals collision the transmitted data is garbled After a collision, data must be sent again Stations can detect collisions No other errors, only collisions

Institut fr Informationstechnik

Torben Weis

14

Dynamic Channel Allocation (4)


Continuous Time Slotted Time

Time is not slotted Station can attempt to send any time Time is slotted (divided in discrete intervals) Frame transmission starts at the beginning of a slot

Institut fr Informationstechnik

Torben Weis

15

Dynamic Channel Allocation (5)


Carrier Sense

No Carrier Sense

Channels are either busy or idle Station can sense whether the channel is busy Before sending, the station checks the channel Station cannot sense the channel Stations just transmit After sending the station knows whether it was successful or not Problem: A transmission has been destroyed

Institut fr Informationstechnik

Torben Weis

16

Dynamic Channel Allocation (6)


Station Model Single Channel Assumption Collision Assumption (a) Continuous Time (b) Slotted Time (a) Carrier Sense (b) No Carrier Sense

Institut fr Informationstechnik

Torben Weis

17

Multiple Access Protocols


ALOHA Carrier Sense Multiple Access Protocols Collision-Free Protocols Limited-Contention Protocols Next week

Wavelength Division Multiple Access Protocols Wireless LAN Protocols

Institut fr Informationstechnik

Torben Weis

18

ALOHA (1)
Norm Abramson at the Univ. of Hawaii mountainous islands land network difficult to install

ACK ACK

ACK ACK

Institut fr Informationstechnik

Torben Weis

19

ALOHA (2)
M nodes can create new frames at any time The node immediately transmits its frame completely on a shared frequency Base station acknowledges packages on a dedicated frequency If the frame collides No ACK is received Retransmission with probability p avoids efficiency to become 0
Institut fr Informationstechnik Torben Weis 20

(Different in slotted ALOHA)

Pure ALOHA

In pure ALOHA, frames are transmitted at completely arbitrary times.


Institut fr Informationstechnik Torben Weis 21

Pure ALOHA (2)

Vulnerable period for the shaded frame = 2t.


Institut fr Informationstechnik Torben Weis 22

Slotted ALOHA
Idea

Result

Create time slots of length t Transmission only at beginning of each time slot Vulnerability reduced from 2t to t We doubled the throughput How does everybody agree on time slots?

Problem

Institut fr Informationstechnik

Torben Weis

23

Pure and Slotted ALOHA

Throughput versus offered traffic for ALOHA systems


Institut fr Informationstechnik Torben Weis 24

Evaluating Aloha
Assumption: Channel can transmit R bit/sec Checklist: If only 1 node is sending than the throughput is R - When M nodes have data to send than the throughput is R/M Decentralized protocol Simple & inexpensive to implement
Institut fr Informationstechnik Torben Weis 25

Carrier Sense Multiple Access (1)


CSMA = Carrier Sense Multiple Access Invented to minimize collisions and increase the performance A station now follows the activity of other stations Simple rules for polite human conversation
Carrier Sense Listen before speaking If someone else begins talking at the same time as you, stop talking
Institut fr Informationstechnik Torben Weis 26

Carrier Sense Multiple Access (2)


If everyone is sensing the medium, how can collisions still occur?

channel propagation delay

Institut fr Informationstechnik

Torben Weis

27

1-persistent CSMA
The protocol

It is called 1-persistent because the station transmits with a probability of 1 whenever it finds the channel idle.

Listen before transmitting If channel busy, wait until is channel idle If channel idle, transmit If collision occurs, wait a random amount of time and start all over again

Institut fr Informationstechnik

Torben Weis

28

Nonpersistent CSMA
The protocol

What is special?

Listen before transmitting If busy, wait a random amount of time and sense the channel again If idle, transmit a packet immediately If collision occurs, wait a random amount of time and start all over again The station does not sense all the time less greedy than 1-persistent CSMA

Institut fr Informationstechnik

Torben Weis

29

p-persistent CSMA
Applies to slotted channels The protocol

Listen before transmitting If channel busy, wait until is channel idle If channel idle Transmit with probability p Wait for next slot with probability q=1-p If collision occurs, repeat the above procedure

Institut fr Informationstechnik

Torben Weis

30

Persistent and Nonpersistent CSMA

Comparison of the channel utilization versus load for various random access protocols
Institut fr Informationstechnik Torben Weis 31

Collision Detection (1)


1. Waiting for an acknowledge (ACK)

2. Sending and receiving

ACK is sent after the frame has been transmitted Frames with collisions are transmitted completely Waiting for ACK wastes time and bandwidth Check, whether you receive what you have sent Collisions can be detected early This is called Collision Detection or just CD

Institut fr Informationstechnik

Torben Weis

32

Collision Detection (2)


When is a collision detected ? Station A sends at time t0 Signal needs to the most distant station X At t0+- station X sends, too
X sensed that the channel is idle

The signal of X needs to station A Result: A must wait 2- before it can detect a collision Problem: Maximum value of depends on the maximum distance between stations
Institut fr Informationstechnik Torben Weis 33

CSMA with Collision Detection

Senders can detect collisions while sending Collision Detection

Institut fr Informationstechnik

Torben Weis

34

Collision-Free Protocols (1)

The basic bit-map protocol

Institut fr Informationstechnik

Torben Weis

35

Collision-Free Protocols (2)


The bitmap protocol is a reservation protocol Overhead calculation for the reservation

Every station (N in total) wants to send a frame Overhead = 1 contention slot per N frames = 1 bit

Only one station wants to send a frame Overhead = 1 contention slot for 1 frame = N bits

Institut fr Informationstechnik

Torben Weis

36

Collision-Free Protocols (3)

The binary countdown protocol A dash indicates silence


Institut fr Informationstechnik Torben Weis 37

Collision-Free Protocols (4)


Binary countdown is a reservation protocol, too Overhead calculation for the reservation
N stations in total At least one wants to send Contention slot has length log2 N

Optimization

Many frames carry the sender address Efficiency can become 100%
Institut fr Informationstechnik Torben Weis 38

Collision-Free Protocols (5)


Binary countdown uses priorities High addresses always win Low addresses can starve to death Possible fix

Address numbers circulate After sending a frame, address numbers are shifted The sending station gets a low address

Institut fr Informationstechnik

Torben Weis

39

Limited-Contention Protocols

Acquisition probability for a symmetric contention channel


Institut fr Informationstechnik Torben Weis 40

Adaptive Tree Walk Protocol (1)

The tree for eight stations


Institut fr Informationstechnik Torben Weis 41

Adaptive Tree Walk Protocol (2)


Idea

Best of both worlds

Limit the number of participants in the contention First, everybody may try to send Collision halve the participants Low delay when there are few collisions Low delay when many station bid for the channel
Almost as good as reservation protocols As good as slotted ALOHA

Institut fr Informationstechnik

Torben Weis

42

Wavelength Division Multiple Access Protocols

Institut fr Informationstechnik

Torben Weis

43

Manchester Code (1)


How to represent 0 and 1 on the wire? Idea 1

Idea 2

1 = +5 Volt, 0 = 0 Volt Problem: How to differentiate 00000000 from an idle sender ? 1 = +5 Volt, 0 = -5 Volt Problem: We cannot be sure that all receivers sample the signal at the same rate (clock drift)

We need a self-clocking encoding


Institut fr Informationstechnik

Torben Weis

44

Manchester Code (2)


Encode 1 bit as 2 bits

This is called Manchester Code


It is used by Ethernet (we will come to that later)

1 = 10 0 = 01 Good news: the signal oscillates in the middle of every bit Bad news: We waste half of the bandwidth

Institut fr Informationstechnik

Torben Weis

45

Manchester Code (3)

Institut fr Informationstechnik

Torben Weis

46

Differential Manchester Code


Encode 1 bit as 2 bits The encoding of bit n depends on the encoding of bit n-1
If n = 1 If n = 0
n-1 encoded as 10 ? -> n = 01 n-1 encoded as 01 ? -> n = 10 n-1 encoded as 10 ? -> n = 10 n-1 encoded as 01 ? -> n = 01

Advantage: Better noise immunity Disadvantage: Requires more complex equipment


Institut fr Informationstechnik Torben Weis 47

IEEE Standard 802 for LANs


Ethernet: Token Bus: Token Ring: Wireless: IEEE IEEE IEEE IEEE 802.3 802.4 802.5 802.11

Institut fr Informationstechnik

Torben Weis

48

IEEE 802.5 Token Ring

Institut fr Informationstechnik

Torben Weis

49

Token Ring Physical Length (1)


A 3 byte token circulates on the ring Sender must not receive its own token data before it sends the last token bit How many bits fit on the ring?

Institut fr Informationstechnik

Torben Weis

50

Token Ring Physical Length (2)


Each station buffers 1 bit

The cable carries some bits

Problem: station can be taken off the net

Additional buffers are required


Institut fr Informationstechnik

Data rate of R Mbit/sec A bit is emitted every 1/R sec Signal propagation speed 200 m/sec Each bit occupies 200/R m Example: R=1 Mbit/sec, length = 1000m Each bit occupies 200m 5 bits on the ring cable

Torben Weis

51

Token Passing (1)

TK

PKT

T PK

T PK

TK

The Token rotates around the ring

Station A captures the Token and converts it to a Packet

Station A transmits the packet

Staton A waits for the Packet

Station A releases the Token

Release After Reception (RAR)

Institut fr Informationstechnik

Torben Weis

52

Token Passing (2)

TK

T PK

T PK

TK

The Token rotates around the ring

Station A captures the Token and converts it to a Packet

Station A transmits the Packet and immediately releases the Token

Release After Transmission (RAT)

Institut fr Informationstechnik

Torben Weis

53

Token Passing (3)


The ring can contain:

The token must fit on the ring The size of a data frame is not limited

A token A data frame (or both in release after transmission)

A data frame is not entirely on the ring The sender can receive its own frame while still sending Can be used for error detection
Institut fr Informationstechnik Torben Weis 54

Token Passing (4)


Is starvation possible?

Stations s1, s2, sn Station si fetches the token and transmits data Then, si issues a new token si+1 can get the token Full load round robin Token ring is fair
as long as only one priority is used
Institut fr Informationstechnik Torben Weis

i.e. a station wants to send but never gets the token ? Answer: No

55

Token Ring Wiring


Wire center

bypass relays

Institut fr Informationstechnik

Torben Weis

56

Token Ring Multistation Access Unit (MSAU)

Institut fr Informationstechnik

Torben Weis

57

Token Ring - Active Monitor


Some station must

This station is the active monitor (AM) All other stations are standby monitors (SM) The active monitor is elected
The station with the largest MAC wins
Institut fr Informationstechnik

inject the token detect circulating frames send a continuous signal (e.g. Differential Manchester encoded 0) to synchronize all stations

Torben Weis

58

Joining a Token Ring


1. (Lobe Check) - Performs a lobe media check to see whether frames are received without error. 2. (Physical Insertion) - A station then sends a 5 volt signal to the MSAU to open the relay. 3. (Address Verification) - A station then sends a message to is own MAC If the Copied flag is set -> The MAC is already used 4. (Participation in Ring Poll) - The station must participate in the periodic (every 7 seconds) ring poll process. 5. (Request Initialization) - Finally a station sends out a special request to a parameter server to obtain configuration information.
Institut fr Informationstechnik Torben Weis 59

Token Structure (1)


SD AC ED 1 1 1 SD AC ED = = = Starting Delimiter Access Control Ending Delimiter

SD JK0JK000 AC PPPTMrrr

J - Phase Violation J K - Phase Violation K 0 - Binary Zero PPP - Priority Bits T - Token Bit M - Monitor Bit rrr - Reservation Bit J - Phase Violation J K - Phase Violation K 1 - Binary One I - Intermediate Bit E - Error Bit
Institut fr Informationstechnik Torben Weis 60

ED JK1JK1IE

Token Structure (2)


SD AC ED 1 1 1 SD AC ED = = = Starting Delimiter Access Control Ending Delimiter

SD JK0JK000

J - Phase Violation J K - Phase Violation K 0 - Binary Zero

The manchester code violation enables a receiver to detect the start of a token Violation is achieved by not switching in the middle of a bit J K assures that the signal is still oscillating
Torben Weis 61

Institut fr Informationstechnik

Data Frame Structure


SD AC FC DA SA 1 SD AC FC DA SA ED FS = = = = = = = 1 1 6 6 DATA n ED FS 1 1

Starting Delimiter Access Control Frame Control Destination Address Source Address Ending Delimiter Frame Status

FC FFZZZZZZ FS AC00AC00

FF - Frame Type ZZZZZZ - Control Bits A = Address Recognized C = Frame Copied


Torben Weis 62

Institut fr Informationstechnik

Token Ring Priority

Institut fr Informationstechnik

Torben Weis

63

IEEE Standard 802 for LANs


Ethernet: Token Bus: Token Ring: Wireless: IEEE IEEE IEEE IEEE 802.3 802.4 802.5 802.11

Institut fr Informationstechnik

Torben Weis

64

IEEE 802.4 Token Bus

Physical: Bus (solid line) Logical: Ring (dashed line)


Institut fr Informationstechnik Torben Weis 65

Why Token Bus ?


Combines:

Different application domains


Pushed by General Motors Real-time important

Cabling of Ethernet (single wire) Determinism of Token Ring

Token Ring / Ethernet: Office Token Bus: Industrial automation

Institut fr Informationstechnik

Torben Weis

66

Token Bus Frame Format

Comparable to IEEE 802.5 format, but unfortunately different

Institut fr Informationstechnik

Torben Weis

67

Token Bus - Messages

Institut fr Informationstechnik

Torben Weis

68

Token Bus MAC Protocol (1)


Initializing a ring
90

Station 90 wants to join

Station 90 detects that there is no traffic Station 90 sends claim_token(90) The station with the highest MAC wins

Institut fr Informationstechnik

Torben Weis

69

Token Bus MAC Protocol (2)


Joining a ring
90 80 70 60

Station 80 wants to join

90 periodically sends solicit_successor(90,70) Station between 90 and 70 may respond 80 sends set_successor(90,80)

Institut fr Informationstechnik

Torben Weis

70

Token Bus MAC Protocol (3)


Joining a ring, part 2
90 80 70 60

Stations 80 and 70 want to join


90 periodically sends solicit_successor(90,60) Station between 90 and 60 may respond 80 and 70 send set_successor(90,xx) collision 90 sends resolve_contention The winner sends set_successor(90,xx)
Institut fr Informationstechnik Torben Weis 71

Token Bus MAC Protocol (4)


Contention Resolution
Station A two random bits Station B

address bits

Use the address bits, two bits at a time, starting from the most significant bit (MSB) To avoid that larger number nodes always win:
Add two random bits before the MSB Regenerated random bits periodically
Institut fr Informationstechnik

L L

Torben Weis

72

Token Bus MAC Protocol (5)


Leaving a ring
90 80 70 60

Stations 80 wants to leave

80 waits for the token 80 sends set_successor(90,70) 90 has new successor 70 has new predecessor

Institut fr Informationstechnik

Torben Weis

73

Token Bus MAC Protocol (6)


Station failure
90 80 70 60

Station 80 fails

90 sends token. If 80 does not reply, 90 sends again Still no response 90 sends who_follows(90,80) 70 sends set_successor(90,70)

Institut fr Informationstechnik

Torben Weis

74

Token Bus MAC Protocol (7)


Station failure, part 2
90 80 70 60

Stations 80 and 70 fail


90 sends token. If 80 does not reply, 90 sends again No response 90 sends who_follows(90,80) No response 90 sends solicit_successor_2(90) Any alive station sends set_successor(90,xx)

Institut fr Informationstechnik

Torben Weis

75

You might also like