Chapter 5: The Data Link Layer Our goals: r understand principles - - PowerPoint PPT Presentation

chapter 5 the data link layer
SMART_READER_LITE
LIVE PREVIEW

Chapter 5: The Data Link Layer Our goals: r understand principles - - PowerPoint PPT Presentation

Chapter 5: The Data Link Layer Our goals: r understand principles behind data link layer services: m error detection, correction m sharing a broadcast channel: multiple access m link layer addressing m reliable data transfer, flow control: done! r


slide-1
SLIDE 1 5: DataLink Layer 5-1

Chapter 5: The Data Link Layer

Our goals:

r understand principles behind data link layer

services:

m error detection, correction m sharing a broadcast channel: multiple access m link layer addressing m reliable data transfer, flow control: done!

r instantiation and implementation of various link

layer technologies

slide-2
SLIDE 2 5: DataLink Layer 5-2

Link Layer

r 5.1 Introduction and

services

r 5.2 Error detection

and correction

r 5.3Multiple access

protocols

r 5.4 Link-Layer

Addressing

r 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP

3201

.

I

$101

.

point to point

} Got .

protocol

} lol

.
slide-3
SLIDE 3 5: DataLink Layer 5-3

Link Layer: Introduction

Some terminology:

r hosts and routers are node

des

r communication channels that

connect adjacent nodes along communication path are lin links

m wired links m wireless links m LANs

r layer-2 packet is a fr

frame me, encapsulates datagram “link”

da data-link laye yer has responsibility of transferring datagram from one node to adjacent node over a link

anti

wt÷

Et

D

a¥I

slide-4
SLIDE 4 5-4

Link layer: context

r Datagram transferred by

different link protocols

  • ver different links:
m e.g., Ethernet on first link,

frame relay on intermediate links, 802.11

  • n last link

r Each link protocol

provides different services

m e.g., may or may not

provide rdt over link

transportation analogy

r trip from Princeton to

Lausanne

m limo: Princeton to JFK m plane: JFK to Geneva m train: Geneva to Lausanne

r tourist = datagram r transport segment =

communication link

r travel agent = routing

algorithm

r transportation access =

link layer protocol Traffic lights, Airport control, Platform scheduling,

slide-5
SLIDE 5 5: DataLink Layer 5-5

Link Layer Services

r Framing, link access:

m encapsulate datagram into frame, adding header, trailer m channel access if shared medium m “MAC” addresses used in frame headers to identify

source, dest

  • different from IP address!

r Reliable delivery between adjacent nodes

m we learned how to do this already (chapter 3)! m seldom used on low bit error link (fiber, some twisted

pair)

m wireless links: high error rates
  • Q: why both link-level and end-end reliability?

I?-q

. . . . . g-IT¥⇒

neo

}

rain

I

slide-6
SLIDE 6 5: DataLink Layer 5-6

Link Layer Services (more)

r Flow Control:

m pacing between adjacent sending and receiving nodes

r Error Detection:

m errors caused by signal attenuation, noise. m receiver detects presence of errors:
  • signals sender for retransmission or drops frame

r Error Correction:

m receiver identifies and corrects bit error(s) without

resorting to retransmission r Half-duplex and full-duplex

m with half duplex, nodes at both ends of link can transmit,

but not at same time

Full

EJ.

Half

Full

El

.

.

←¥

slide-7
SLIDE 7 5: DataLink Layer 5-7

Adaptors Communicating

r link layer implemented in

“adaptor” (aka NIC)

m Ethernet card, PCMCI

card, 802.11 card r sending side:

m encapsulates datagram in

a frame

m adds error checking bits,

rdt, flow control, etc. r receiving side

m looks for errors, rdt, flow

control, etc

m extracts datagram, passes

to rcving node r adapter is semi-

autonomous

r link & physical layers

sending node frame rcving node datagram frame adapter adapter link layer protocol

O

D →

NIC = Nientferfacecard

slide-8
SLIDE 8 5: DataLink Layer 5-8

Link Layer

r 5.1 Introduction and

services

r 5.2 Error detection

and correction

r 5.3Multiple access

protocols

r 5.4 Link-Layer

Addressing

r 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization:

ATM

}

}

⇒ §

Point to Point

gi:nm8

slide-9
SLIDE 9 5: DataLink Layer 5-9

Error Detection

EDC= Error Detection and Correction bits (redundancy) D = Data protected by error checking, may include header fields

  • Error detection not 100% reliable!
  • protocol may miss some errors, but rarely
  • larger EDC field yields better detection and correction

1€

'i:.¥ MAC MAC 1010001

Kill

¥

.

*←*

. " H'÷

""

refiner

,.ee?i

EDO

slide-10
SLIDE 10 5: DataLink Layer 5-10

Parity Checking

Single Bit Parity:

De Detect single bit errors

Two Dimensional Bit Parity:

De Detect an and correct si single bit t error
  • rs

:

:

Etsy

slide-11
SLIDE 11 5: DataLink Layer 5-11

Internet checksum

Sender:

r treat segment contents

as sequence of 16-bit integers

r checksum: addition (1’s

complement sum) of segment contents

r sender puts checksum

value into UDP checksum field Receiver:

r compute checksum of received

segment

r check if computed checksum

equals checksum field value:

m NO - error detected m YES - no error detected. But

maybe errors nonetheless? More later ….

Goal: detect “errors” (e.g., flipped bits) in transmitted segment (note: used at transport layer only)

slide-12
SLIDE 12 5: DataLink Layer 5-12

Link Layer

r 5.1 Introduction and

services

r 5.2 Error detection

and correction

r 5.3Multiple access

protocols

r 5.4 Link-Layer

Addressing

r 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization:

ATM

} ±¥¥÷'÷i

A

B

C

D

I

slide-13
SLIDE 13

' 33 Cz 'In

'

÷÷i÷÷÷÷÷÷÷

:L

E-

I have a

question

say #equation N nodes

ceaYTY.%9coaiIIHE.HR

P BIN

÷÷÷÷#÷;i

time

r
slide-14
SLIDE 14

cnet.IE?opEE....P

"

aanegap.TT

¥t¥°÷÷÷÷÷÷÷÷f...÷

'X i:*:* .

deep:]

/

e
  • -
  • -

ga

t

'

¥#i¥÷÷÷÷:÷

li÷÷÷÷÷

:

" ¥÷÷÷÷
  • .
  • ho

tu la b

slide-15
SLIDE 15
slide-16
SLIDE 16 5: DataLink Layer 5-13

Multiple Access Links and Protocols

Two types of “links”:

r point-to-point

m PPP for dial-up access m point-to-point link between Ethernet switch and host

r broadcast (shared wire or medium)

m traditional Ethernet m Bluetooth m 802.11 wireless LAN

Dae

×ed

.

'

as lab

slide-17
SLIDE 17 5: DataLink Layer 5-14

Multiple Access protocols

r single shared broadcast channel r two or more simultaneous transmissions by nodes:

interference

m collision if node receives two or more signals at the same time

multiple access protocol

r distributed algorithm that determines how nodes

share channel, i.e., determine when node can transmit

r communication about channel sharing must use channel

itself!

m no out-of-band channel for coordination

Project

Comm?. I

control

Comm? → Planning

Data

Comm ? → Execution

slide-18
SLIDE 18 5: DataLink Layer 5-15

Ideal Multiple Access Protocol

Broadcast channel of rate R bps

  • 1. When one node wants to transmit, it can send at

rate R.

  • 2. When M nodes want to transmit, each can send at

average rate R/M

  • 3. Fully decentralized:
m no special node to coordinate transmissions m no synchronization of clocks, slots
  • 4. Simple
slide-19
SLIDE 19 5: DataLink Layer 5-16

MAC Protocols: a taxonomy

Three broad classes:

r Channel Partitioning

m divide channel into smaller “pieces” (time slots,

frequency, code)

m allocate piece to node for exclusive use

r Random Access

m channel not divided, allow collisions m “recover” from collisions

r “Taking turns”

m Nodes take turns, but nodes with more to send can take

longer turns

slide-20
SLIDE 20 5: DataLink Layer 5-17

Channel Partitioning MAC protocols: TDMA

TDMA: time division multiple access

r access to channel in "rounds" r each station gets fixed length slot (length = pkt

trans time) in each round

r unused slots go idle r example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6

idle

slide-21
SLIDE 21 5: DataLink Layer 5-18

Channel Partitioning MAC protocols: FDMA

FDMA: frequency division multiple access

r channel spectrum divided into frequency bands r each station assigned fixed frequency band r unused transmission time in frequency bands go idle r example: 6-station LAN, 1,3,4 have pkt, frequency

bands 2,5,6 idle

frequency bands t i m e

cate time -frequency blocks -_ ij to a phone that wants to transmit

"

time

in .

slide-22
SLIDE 22 5: DataLink Layer 5-19

Random Access Protocols

r When node has packet to send

m transmit at full channel data rate R. m no a priori coordination among nodes

r two or more transmitting nodes ➜ “collision”, r random access MAC protocol specifies:

m how to detect collisions m how to recover from collisions (e.g., via delayed

retransmissions) r Examples of random access MAC protocols:

m slotted ALOHA m ALOHA m CSMA, CSMA/CD, CSMA/CA
slide-23
SLIDE 23 5: DataLink Layer 5-20

Slotted ALOHA

Assumptions

r all frames same size r time is divided into

equal size slots, time to transmit 1 frame

r nodes start to transmit

frames only at beginning of slots

r nodes are synchronized r if 2 or more nodes

transmit in slot, all nodes detect collision Operation

r when node obtains fresh

frame, it transmits in next slot

r no collision, node can send

new frame in next slot

r if collision, node

retransmits frame in each subsequent slot with prob. p until success

I

② ③

✓=

÷

slide-24
SLIDE 24 5: DataLink Layer 5-21

Slotted ALOHA

Pros

r single active node can

continuously transmit at full rate of channel

r highly decentralized:

  • nly slots in nodes

need to be in sync

r simple

Cons

r collisions, wasting slots r idle slots r nodes must be able to

detect collision in less than time to transmit packet

r clock synchronization

#

success slot

E

  • -

A

total # slots

l

l

collision

'

Empty success

slide-25
SLIDE 25 5: DataLink Layer 5-22

Slotted Aloha efficiency

r Suppose N nodes with

many frames to send, each transmits in slot with probability p

r prob that node 1 has

success in a slot

= p(1-p)N-1 r prob that any node has

a success = Np(1-p)N-1

r For max efficiency

with N nodes, find p* that maximizes Np(1-p)N-1

r For many nodes, take

limit of Np*(1-p*)N-1

1 as

N goes to infinity, gives 1/e = .37 Ef Efficiency is the long-run fraction of successful slots when there are many nodes, each with many frames to send At best: channel used for useful transmissions 37%

  • f time!

→ ratio

p*=f(N)

  • Lim Np*a
  • p*)
"" = f- ( N)

NSN

slide-26
SLIDE 26 5: DataLink Layer 5-23

Pure (unslotted) ALOHA

r unslotted Aloha: simpler, no synchronization r when frame first arrives

m transmit immediately

r collision probability increases:

m frame sent at t0 collides with other frames sent in [t0-1,t0+1]

Aaaa

to-157+6

slide-27
SLIDE 27 5: DataLink Layer 5-24

Pure Aloha efficiency

P(success by given node) = P(node transmits) . P(no other node transmits in [t0-1,t0] . P(no other node transmits in [t0,t0+1] = p . (1-p)N-1 . (1-p)N-1 = = p . (1-p)2(

2(N-1) 1)

… choosing optimum p and then letting n -> infty ... = 1/(2e) = .18

Even worse !

slide-28
SLIDE 28 5: DataLink Layer 5-25

CSMA (Carrier Sense Multiple Access)

CS CSMA: listen before transmit: If channel sensed idle: transmit entire frame

r If channel sensed busy, defer transmission r Human analogy: don’t interrupt others! M nodes

.
  • Before talking

& while talking

slide-29
SLIDE 29 5: DataLink Layer 5-26

CSMA collisions

collisions can still occur:

propagation delay means two nodes may not hear each other’s transmission

collision:

entire packet transmission time wasted

spatial layout of nodes

note:

role of distance & propagation delay in determining collision probability

slide-30
SLIDE 30 5: DataLink Layer 5-27

CSMA/CD (Collision Detection)

CSMA/CD: carrier sensing, deferral as in CSMA

m collisions detected within short time m colliding transmissions aborted, reducing channel

wastage r collision detection:

m easy in wired LANs: measure signal strengths,

compare transmitted, received signals

m difficult in wireless LANs: receiver shut off while

transmitting r human analogy: the polite conversationalist

07¥

great

at

by

slide-31
SLIDE 31 5: DataLink Layer 5-28

CSMA/CD collision detection

slide-32
SLIDE 32 5: DataLink Layer 5-29

“Taking Turns” MAC protocols

channel partitioning MAC protocols:

m share channel efficiently and fairly at high load m inefficient at low load: delay in channel access,

1/N bandwidth allocated even if only 1 active node! Random access MAC protocols

m efficient at low load: single node can fully

utilize channel

m high load: collision overhead

“taking turns” protocols look for best of both worlds!

slide-33
SLIDE 33 5: DataLink Layer 5-30

“Taking Turns” MAC protocols

Polling:

r master node

“invites” slave nodes to transmit in turn

r concerns:

m polling overhead m latency m single point of

failure (master)

Token passing:

r control tok

  • ken passed from
  • ne node to next

sequentially.

r token message r concerns:

m token overhead m latency m single point of failure (token)

noir

got

  • =
slide-34
SLIDE 34 5: DataLink Layer 5-31

Summary of MAC protocols

r What do you do with a shared media?

m Channel Partitioning, by time, frequency or code

  • Time Division, Frequency Division

m Random partitioning (dynamic),

  • ALOHA, S-ALOHA, CSMA, CSMA/CD
  • carrier sensing: easy in some technologies (wire), hard

in others (wireless)

  • CSMA/CD used in Ethernet
  • CSMA/CA used in 802.11

m Taking Turns

  • polling from a central site, token passing
slide-35
SLIDE 35

nonentity

A

B

C

D

lis£befwetd€

¥⇒

  • i. IN

÷i÷÷÷÷÷

A B C D
  • "

I

.

www.f-gra

'

'

For

.÷÷÷:{FE,

slide-36
SLIDE 36 A B C D
  • Mc
  • r
a # D

rash]otweetedown

free IT come

rpfreef-

B

  • re

Ii

choose

ra E [ min

, max] tend # . rand from [ O , 16) timeouts .

If collision ,

choose new

*

as:::±÷:÷÷¥ .. IEEE:

Exponential

B

attempts

Once

success . reset max = 16
  • us
'

¥ l⑤¥⑤

slide-37
SLIDE 37 5: DataLink Layer 5-32

Link Layer

r 5.1 Introduction and

services

r 5.2 Error detection

and correction

r 5.3Multiple access

protocols

r 5.4 Link-Layer

Addressing

r 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization:

ATM