Medium Access Control Protocols · Medium Access Control Protocols Ch. 6 Leon-Garcia & Widjaja....

Post on 28-Feb-2021

10 views 1 download

Transcript of Medium Access Control Protocols · Medium Access Control Protocols Ch. 6 Leon-Garcia & Widjaja....

Medium Access Control Protocols

Ch. 6Leon-Garcia & Widjaja

Multiple Access Communications

● Shared Multiple Access Medium– Air for wi-fi

– Ether for ethernet

● Separate channels (channelization)– Collision free

– Static sharing

● Dynamic sharing (MAC)– Collisions possible

– Flexible sharing

Channelization Schemes

● Good for steady streams of data● The channels could be based on frequency or

scheduling● Old style radio and TV had channels● Satellites have channels● Most cell-phone protocols involve

channelization

MAC Schemes● Various techniques to avoid or handle

collisions● Multidrop lines

– Old style terminals connected to a mainframe computer

– Sensor networks on robotics/automotive/automation networks

– Use polling

● Ring networks– Ring adapters connected with point-2-point lines

– Each adapter monitors traffic.

MAC Schemes

● Shared buses (ethernet)● Frames are injected into the bus● Collisions can happen● Need methods to detect and handle collisions● These range from “do nothing” to exact

scheduling

MAC Schemes

● Wi-Fi● Shared wireless medium● Great variety of services● Need to optimize the use of the resource● Satisfy very different needs (QoS)

A Simple Protocol

● Two stations sharing a medium● Each station monitors the medium● If all is quiet and needs to send it, sends● If not quiet, waits● If while transmitting it detects a collision it

aborts and retries● Needs a “backoff” algorithm

A Simple Protocol

BA

BA

BA

t = 2 t pro

t = 0

A Simple Protocol

● If B starts transmission between time -t_prop and t_prop, there will be a collision

● Station A will detect this sometime between time 0 and 2*t_prop

● They should decide who goes first– If we know t_prop, the one that started first

● The winning station should stay quiet for 2*t_prop after sending its message

A Simple Protocol

LX = L/RL /R + 2 t pro

2 t pro Time to coordinate access

Number of bits in a frame

Time to transmit L bits

Total time to get L bits across(first bit leaves sender to last bitArrive at receiver)

A Simple Protocol

a=t proR

L=t prottra

=1

1+2 t pro R

L

=1

1+2a

ρmax =

LR

LR

+2 t pro

=L

(LR

+2 t pro )R

A Simple Protocol

● Parameter “a” is the normalized “delay-bandwidth” product

● When “a” is very small efficiency is high● Parameter “a” is small for small distances and

low transmission rates– Efficient for small area fast networks (LAN)

– Large slow networks

● CSMA-CD (Carrier Sensing Multiple Access – Collision Detection) has similar efficiency (but 6.44 instead of 2)

Selecting a Protocol

● Efficiency● Frame Transfer Delay

– Time between first bit getting to the source until last bit arrives at destination

● Fairness (compliance to priorities policy)● QoS (streaming vs. bursty traffic)● Scalability● Cost

Transfer Delay

● Every MAC protocol has a maximum efficiency● As the load (normalized throughput)

approaches the max efficiency the delay increases (due to waiting, collisions and retransmissions)

● At max. utilization delay goes to infinity● If “a” is small max efficiency is close to 1

Transfer Delaya<a '

a '

ρ ' max

a

ρmax

Random Access

● Two main classes of MAC protocols– Random

– Scheduling

● Random is not as bad an idea as it sounds– Simple

– No (or few) scheduling decisions to take

– We can proceed without wasting time for collision detection

ALOHA

● Obviously from Hawaii● Frames were transmitted by radio● Sometimes frames collide● These will be detected as errors and ARQ will

take care of them● Under light traffic retransmissions and delay

will be low

ALOHA

● Analysis is a bit different as transmission errors affect one communication pair while collisions affect two

● Backoff algorithm for ALOHA is simple: random wait for retransmission

● If no ACK received, we backoff and re-transmit

ALOHA

● ALOHA has two modes● Low traffic

– Collisions are few and have little effect

● High traffic– Most traffic is retransmissions due to collisions

– Every frame is attempted several times before it succeeds

ALOHA

SGX = L/Rt 0−X… t0+X

L Bits per frame

Frames transmitted per X seconds

Frames transmitted incl.Retransmissions per X sec

Time to transmit a frame

Vulnerable period

ALOHA

S =G P0

G = S (1+P≥1+P≥12

+...)

G = S1P0

G = S +S P≥1+S P≥12 + ...

G = S1

1−P≥1

ALOHA

Pk =( 2G )k

k !e−2G

S =G P0

S=G(2G )0

0!e−2G

=Ge−2G

Maximum Throughput

e−2G= 2Ge−2G

⇒G =12

S =G e−2G

∂ S∂G

= e−2G−2Ge−2G

= 0

Efficiency

● The throughput is maximal when the number of packages (including retransmissions) is 50% of the capacity

● This means that just 18.4% of the channel capacity is useful traffic

● And this is independent of delay-bandwidth product!

Slotted ALOHA

● Can we do better?● If we require packets to start transmission at

the beginning of pre-arranged time slots the vulnerability interval is halved

● We get a step closer to TDMA

Efficiency of Slotted ALOHA

∂ S∂G

= e−G−G e−G = 0

G=1

S =G e−G

The Verdict

● ALOHA is not that bad● Low efficiency is sometimes compensated by

simplicity:– No need to know any system parameter

– Very simple to implement

– Does not depend on the normalized bandwidth-delay product: it is good for small packages

Carrier Sense Multiple Access

● What did a CSMA tomato say to an ALOHA tomato that crossed the road?

● Moral of the story: look before you cross● Sense the carrier and if it is quiet transmit● Within t_pro everybody knows that we are

transmitting● Collisions are still possible

1-Persistent CSMA

● If channel quiet transmit● If busy wait until quiet● Problem?● While transmitting, packets will queue up● At the end of the transmission all of them will

attempt

Non-Persistent CSMA

● If busy use the backoff algorithm to determine when to sense again

● Fewer collisions than 1-Persistent● Has slightly longer delays than 1-Persistent in

low traffic

P-Persistent CSMA

● Sense the channel. If busy keep sensing● When/if idle use a random number generator

to decide what to do● With probability p transmit● With probability 1-p wait t_pro time and select

a random number again

CSMA-CD

● Like the previous CSMA-CD we can find within 2*t_pro if we have a collision

● If a collision is detected we send a jamming signal to notify all that there was a collision

● Use a backoff algorithm to decide when to try again

CSMA-CD

p

P suc= n p(1− p)n−1

n

P suc⩽ n1n (1−

1n )

n−1

= (1−1n )

n−1

→1e

p=1n

2 t pro Contention interval

Probability to transmit

Number of contenders

Value that maximizesProbability of success

Efficiency of CSMA-CD

a =t proX

Where:

Silence after transmission

ρmax =X

X +t pro+2e t pro=

11+(2e+1)a

Duration of contention interval

The Verdict

● For low traffic or low “a”, efficiency is high● When “a” approaches 1 performance is worse

than ALOHA● Sayonara!● Seems we can use some collision detection!

Scheduling Approaches

● If efficiency is low we need to consider scheduling

● Between random and TDMA there are several intermediate approaches

● Reservation systems● Polling● Token rings

Reservation Systems

● Stations take turns transmitting at full rate● Each station gets a reserved slot if it needs to

transmit● Every cycle starts with a reservation interval● Simplest reservation interval has M 1-bit slots

– If a station wants to transmit it broadcasts “1” in its bit, o/w “0”

● Could also handle frame lengths with more reservation bits

Efficiency of Reservation Systems

u=tmsX

ρmax =X

X +M tms=

11+M u

X Time we transmit information

Efficiency if one station transmit

Fraction of the minislot time

ρmax =X

X +tms=

11+u

Efficiency if all stations transmit

Multi-slot Reservations

● A station might reserve more than one slot– A form of variable size slots

ρmax =1

1+u/ k

Avg number of slots

Many Stations Little Traffic

● Most of the transmission would be reservation traffic

● Use a random access technique for the reservation slot (ALOHA or slotted ALOHA)

● ALOHA has rather low efficiency– That's OK, it is just reservation info

– Allows us to have arbitrary/dynamic number of stations

Minislot Reservation with ALOHA

● Slotted ALOHA has low efficiency● We need to allocate time for more minislots● If we have allocated the right number of

minislots

ρmax =1

1+2.72uρALOHA=

12.72

Polling

● Another way to have orderly access to medium

● At every one instant one station only has the right to transmit

● Three main ways to manage the right to transmit

Right to Transmit

● Polling by a central controller over lines– One out-, one in-bound

– Polling in RR fashion

– HDLC was initially developed for this

● Over radio– Frequency division duplex

– Time division duplex

Masterless Polling

● Can be done without central controller● We have to establish a way to determine

polling order● All transmissions must be accessible by all● Token rings are of this nature

Polling Protocol

● Controller polls every station in turn● Stations may respond with a frame of “nothing to

declare” (or timeout)● Or if a station has something to transmit, transmits

it, o/w next station is polled● The time consumed in polling of a station is called

walk time● Total walk time is the sum of the walk times of all

stations in one cycle

Walk Time

● The components of the walk time are:– Propagation time

– Processing time

– Time to transmit the polling message

Avg Cycle Time

N̄ c

N̄ c X + tw

T̄ c = M ( N̄ c X +tw)= M ( λMT̄ c X + tw)

λ

ρ=λ X

M

: total arrival rateλM

: number of stations

T̄ c

N̄ c =λMT̄ c : avg number of messages in one cycle

: avg cycle time

T̄ c =M tw

1−λ X=M

tw1−ρ

: load (always less than one)ρ

: time spent at each station

Efficiency

ηT̄ c = M

tw1−ρ

η =T̄ c−M twT̄ c

=

Mtw

1−ρ−M tw

Mtw

1−ρ

= 1−M twM tw1−ρ

= ρ

: efficiency

Token Rings

● Successful distributed polling system● Every node has an interface connected with

two point-to-point lines to other interfaces in a ring

● Every interface listens, forwards, consumes, modifies, or copies incoming frames

● One of the frames is “the token”. Can be free or busy. Can be more than one

Token Rings

● When a free token arrives to an interface– If the node wants to transmit converts it to busy

token and transmits

● There are three ways to re-inject the free token in the ring– Immediately after the end of the transmission

(multitoken)

– Immediately after the busy token returns and the last bit of the frame transmitted (single token)

– Immediately after the last bit of the transmitted frame returns and is checked for errors (single frame)

Efficiency

ρmax=MX

M max (X , t ' )+t '=

1

max(1 , t ' / X )+t 'MX

ρmax=MX

M (X +t ')+ t '=

1

1+a ' (1+1M

)

Multitoken

Single token

ρmax=MX

MX + t '=

1

1+t 'MX

t ' = t+M bR

a '=t 'X

Single frame

Ring latency

Efficiency

ρmax =1

max(1 , t ' /X )+t 'MX

=1

max (1 , a ')+a 'M

ρmax =1

1+a ' (1+1M

)

Multitoken

Single token

ρmax=1

1+t 'MX

=1

1+a 'M

t ' = t+M bR

a '=t 'X

Single frame

Ring latency

Comparison (poll vs reserve)

● Token passing rings are extension of polling– Similar to TDMA, but dynamic

– Need to recover from errors

● Reservation systems are the most direct– But have to maintain gaps between transmissions

– Have to have a central node

● Polling systems are the most basic– Their overhead is the walk times

Comparison (random vs scheduled)

● Random methods are simple and efficient with light loads

● Random access make inefficient use of bandwidth at high loads

● The overhead of random methods is the cost of resolving conflicts (retransmissions)

● A key parameter is the normalized delay-bandwidth product (except ALOHA)

FDMA

● Each channel is on different frequency band● In real life we need guard bands

– For first approximation neglect guard bands

● Each station uses the band all the time– Good for connection oriented systems

● If traffic is bursty could give a band to more than one stations and let them share it with a dynamic scheme– The cost is collisions

FDMA

● Good for steady stream, connection oriented traffic– E.g. cellular telephony

● Cost of guard bands– We cannot split the bandwidth very thinly

TDMA

● Stations take turns making use of the full bandwidth

● Different stations have different propagation delays

● Need guard times to account for this● We also need preamples (e.g. to sync clocks

before transmission)● Also bad for bursty traffic

CDMA

● Code Division Multiple Access– Not separated in time (TDMA)

– Not separated in frequency (FDMA)

● CDMA uses the whole band all the time● The secret is in the code

CDMA● Zeros are represented by -1, ones by 1● Sender and receiver share a “code”

– The code is a pseudo random sequence of -1s and 1s

● Sender multiplies every bit of his signal by G bits from the code

● The transmitted signal is G times longer● G is the spreading factor● CDMA is a spread spectrum method

CDMA

c2 = 1,1,−1,1

w1 = 1,−1,1,−1, −1,1,−1,1, −1,1,−1,1, 1,−1,1,−1

s1 = 1,−1,−1,1

w1∗c2 = −2,2, 2,−2

c1 = 1,−1,1,−1

w1∗c1 = 4,−4,−4, 4

w1∗c1 = 1+1+1+1,−1−1−1−1,−1−1−1−1, 1+1+1+1

w1∗c2 = 1−1−1−1,−1+1+1+1,−1+1+1+1,1−1−1−1

CDMA

● Near-far problem● Power control mechanisms● Long synchronized pseudo-random

sequences

LAN Protocols

● LANs are– High speed

– Low cost

– Reliable

– Small area

● Need different approach than wide area networks

LAN Protocols

● Developed by the IEEE 802● Examples include

– Ethernet (100BaseT4, 100BaseTX, 100BaseFX, 1000BaseT, etc). AKA IEEE 802.3

– WiFi IEEE 802.11

– FDDI IEEE 802.5

● Has evolved considerably since it was invented

LAN Structure

● Bus, ring, star● Twisted pair, coaxial, fiber, airwaves● 6 byte globally unique MAC address for every

NIC– 3 bytes vendor OUI

– 3 bytes device

Layers of a LAN

Network Layer

802.2 Logical Link Control

802.3 802.5 Whatever

802.11

Various Physical Layers

Networklayer

Data LinkLayer

PhysicalLayer

IEEE 802 OSI

Ethernet

● First developed by Robert Metcalfe in the 70's● DIX in the 80's● 100BaseT 1995● 1000Base in 1998● 10G in 2002

The Protocol

● Started as broadcast over a shared medium● CSMA-CD was the heart of the system● Uses 1-persistent mode● In two t_prop time it knows that it owns the

channel● With 10Mbps and 2500m distance, with 4

repeaters– t_prop = 2500/c+t_repeat = 51.2usec

– 64 bytes is the minimum frame size

Backoff Algorithm

● If there is a collision the backoff algorithm is activated– Truncated Binary Exponential Backoff

● For the kth attempt backoff delay is a random number between 0 … 2k

● After the 10th attempt exponent stays at 10● Tries 16 times before quitting● Takes about a second to fail

Physical Layers

● Thick, thin coaxial● UTP● CAT-3, CAT-5, CAT-5e, CAT-6● With switch to twisted pair we moved to star

topology● Initially hubs (single collision domain)● Switches: collision free (almost)● Full duplex: collision free

Delay on Ethernet

● On a shared ethernet we have– Idle times

– Transmission

– Collisions

● When load goes up– Efficiency goes up (up to a point)

– Collisions go up

– Delays go up (and up)

Fast Ethernet

● AKA 100BaseT● Framing, size and procedures unchanged● Hub is minimum (no bus)● 100BaseTX uses 2 pairs (one each direction)● Two modes:

– Single collision domain

– Buffered and switched (no CSMA-CD)

Gigabit Ethernet

● Severely limited CSMA-CD● Minimum frame 512 bytes● Mainly switched● Frame bursting● Needs at least cat-5e or cat-6● Most routers/bridges support it

Frame Structure

PreambleDestaddr

Sourceaddr

LengthOr

type

ORG=000

pad FCSSD

7x(0xAA)

Start Delim 0xAB

br-gl-46bit MAC

00-46bit MAC

0-0x05FF:length0x0600-0xFFFF: type

VLAN (opt)

LLC PDU

Padding for min-64

Frame Check Seq

Info

TypeXX InfoAA-AA-03

SNAP (subnet Access Proto)

-03: Type 1 LLCAA:DSAP-SSAP(dest. SAP, src SAP)

00:unicast-local

LAN Bridges

● Repeater: interconnection at the physical layer● Bridge: interconnection at the MAC or data link

layer● Router: interconnection at the network or IP

layer● Gateway: (broad term) protocol conversion

(e.g. NAT)

Repeaters

● Rectify, amplify signals● Subject to max. distance limits● Mainly for range extension and increased

connectivity– Cannot reduce traffic

– Cannot provide security

Bridges

● Connect two segments● May inspect and modify the MAC and LLC

headers● Can limit traffic (by restricting traffic local to a

segment within the segment)● May provide low level security● Can forward (or block) {broad|multi}casting● Mostly copy and forward

Bridges

● There are two types: transparent and source routing

● Transparent:– Source unaware of the existence of the bridge

● Source routing:– The source has to specify the sequence of bridges

– The source has to explore the network and find the best routes

Bridge Learning

● Bridge has to discover who is connected to which network

● Without this information it has to broadcast everything– It is little more than a repeater

● Can learn without sending or receiving extra messages

Bridge Learning

M5

M4

M7

M8

M6

M2

M3

M1

12M711M1

7M713M19M7

1M1

2

1

3

9

4 5

11

12 13

6

7

8

M1->M7

Forwarding table

Spanning Tree

M5

M4

M7

M8

M6

M2

M3

RP:root port

2

1 3

100BaseT

10BaseT

1GBaseT

X RP

RP

M1

RB:root bridge

Source Routing Bridges

● Mainly for token rings● Source station determines optimal route● Uses routing table● If the table has an entry for the destination

uses it● If not, it initiates a route discovery procedure● Bridges just follow the instructions

Source Routing Bridges

● Route Discovery has two phases– Single-route broadcast by source

● Source station b/casts a route-less frame to destination● At every bridge in the spanning tree the two ports and

bridge id are added and frame is forwarded

– All-routes broadcast by destination● Destination b/casts a route-less frame to source● At every bridge the two ports and bridge id are added

and frame is forwarded, if this was the first time through

Mixed-Media Bridges● Bridges connecting two different LANs

– Ethernet and token-ring

● Bit string in MAC addresses are opposite

– Token rings: MSb first

– Ethernet: LSb first

● Frame size different

– Token rings: no limit

– Ethernet: 1500 bytes

● No copied bit in Ethernet

● Different transmission rates

Virtual LANs

● We may have one LAN but want to partition it virtually into two or more LANs

– To be served by distinct DHCPs, printers, wake-on-lan etc

● Can be done based on port

– No need for VLAN aware bridges

– Cannot put two stations from different VLAN on one port

● Can be done with VLAN tags

– VLAN tag is an optional field between source MAC and type/length

– Broadcasts to the wrong VLAN are ignored or blocked

TCP/IP

● Overview of TCP/IP● IP packet structure

– NOTE● IP: packets● Ethernet: frames

TCP/IP

ApplicationApplication

UDPTCP

IP ARP RARPICMP

Network Interface

TCP/IP

HTTP request

HTTP request

HTTP request

HTTP request

TCPheader

TCPheader

TCPheader

IPheader

IPheader

FCSMAC

header

TCP/IP

Internet

Networkinterface

Application

Transport

Internet

Networkinterface

Application

Transport

Internet

Networkinterface

Network-2Network-1

IP Packet Structure

Version IHL Type of Service Total Length

Identification Flags Fragment offset

Time to live Protocol Header checksum

Source address

Destination Addres

Options Padding

IP Packet Structure

● Version: IPv4, IPv6, etc● IHL: Internet Header Length (5 if no options)● Type of service: three bits for priority level,

four for requirement.● Total length: in bytes. Usually limited by the

length of the ethernet frame (1500)● Identification, flags, fragment offset: for

fragmentation and reassembly.

IP Packet Structure

● Time to Live: usually number of hops remaining. Decremented after each hop. If zero, discarded and error sent back.

● Protocol: next protocol up. TCP: 6, UDP: 17, ICMP: 1

● Header Checksum: verifies the header. The load is not verified. Recomputed after each TTL decrement.

IP Packet Structure

● Source and destination: the 32 bit IP address● Options: can be a multiple of 32 bits. Routing

information, reservation of resources, etc● Padding: to make options a multiple of 32 bits

IP Addressing

● Every node needs unique (or almost unique) IP address

● Two components– Network ID (globally assigned, 1-4 MSB bits is

class (0, 10, 110, 1110, 1111)

– Host ID (locally assigned, 8(C), 16(B), 24(A) bits)

● Normally written as four bytes (dotted notation)

Subnetting

● Class specifies the network structure.● Too restrictive: class B: 65k hosts, class C:

256 hosts● Subnet masks allow arbitrary subnetting

– Make IP assignment easier

– Allow simple and easy local routing

● Sometimes specified with the slash notation (192.168.1.0/24)

IP Routing

● On a simple network it is easy:– If within the same network put it on the LAN and

ethernet will deliver it

– If it goes outside, send it to the gateway

● In general it is more complex● IP tables are used to route a packet