0% found this document useful (0 votes)
4 views

5. Link Layer - Part 1

Chapter 5 of 'Computer Networking: A Top Down Approach' covers the link layer, which is responsible for transferring datagrams between adjacent nodes over various types of links. It discusses link layer services such as framing, error detection and correction, flow control, and multiple access protocols. The chapter also outlines the implementation of the link layer in network interface cards and various protocols used for communication in local area networks (LANs).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

5. Link Layer - Part 1

Chapter 5 of 'Computer Networking: A Top Down Approach' covers the link layer, which is responsible for transferring datagrams between adjacent nodes over various types of links. It discusses link layer services such as framing, error detection and correction, flow control, and multiple access protocols. The chapter also outlines the implementation of the link layer in network interface cards and various protocols used for communication in local area networks (LANs).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

Chapter 5

Link Layer

Computer
Networking: A
Top Down
Approach
6th edition
Jim Kurose, Keith
Ross
Addison-Wesley
March 2012

Link Layer 5-1


Link layer:
introduction
terminology:
 hosts and routers: nodes
 communication channels global ISP
that connect adjacent
nodes along
communication path: links
 wired links
 wireless links
 LANs
 layer-2 packet: frame,
encapsulates datagram

data-link layer has responsibility of


transferring datagram from one node
to physically adjacent node over a link
Link Layer 5-2
Link layer: context
 datagram transferred transportation
by different link analogy:
protocols over different  trip from A to B
links:  limo: A to X
 e.g., Ethernet on  plane: X to Y
first link, frame relay  train: Y to B
on intermediate  tourist = datagram
links, 802.11 on last  transport segment =
link
communication link
 each link protocol  transportation mode =
provides different
link layer protocol
services
 e.g., may or may not
 travel agent = routing
algorithm
provide rdt over link
Link Layer 5-3
Link layer services

framing, link access:
 encapsulate datagram into frame, adding
header, trailer
 channel access if shared medium
 “MAC” addresses used in frame headers to
identify source, dest
• different from IP address!
 reliable delivery between adjacent nodes
 we learned how to do this already (chapter 3)!
 seldom used on low bit-error link (fiber, some
twisted pair)
 wireless links: high error rates
• Q: why both link-level and end-end
reliability?

Link Layer 5-4


Link layer services
(more)
 flow control:
 pacing between adjacent sending and receiving
nodes
 error detection:
 errors caused by signal attenuation, noise.
 receiver detects presence of errors:
• signals sender for retransmission or drops frame
 error correction:
 receiver identifies and corrects bit error(s) without
resorting to retransmission
 half-duplex and full-duplex
 with half duplex, nodes at both ends of link can
transmit, but not at same time

Link Layer 5-5


Where is the link layer
implemented?
 in each and every host
 link layer implemented
in “adaptor” (aka
network interface card
NIC) or on a chip
 Ethernet card, 802.11 application
transport
card; Ethernet chipset network
link
cpu memory

 implements link,
physical layer host
bus
 attaches into host’s link
controller (e.g., PCI)

system buses physical


physical
 combination of transmission

hardware, software,
firmware network adapter
card

Link Layer 5-6


Adaptors communicating

datagram datagram

controller controller

sending host receiving host


datagram

frame

 sending side:  receiving side


 encapsulates datagram in frame  looks for errors, rdt, flow
 adds error checking bits, rdt, control, etc
flow control, etc.  extracts datagram,
 transmits the frame into the passes to upper layer at
communication link, following the link- receiving side
access protocol

Link Layer 5-7


Link layer, LANs: outline
5.1 introduction, 5.5 link virtualization:
services MPLS
5.2 error detection, 5.6 data center
correction networking
5.3 multiple access 5.7 a day in the life
protocols of a web request
5.4 LANs
 addressing, ARP
 Ethernet
 switches
 VLANS

Link Layer 5-8


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

• Error detection not 100% reliable!


• protocol may miss some errors, but rarely
• larger EDC field yields better detection and correction

otherwise

Error-detection and -correction scenario Link Layer 5-9


Parity checking
single bit parity: two-dimensional bit parity:
 detect single bit  detect and correct single bit errors
errors

0 0

Link Layer 5-10


Suppose that a packet’s payload consists of 10 eight-bit
values (e.g., representing ten ASCII-encoded characters)
shown below.

1. For figure 1, compute the two-dimensional parity bits


for the 16 columns.
2. For figure 1, compute the two-dimensional parity bits
for the 5 rows starting from the top).
3. For figure 1, compute the parity bit for the parity bit
row from question 1. Assume that the result should be
even.
4. For figure 2, indicate the row and column with the
flipped bit (format as: x,y), assuming the top-left bit is
0,0 Data Link Layer 5-11
Internet checksum (review)
goal: detect “errors” (e.g., flipped bits) in transmitted
packet (note: used at transport layer only)
receiver:
sender:  receiver checks the
 Bytes of data are checksum by taking the 1s
treated as 16-bit complement of the sum of
integers and the received data
 check if computed
summed
 1s complement of checksum equals checksum
field value:
this sum then forms  Not Equal - error
the Internet
checksum detected
 Equal - no error detected.
 sender puts But maybe errors
checksum value into nonetheless?
UDP checksum field

Link Layer 5-12


Why is check summing used at the transport layer and
cyclic redundancy check used at the link layer?

the transport layer is error detection at


typically implemented
the link layer is
in software in a host as
part of the host’s implemented in
operating system. dedicated hardware
in adapters, which
transport-layer error can rapidly perform
detection is the more complex
implemented in CRC operations.
software, it is
important to have a
simple and fast error-
detection scheme such
as checksumming.
Data Link Layer 5-13
Cyclic redundancy check
more powerful error-detection coding
Consider d-bit piece of data, D, that the sending node wants to
send to the receiving node
The sender and receiver must first agree on an r + 1 bit pattern,
known as a generator G.
goal: Sender chooses r CRC bits, R, and append them to D
such that
 <D,R> exactly divisible by G (modulo 2)
receiver divides <D,R> by G. If non-zero remainder: error
detected!
 can detect all burst errors less than r+1 bits
widely used in practice (Ethernet, 802.11 WiFi, ATM)

Link Layer 5-14


Data Link Layer 5-15
D = 101110, d = 6, G = 1001, and r=3.
CRC example The 9 bits transmitted in this case are 101110
011

want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r
by G, want
remainder R to
satisfy:
D.2r
R = remainder[ ]
G

Link Layer 5-16


Consider the Cyclic Redundancy Check
(CRC) algorithm, Suppose that the 4-bit
generator (G) is 1001, that the data
payload (D) is 10011011 and that r = 3.
What are the CRC bits (R) associated with
the data payload D?

Data Link Layer 5-17


A bit stream 10011101 is transmitted using the standard CRC
method. The generator polynomial is 1001.
1.What is the actual bit string transmitted?
2.Suppose the third bit from the left is inverted during
transmission. How will receiver detect this error?

A bit stream 1101011011 is transmitted using the standard CRC


method. The generator polynomial is x4+x+1. What is the actual
bit string transmitted?

Data Link Layer 5-18


Link layer, LANs: outline
5.1 introduction,
services
5.2 error detection,
correction
5.3 multiple access
protocols
5.4 LANs
 addressing, ARP
 Ethernet
 switches
 VLANS

Link Layer 5-19


Multiple access links,
protocols
two types of “links”:
 point-to-point
 PPP for dial-up access
 point-to-point link between Ethernet switch, host
 broadcast (shared wire or medium)
 old-fashioned Ethernet
 upstream HFC (Hybrid fiber-coaxial)
 802.11 wireless LAN

shared wire (e.g., shared RF shared RF humans


cabled Ethernet) (e.g., 802.11 WiFi) (satellite)

Link Layer 5-20


Multiple access protocols
 single 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 protocol


 distributed algorithm that determines how nodes
share channel, i.e., determine when node can
transmit
 communication about channel sharing must use
channel itself!
 no out-of-band channel for coordination

Link Layer 5-21


An ideal multiple access
protocol
given: broadcast channel of rate R bps
The desired characteristics:
 when one node wants to transmit, it can send
at rate R.
 when M nodes want to transmit, each can send
at average rate R/M
 fully decentralized:
• no special node to coordinate transmissions
• no synchronization of clocks, slots
 simple

Link Layer 5-22


MAC protocols: taxonomy
three broad classes:
 channel partitioning
 divide channel into smaller “pieces” (time slots,
frequency, code)
 allocate piece to node for exclusive use
 random access
 channel not divided, allow collisions
 “recover” from collisions
 “taking turns”
 nodes take turns, but nodes with more to send can
take longer turns

Link Layer 5-23


Channel partitioning MAC protocols:
TDMA
TDMA: time division multiple access
 access 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, 1,3,4


have pkt, slots 2,5,6 idle

Link Layer 5-24


Channel partitioning MAC protocols:
FDMA
FDMA: frequency division multiple
access
 channel spectrum divided into
frequency bands
 each station assigned fixed
frequency band
 unused transmission time in
frequency bands go idle time
 example: 6-station LAN, 1,3,4 have
frequency bands
pkt, frequency bands 2,5,6 idle

FDM cable

Link Layer 5-25


Code Division Multiple
Access
(CDMA) Used in Radio & Television
broadcasting

Used in digital cellular telephone and


mobile radio communication.

Used in 2G and 3G cellular telephony

4G and 5G use orthogonal frequency division multiple access (OFD


Data Link Layer 5-26
Random access protocols
 when node has packet to send
 transmit at full channel data rate R.
 no a priori coordination among nodes
 two or more transmitting nodes ➜
“collision”,
 random access MAC protocol specifies:
 how to detect collisions
 how to recover from collisions (e.g., via
delayed retransmissions)
 examples of random access MAC
protocols:
 slotted ALOHA
 ALOHA
 CSMA, CSMA/CD, CSMA/CA
Link Layer 5-27
Slotted ALOHA
assumptions: operation:
 all frames same size  when node obtains fresh
 time divided into frame, transmits in next
equal size slots (time slot
to transmit 1 frame)  if no collision: node
 nodes start to can send new frame
transmit only slot in next slot
beginning  if collision: node
 nodes are retransmits frame in
synchronized each subsequent slot
 if 2 or more nodes with prob. p until
transmit in slot, all success
nodes detect collision

Link Layer 5-28


Slotted ALOHA
node 1 1 1 1 1

node 2 2 2 2

node 3 3 3 3

C E C S E C E S S

Pros: Cons:
 single active node  collisions, wasting
can continuously slots
transmit at full rate  idle slots
of channel  nodes may be able to
 highly decentralized: detect collision in less
only slots in nodes than time to transmit
need to be in sync packet
 simple  clock synchronization
Link Layer 5-29
Slotted ALOHA: efficiency

!
efficiency: long-run at best:
fraction of successful channel
slots used for useful
(many nodes, all with transmissions
many frames to send) 37%
of time!

Link Layer 5-30


Pure (unslotted) ALOHA
 unslotted Aloha: simpler, no synchronization
 when frame first arrives
 transmit immediately
 collision probability increases:
 frame sent at t0 collides with other frames sent
in [t0-1,t0+1]

Link Layer 5-31


Pure ALOHA efficiency
P(success by given node) = P(node transmits) .
P(no other node transmits in [t0-
1,t0] .
P(no other node transmits in [t0-
1,t0]

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

… choosing optimum p and then letting n

= 1/(2e) = .18
even worse than slotted Aloha!

Link Layer 5-32


CSMA (carrier sense multiple
access)
CSMA: listen before transmit:
if channel sensed idle: transmit entire frame

if channel sensed busy, defer transmission

Link Layer 5-33


CSMA collisions spatial layout of nodes

 collisions can still


occur: propagation
delay means two
nodes may not hear
each other’s
transmission
 collision: entire
packet
transmission time
wasted
 distance &
propagation delay
play role in in
determining collision
probability

Link Layer 5-34


CSMA/CD (collision
detection)
CSMA/CD: carrier sensing, deferral as in
CSMA
 collisions detected within short time
 colliding transmissions aborted, reducing
channel wastage
 collision detection:
 easy in wired LANs: measure signal strengths,
compare transmitted, received signals
 difficult in wireless LANs: received signal
strength overwhelmed by local transmission
strength
 human analogy: the polite conversationalist

Link Layer 5-35


CSMA/CD (collision
detection)
spatial layout of nodes

Link Layer 5-36


Ethernet CSMA/CD
algorithm
1. NIC receives datagram 4. If NIC detects another
from network layer, transmission while
creates frame transmitting, aborts
2. If NIC senses channel and sends jam signal
idle, starts frame 5. After aborting, NIC
transmission. If NIC enters binary
senses channel busy, (exponential) backoff:
waits until channel  after mth collision, NIC
idle, then transmits. chooses K at random
from {0,1,2, …, 2m-1}.
3. If NIC transmits entire NIC waits K·512 bit
frame without times, returns to Step 2
detecting another  longer backoff interval
transmission, NIC is with more collisions
done with frame !

Link Layer 5-37


CSMA/CD efficiency
 Tprop = max prop delay between 2 nodes in LAN
 ttrans = time to transmit max-size frame

 efficiency goes to 1
 as tprop goes to 0
 as ttrans goes to infinity
1
efficiency 
better performance than ALOHA: and simple, cheap, decentralized!

1  5t prop /t trans

Link Layer 5-38


 Refer to questions at end of chapter

Data Link Layer 5-39


“Taking turns” MAC
protocols
channel partitioning MAC protocols:
 share channel efficiently and fairly at high
load
 inefficient at low load: delay in channel
access, 1/N bandwidth allocated even if only
1 active node!
random access MAC protocols
 efficient at low load: single node can fully
utilize channel
 high load: collision overhead
“taking turns” protocols
look for best of both worlds!

Link Layer 5-40


“Taking turns” MAC
protocols
polling:
 master node
“invites” slave data
nodes to transmit poll
in turn
 typically used with master
“dumb” slave data
devices
 concerns:
 polling
slaves
overhead
 latency
 single point of
failure (master)
Link Layer 5-41
“Taking turns” MAC
protocols
token passing:
T
 control token
passed from one
node to next
sequentially.
(nothing
 token message to send)
 concerns: T
 token overhead
 latency
 single point of
failure (token)

data
Link Layer 5-42
Summary of MAC
protocols
 channel partitioning, by time, frequency or
code
 Time Division, Frequency Division
 random access (dynamic),
 ALOHA, S-ALOHA, CSMA, CSMA/CD
 carrier sensing: easy in some technologies
(wire), hard in others (wireless)
 CSMA/CD used in Ethernet
 CSMA/CA used in 802.11
 taking turns
 polling from central site, token passing
 bluetooth, FDDI, token ring

Link Layer 5-43

You might also like