2/25/21
Chapter 6
The Link Layer
and LANs
A note on the use of these PowerPoint slides:
We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you see the animations; and can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following:
§ If you use these slides (e.g., in a class) that you mention their source (after all, we’d like people to use our book!)
§ If you post any slides on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material.
For a revision history, see the slide note for this page. Thanks and enjoy! JFK/KWR
All material copyright 1996-2020
J.F Kurose and K.W. Ross, All Rights Reserved
Computer Networking: A
Top-Down Approach
8th edition
Jim Kurose, Keith Ross Pearson, 2020
Link layer and LANs: our goals
§understand principles behind link layer services:
• error detection, correction
• sharing a broadcast channel:
multiple access
• link layer addressing
• local area networks:
Ethernet, VLANs §datacenter networks
§instantiation, implementation of various link layer technologies
Link Layer: 6-2
12
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§ link virtualization: MPLS § data center networking
§ a day in the life of a web request
Link Layer: 6-3
Link layer: introduction
terminology:
§ hosts and routers: nodes
§ communication channels that connect adjacent nodes along communication path: links
• wired
• wireless • LANs
§ layer-2 packet: frame, encapsulates datagram
mobile network
enterprise network
national or global ISP
da er ne
Link Layer: 6-4
tacent twork
link layer has responsibility of transferring datagram from one node to physically adjacent node over a link
34
1
Link layer: services
§ framing, link access:
• encapsulate datagram into frame, adding …
header, trailer
• channel access if shared medium
• “MAC” addresses in frame headers identify
source, destination (different from IP address!)
§ reliable delivery between adjacent nodes • we already know how to do this!
• seldom used on low bit-error links
• wireless links: high error rates
• Q: why both link-level and end-end reliability?
…
Link Layer: 6-6
56
Link layer: services (more)
§ flow control: …
• pacing between adjacent sending and receiving nodes
§ error detection:
• errors caused by signal attenuation, noise. • receiver detects errors, signals
retransmission, or drops frame
§ error correction:
• receiver identifies and corrects bit error(s)
without retransmission
§ half-duplex and full-duplex:
• with half duplex, nodes at both ends of link can transmit, but not at same time
…
Link Layer: 6-7
Where is the link layer implemented?
§in each-and-every host
§link layer implemented in network interface card (NIC) or on a chip
• Ethernet, WiFi card or chip
• implements link, physical layer
§attaches into host’s system buses
§combination of hardware, software, firmware
host bus (e.g., PCI)
nterface
Link Layer: 6-8
application transport
network
link
cpu
memory
controller
link
physical
physical
network i
78
2/25/21
Link layer: context
§datagram transferred by different link protocols over differentlinks:
• e.g., WiFi on first link, Ethernet onnextlink
§each link protocol provides different services
• e.g., may or may not provide reliable data transfer over link
transportation analogy:
§ trip from Princeton to Lausanne • limo:PrincetontoJFK
• plane: JFK to Geneva
• train:GenevatoLausanne
§tourist = datagram §transport segment =
communication link
§ transportation mode = link-layer protocol
§travel agent = routing algorithm
Link Layer: 6-5
2
2/25/21
Interfaces communicating
datagram network
application transport
network
link
application transport
cpu m
emory
memory
CPU
link
l
datagram
datagram
receiving side:
§ looks for errors, reliable data
transfer, flow control, etc.
§ extracts datagram, passes to upper layer at receiving side
l
i
i
n
n
k
k
h
controller
controller
h
link
physical
link
physical
physical
physical
sending side:
§ encapsulates datagram in frame
§ adds error checking bits, reliable data
transfer, flow control, etc.
Link Layer: 6-9
Link layer, LANs: roadmap
§ introduction
§error detection, correction §multiple access protocols
§ LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§link virtualization: MPLS §data center networking
§ a day in the life of a web request
Link Layer: 6-10
9 10
Error detection
EDC: error detection and correction bits (e.g., redundancy)
D: data protected by error checking, may include header fields
datagram
d data bits
D EDC
bit-error prone link
all
bits in D’ N
OK detected ? error
D’ EDC’
datagram
otherwise
Error detection not 100% reliable!
§ protocol may miss some errors, but rarely
§ larger EDC field yields better detection and correction
Link Layer: 6-11
Parity checking
single bit parity:
§ detect single bit errors
d data bits
parity bit
Even parity: set parity bit so there is an even number of 1’s
two-dimensional bit parity:
§ detect and correct single bit errors row parity
0111000110101011
1
d1,1 . . . d2,1 . . . … …
d1,j d1,j+1 d2,j d2,j+1 … …
di,j di,j+1 di+1,j di+1,j+1
detected 10101 1 and
column parity
noerrors: 10101 1 11110 0 01110 1 10101 0
di,1 di+1,1
. . .
. . .
* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Link Layer: 6-12
parity correctable 10110 0 error
single-bit error:
01110 1 10101 0
parity error
11 12
3
2/25/21
Internet checksum (review)
Goal: detect errors (i.e., flipped bits) in transmitted segment
sender:
§treat contents of UDP segment (including UDP header fields and IP addresses) as sequence of 16-bit integers
§checksum: addition (one’s complement sum) of segment content
§checksum value put into UDP checksum field
receiver:
§compute checksum of received segment
§check if computed checksum equals checksum field value:
• not equal – error detected
• equal – no error detected. But maybe
errors nonetheless? More later ….
Transport Layer: 3-13
Cyclic Redundancy Check (CRC)
§more powerful error-detection coding
§D: data bits (given, think of these as a binary number) §G: bit pattern (generator), of r+1 bits (given)
r CRC bits d data bits
D R bit pattern
goal: choose r CRC bits, R, such that
• can detect all burst errors less than r+1 bits
• widely used in practice (Ethernet, 802.11 WiFi)
Link Layer: 6-14
13 14
Link layer, LANs: roadmap
§ introduction
§error detection, correction §multiple access protocols
§ LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§link virtualization: MPLS §data center networking
§ a day in the life of a web request
Link Layer: 6-16
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
• upstream HFC in cable-based access network
• 802.11 wireless LAN, 4G/4G. satellite
shared wire (e.g., shared radio: 4G/5G shared radio: WiFi cabled Ethernet)
shared radio: satellite
humans at a cocktail party (shared air, acoustical)
Link Layer: 6-17
16 17
4
18 19
2/25/21
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: 6-18
An ideal multiple access protocol
given: multiple access channel (MAC) of rate R bps
desiderata:
1. when one node wants to transmit, it can send at rate R.
2. when M nodes want to transmit, each can send at average
rate R/M
3. fully decentralized:
• no special node to coordinate transmissions
• no synchronization of clocks, slots 4. simple
Link Layer: 6-19
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: 6-20
Channel partitioning MAC protocols: TDMA
TDMA: time division multiple access
§ access to channel in “rounds”
§ each station gets fixed length slot (length = packet transmission time) in each round
§ unused slots go idle
§ example: 6-station LAN, 1,3,4 have packets to send, slots 2,5,6 idle
6-slot 6-slot frame frame
134134
Link Layer: 6-21
20 21
5
22 23
2/25/21
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
§ example: 6-station LAN, 1,3,4 have packet to send, frequency bands 2,5,6 idle
FDM cable
Link Layer: 6-22
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:
• ALOHA, slotted ALOHA
• CSMA, CSMA/CD, CSMA/CA
Link Layer: 6-23
Slotted ALOHA
assumptions:
§all frames same size
§time divided into equal size
slots (time to transmit 1 frame)
§nodes start to transmit only slot beginning
§nodes are synchronized
§if 2 or more nodes transmit in slot, all nodes detect collision
operation:
§when node obtains fresh frame, transmits in next slot
• if no collision: node can send new frame in next slot
• if collision: node retransmits frame in each subsequent slot with probability p until success
randomization – why?
Link Layer: 6-24
Slotted ALOHA
node111 11 node 2 2 2 2
C: collision S: success E: empty
node3 3 CECSECESS
3 3
Pros:
§ single active node can continuously transmit at full rate of channel
§ highly decentralized: only slots in nodes need to be in sync
§ simple
Cons:
§ collisions, wasting slots
§ idle slots
§ nodes may be able to detect collision in less than time to transmit packet
§ clock synchronization
Link Layer: 6-25
24 25
6
time
frequency bands
2/25/21
Slotted ALOHA: efficiency
efficiency: long-run fraction of successful slots (many nodes, all with many frames to send)
§ suppose: N nodes with many frames to send, each transmits in 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, take limit of Np*(1-p*)N-1 as N goes to infinity, gives:
max efficiency = 1/e = .37
§ at best: channel used for useful transmissions 37% of time!
Link Layer: 6-26
Pure ALOHA
§ unslotted Aloha: simpler, no synchronization • when frame first arrives: transmit immediately
§ collision probability increases with no synchronization:
• frame sent at t0 collides with other frames sent in [t0-1,t0+1]
will overlap with start of i’s frame
will overlap
with end of i’s frame
§ pure Aloha efficiency: 18% !
t0 -1
t0
t0 +1
Link Layer: 6-27
26 27
CSMA (carrier sense multiple access)
simple CSMA: listen before transmit:
• if channel sensed idle: transmit entire frame • if channel sensed busy: defer transmission
§human analogy: donʼt interrupt others!
CSMA/CD: CSMA with collision detection
• collisions detected within short time
• colliding transmissions aborted, reducing channel wastage • collision detection easy in wired, difficult with wireless
§human analogy: the polite conversationalist
Link Layer: 6-28
CSMA: collisions
§collisions can still occur with carrier sensing:
• propagation delay means two nodes may not hear each other’s just- started transmission
§collision: entire packet transmission time wasted
• distance & propagation delay play role in in determining collision probability
spatial layout of nodes
Link Layer: 6-29
28 29
7
30 31
2/25/21
CSMA/CD:
§CSMA/CS reduces the amount of time wasted in collisions
• transmission aborted on collision detection
spatial layout of nodes
Link Layer: 6-30
Ethernet CSMA/CD algorithm
1. NIC receives datagram from network layer, creates frame
2. If NIC senses channel:
if idle: start frame transmission.
if busy: wait until channel idle, then transmit
3. If NIC transmits entire frame without collision, NIC is done with frame !
4. If NIC detects another transmission while sending: abort, send jam signal
5. After aborting, NIC enters binary (exponential) backoff:
• aftermthcollision,NICchoosesKatrandomfrom{0,1,2,…,2m-1}.NICwaits
K·512 bit times, returns to Step 2
• morecollisions:longerbackoffinterval
Link Layer: 6-31
CSMA/CD efficiency
§Tprop = max prop delay between 2 nodes in LAN §ttrans = time to transmit max-size frame
efficiency = 1 1+5tprop/ttrans
§ efficiency goes to 1
• as tprop goes to 0
• as ttrans goes to infinity
§ better performance than ALOHA: and simple, cheap, decentralized!
Link Layer: 6-32
“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: 6-33
32 33
8
“Taking turns” MAC protocols
polling:
§master node “invites” other nodes to transmit in turn
§typically used with “dumb” devices
§ concerns:
• polling overhead
• latency
• single point of failure (master)
data
poll
master
data
slaves
Link Layer: 6-34
“Taking turns” MAC protocols
token passing:
§ control token passed from one node to next sequentially.
§ token message § concerns:
• token overhead
• latency
• single point of failure
(token)
T
(nothing to send)
T
data
Link Layer: 6-35
34 35
2/25/21
Cable access network: FDM, TDM and random access! Internet frames, TV channels, control transmitted
cable headend
downstream at different frequencies
…
CMTS
…
splitter
cable modem
IS
P
cable modem termination system
§ multiple downstream (broadcast) FDM channels: up to 1.6 Gbps/channel § single CMTS transmits into channels
§ multiple upstream channels (up to 1 Gbps/channel)
§ multiple access: all users contend (random access) for certain upstream channel time slots; others assigned TDM
Link Layer: 6-36
Cable access network:
MAP frame for Interval [t1, t2]
Downstream channel i Upstream channel j
CMTS
cable headend
t1
Minislots containing minislots request frames
Residences with cable modems
Assigned minislots containing cable modem upstream data frames
DOCSIS: data over cable service interface specificaiton § FDM over upstream, downstream frequency channels
§ TDM upstream: some slots assigned, some have contention
• downstream MAP frame: assigns upstream slots
• request for upstream slots (and data) transmitted random access (binary backoff) in selected slots
Link Layer: 6-37
t2
36 37
9
2/25/21
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: 6-38
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§ link virtualization: MPLS § data center networking
§ a day in the life of a web request
Link Layer: 6-39
38 39
MAC addresses
§ 32-bit IP address:
• network-layer address for interface
• used for layer 3 (network layer) forwarding • e.g.: 128.119.40.136
§ MAC (or LAN or physical or Ethernet) address:
• function: used “locally” to get frame from one interface to another
physically-connected interface (same subnet, in IP-addressing sense)
• 48-bit MAC address (for most LANs) burned in NIC ROM, also sometimes software settable
• e.g.: 1A-2F-BB-76-09-AD
hexadecimal (base 16) notation (each “numeral” represents 4 bits)
Link Layer: 6-40
MAC addresses
each interface on LAN
§ has unique 48-bit MAC address
§ has a locally unique 32-bit IP address (as we’ve seen)
137.196.7.78
1A-2F-BB-76-09-AD
LAN (wired or wireless)
137.196.7/24
71-65-F7-2B-08-53
137.196.7.23
58-23-D7-FA-20-B0
137.196.7.14
0C-C4-11-6F-E3-98
137.196.7.88
Link Layer: 6-41
40 41
10
ARP: address resolution protocol
Question: how to determine interface’s MAC address, knowing its IP address?
ARP table: each IP node (host, router) on LAN has 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)
Link Layer: 6-43
ARP
ARP
137.196.7.78
1A-2F-BB-76-09-AD LAN
ARP
71-65-F7-2B-08-53
58-23-D7-FA-20-B0
137.196.7.23
137.196.7.14
ARP
0C-C4-11-6F-E3-98
137.196.7.88
42 43
1
A broadcasts ARP query, containing B’s IP addr
• destination MAC address = FF-FF-FF-FF-FF-FF • allnodesonLANreceiveARPquery
C
Ethernet frame (sent to FF-FF-FF-FF-FF-FF)
ARP protocol in action
example: A wants to send datagram to B
• BʼsMACaddressnotinA’sARPtable,soAusesARPtofindB’sMACaddress
ARP table in A
Source MAC: 71-65-F7-2B-08-53 Source IP: 137.196.7.23
Target IP address: 137.196.7.14
…
B
58-23-D7-FA-20-B0
137.196.7.14
IP addr
MAC addr
TTL
A
1
71-65-F7-2B-08-53 137.196.7.23
D
Link Layer: 6-44
ARP protocol in action
example: A wants to send datagram to B
• BʼsMACaddressnotinA’sARPtable,soAusesARPtofindB’sMACaddress
ARP message into Ethernet frame (sent to 71-65-F7-2B-08-53)
B
2
D
Target IP address: 137.196.7.14 Target MAC address:
ARP table in A
C A
…
58-23-D7-FA-20-B0
IP addr
MAC addr
TTL
71-65-F7-2B-08-53 137.196.7.23
58-23-D7-FA-20-B0
137.196.7.14
B replies to A with ARP response, giving its MAC address
Link Layer: 6-45
2
44 45
2/25/21
MAC addresses
§MAC address allocation administered by IEEE §manufacturer buys portion of MAC address space (to
assure uniqueness)
§ analogy:
• MAC address: like Social Security Number • IP address: like postal address
§ MAC flat address: portability
• can move interface from one LAN to another
• recall IP address not portable: depends on IP subnet to which
node is attached
Link Layer: 6-42
11
ARP protocol in action
example: A wants to send datagram to B
• BʼsMACaddressnotinA’sARPtable,soAusesARPtofindB’sMACaddress
ARP table in A
C A
71-65-F7-2B-08-53 137.196.7.23
IP addr
MAC addr
TTL
137.196. 7.14
58-23-D7-FA-20-B0
500
B
58-23-D7-FA-20-B0
137.196.7.14
3 A receives B’s reply, adds B entry into its local ARP table
D
Link Layer: 6-46
Routing to another subnet: addressing
walkthrough: sending a datagram from A to B via R
§focus on addressing – at IP (datagram) and MAC layer (frame) levels §assume that:
• • •
A knows B’s IP address
A knows IP address of first hop router, R (how?) A knows R’s MAC address (how?)
A
111.111.111.111 74-29-9C-E8-FF-55
111.111.111.112 CC-49-DE-D0-AB-7D
R
222.222.222.220 1A-23-F9-CD-06-9B
111.111.111.110 E6-E9-00-17-BB-4B
B
222.222.222.222 49-BD-D2-C7-56-2A
222.222.222.221 88-B2-2F-54-1A-0F
Link Layer: 6-47
46 47
Routing to another subnet: addressing
§ A creates IP datagram with IP source A, destination B
§ A creates link-layer frame containing A-to-B IP datagram
• R’sMACaddressisframe’sdestination
MAC src: 74-29-9C-E8-FF-55 MAC dest: E6-E9-00-17-BB-4B
c: 111.111.111.111 dest: 222.222.222.222
IP sr IP
IP
Eth
Phy
A
111.111.111.111 74-29-9C-E8-FF-55
111.111.111.112 CC-49-DE-D0-AB-7D
R
222.222.222.220 1A-23-F9-CD-06-9B
111.111.111.110 E6-E9-00-17-BB-4B
B
222.222.222.222 49-BD-D2-C7-56-2A
222.222.222.221 88-B2-2F-54-1A-0F
Link Layer: 6-48
Routing to another subnet: addressing
§ frame sent from A to R
§ frame received at R, datagram removed, passed up to IP
B
222.222.222.222 49-BD-D2-C7-56-2A
222.222.222.221 88-B2-2F-54-1A-0F
MAC src: 74-29-9C-E8-FF-55
MAC dest: E6-E9-00-17-BB-4B
dest: 222.222.222.222
IP src: 111.111.111.111
IP dest: 222.222.222.222 c: 111.111.111.111
IP sr IP
IP
Eth
Phy
IP
Eth
Phy
A
111.111.111.111 74-29-9C-E8-FF-55
111.111.111.112 CC-49-DE-D0-AB-7D
R
222.222.222.220 1A-23-F9-CD-06-9B
111.111.111.110 E6-E9-00-17-BB-4B
Link Layer: 6-49
48 49
2/25/21
12
Routing to another subnet: addressing
§ R determines outgoing interface, passes datagram with IP source A, destination B to link layer
§ R creates link-layer frame containing A-to-B IP datagram. Frame destination address:
B’s MAC address
A
111.111.111.111 74-29-9C-E8-FF-55
111.111.111.112 CC-49-DE-D0-AB-7D
MAC src: 1A-23-F9-CD-06-9B MAC dest: 49-BD-D2-C7-56-2A
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
Eth
Phy
R
222.222.222.220 1A-23-F9-CD-06-9B
111.111.111.110 E6-E9-00-17-BB-4B
B
222.222.222.222 49-BD-D2-C7-56-2A
222.222.222.221 88-B2-2F-54-1A-0F
Link Layer: 6-50
Routing to another subnet: addressing
§ R determines outgoing interface, passes datagram with IP source A, destination B to link layer
§ R creates link-layer frame containing A-to-B IP datagram. Frame destination address:
B’s MAC address
§ transmits link-layer frame
MAC src: 1A-23-F9-CD-06-9B MAC dest: 49-BD-D2-C7-56-2A
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
Eth
Phy
IP
Eth
Phy
A
111.111.111.111 74-29-9C-E8-FF-55
111.111.111.112 CC-49-DE-D0-AB-7D
R
222.222.222.220 1A-23-F9-CD-06-9B
111.111.111.110 E6-E9-00-17-BB-4B
B
222.222.222.222 49-BD-D2-C7-56-2A
222.222.222.221 88-B2-2F-54-1A-0F
Link Layer: 6-51
50 51
2/25/21
Routing to another subnet: addressing
§ B receives frame, extracts IP datagram destination B § B passes datagram up protocol stack to IP
IP
Eth
Phy
IP
Eth
Phy
A
111.111.111.111 74-29-9C-E8-FF-55
111.111.111.112 CC-49-DE-D0-AB-7D
R
222.222.222.220 1A-23-F9-CD-06-9B
111.111.111.110 E6-E9-00-17-BB-4B
IP src: 111.111.111.111
IP dest: 222.222.222.222
B
222.222.222.222 49-BD-D2-C7-56-2A
222.222.222.221 88-B2-2F-54-1A-0F
Link Layer: 6-52
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§ link virtualization: MPLS § data center networking
§ a day in the life of a web request
Link Layer: 6-53
52 53
13
54 55
2/25/21
Ethernet
“dominant” wired LAN technology:
§ first widely used LAN technology
§simpler, cheap
§ kept up with speed race: 10 Mbps – 400 Gbps
§ single chip, multiple speeds (e.g., Broadcom BCM5761)
Metcalfe’s Ethernet sketch
https://www.uspto.gov/learning-and-resources/journeys-innovation/audio-stories/defying-doubters
Link Layer: 6-54
Ethernet: physical topology
§ bus: popular through mid 90s
• all nodes in same collision domain (can collide with each other)
§ switched: prevails today
• active link-layer 2 switch in center
• each “spoke” runs a (separate) Ethernet protocol (nodes do not collide with each other)
bus: coaxial cable switched
Link Layer: 6-55
Ethernet frame structure
sending interface encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame
type
preamble
dest. address
source address
data (payload)
CRC
preamble:
§ used to synchronize receiver, sender clock rates
§7 bytes of 10101010 followed by one byte of 10101011
Link Layer: 6-56
Ethernet frame structure (more)
type
§addresses: 6 byte source, destination MAC addresses
• if adapter receives frame with matching destination address, or with broadcast
address (e.g., ARP packet), it passes data in frame to network layer protocol
• otherwise, adapter discards frame
preamble
dest. address
source address
data (payload)
CRC
§type: indicates higher layer protocol
• mostly IP but others possible, e.g., Novell IPX, AppleTalk • used to demultiplex up at receiver
§CRC: cyclic redundancy check at receiver • error detected: frame is dropped
Link Layer: 6-57
56 57
14
58 59
2/25/21
Ethernet: unreliable, connectionless
§connectionless: no handshaking between sending and receiving NICs
§unreliable: receiving NIC doesn’t send ACKs or NAKs to 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 backoff
Link Layer: 6-58
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, 1Gbps, 10 Gbps, 40 Gbps • different physical layer media: fiber, cable
application
MAC protocol and frame format
transport
network
100BASE-TX
100BASE-T2
100BASE-FX
link physical
100BASE-T4
100BASE-SX
100BASE-BX
copper (twister pair) physical layer fiber physical layer
Link Layer: 6-59
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§ link virtualization: MPLS § data center networking
§ a day in the life of a web request
Link Layer: 6-60
Ethernet switch
§Switch is a 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 segment, uses CSMA/CD to access segment
§transparent: hosts unaware of presence of switches
§plug-and-play, self-learning
• switches do not need to be configured
Link Layer: 6-61
60 61
15
Switch: multiple simultaneous transmissions
§ hosts have dedicated, direct connection to switch
§ switches buffer packets C’
§ Ethernet protocol used on each
incoming link, so:
• no collisions; full duplex
• each link is its own collision B’ domain
§ switching: A-to-A’ and B-to-B’ can transmit simultaneously, without collisions
A
2
3
C switch with six
Link Layer: 6-62
B
1
6 5
4
A’
interfaces (1,2,3,4,5,6)
Switch: multiple simultaneous transmissions
§ hosts have dedicated, direct connection to switch
§ switches buffer packets C’
§ Ethernet protocol used on each
incoming link, so:
• no collisions; full duplex
• each link is its own collision B’ domain
§ switching: A-to-A’ and B-to-B’ can transmit simultaneously, without collisions
• butA-to-A’andCtoA’cannothappen simultaneously
A
2
3
C switch with six
Link Layer: 6-63
6 5
4
1
B
A’
interfaces (1,2,3,4,5,6)
62 63
Switch forwarding table
Q: how does switch know A’ reachable via interface 4, B’ reachable via interface 5? C’
A: each switch has a switch table, each entry:
§ (MAC address of host, interface to reach host, time stamp)
§ looks like a routing table! B’
Q: how are entries created, maintained in switch table?
§ something like a routing protocol?
A
2 3
B
1 6
54
A’ C
Link Layer: 6-64
Switch: self-learning
§switch learns which hosts
can be reached through
which interfaces C’
• when frame received, switch “learns” location of sender: incoming LAN segment
• records sender/location pair B’ in switch table
Source: A Dest: A’
A A’ A
2 3
A’ C
Switch table (initially empty)
Link Layer: 6-65
B
1 6
54
MAC addr
interface
TTL
A
1
60
64 65
2/25/21
16
Self-learning, forwarding: example
Source: A Dest: A’
A A’ A
B
C
(initially empty)
Link Layer: 6-67
§frame destination, A’, location unknown: flood
§ destination A location known: selectively send
on just one link
C’
B’
12 A A’ 3
6 54
A’ AA’
switch table
MAC addr
interface
TTL
A A’
1 4
60 60
66 67
Interconnecting switches
self-learning switches can be connected together:
S4
S3
DFI
GH
Q: sending from A to G – how does S1 know to forward frame destined to G via S4 and S3?
§ A: self learning! (works exactly the same as in single-switch case!)
Link Layer: 6-68
S1
S2
A
BC
E
Self-learning multi-switch example
Suppose C sends frame to I, I responds to C
S4
S3
DFI
GH
Q: show switch tables and packet forwarding in S1, S2, S3, S4
Link Layer: 6-69
S1
S2
A
BC
E
68 69
2/25/21
Switch: frame filtering/forwarding
when frame received at 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 */
Link Layer: 6-66
17
Small institutional network
to external network
mail server
web server
IP subnet
router
Link Layer: 6-70
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
datagram frame
application
transport
network
link
physical
switch
link frame
network datagram link frame
Link Lay6e-r7:16-71
physical
physical
application
transport
network
link
physical
70 71
2/25/21
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§ link virtualization: MPLS § data center networking
§ a day in the life of a web request
Link Layer: 6-72
Virtual LANs (VLANs): motivation
Q: what happens as LAN sizes scale, users change point of attachment? single broadcast domain:
Computer Science
EE
§scaling: all layer-2 broadcast traffic (ARP, DHCP, unknown MAC) must cross entire LAN
§efficiency, security, privacy issues
Link Layer: 6-73
72 73
18
Virtual LANs (VLANs): motivation
Q: what happens as LAN sizes scale, users change point of attachment? single broadcast domain:
Computer Science
EE
§scaling: all layer-2 broadcast traffic (ARP, DHCP, unknown MAC) must cross entire LAN
§efficiency, security, privacy, efficiency issues
administrative issues:
§ CS user moves office to EE – physically attached to EE switch, but wants to remain logically attached to CS switch
Link Layer: 6-74
Port-based VLANs
Virtual Local Area Network (VLAN)
switch(es) supporting VLAN capabilities can be configured to define multiple virtual LANS over single physical LAN infrastructure.
port-based VLAN: switch ports grouped (by switch management software) so that single physical switch ……
……
EE (VLAN ports 1-8) CS (VLAN ports 9-15)
… operates as multiple virtual switches
……
EE (VLAN ports 1-8) CS (VLAN ports 9-15)
Link Layer: 6-75
1
79
15
2
8 10
16
9
15
10
16
17
28
74 75
Port-based VLANs
§traffic isolation: frames to/from ports 1-8 can only reach ports 1-8
• can also define VLAN based on MAC addresses of endpoints, rather than switch port
§dynamic membership: ports can be dynamically assigned among VLANs
§ forwarding between VLANS: done via
routing (just as with separate switches)
• in practice vendors sell combined switches plus routers
… …
1 79 15
2 810 16
EE (VLAN ports 1-8)
CS (VLAN ports 9-15)
Link Layer: 6-76
VLANS spanning multiple switches
1
79
15
2
8 10
16
1357
2468
……
…
EE (VLAN ports 1-8) CS (VLAN ports 9-15) Ports 2,3,5 belong to EE VLAN Ports 4,6,7,8 belong to CS VLAN
trunk port: carries frames between VLANS defined over multiple physical switches
§ frames forwarded within VLAN between switches can’t be vanilla 802.1 frames (must carry VLAN ID info)
§ 802.1q protocol adds/removed additional header fields for frames forwarded between trunk ports
Link Layer: 6-77
76 77
2/25/21
19
2/25/21
802.1Q VLAN frame format
type
type
Tag Control Information
(12 bit VLAN ID field, 3 bit priority field like IP TOS)
preamble
dest. address
source address
data (payload)
CRC
preamble
dest. address
source address
data (payload)
CRC
2-byte Tag Protocol Identifier (value: 81-00)
802.1 Ethernet frame
802.1Q frame
Link Layer: 6-78
Recomputed CRC
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§link virtualization: MPLS § data center networking
§ a day in the life of a web request
Link Layer: 6-79
78 79
Multiprotocol label switching (MPLS)
§ goal: high-speed IP forwarding among network of MPLS-capable routers, using fixed length label (instead of shortest prefix matching)
• faster lookup using fixed length identifier
• borrowing ideas from Virtual Circuit (VC) approach • but IP datagram still keeps IP address!
20 315
IP sses
Ethernet remaindrermoafinEdtheerronfeEt tfhraemrne,tinfrcalmudei,nigncIPluding
MPLS header
header header hweitahdIePr swoiuthrcIeP, sdoeusrtcinea, tdioenstaindadtrioenssaedsdre
label
Exp
S
TTL
Link Layer: 6-80
MPLS capable routers
§ a.k.a. label-switched router
§ forward packets to outgoing interface based only on label value (don’t inspect IP address)
• MPLS forwarding table distinct from IP forwarding tables
§flexibility: MPLSforwardingdecisionscandifferfrom those of IP
• use destination and source addresses to route flows to same
destination differently (traffic engineering)
• re-route flows quickly if link fails: pre-computed backup paths
Link Layer: 6-81
80 81
20
MPLS versus IP paths
R6
R4 R5
D R3
R2
IP router
A
§IP routing: path to destination determined by destination address alone
Link Layer: 6-82
MPLS versus IP paths
IP/MPLS entry router (R4) can use different MPLS routes to A based, e.g., on IP source address or other fields
R6
R4 R5
§ MPLS routing: path to destination can be based on source and destination address
• flavor of generalized forwarding (MPLS 10 years earlier)
• fast reroute: precompute backup routes in case of link failure
D R3
IP router
IP/MPLS router
§IP routing: path to destination determined by destination address alone
A
R2
R1
Link Layer: 6-83
82 83
MPLS signaling
§modify OSPF, IS-IS link-state flooding protocols to carry info used by MPLS routing:
• e.g., link bandwidth, amount of “reserved” link bandwidth §entry MPLS router uses RSVP-TE signaling protocol to set up
MPLS forwarding at downstream routers
RSVP-TE
R2
R6
R4
R5 modified link state flooding
D R3
A
R1
Link Layer: 6-84
MPLS forwarding tables
R6
R4 R5
in label
out label
10
dest
A
out interface
0
12 8
D A
0 1
in label
out label
dest
out interface
10 12
6 9
A D
1 0
00 11
D R3
00 R2 R1
A
in label
out label
dest
out interface
8
6
A
0
in label
6
out label
–
dest
A
out interface
0
Link Layer: 6-85
84 85
2/25/21
21
2/25/21
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§ link virtualization: MPLS § data center networking
§ a day in the life of a web request
Link Layer: 6-86
Datacenter networks
10’s to 100’s of thousands of hosts, often closely coupled, in close proximity:
§ e-business (e.g. Amazon)
§ content-servers (e.g., YouTube, Akamai, Apple, Microsoft) § search engines, data mining (e.g., Google)
challenges:
§ multiple applications, each serving
massive numbers of clients
§ reliability
§ managing/balancing load, avoiding
processing, networking, data bottlenecks
Inside a 40-ft Microsoft container, Chicago data center
Link Layer: 6-87
86 87
Datacenter networks: network elements
………… …………
Border routers
§ connections outside datacenter Tier-1 switches
§connectingto ~16T-2sbelow Tier-2 switches
§connectingto ~16TORsbelow
Top of Rack (TOR) switch
§ one per rack
§ 40-100Gbps Ethernet to blades
Server racks
§ 20- 40 server blades: hosts
Link Layer: 6-88
Datacenter networks: network elements
Facebook F16 data center network topology:
https://engineering.fb.com/data-center-engineering/f16-minipack/ (posted 3/2019)
Link Layer: 6-89
88 89
22
90
91
92
93
Datacenter networks: multipath
§ rich interconnection among switches, racks:
• increased throughput between racks (multiple routing paths possible) • increased reliability via redundancy
9 10 11 12 13 14 15 16 two disjoint paths highlighted between racks 1 and 11
Datacenter networks: application-layer routing
Internet
Datacenter networks: protocol innovations
§ link layer:
• RoCE: remote DMA (RDMA) over Converged Ethernet
§ transport layer:
• ECN (explicit congestion notification) used in transport-layer congestion control (DCTCP, DCQCN)
• experimentation with hop-by-hop (backpressure) congestion control
Link layer, LANs: roadmap
§ introduction
§ error detection, correction § multiple access protocols § LANs
• addressing, ARP • Ethernet
• switches
• VLANs
§ link virtualization: MPLS § data center networking
§routing, management:
• SDN widely used within/among organizations’ datacenters
• place related services, data as close as possible (e.g., in same rack or nearby
§ a day in the life of a web request
rack) to minimize tier-2, tier-1 communication
Link Layer: 6-90
Link Layer: 6-91
Link Layer: 6-92
Link Layer: 6-93
… …………
… … …
Load balancer
load balancer: application-layer routing
§ receives external client requests
§ directs workload
within data center
§ returns results to
external client (hiding data center internals from client)
2/25/21
23
A day in the life: scenario
browser
school network 68.80.2.0/24
web page
web server 64.233.169.105
DNS server
Comcast network 68.80.0.0/13
Google’s network 64.233.160.0/19
scenario:
§ arriving mobile client attaches to network …
§ requests web page:
www.google.com
Sounds simple!
Link Layer: 6-95
94 95
A day in the life: connecting to the Internet
DHCP
UDP
IP
Eth
Phy
DHCP DHCP DHCP DHCP
arriving mobile: DHCP client
router has DHCP server
§connecting laptop needs to get its own IP address, addr of first-hop router, addr of DNS server: use DHCP
§DHCP request encapsulated in UDP, encapsulated in IP, encapsulated in 802.3 Ethernet
§Ethernet frame broadcast (dest: FFFFFFFFFFFF) on LAN, received at router running DHCP server
§Ethernet demuxed to IP demuxed, UDP demuxed to DHCP
Link Layer: 6-96
DHCP
DHCP
UDP
IP
Eth
Phy
DHCP DHCP DHCP DHCP
A day in the life: connecting to the Internet
DHCP
UDP
IP
Eth
Phy
DHCP DHCP DHCP DHCP
DHCP DHCP DHCP DHCP
DHCP
arriving mobile: DHCP client
router has DHCP server
§DHCP server formulates DHCP ACK containing client’s IP address, IP address of first-hop router for client, name & IP address of DNS server
§encapsulation at DHCP server, frame forwarded (switch learning) through LAN, demultiplexing at client
DHCP
UDP
IP
Eth
Phy
§DHCP client receives DHCP ACK reply
Client now has IP address, knows name & addr of DNS server, IP address of its first-hop router
Link Layer: 6-97
96 97
2/25/21
Synthesis: a day in the life of a web request
§our journey down the protocol stack is now complete! • application, transport, network, link
§putting-it-all-together: synthesis!
• goal: identify, review, understand protocols (at all layers) involved in
seemingly simple scenario: requesting www page
• scenario: student attaches laptop to campus network, requests/receives www.google.com
Link Layer: 6-94
24
A day in the life… ARP (before DNS, before HTTP)
§ before sending HTTP request, need IP address
DNS
DNS DNS DNS
ARP query
ARP reply
ARP
arriving mobile: ARP client
router has ARP server
of www.google.com: DNS
§ DNS query created, encapsulated in UDP, encapsulated in IP, encapsulated in Eth. To send frame to router, need MAC address of router interface: ARP
§ ARP query broadcast, received by router, which replies with ARP reply giving MAC address of router interface
§ client now knows MAC address of first hop router, so can now send frame containing DNS query
Link Layer: 6-98
UDP
ARPIP
Eth
Phy
Eth
Phy
A day in the life… using DNS
DNS DNS DNS DNS
DNS
§ IP datagram containing DNS query forwarded via LAN switch from client to 1st hop router
DNS
§ demuxed to DNS
§ DNS replies to client
with IP address of www.google.com
DNS
UDP
IP
Eth
Phy
DNS
UDP
IP
Eth
Phy
DNS DNS DNS DNS
DNS server
Comcast network 68.80.0.0/13
§ IP datagram forwarded from campus network into Comcast network, routed (tables created by RIP, OSPF, IS-IS and/or BGP routing protocols) to DNS server
Link Layer: 6-99
98 99
100 101
H H
T T
§ HTTP request sent into TCP socket
§ IP datagram containing HTTP request routed to www.google.com
§ web server responds with HTTP reply (containing web page)
§ IP datagram containing HTTP reply routed back to client
Link Layer: 6-101
T
P
HTTP TCP IP Eth Phy
H
T
T
H
T T
HT
A day in the life… HTTP request/reply
T T
P P
TT
TP
P
HTTP HTTP HTTP HTTP
HTTP TCP IP Eth Phy
Google web server 64.233.169.105
Comcast network 68.80.0.0/13
2/25/21
A day in the life…TCP connection carrying HTTP
HTTP
TCP
IP
Eth Phy
HTTP
S YSNYANC K SYSNYANCK S YS SNY YAN NC K
S Y SN YA NC K S YSNYANC K SYSNYANCK
Comcast network 68.80.0.0/13
§ to send HTTP request, client first opens TCP socket to web server
§ TCP SYN segment (step 1 in TCP 3-way handshake) inter- domain routed to web server
§ web server responds with TCP SYNACK (step 2 in TCP 3- way handshake)
§ TCP connection established! Link Layer: 6-100
TCP
IP Eth Phy
Google
web server 64.233.169.105
H H
T T
P P
H H
P P
§ web page finally (!!!) displayed
T T
T
25
102 103
2/25/21
Chapter 6: Summary
§principles behind data link layer services: • error detection, correction
• sharing a broadcast channel: multiple access • link layer addressing
§ instantiation, implementation of various link layer technologies • Ethernet
• switched LANS, VLANs
• virtualized networks as a link layer: MPLS
§ synthesis: a day in the life of a web request
Link Layer: 6-102
Chapter 6: let’s take a breath
§ journey down protocol stack complete (except PHY)
§ solid understanding of networking principles, practice! § ….. could stop here …. but more interesting topics!
• wireless • security
Link Layer: 6-103
Additional Chapter 6 slides
Network Layer: 5-104
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: 6-105
104 105
26