33
© Janice Regan, CMPT 128, 2007-2012 1 CMPT 371 Data Communications and Networking LANs 2: MAC protocols

CMPT 371

  • Upload
    bob

  • View
    68

  • Download
    0

Embed Size (px)

DESCRIPTION

CMPT 371. Data Communications and Networking LANs 2: MAC protocols. Point to point link. Direct connection between two hosts, medium connecting hosts is 100% available to the two endpoint hosts. Broadcast link. The medium connecting the hosts is shared between many hosts. - PowerPoint PPT Presentation

Citation preview

Page 1: CMPT 371

© Janice Regan, CMPT 128, 2007-20121

CMPT 371Data Communications and Networking

LANs 2: MAC protocols

Page 2: CMPT 371

Janice Regan © 2005-2012 2

Point to point link Direct connection between two hosts,

medium connecting hosts is 100% available to the two endpoint hosts

Page 3: CMPT 371

Janice Regan © 2005-2012 3

Broadcast link The medium connecting the hosts is shared between

many hosts. Each time a frame is sent (broadcast or unicast) every

other host attached to the medium receives a copy A multiple access protocol is used to define how that

sharing is accomplished

Page 4: CMPT 371

Janice Regan © 2005-2012 4

Medium Access Control LAN is a single shared broadcast channel Transmission of a frame may be initiated at any time, or

only at the beginning of defined ‘slots’ Two or more simultaneous transmissions by nodes on

the LAN will collide and cause interference only one node can successfully send at any given time

communication about channel sharing must use channel itself

stations may or may not be able to ‘sense’ a transmission from another station on the network

Need a distributed set of procedures that determines how to share the channel. Such procedures are defined in a Medium Access Control Protocol (MAC Protocol)

Page 5: CMPT 371

Janice Regan © 2005-2012 5

MAC Protocols Static Channel Allocation or Channel Partitioning

divide channel into time slots, frequency bands, code channels, may use a round robin technique

allocate one to each node for exclusive use Contention or Random Access

Allow and recover from collisions for bursty traffic Straightforward to implement adequate for light to moderate loads

Taking turns protocols tightly coordinate shared access to avoid collisions Reservation methods poll stations each cycle, but reserve

transmission slots of for stations with data to transmit. (slightly more overhead than round robin, but improved efficiency due to avoiding empty slots)

Page 6: CMPT 371

Janice Regan © 2005-2012 6

Channel Partitioning MAC: TDMATDMA: time division multiple access

(used for some cellular telephones ) access to channel in “cycles" each station gets fixed length slot (length = pkt trans time) in

each cycle unused slots go idle, channel utilization may be low example: 6-station LAN

Frame 1: 1,2,4,5 have pkt, slots 2 and 6 idle Frame 2: 2,5,6 have pkt, slots 1 ,3,4 idle

D D D D D D D

1 frame (6 slots)

Page 7: CMPT 371

Janice Regan © 2005-2012 7

Channel Partitioning MAC: FDMAFDMA: frequency division multiple access

(used for some cellular telephones ) Spectrum divided into frequency bands Each station assigned a fixed frequency band unused transmission time in frequency bands go idle example: 6-station LAN

Frame 1: 1,2,4,5 have pkt, slots 2 and 6 idle Frame 2: 2,5,6 have pkt, slots 1 ,3,4 idle

Spectrum of frame 1 (6 bands)

Page 8: CMPT 371

Janice Regan © 2005-2012 8

Channel Partitioning (CDMA)CDMA (Code Division Multiple Access) Used mostly in wireless broadcast channels such as cellular

phones All users share same frequency band. Information from each

user is spread throughout that frequency band Each user has their own orthogonal Walsh code ‘chipping’

sequence to encode data. encoded signal = (original data) X (Walsh code) Encoded signals from each channel are added, the summed

signal is transmitted The orthogonal property of Walsh codes guarantees that

(ignoring transmission errors) multiplying the received signal by a Walsh code will extract the data for the channel encoded using that Walsh code from the received (summed) signal.

Decoded signal = (received summed signal X Walsh code)

Page 9: CMPT 371

Janice Regan © 2005-2012 9

Random Access Protocols When node has packet to send it

transmits that packet at full channel data rate R.

When two or more nodes transmit at the same time a collision occurs

A Random Access MAC protocol specifies how to detect and recover from collisions

Examples of Random Access MAC Protocols: ALOHA, Slotted ALOHA CSMA, CSMA/CD

Page 10: CMPT 371

Janice Regan © 2005-2012 10

Pure (unslotted) ALOHA No synchronization, simplest possible approach When frame arrives at a station transmit immediately Listen for an ACK for twice the maximum propagation time between stations

in the network plus a small additional time Retransmit if no ACK is received A frame of duration (transmission time) 1 sent by station i at time t0. It will

collide with frames sent by other stations in the time interval [t0-1,t0+1]

t0t0-1 t0+1

Packet from station i

Packet from other station

Packet from other station

Any packet starting between t0 and t0+1 collides

Any packet starting between t0 and t0-1 colides

Page 11: CMPT 371

Janice Regan © 2005-2012 11

Pure Aloha efficiency Frames are generated at a rate of N per frame transmission time. If

N>1 frames are being generated at a rate faster than they can possibly be transmitted (even in ideal conditions)

Frames may also be retransmitted. The average number of frames (original and retransmitted) transmitted in one frame transmission time is G.

Let P0 be the probability that the frame does not suffer a collision is P0=e-2G (for a Poisson distribution)

The throughput, S, (or efficiency) is the product of P0 and the load presented G S=Ge-2G

At G = 0.5 the maximum value of S (S=0.18) is attained THE BEST WE CAN HOPE FOR IS 18%

Page 12: CMPT 371

Janice Regan © 2005-201212

Slotted ALOHA All nodes are synchronized so time can be divided into

fixed length slots, with the first slot beginning at a reference time

Duration of a slot is transmission time of 1 frame When 2 or more nodes transmit in the same slot, all

nodes detect the resulting collision A frame begins transmission at the beginning of a slot, After a collision the node retransmits frame. The

probability that the frame will be retransmitted in each subsequent slot will be P (until retransmission occurs)

Page 13: CMPT 371

Janice Regan © 2005-201213

Slotted ALOHA

single node can continuously transmit at full rate of channel Slots in nodes need to be in sync between nodes Frames that overlap do so completely, reducing contentions Collisions cause frequent retransmission, idle slots Nodes may be able to detect collision in less than time to transmit packet so

extra time is spent transmitted packets known to be corrupted

Node 1

Node 4

Node 1

Node 4Node 3

Node 2

Node 4

Node 2 Node 2Node 3

Node 1

collision collision collision

Retransmitsuccess success

Retransmitsuccess

Retransmitsuccess

Retransmitsuccess

Page 14: CMPT 371

14Janice Regan © 2005-2012

Slotted Aloha efficiency Utilization is the number of successful transmissions as a fraction of slots

available Let P0 be the probability that the frame does not suffer a collision is P0=e-2G

(for a Poisson distribution) The probability of transmission on the kth try is

Pk = P( k-1 collisions) * P( successful transmission) = ( 1-e-2G )k-1 e-2G

The expected number of transmissions for each packet is

The maximum throughput is then the presented load time the expected number of retransmissions S=Ge-G is a minimum, that is G=1

The channel used for successful transmissions no more than 37% of time

1

11k

GkGG e)e(ke

Page 15: CMPT 371

Janice Regan © 2005-2012 15

Carrier Sense Multiple AccessCSMA: listen (sense channel) before transmit: If channel sensed idle: Transmit entire frame

immediately If channel sensed busy:

1-persistant CSMA: Listen until the channel is available then the station transmits as soon as the medium is available (immediately with probability 1)

Non-persistant CSMA: station waits a random time period and the checks the medium again, transmitting immediately if the channel is now free (better U but longer delays)

P-persistant CSMA: Listen until the channel is available, then transmit with probability p. (Probability q=1-p that the station will wait one time period, usually the maximum propagation delay, to transmit)

Channel is not sensed during transmission, whole packet is sent even if a collision occurs

Page 16: CMPT 371

Janice Regan © 2005-201216

CSMA collisions collisions can still occur: propagation delay means two

nodes may not hear each other’s transmissions Consider node A starts transmitting packet 1 at time t0. Node C starts

transmitting packet 2 at time t1. The propagation time from A to C is 2t1

A B

A

C

Time t3=2.5*t1

A

C

Time t2=1.5*t1

Collision detected at station B starting at time 2t1

Collision has occurred but has not been detected

C

B

B

Collision may never detected at station A or station C

Time t3=2*t1

Page 17: CMPT 371

Janice Regan © 2005-2012 17

CSMA/CD (Collision Detection) A station has a packet to transmit, packets are long

enough that transmission time is longer than the end to end propagation time in the network (otherwise becomes no more efficient the plain CSMA)

If the medium is idle, transmit immediately If the medium is busy listen until the medium is

available If a collision is detected,

transmit a short jamming signal to inform all stations there has been a collision

Then wait a random length of time (referred to as the backoff) and retransmit

Page 18: CMPT 371

Janice Regan © 2005-2012 18

Binary Exponential Backoff When a collision is detected,

transmit a short jamming signal to inform all stations there has been a collision

Then wait a length of time, L, chosen from a random distribution with mean, M. L is referred to as the backoff. After time L retransmit

Each time a collision is detected for a retransmitted frame the mean of the random distribution is doubled. An L is chosen from the new distribution and the frame is retransmitted after time L.

The doubling of the mean of the distribution continues for the first 10 retransmissions. For retransmission attempts 11 to 16 the random distribution remains the same.

After 16 retransmissions the station gives up and reports an error

Page 19: CMPT 371

Janice Regan © 2005-2012 19

Collision Detection Collisions detected within short time

‘Short time’ For the detecting station is the propagation time from the sending

station to the detecting station The sending station learns of the collision when the jamming

signal reaches it, after a time equal to twice the propagation time. Easier in wired LANs: measure signal strengths, compare

transmitted, received signals. Possible difficulties with attenuation along very long propagations paths, when transmitted signal powers may fall below detection levels.

More difficult in wireless LANs: receiver shut off while transmitting

Reduces channel wastage by reducing amount of time transmitting during contention conditions.

Page 20: CMPT 371

Janice Regan © 2005-201220

CSMA collisions and CSMA/CD Consider node A starts transmitting packet 1 at time t0. Node C

starts transmitting packet 2 at time t1. The propagation time from A to C is 2t1

A B

A

C

t3=2*t1

A

C

t2=1.5*t1

Collision detected by A and C. station A and C send jamming signal

Collision detected at stations B

C

B

B

t3=3*t1

Collision has occurred but has not been detected

DA

D

Page 21: CMPT 371

Janice Regan © 2005-201221

CSMA collisions and CSMA/CD Consider node A starts transmitting packet 1 at time t0. Node C

starts transmitting packet 2 at time t1. The propagation time from A to C is 2t1

CA

Collision detected by A and C. station A and C send jamming signal

B

t3=3*t1

A and C. receive jamming signal

B

t3=5*t1

D

A

CA

jamming signal received by B and D

B

t3=4*t1

D

Page 22: CMPT 371

Janice Regan © 2005-2012 22

MAC protocols

Network Layer

802.2 Logical Link Control (LLC)

802.3Ethernet

Physical Layer

802.4Token Ring

802.5Token Bus

802.11Wireless

Data Link Layer

Page 23: CMPT 371

Janice Regan © 2005-2012 23

IEEE 802 Protocol Layers

Stallings 2003: fig 15.5

Page 24: CMPT 371

Janice Regan © 2005-2012 24

MAC Frame Preamble: 7 octets of alternating 1’s and 0’s used to establish

sychronization Start Frame Delimiter (SFD): The sequence 10101011 used to

indicate the start of the frame. Destination address (DA): address of the station for which the

frame is intended (MAC address of interface) Source address (SA): The address of the station that sent the

frame Length/Type: Length of the LLC data field (<1500 octets), or the

type of protocol (if not 802.3) Pad: added to make sure the transmission time of the packet is at

least as long as the propagation time through the network (required for efficient use of CSMA/CD)

FCS: 32 bit CRC

Page 25: CMPT 371

Janice Regan © 2005-201225

IEEE 802.3 (Ethernet MAC Frame)

Stallings 2000: fig 14.2, 17.8

IEEE 802.11 (Wireless MAC Frame)

Page 26: CMPT 371

Janice Regan © 2005-2012 26

Taking turns MAC protocolschannel partitioning MAC protocols:

share channel efficiently and fairly at high load inefficient at low load due to ‘idle’ slots

Random access MAC protocols efficient at low load: single node can fully utilize channel collision overhead increases with load

Taking turns protocols look for best of both Poll, transmit only when polled or only when told by central

station Use token passing (e.g. a token ring network)

Page 27: CMPT 371

Janice Regan © 2005-2012 27

Polling Eliminate collisions and empty frames Controlled by a central station which

Sends a Poll message to start selected station transmitting Watches for the end of the data transmitted by the station (no

signal on the link for some limiting time > round trip travel time between the central station and the polled station = delay time)

Repeats the previous 2 steps until all hosts on the broadcast link have been polled

Repeats the polling of the whole set of stations Addition overhead of delay time for each host, even if host has no

data to transmit If master node fails, whole link fails

Page 28: CMPT 371

Janice Regan © 2005-2012 28

Example of Token Passing Token Ring: Governed by standard 802.5 Based on the use of a small frame called a token A station may only transmit when it has possession of a

token Transmission is a three step process

A station grabs the token as it passes (flipping token bit) The station transmits its frame The station reemits the token when both

Transmission is complete The leading edge of the packet has returned to

the transmitting station

Page 29: CMPT 371

Janice Regan © 2005-201229

IEEE 802.5 Frame Format

Stallings 2000: fig 14.6

Page 30: CMPT 371

Janice Regan © 2005-2012 30

Token Ring Operation Transmission steps are as follows

A station wishing to transmit waits until the token passes and flips the token bit in the access control field

The station appends the rest of its packet after the ACR field The station continues to transmit until it has transmitted all its

packets or the token holding timer expires. When the ACR field of the last transmitted frame returns the

token bit is turned back on and the end data delimiter is appended

A frame returning to the originating station uses the frame status field to differentiate between Destination station not active or does not exist (A=0,C=0) Destination station exists but frame not copied (A=1,C=0) Frame received (A=1,C=1)

Page 31: CMPT 371

Janice Regan © 2005-201231

Token Ring Operation

Stallings 2000: fig 14.5

Page 32: CMPT 371

Janice Regan © 2005-201232

Token Ring Operation

Stallings 2000: fig 14.5

Page 33: CMPT 371

Janice Regan © 2005-201233

Token Ring Operation

Stallings 2000: fig 14.5