0% found this document useful (0 votes)
162 views57 pages

W4 - 5 - 6 Data Link Layer (8th Ed)

Uploaded by

ahmedemadsaid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views57 pages

W4 - 5 - 6 Data Link Layer (8th Ed)

Uploaded by

ahmedemadsaid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Computer Networking: A Top Down

Approach
Eighth Edition

Chapter 6
The Link Layer and LANs

Slides in this presentation contain


hyperlinks. JAWS users should be
able to get a list of links by using
INSERT+F7

Copyright © 2020, 2017, 2013, 2010 Pearson Education, Inc. All Rights Reserved
Chapter 6: Link Layer and LANs
6.1 Introduction, services
6.2 Error detection, correction
6.3 Multiple access protocols
6.4 LANs
– Addressing, ARP
– Ethernet
– Switches
– VLANS
6.5 Link virtualization: MPLS
6.6 Data center networking
6.7 A day in the life of a web request
6.1. Data Link Layer: Introduction
mobile network

terminology: national or global ISP

• hosts and routers: nodes

• communication channels that connect


adjacent nodes along communication
path: links
– wired links
– wireless links
– LANs

• layer-2 packet: frame, encapsulates datacenter


network
datagram

data-link layer has responsibility of


transferring datagram from one node to enterprise
physically adjacent node over a link network
Major Link Layer Services (1 of 2)
• framing, link access:
– encapsulate datagram into frame, adding header, trailer
– channel access if shared medium
– “MAC” addresses used in frame headers to identify source,
destination
▪ different from IP address!
• reliable delivery between adjacent nodes
– seldom used on low bit-error links (e.g., fiber, some twisted pair)
– wireless links: high error rates
▪ Q: why both link-level and end-end reliability?
Major Link Layer Services (2 of 2)
• 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
Where is the Link Layer Implemented?

• in each and every host and router


• link layer implemented in
“adaptor” (aka network interface
card, NIC) or on a chip
application
– Ethernet card, 802.11 card; transport
cpu memory
network
Ethernet chipset link

– implements link and physical host bus


layer controller
(e.g., PCI)
link
• combination of hardware, physical
physical
firmware and software
network interface
Interfaces communicating

application application
transport transport
memory network
datagram network cpu memory CPU
link
link

linkh datagram controller controller datagram


link link
physical physical
physical physical

sending side: receiving side:


§ encapsulates datagram in frame § looks for errors, reliable data
§ adds error checking bits, reliable transfer, flow control, etc.
data transfer, flow control, etc. § extracts datagram, passes to
upper layer at receiving side
Chapter 6: Link Layer and LANs
6.1 Introduction, services
6.2 Error detection, correction
6.3 Multiple access protocols
6.4 LANs
– Addressing, ARP
– Ethernet
– Switches
– VLANS
6.5 Link virtualization: MPLS
6.6 Data center networking
6.7 A day in the life of a web request
6.2. Error Detection & Correction
D = Data protected by error checking, may include header fields
EDC = Error Detection and Correction bits (redundancy)
• EDC = function(D)
• Error detection is not 100% reliable!
– Protocol may miss some errors, but rarely
– A larger EDC field yields better detection and correction

datagram datagram
otherwise
all
bits in D’ N
OK detected
? error
d data bits
D EDC D’ EDC’

bit-error prone link


Parity Checking – relatively weak
Single bit parity: Two-dimensional bit parity:

• detect single (or odd) bit errors • detect and correct single bit errors

0111000110101011 1

d data bits
parity
bit
Even parity: set parity
bit so there is an even
number of 1’s in all 17
bits

* Check out the online interactive exercises for more examples:


http://gaia.cs.umass.edu/kurose_ross/interactive/
Checksum: Cyclic Redundancy Check
• More powerful error-detection coding: Given D data bit to be protected, wish
to add r redundant bits for protection

• D: given data bits D (think of as a binary number)

• G: Choose r+1 bit pattern (generator)

• Goal: choose r CRC bits, R, such that


– <D,R> exactly divisible by G (modulo 2)
– receiver knows G, 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 Wi-Fi, …)


CRC Example
want: D.2r XOR R =nG

equivalently: D.2r = nGXOR R


equivalently: if we divide D.2r
by G, want remainder R to satisfy:

é D.2r ù
R = remainder ê ú
ë G û

* Check out the online interactive exercises for more examples:


http://gaia.cs.umass.edu/kurose_ross/interactive/
Chapter 6: Link Layer and LANs
6.1 Introduction, services
6.2 Error detection, correction
6.3 Multiple access protocols
6.4 LANs
– Addressing, ARP
– Ethernet
– Switches
– VLANS
6.5 Link virtualization: MPLS
6.6 Data center networking
6.7 A day in the life of a web request
6.3. Multiple Access Links, Protocols
Two types of “links”:
• point-to-point
– point-to-point link between Ethernet switch, host
– PPP for dial-up access

• Broadcast (shared wire or medium)


– old-fashioned Ethernet
– 802.11 wireless LAN, 4G/5G, satellite
Multiple Access Protocols
• Single shared broadcast channel
• Two or more simultaneous transmissions by nodes:
cause interference
– Collision if a node receives two or more signals at the same time

Multiple Access Protocol


• Distributed algorithm (run by nodes): how to share the
channel? i.e., determine when a node can transmit!
• N.B. Communication to coordinate about channel sharing must
use the same data channel itself!
– No other channel for coordination
The Ideal MAC Protocol
Given: Broadcast channel of rate R bps
Desired Features:
1. When one node wants to transmit, it can send at max. rate, R.
(fully utilize the channel capacity, R)

2. When M > 1 nodes want to transmit on (i.e. share) the


channel, each can send at average rate R/M (fair sharing)
3. Fully decentralized:
– no special node to coordinate transmissions
– no synchronization of clocks, slots
4. Simple
MAC Protocols: Taxonomy
Three broad classes:
• Channel Partitioning (contention-free)
– divide channel (resource) into smaller “pieces” (time slots,
frequency, code)
– allocate piece of “resource” to a node for exclusive use
– No collisions!

• Random Access (contention-based)


– channel not divided: nodes compete for the shared channel
– Collisions possible => Need to “recover” from collisions

• “Taking turns” (e.g., AP arbitrates between users)


– nodes take turns, but nodes with more to send can take
longer turns
1.1. Channel Partitioning MAC
Protocols: TDMA
TDMA: time division multiple access
TDMA
• Access to channel in “rounds”;
frequency
recurring frames (epochs)
• Each station gets fixed length slot
(length = frame transmission time) in
each round
• Main Disadvantage: unused slots go
idle, doesn’t scale
• Example: time
– 6-station LAN, 1,3,4 have packets to
send, slots 2,5,6 idle

Highly inefficient at light loads!


1.2. Channel Partitioning MAC
Protocols: FDMA
FDMA: frequency division multiple access

• Channel spectrum divided into frequency channels

• Each station assigned a fixed, exclusive frequency channel

• Main Disadvantage: unused transmission time in frequency bands go idle

• Example: 6-station LAN, only nodes 1,3,4 have packets to send, frequency
bands 2,5,6 go idle
FDMA
frequency

time

Highly inefficient at light loads!


2. Random Access MAC Protocols
• when a node has packet to send
– Like Ideal MAC: transmit at full channel data rate R
– no a priori coordination among nodes

• But, two or more transmitting nodes → “collision”


• Random Access MAC protocol specifies:
– how to detect (or avoid) collisions
– how to recover from collisions (e.g., via randomly delayed
retransmissions)

• Examples of random access MAC protocols:


– ALOHA / Slotted ALOHA
– CSMA, CSMA/CD, CSMA/CA
ALOHA (Pure, Unslotted)
• unslotted Aloha: simpler, no synchronization
• when frame first arrives
– transmit immediately
• collision probability increases: (partial frame overlap possible)
– frame sent at t0 collides with other frames sent in [t0-1, t0+1]
Slotted ALOHA
• Time is divided into equal size slots (time to transmit one frame)
• Nodes start to transmit only at the slot beginning!

Pros: Cons:
• single active node can • collisions, wasting slots
continuously transmit at full • idle slots
rate of channel
• clock synchronization
• highly decentralized
• simple
Slotted ALOHA: efficiency (throughput)
Efficiency (throughput): long-run fraction of successful
slots (assuming many nodes, all with many frames to send)
• Consider N nodes with many frames to send, each
transmits in a slot with probability p
– prob that given node has success in a slot = p(1-p)N-1
– prob that any node has a success = Np(1-p)N-1
– max efficiency: find p* that maximizes Np(1-p)N-1
– for many nodes (N → infinity): Np (1-p)N-1 ~ Np.e-Np (= G.e-G)

max efficiency = 1/e = 0.367


• at best: the channel is used for useful transmissions 37% of time!
CSMA (Carrier Sense Multiple Access)
CSMA: listen before talk (transmit):
• Q: How is channel sensing done (Carrier Sensing)?
– CS: Tx collects RF energy for a pre-specified duration and
compares it with a pre-set threshold
– if channel sensed idle: transmit the frame
– else, if channel sensed busy, defer transmission

• Human analogy: don’t interrupt others!

One step of RA node coordination, beyond simple Aloha!


CSMA Collisions
• 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
determining collision
probability
CSMA/CD (Collision Detection) (1 of 2)
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!
CSMA/CD (Collision Detection) (2 of 2)

§ CSMA/CD reduces the


amount of time wasted
in collisions
• transmission aborted on
collision detection
3. “Taking Turns” MAC Protocols (1 of 3)
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 the best of both worlds!
3.1. “Taking Turns” MAC protocols
Polling: Token passing:
v control token passed from one
• master node “invites” slave nodes
to transmit in turn node to next sequentially.
v token message
• typically used with “dumb” slave
devices v concerns:

• concerns: § token overhead


– polling overhead § latency
– latency § single point of failure (token)
– single point of failure (master)
data
poll

master
data

slaves
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

• Taking turns
– polling from central site, token passing
– Bluetooth, FDDI, IBM Token Ring
Chapter 6: Link Layer and LANs
6.1 Introduction, services
6.2 Error detection, correction
6.3 Multiple access protocols
6.4 LANs
– Addressing, ARP
– Ethernet
– Switches
– VLANS
6.5 Link virtualization: MPLS
6.6 Data center networking
6.7 A day in the life of a web request
MAC Addresses and ARP
• 32-bit IPv4 address:
– network-layer address for interface
– used for layer 3 (network layer) forwarding over WANs
• MAC (or LAN or physical or Ethernet) address:
– function: used “locally” to get frame from one interface to
another physically-connected interface (same network, in
IP-addressing sense)
– 48 bit MAC address (for most LANs) burned in NIC ROM, also
sometimes software settable
– e.g.: 1 A-2 F-BB-76-09-AD
LAN Addresses and ARP
Each NIC on the LAN has:
• a unique 48-bit MAC address
• a locally unique 32-bit IP address (as we’ll see later)

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

= adapter (NIC)
MAC Addresses
• MAC address allocation administered by IEEE
• manufacturer buys portion of MAC address space
(to ensure uniqueness worldwide)
• Analogy:
– MAC address: like Social Security Number (i.e. National ID)
– IP address: like postal address

• MAC flat address → portability


– can move LAN card from one LAN to another

• IP hierarchical address not portable


– address depends on IP subnet to which node is attached
ARP: Address Resolution Protocol
Question: how to determine ARP table: each IP node
Interface’s MAC address (host, router) on LAN has a
Knowing its IP address? table
– IP/MAC address
mappings for some
LAN nodes:
< IP address; MAC
address; TTL>
– TTL (Time To Live):
time after which
address mapping will
be forgotten (typically
20 min)
ARP Protocol: Same LAN
Chapter 6: Link Layer and LANs
6.1 Introduction, services
6.2 Error detection, correction
6.3 Multiple access protocols
6.4 LANs
– Addressing, ARP
– Ethernet
– Switches
– VLANS
6.5 Link virtualization: MPLS
6.6 Data center networking
6.7 A day in the life of a web request
Ethernet (IEEE 802.3)
“dominant” wired LAN technology:
• single chip, multiple speeds
• first widely used LAN technology
• simpler, cheap
• kept up with speed race: 10 Mbps – 10 Gbps

Metcalfe’s Ethernet sketch


Ethernet: Physical Topology
• Bus (broadcast medium): bus: coaxial cable
popular through mid 90s
(Hub-based Ethernet)
– all nodes in same collision
domain (can collide with each
other)

• Star: prevails today.


star
(Switched Ethernet)
– active switch in center
– each “spoke” runs a
(separate) Ethernet protocol
(nodes do not collide with
each other!)
Ethernet Frame Structure (1 of 2)
Sending node encapsulates IP datagrams (or other
network layer protocol packet) in an Ethernet frame

Preamble:
• 7 bytes with the pattern 10101010 followed by one byte with
the pattern 10101011
• used to synchronize receiver and sender clock rates
Ethernet Frame Structure (2 of 2)
• Addresses: 6 byte source, destination MAC addresses
– If a node receives a frame with matching destination address,
or with broadcast address (e.g. ARP packet), it passes the
datagram in the frame to the network layer protocol
– Otherwise, adapter discards frame
• Type: indicates which higher layer protocol (mostly IP, but others
possible)
• CRC: cyclic redundancy check at receiver
– If error is detected: the frame is dropped
Ethernet: Unreliable, Connectionless
• connectionless: no handshaking between sending and
receiving NICs
• unreliable: receiving NIC doesn't send acks or nacks to
the sending NIC
– data in dropped frames recovered only if initial sender uses
higher layer rdt (e.g., TCP), otherwise dropped data lost

• Ethernet’s MAC protocol: unslotted CSMA/CD with


binary (exponential) backoff
Ethernet CSMA/CD Algorithm
1. NIC receives datagram from network layer, creates frame

2. If NIC senses channel idle (i.e. Carrier Sensing), starts frame transmission.
If NIC senses channel busy, waits until channel idle then transmits.

3. If NIC transmits entire frame without detecting another transmission, NIC is


done with the frame!

4. If NIC detects another transmission while transmitting (i.e. Collision


Detection), it aborts and sends a jam signal

5. After aborting, NIC enters binary (exponential) backoff:


– after mth collision, NIC chooses K at random from {0,1,2, …, 2m - 1}.
NIC waits K*512 bit times, returns to Step 2
– → experiences longer backoff interval with more collisions
5-44

Ethernet’s CSMA/CD (more)


Jam Signal: make sure all Exponential Backoff:
other transmitters are aware • Goal: adapt retransmission
of collision; 48 bits attempts based on the
Bit time: 0.1 microsec for 10 estimated current load
Mbps Ethernet ; – heavy load: random wait
for K=1023, wait time is about will be longer
50 msec = 1023 * 512 * 10-7 • first collision: choose K from
{0,1}; delay is K· 512 bit
transmission times
• after second collision: choose K
from {0,1,2,3}…
• after ten collisions, choose K
from {0,1,2,3,4,…,1023}
IEEE 802.3 Ethernet Standards: Link &
Physical Layers
• many different Ethernet standards
– common MAC protocol and frame format
– different speeds: 2 Mbps, 10 Mbps, 100 Mbps, 1Gbp
s, 10 Gbps, 40 Gbps
3

– different physical layer media: fiber, cable


Chapter 6: Link Layer and LANs
6.1 Introduction, services
6.2 Error detection, correction
6.3 Multiple access protocols
6.4 LANs
– Addressing, ARP
– Ethernet
– Switches
– VLANS
6.5 Link virtualization: MPLS
6.6 Data center networking
6.7 A day in the life of a web request
Hubs (physical layer device)
… physical-layer (“dumb”) repeaters:
– bits coming in one link go out on all other links at same rate
– all nodes connected to a hub can collide with one another
– no frame buffering
– no CSMA/CD at hub: host NICs detect collisions

twisted pair

hub
Ethernet Switch (link layer device)
• Link-layer device: takes an active role
– store, forward Ethernet frames
– examine incoming frame’s MAC address, selectively
forward frame to one-or-more outgoing links when
frame is to be forwarded on a segment, uses
CSMA/CD to access segment
• Transparent
– hosts are unaware of presence of switches
• Plug-and-play, self-learning
– switches do not need to be configured
Switch: allows multiple simultaneous
transmissions
• hosts have dedicated, direct
connections to switch
• switches buffer packets
• Ethernet protocol used on
each incoming link, but no
collisions; full duplex
– each link is its own
collision domain
• switching: A-to-A’ and B-to-B’
can transmit simultaneously,
without collisions
Switch Forwarding Table
Q: how does the switch know A’ is
reachable via interface 4, B’ reachable
via interface 5?
• A: each switch has a switch table,
each entry:
– (MAC address of host, interface
to reach host, time stamp)
– looks like a routing table!

Q: how are entries created,


maintained in the switch table?
– something like a routing
protocol?
Switch: Self-Learning
• switch learns which hosts can be reached through which
interfaces
– when frame received, switch “learns” location of sender:
incoming LAN segment
– records the sender/location pair in switch table
– If switch doesn’t receive from this host yet, it floods to reach it!

Example:
When switch receives frame from A,
it records Interface 1 as the interface to
reach A
MAC addr interface Time
A 1 9:32

switch table (initially empty)


Switch: Frame Filtering/Forwarding
When a frame is received at a switch:
1. record incoming link, MAC address of sending host
2. index switch table using MAC destination address
3. if entry found for destination
then {
if destination on segment from which frame arrived
then drop frame
else forward frame on interface indicated by entry
}
else flood /* forward on all interfaces except arriving
interface */
Self-Learning, Forwarding: Example
• frame destination, A’,
location unknown: flood
• destination A location
known: selectively send
on just one link

MAC addr interface Time


A 1 9:32
A’ 4 9:36

switch table (initially empty)


Interconnecting Switches
self-learning switches can be connected together:

Q: sending from A to G - how does S1 know how to forward


frame destined to G via S4 and S3?
– A: self learning! (works exactly the same as in single-
switch case!)
Self-Learning Multi-Switch Example
Suppose C sends frame to I, I responds to C

1
2

• Q: show switch tables and packet forwarding in S1, S2,


S3, S4
Institutional Network
Switches vs. Routers
Both are store-and-forward:
• routers: network-layer devices
(examine network-layer headers)
• switches: link-layer devices
(examine link-layer headers)

Both have forwarding tables:


• routers: compute tables using
routing algorithms, IP addresses
• switches: learn forwarding table
using flooding, learning MAC
addresses

You might also like