chapter 5 link layer and lans - hong kong university of

76
5: DataLink Layer 5-1 Chapter 5 Link Layer and LANs Computer Networking: A Top Down Approach 4 th edition. Jim Kurose, Keith Ross Addison-Wesley, July 2007. A note on the use of these ppt slides: All material copyright 1996-2007 J.F Kurose and K.W. Ross, All Rights Reserved

Upload: others

Post on 11-Jan-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-1

Chapter 5Link Layer and LANs

Computer Networking A Top Down Approach

4th edition Jim Kurose Keith RossAddison-Wesley July

2007

A note on the use of these ppt slides

All material copyright 1996-2007JF Kurose and KW Ross All Rights Reserved

5 DataLink Layer 5-2

Chapter 5 The Data Link Layer

Our goals OverviewUnderstand principles behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressingReliable data transfer flow control done

Instantiation and implementation of various link layer technologies

Link layer servicesError detection correctionMultiple access protocols and LANsLink layer addressing ARPSpecific link layer technologies

Ethernethubs bridges switches

5 DataLink Layer 5-3

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-4

Link Layer Setting the Context

5 DataLink Layer 5-5

Link Layer Setting the ContextTwo physically connected devices

Host-router router-router host-hostUnit of data frame

applicationtransportnetwork

linkphysical

networklink

physical

MMMM

Ht

HtHnHtHnHl MHtHnHl

phys link

data linkprotocol

adapter card

frame

5 DataLink Layer 5-6

Link Layer IntroductionSome terminology

Hosts and routers are nodesCommunication channels that connect adjacent nodes along communication path are links

Wired linksWireless linksLANs

Layer-2 packet is a frameencapsulates datagram

ldquolinkrdquo

Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link

5 DataLink Layer 5-7

Link Layer Introduction ldquolinkrdquo

Datagram transferred by different link protocols over different links

eg Ethernet on first link frame relay on intermediate links 80211 on last link

Each link protocol provides different services

eg may or may not provide rdt over link

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 2: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-2

Chapter 5 The Data Link Layer

Our goals OverviewUnderstand principles behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressingReliable data transfer flow control done

Instantiation and implementation of various link layer technologies

Link layer servicesError detection correctionMultiple access protocols and LANsLink layer addressing ARPSpecific link layer technologies

Ethernethubs bridges switches

5 DataLink Layer 5-3

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-4

Link Layer Setting the Context

5 DataLink Layer 5-5

Link Layer Setting the ContextTwo physically connected devices

Host-router router-router host-hostUnit of data frame

applicationtransportnetwork

linkphysical

networklink

physical

MMMM

Ht

HtHnHtHnHl MHtHnHl

phys link

data linkprotocol

adapter card

frame

5 DataLink Layer 5-6

Link Layer IntroductionSome terminology

Hosts and routers are nodesCommunication channels that connect adjacent nodes along communication path are links

Wired linksWireless linksLANs

Layer-2 packet is a frameencapsulates datagram

ldquolinkrdquo

Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link

5 DataLink Layer 5-7

Link Layer Introduction ldquolinkrdquo

Datagram transferred by different link protocols over different links

eg Ethernet on first link frame relay on intermediate links 80211 on last link

Each link protocol provides different services

eg may or may not provide rdt over link

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 3: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-3

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-4

Link Layer Setting the Context

5 DataLink Layer 5-5

Link Layer Setting the ContextTwo physically connected devices

Host-router router-router host-hostUnit of data frame

applicationtransportnetwork

linkphysical

networklink

physical

MMMM

Ht

HtHnHtHnHl MHtHnHl

phys link

data linkprotocol

adapter card

frame

5 DataLink Layer 5-6

Link Layer IntroductionSome terminology

Hosts and routers are nodesCommunication channels that connect adjacent nodes along communication path are links

Wired linksWireless linksLANs

Layer-2 packet is a frameencapsulates datagram

ldquolinkrdquo

Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link

5 DataLink Layer 5-7

Link Layer Introduction ldquolinkrdquo

Datagram transferred by different link protocols over different links

eg Ethernet on first link frame relay on intermediate links 80211 on last link

Each link protocol provides different services

eg may or may not provide rdt over link

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 4: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-4

Link Layer Setting the Context

5 DataLink Layer 5-5

Link Layer Setting the ContextTwo physically connected devices

Host-router router-router host-hostUnit of data frame

applicationtransportnetwork

linkphysical

networklink

physical

MMMM

Ht

HtHnHtHnHl MHtHnHl

phys link

data linkprotocol

adapter card

frame

5 DataLink Layer 5-6

Link Layer IntroductionSome terminology

Hosts and routers are nodesCommunication channels that connect adjacent nodes along communication path are links

Wired linksWireless linksLANs

Layer-2 packet is a frameencapsulates datagram

ldquolinkrdquo

Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link

5 DataLink Layer 5-7

Link Layer Introduction ldquolinkrdquo

Datagram transferred by different link protocols over different links

eg Ethernet on first link frame relay on intermediate links 80211 on last link

Each link protocol provides different services

eg may or may not provide rdt over link

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 5: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-5

Link Layer Setting the ContextTwo physically connected devices

Host-router router-router host-hostUnit of data frame

applicationtransportnetwork

linkphysical

networklink

physical

MMMM

Ht

HtHnHtHnHl MHtHnHl

phys link

data linkprotocol

adapter card

frame

5 DataLink Layer 5-6

Link Layer IntroductionSome terminology

Hosts and routers are nodesCommunication channels that connect adjacent nodes along communication path are links

Wired linksWireless linksLANs

Layer-2 packet is a frameencapsulates datagram

ldquolinkrdquo

Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link

5 DataLink Layer 5-7

Link Layer Introduction ldquolinkrdquo

Datagram transferred by different link protocols over different links

eg Ethernet on first link frame relay on intermediate links 80211 on last link

Each link protocol provides different services

eg may or may not provide rdt over link

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 6: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-6

Link Layer IntroductionSome terminology

Hosts and routers are nodesCommunication channels that connect adjacent nodes along communication path are links

Wired linksWireless linksLANs

Layer-2 packet is a frameencapsulates datagram

ldquolinkrdquo

Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link

5 DataLink Layer 5-7

Link Layer Introduction ldquolinkrdquo

Datagram transferred by different link protocols over different links

eg Ethernet on first link frame relay on intermediate links 80211 on last link

Each link protocol provides different services

eg may or may not provide rdt over link

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 7: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-7

Link Layer Introduction ldquolinkrdquo

Datagram transferred by different link protocols over different links

eg Ethernet on first link frame relay on intermediate links 80211 on last link

Each link protocol provides different services

eg may or may not provide rdt over link

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 8: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-8

Link Layer ServicesFraming link access

Encapsulate datagram into frame adding header trailerChannel access if shared mediumldquoMACrdquo addresses used in frame headers to identify source dest

bull Different from IP address

Reliable delivery between adjacent nodesWe learned how to do this already (chapter 3)Seldom used on low bit error link (fiber some twisted pair)Wireless links high error rates

bull Q why both link-level and end-end reliability

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 9: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-9

Link Layer Services (more)

Flow ControlPacing between adjacent sending and receiving nodes

Error DetectionErrors caused by signal attenuation noise Receiver detects presence of errors

bull Signals sender for retransmission or drops frame

Error CorrectionReceiver identifies and corrects bit error(s) without resorting to retransmission

Half-duplex and full-duplexWith half duplex nodes at both ends of link can transmit but not at same time

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 10: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-10

Link Layer

51 Introduction and services52 Error detection and correction53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 11: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-11

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

bull Error detection not 100 reliablebull Protocol may miss some errors but rarelybull Larger EDC field yields better detection and correction

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 12: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-12

Parity CheckingTwo Dimensional Bit ParitySingle Bit ParityDetect and CORRECT single bit errorsDetect single bit errors

0 0

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 13: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-13

Internet Checksum Goal detect ldquoerrorsrdquo (eg flipped bits) in transmitted

segment (note used at transport layer only)

ReceiverSenderCompute checksum of received segmentCheck if computed checksum equals checksum field value

NO - error detectedYES - no error detected But maybe errors nonetheless More later hellip

Treat segment contents as sequence of 16-bit integersChecksum addition (1rsquos complement sum) of segment contentsSender puts checksum value into UDP checksum field

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 14: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-14

Checksumming Cyclic Redundancy CheckView data bits D as a binary numberChoose r+1 bit pattern (generator) GGoal choose r CRC bits R such that

ltDRgt exactly divisible (polynomial division) by G (modulo 2) Receiver knows G divides ltDRgt by G If non-zero remainder error detectedCan detect all burst errors less than r+1 bits

Widely used in practice (ATM HDLC)

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 15: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-15

All CRC calculations are done in modulo-2 arithmetic without carries in addition or borrows in subtraction

Addition and subtraction are identicalEquivalent to the bitwise XOR

1011 XOR 0101 = 11101001 XOR 1101 = 0100

1011 ndash 0101 = 11101001 ndash 1101 = 0100

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 16: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-16

CRC ExampleWant

D2r XOR R = nGequivalently

D2r = nG XOR R equivalently

if we divide D2r by G want remainder R

R = remainder[ ]D2r

G

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 17: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-17

Example (r=3)Bits in word are coefficients of polynomial

D = 101110 then D(x) = x^5 + x^3 + x^2 + x

D = 101110 D(x) = x^5 + x^3 + x^2 + x

G = 1001 G(x) = x^3 + 1

2rD = 101110000 x^3 D(x) = x^8 + x^6 + x^5 +x^4

x^3 D(x) = G(x) (x^5 + x^3 + x + 1) + (x+1)

So R(x) = x+1 and R = 011

CRC will transmit D2r XOR R = 101110011

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 18: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-18

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 19: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-19

Multiple Access Links and ProtocolsTwo types of ldquolinksrdquo

Point-to-pointPPP for dial-up accessPoint-to-point link between Ethernet switch and host

Broadcast (shared wire or medium)Old-fashioned EthernetUpstream HFC80211 wireless LAN

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 20: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-20

Multiple Access protocolsSingle shared broadcast channel Two or more simultaneous transmissions by nodes interference

Collision if node receives two or more signals at the same time

Multiple access protocolDistributed algorithm that determines how nodes share channel ie determine when node can transmitCommunication about channel sharing must use channel itself

No out-of-band channel for coordination

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 21: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-21

Ideal Multiple Access Protocol

Broadcast channel of rate R bps1 When one node wants to transmit it can send at

rate R2 When M nodes want to transmit each can send at

average rate RM3 Fully decentralized

No special node to coordinate transmissionsNo synchronization of clocks slots

4 Simple

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 22: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-22

MAC Protocols a Taxonomy

Three broad classesChannel Partitioning TDMA FDMA CDMA (in wireless)

Divide channel into smaller ldquopiecesrdquo (time slots frequency code)Allocate piece to node for exclusive use

Random Access ALOHA CSMA CSMACD CSMACAChannel not divided allow collisionsldquoRecoverrdquo from collisions

ldquoTaking turnsrdquo Polling Token passingNodes take turns but nodes with more to send can take longer turns

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 23: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-23

Channel Partitioning MAC protocols TDMA

TDMA time division multiple accessAccess to channel in rounds Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example 6-station LAN 134 have pkt slots 256 idle

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 24: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-24

Channel Partitioning MAC protocols FDMA

FDMA frequency division multiple accessChannel spectrum divided into frequency bandsEach station assigned fixed frequency bandUnused transmission time in frequency bands go idle Example 6-station LAN 134 have pkt frequency bands 256 idle

freq

uenc

y ba

nds

time

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 25: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-25

Random Access Protocols

When node has packet to sendTransmit at full channel data rate RNo a priori coordination among nodes

Two or more transmitting nodes ldquocollisionrdquoRandom access MAC protocol specifies

How to detect collisionsHow to recover from collisions (eg via delayed retransmissions)

Examples of random access MAC protocolsSlotted ALOHAALOHACSMA CSMACD CSMACA

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 26: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-26

Slotted ALOHA

AssumptionsAll frames same sizeTime is divided into equal size slots time to transmit 1 frameNodes start to transmit frames only at beginning of slotsNodes are synchronizedIf 2 or more nodes transmit in slot all nodes detect collision

OperationWhen node obtains fresh frame it transmits in next slotNo collision node can send new frame in next slotIf collision node retransmits frame in each subsequent slot with prob p until success

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 27: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-27

Slotted ALOHA

ProsSingle active node can continuously transmit at full rate of channelHighly decentralized only slots in nodes need to be in syncSimple

ConsCollisions wasting slotsIdle slotsNodes may be able to detect collision in less than time to transmit packetClock synchronization

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 28: Chapter 5 Link Layer and LANs - Hong Kong University of

Slotted Aloha Efficiency

Suppose N nodes with many frames to send each transmits in slot with probability pProb that node 1 has success in a slot = p(1-p)N-1

Prob that any node has a success = Np(1-p)N-1

For max efficiency with N nodes find p that maximizes Np(1-p)N-1

For many nodes take limit of Np(1-p)N-1 as N goes to infinity gives 1e = 37

Efficiency is the long-run fraction of successful slots when there are many nodes each with many frames to send

At best channelused for useful transmissions 37of time

5 DataLink Layer 5-28

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 29: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-29

Pure (Unslotted) ALOHAUnslotted Aloha simpler no synchronizationWhen frame first arrives

Transmit immediately Collision probability increases

Frame sent at t0 collides with other frames sent in [t0-1t0+1]

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 30: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-30

Pure Aloha EfficiencyP(success by given node) = P(node transmits)

P(no other node transmits in [p0-1p0] P(no other node transmits in [p0p0+1]

= p (1-p)N-1 (1-p)N-1

= p (1-p)2(N-1)

hellip choosing optimum p and then letting n -gt infty

= 1(2e) = 18

Even worse

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 31: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-31

CSMA (Carrier Sense Multiple Access)

CSMA listen before transmitThis is Carrier Sensing

If channel sensed idle transmit entire frameIf channel sensed busy defer transmission

Human analogy donrsquot interrupt others

If someone else is already transmitting then back off (wait) until channel is free

Wait how long

If collision is detected during transmission then must retransmit the frame

When is it retransmitted

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 32: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-32

CSMA (Carrier Sense Multiple Access)

1-Persistent CSMAIf channel sensed idle transmit entire pktIf channel sensed busy wait until channel becomes idle and thentransmit right awayIf collision occurs wait random time and then restart process

Non-persistent CSMA (for nonslotted channels) If channel sensed idle transmit entire pktIf channel sensed busy wait random time before trying againIf collision occurs wait random time and then restart process

P-Persistent CSMA (for slotted channels) If channel sensed idle then with probability p transmit in current

slot With probability q=1-p wait until next slot and try again (with probability p)If channel sensed busy wait until next slot and try againIf collision occurs wait random time and then restart process

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 33: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-33

CSMA Collisions spatial layout of nodes

Collisions can still occurpropagation delay means two nodes may not heareach otherrsquos transmission

Collisionentire packet transmission time wastedNoterole of distance amp propagation delay in determining collision probability

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 34: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-34

CSMACD (Collision Detection)CSMACD carrier sensing deferral as in CSMA

Collisions detected within short timeColliding transmissions aborted reducing channel wastage

Collision detection Easy in wired LANs measure signal strengths compare transmitted received signalsDifficult in wireless LANs receiver shut off while transmitting

Human analogythe polite conversationalist

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 35: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-35

CSMACD Collision Detection

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 36: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-36

ldquoTaking Turnsrdquo MAC protocolsChannel partitioning MAC protocols

Share channel efficiently and fairly at high loadInefficient at low load delay in channel access 1N bandwidth allocated even if only 1 active node

Random access MAC protocolsEfficient at low load single node can fully utilize channelHigh load collision overhead

ldquoTaking turnsrdquo protocolsLook for best of both worlds

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 37: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-37

ldquoTaking Turnsrdquo MAC protocolsPolling

Master node ldquoinvitesrdquo slave nodes to transmit in turnConcerns

Polling overhead LatencySingle point of failure (master)

Token passingControl token passed from one node to next sequentiallyToken messageConcerns

Token overhead LatencySingle point of failure (token)

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 38: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-38

Summary of MAC Protocols

What do you do with a shared mediaChannel Partitioning by time frequency or code

bull Time Division Frequency DivisionRandom partitioning (dynamic)

bull ALOHA S-ALOHA CSMA CSMACDbull Carrier sensing easy in some technologies (wire) hard

in others (wireless)bull CSMACD used in Ethernetbull CSMACA used in 80211

Taking Turnsbull Polling from a central site token passing

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 39: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-39

LAN TechnologiesData link layer so far

Services error detectioncorrection multiple access

Next LAN technologiesAddressingEthernetHubs switchesIEEE 80211 (wireless)PPP

LAN

Router

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 40: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-40

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 41: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-41

MAC Addresses and ARP

32-bit IP address Network-layer addressUsed to get datagram to destination IP subnet

MAC (or LAN or physical or Ethernet) address

Used to get frame from one interface to another physically-connected interface (same network)48 bit MAC address (for most LANs) burned in the adapter ROM

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 42: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-42

LAN Addresses and ARPEach adapter on LAN has unique LAN address

Broadcast address =FF-FF-FF-FF-FF-FF

= adapter

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN(wired orwireless)

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 43: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-43

LAN Address (more)

MAC address allocation administered by IEEEManufacturer buys portion of MAC address space (to assure uniqueness)Analogy

(a) MAC address like HKID(b) IP address like postal address

MAC flat address portability Can move LAN card from one LAN to another

IP hierarchical address NOT portableDepends on IP subnet to which node is attached

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 44: Chapter 5 Link Layer and LANs - Hong Kong University of

Recall Earlier Routing Discussion

223111

223112

223113

223114 223129

223122

223121

5 DataLink Layer 5-44

223132223131

2231327

A

B

Starting at A given IP datagram addressed to BLook up net address of B find B on same net as ALink layer send datagram to B inside link-layer frame

Brsquos MACaddr

Arsquos MACaddr

Arsquos IPaddr

Brsquos IPaddr IP payload

E

frame sourcedest address

datagram sourcedest address

datagramframe

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 45: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-45

ARP Address Resolution Protocol

Each IP node (Host Router) on LAN has ARP tableARP Table IPMAC address mappings for some LAN nodes

lt IP address MAC address TTLgtTTL (Time To Live) time after which address mapping will be forgotten (typically 20 min)

Question how to determineMAC address of B knowing Brsquos IP address

1A-2F-BB-76-09-AD

58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98

71-65-F7-2B-08-53

LAN

137196723

137196778

137196714

137196788

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 46: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-46

ARP Protocol Same LAN (network)

A wants to send datagram to B and Brsquos MAC address not in Arsquos ARP tableA broadcasts ARP query packet containing Bs IP address

Dest MAC address = FF-FF-FF-FF-FF-FFAll machines on LAN receive ARP query

B receives ARP packet replies to A with its (Bs) MAC address

Frame sent to Arsquos MAC address (unicast)

A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out)

Soft state information that times out (goes away) unless refreshed

ARP is ldquoplug-and-playrdquoNodes create their ARP tables without intervention from net administrator

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 47: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-47

Routing to Another LANWalkthrough send datagram from A to B via R

assume A knows B IP address

Two ARP tables in router R one for each IP network (LAN)

A

RB

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 48: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-48

A creates datagram with source A destination B A uses ARP to get Rrsquos MAC address for 111111111110A creates link-layer frame with Rs MAC address as dest frame contains A-to-B IP datagramArsquos data link layer sends frame Rrsquos data link layer receives frame R removes IP datagram from Ethernet frame sees itrsquos destined to BR uses ARP to get Brsquos physical layer address R creates frame containing A-to-B IP datagram sends to B

A

RB

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 49: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-49

Link Layer

51 Introduction and services52 Error detection and correction 53 Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Hubs and switches57 PPP

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 50: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-50

EthernetldquoDominantrdquo wired LAN technology

Cheap $20 for 100MbsFirst widely used LAN technologySimpler cheaper than token LANs and ATMKept up with speed race 10 Mbps ndash 10 Gbps

Metcalfersquos Ethernetsketch

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 51: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-51

Star TopologyBus topology popular through mid 90sNow star topology prevailsConnection choices hub or switch (more later)

hub orswitch

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 52: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-52

Ethernet Frame Structure

Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame

Preamble (8 bytes)7 bytes with pattern 10101010 followed by one byte with pattern 10101011Used to synchronize receiver sender clock rates

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 53: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-53

Ethernet Frame Structure (more)

Addresses 6 bytes for eachIf adapter receives frame with matching destination address or with broadcast address (eg ARP packet) it passes data in frame to net-layer protocolotherwise adapter discards frame

Type (2 bytes)Indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk)

CRC (4 bytes) Checked at receiver drop the frame if error is detected

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 54: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-54

Unreliable Connectionless Service

Connectionless no handshaking between sending and receiving adapter

Unreliable receiving adapter doesnrsquot send ACKs or NACKs to sending adapter

Stream of datagrams passed to network layer can have gapsGaps will be filled if app is using TCPOtherwise app will see the gaps

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 55: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-55

Ethernet uses CSMACD

No slotsAdapter doesnrsquot transmit if it senses that some other adapter is transmitting that is carrier senseTransmitting adapter aborts when it senses that another adapter is transmitting that is collision detection

Before attempting a retransmission adapter waits a random time that is random accessrandom timedepends upon collisions so far

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 56: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-56

Ethernet CSMACD Algorithm4 If adapter detects another

transmission while transmitting aborts and sends jam signal

5 After aborting adapter enters exponential backoff after the mth collision adapter chooses a K at random from 012hellip2m-1 Adapter waits K512 bit times and returns to Step 2

1 Adaptor receives datagram from network layer amp creates frame

2 If adapter senses channel idle it starts to transmit frame If it senses channel busy waits until channel idle and then transmits

3 If adapter transmits entire frame without detecting another transmission the adapter is done with frame

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 57: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-57

Ethernetrsquos CSMACD (more)Jam Signal make sure all

other transmitters are aware of collision 48 bits

Bit time 1 microsec for 10 Mbps Ethernet for K=1023 wait time is about 50 msec

Exponential BackoffGoal adapt retransmission attempts to estimated current load

Heavy load random wait will be longer

First collision choose K from 01 delay is K 512 bit transmission timesAfter second collision choose K from 0123hellipAfter ten collisions choose K from 01234hellip1023

Seeinteract with Javaapplet on AWL Web sitehighly recommended

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 58: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-58

CSMACD Efficiency

Tprop = max time to propagate between 2 nodes in LANTtrans = time to transmit max-size Ethernet frame

Efficiency goes to 1 as tprop goes to 0Goes to 1 as ttrans goes to infinityMuch better than ALOHA but still decentralized simple and cheap

transprop TT 511efficiency

+=

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 59: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-59

Link Layer

51 Introduction and services52 Error detection and correction 53Multiple access protocols54 Link-Layer Addressing55 Ethernet

56 Interconnections Hubs and switches57 PPP

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 60: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-60

Interconnecting LANs

Q Why not just one big LAN Limited amount of supportable traffic on single LAN all stations must share bandwidth Limited length 8023 specifies maximum cable length Large ldquocollision domainrdquo (can collide with many stations)Limited number of stations 8025 have token passing delays at each station

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 61: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-61

HubsPhysical Layer devices essentially repeaters operating at bit levels repeat received bits on one interface to all other interfacesHubs can be arranged in a hierarchy (or multi-tier design) with backbone hub at its top

hub hub hub

hub

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 62: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-62

Hubs (more)

Each connected LAN referred to as LAN segmentHubs do not isolate collision domains node may collide with any node residing at any segment in LAN Hub Advantages

Simple inexpensive deviceMulti-tier provides graceful degradation portions of the LAN continue to operate if one hub malfunctionsExtends maximum distance between node pairs (100m per Hub)

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 63: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-63

Hub Limitations

Single collision domain results in no increase in max throughput

Multi-tier throughput same as single segment throughput

Individual LAN restrictions pose limits on number of nodes in same collision domain and on total allowed geographical coverage Cannot connect different Ethernet types (eg 10BaseT and 100baseT)

We now move on to switches

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 64: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-64

Switch

Link layer deviceStores and forwards Ethernet framesExamines frame header and selectivelyforwards frame based on MAC dest addressWhen frame is to be forwarded on segment uses CSMACD to access segment

TransparentHosts are unaware of presence of switches

Plug-and-play self-learningSwitches do not need to be configured

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 65: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-65

Switch Traffic IsolationSwitch installation breaks subnet into LAN segmentsSwitch filters packets

Same-LAN-segment frames not usually forwarded onto other LAN segmentsSegments become separate collision domains

hub hub hub

switch

collision domain collision domain

collision domain

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 66: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-66

Switch Forwarding

hub hubhub

switch1

2 3

How do determine onto which LAN segment to forward frameLooks like a routing problem

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 67: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-67

Switch Self Learning

A switch has a switch tableEntry in switch table

(MAC Address Interface Time Stamp)Stale entries in table dropped (TTL can be 60 min)

Switch learns which hosts can be reached through which interfaces

When frame received switch ldquolearnsrdquo location of sender incoming LAN segmentRecords senderlocation pair in switch table

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 68: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-68

Switch FilteringForwardingWhen switch receives a frame

Index switch table using MAC dest addressif entry found for destination

thenif dest on segment from which frame arrived

then drop the frameelse forward the frame on interface indicated

else flood

forward on all but the interface on which the frame arrived

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 69: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-69

Switch ExampleSuppose C sends frame to D

Switch receives frame from from CNotes in switch table that C is on interface 1Because D is not in table switch forwards frame into interfaces 2 and 3

Frame received by D

hub hub hub

switch

B CD G H

A

EF

I

address interface1

2 3 1123

ABEG

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 70: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-70

Switch ExampleSuppose D replies back with frame to C

Switch receives frame from from DNotes in switch table that D is on interface 2Because C is in table switch forwards frame only to interface 1

Frame received by C

hub hub hub

switch

B CD G H

A

EF

I

address interface11231

ABEGC

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 71: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-71

Switches Dedicated Access

switch

A

Arsquo

B

Brsquo

C

CrsquoSwitch with many interfacesHosts have direct connection to switchNo collisions full duplex

Switching A-to-Arsquo and B-to-Brsquosimultaneously no collisions

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 72: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-72

More on Switches

Cut-through switching frame forwarded from input to output port without first collecting entire frame

Slight reduction in latency

Combinations of shareddedicated 101001000 Mbps interfaces

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 73: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-73

Institutional Network

hub hubhub

switch

to externalnetwork

router

IP subnet

mail server

web server

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 74: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-74

Switches vs RoutersBoth store-and-forward devices

Routers network layer devices (examine network layer headers)Switches are link layer devices

Routers maintain routing tables implement routing algorithmsSwitches maintain switch tables implement filtering learning algorithms

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 75: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-75

Summary Comparison

switcheshubs routers

trafficisolation

no yes yes

plug amp play yes no yes

optimalrouting

no yes no

cutthrough

yes no yes

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary
Page 76: Chapter 5 Link Layer and LANs - Hong Kong University of

5 DataLink Layer 5-76

Chapter 5 SummaryPrinciples behind data link layer services

Error detection correctionSharing a broadcast channel multiple accessLink layer addressing

Instantiation and implementation of various link layer technologies

EthernetHubs switchesIEEE 80211 (detailed see next Chapter)PPP

  • Chapter 5 The Data Link Layer
  • Link Layer
  • Link Layer Setting the Context
  • Link Layer Setting the Context
  • Link Layer Introduction
  • Link Layer Introduction
  • Link Layer Services
  • Link Layer Services (more)
  • Link Layer
  • Error Detection
  • Parity Checking
  • Internet Checksum
  • Checksumming Cyclic Redundancy Check
  • CRC Example
  • Example (r=3)
  • Link Layer
  • Multiple Access Links and Protocols
  • Multiple Access protocols
  • Ideal Multiple Access Protocol
  • MAC Protocols a Taxonomy
  • Channel Partitioning MAC protocols TDMA
  • Channel Partitioning MAC protocols FDMA
  • Random Access Protocols
  • Slotted ALOHA
  • Slotted ALOHA
  • Slotted Aloha Efficiency
  • Pure (Unslotted) ALOHA
  • Pure Aloha Efficiency
  • CSMA (Carrier Sense Multiple Access)
  • CSMA (Carrier Sense Multiple Access)
  • CSMA Collisions
  • CSMACD (Collision Detection)
  • CSMACD Collision Detection
  • ldquoTaking Turnsrdquo MAC protocols
  • ldquoTaking Turnsrdquo MAC protocols
  • Summary of MAC Protocols
  • LAN Technologies
  • Link Layer
  • MAC Addresses and ARP
  • LAN Addresses and ARP
  • LAN Address (more)
  • Recall Earlier Routing Discussion
  • ARP Address Resolution Protocol
  • ARP Protocol Same LAN (network)
  • Routing to Another LAN
  • Link Layer
  • Ethernet
  • Star Topology
  • Ethernet Frame Structure
  • Ethernet Frame Structure (more)
  • Unreliable Connectionless Service
  • Ethernet uses CSMACD
  • Ethernet CSMACD Algorithm
  • Ethernetrsquos CSMACD (more)
  • CSMACD Efficiency
  • Link Layer
  • Interconnecting LANs
  • Hubs
  • Hubs (more)
  • Hub Limitations
  • Switch
  • Switch Traffic Isolation
  • Switch Forwarding
  • Switch Self Learning
  • Switch FilteringForwarding
  • Switch Example
  • Switch Example
  • Switches Dedicated Access
  • More on Switches
  • Institutional Network
  • Switches vs Routers
  • Summary Comparison
  • Chapter 5 Summary