Link layer, LANs: roadmap
introduction
error detection, correction
multiple access protocols
LANs
• addressing, ARP
• Ethernet
• switches
• VLANs
Link Layer: 6-1
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-2
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 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14
0C-C4-11-6F-E3-98
137.196.7.88
Link Layer: 6-3
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-4
ARP: address resolution protocol
Question: how to determine interface’s MAC address, knowing its IP
address?
ARP table: each IP node (host,
ARP
router) on LAN has table
137.196.7.78
ARP
1A-2F-BB-76-09-AD • IP/MAC address mappings for
ARP some LAN nodes:
LAN < IP address; MAC address; TTL>
71-65-F7-2B-08-53
137.196.7.23
58-23-D7-FA-20-B0
137.196.7.14 • TTL (Time To Live): time after
ARP 0C-C4-11-6F-E3-98 which address mapping will be
137.196.7.88
forgotten (typically 20 min)
Link Layer: 6-5
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address
A broadcasts ARP query, containing B's IP addr
Ethernet frame (sent to FF-FF-FF-FF-FF-FF)
1 • destination MAC address = FF-FF-FF-FF-FF-FF
• all nodes on LAN receive ARP query C Source MAC: 71-65-F7-2B-08-53
Source IP: 137.196.7.23
ARP table in A Target IP address: 137.196.7.14
…
IP addr MAC addr TTL
TTL
A B
1
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14
D
Link Layer: 6-6
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address
ARP message into Ethernet frame
(sent to 71-65-F7-2B-08-53)
C Target IP address: 137.196.7.14
Target MAC address:
ARP table in A 58-23-D7-FA-20-B0
…
IP addr MAC addr TTL
TTL
A B
2
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14
2 B replies to A with ARP response,
giving its MAC address
D
Link Layer: 6-7
ARP protocol in action
example: A wants to send datagram to B
• B’s MAC address not in A’s ARP table, so A uses ARP to find B’s MAC address
C
ARP table in A
IP addr MAC addr TTL
TTL
137.196. 58-23-D7-FA-20-B0 500
A B
7.14
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
137.196.7.23 137.196.7.14
3 A receives B’s reply, adds B entry
into its local ARP table
D
Link Layer: 6-8
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 B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-9
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's MAC address is frame’s destination
MAC src: 74-29-9C-E8-FF-55
MAC dest: E6-E9-00-17-BB-4B
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
Eth
Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-10
Routing to another subnet: addressing
frame sent from A to R
frame received at R, datagram removed, passed up to IP
MAC src: 74-29-9C-E8-FF-55
IP src: 111.111.111.111
MAC dest: E6-E9-00-17-BB-4B
IP dest: 222.222.222.222
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP IP
Eth Eth
Phy Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-11
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
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
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-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
MAC src: 1A-23-F9-CD-06-9B
transmits link-layer frame MAC dest: 49-BD-D2-C7-56-2A
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
IP Eth
Eth Phy
Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-13
Routing to another subnet: addressing
B receives frame, extracts IP datagram destination B
B passes datagram up protocol stack to IP
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP
IP Eth
Eth Phy
Phy
A B
R
111.111.111.111
74-29-9C-E8-FF-55 222.222.222.222
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B
111.111.111.112 111.111.111.110
CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 222.222.222.221
88-B2-2F-54-1A-0F
Link Layer: 6-14
Link Layer: 6-15
Reverse Address Resolution
Protocol
RARP (Reverse Address Resolution Protocol) is a network protocol used
to map a physical address (MAC address) to an IP address in a local
network.
It operates in the data link layer of the OSI model and is considered the
reverse of ARP (Address Resolution Protocol), which maps an IP address
to a MAC address.
It is an older protocol designed to help devices discover their IP address
based on their MAC address.
While useful in its time, it has been largely replaced by BOOTP and DHCP,
which are more flexible and widely used today.
Link Layer: 6-16
Link layer, LANs: roadmap
introduction
error detection, correction
multiple access protocols
LANs
• addressing, ARP
• Ethernet
• switches
• VLANs
Link Layer: 6-17
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-18
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-19
Ethernet frame structure
sending interface encapsulates IP datagram (or other network layer
protocol packet) in Ethernet frame
type
preamble dest. source data (payload) CRC
address address
preamble:
used to synchronize receiver, sender clock rates
Link Layer: 6-20
Ethernet frame structure (more)
type
preamble dest. source data (payload) CRC
address address
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
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-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-22
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
MAC protocol
application
and frame format
transport
network 100BASE-TX 100BASE-T2 100BASE-FX
link 100BASE-T4 100BASE-SX 100BASE-BX
physical
copper (twister pair) physical layer fiber physical layer
Link Layer: 6-23
Link layer, LANs: roadmap
introduction
error detection, correction
multiple access protocols
LANs
• addressing, ARP
• Ethernet
• switches
• VLANs
Link Layer: 6-24
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.
transparent: hosts unaware of presence of switches
plug-and-play, self-learning
• switches do not need to be configured
Link Layer: 6-25
Switch: multiple simultaneous transmissions
hosts have dedicated, direct
connection to switch A
switches buffer packets C’ B
Ethernet protocol used on each 1 2
6
incoming link, so: 3
5 4
• no collisions; full duplex
• each link is its own collision B’ C
A’
domain A-to-A’ and B-to-B’ can transmit
switching:
simultaneously, without collisions switch with six
interfaces (1,2,3,4,5,6)
Link Layer: 6-26
Switch: multiple simultaneous transmissions
hosts have dedicated, direct
connection to switch A
switches buffer packets C’ B
Ethernet protocol used on each 1 2
6
incoming link, so: 3
5 4
• no collisions; full duplex
• each link is its own collision B’ C
A’
domain A-to-A’ and B-to-B’ can transmit
switching:
simultaneously, without collisions switch with six
interfaces (1,2,3,4,5,6)
• but A-to-A’ and C to A’ can not happen
simultaneously
Link Layer: 6-27
Switch forwarding table
Q: how does switch know A’ reachable via
interface 4, B’ reachable via interface 5? A
C’ B
A: each switch has a switch table, each
entry: 1 2
6
(MAC address of host, interface to reach 3
host, time stamp) 5 4
looks like a routing table! B’ C
A’
Q: how are entries created, maintained
in switch table?
something like a routing protocol?
Link Layer: 6-28
Switch: self-learning Source: A
switch learns which hosts Dest: A’
A A’
can be reached through A
which interfaces C’ B
• when frame received, switch 1 2
6
“learns” location of sender: 3
5
incoming LAN segment 4
• records sender/location pair B’ C
A’
in switch table
Switch table
MAC addr interface TTL (initially empty)
A 1 60
Link Layer: 6-29
Self-learning, forwarding: example Source: A
Dest: A’
frame destination, A’, A A’
location unknown: flood A
C’ B
destination A location
1
known: selectively send 6A A’
2
on just one link 5 4
3
B’ C
A’ A A’
MAC addr interface TTL
A 1 60 switch table
A’ 4 60 (initially empty)
Link Layer: 6-30
Interconnecting switches
self-learning switches can be connected together:
S4
S1
S3
A S2
F
D I
B C
G H
E
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-31
Self-learning multi-switch example
Suppose C sends frame to I, I responds to C
S4
S1
S3
A S2
F
D I
B C
G H
E
Q: show switch tables and packet forwarding in S1, S2, S3, S4
Link Layer: 6-32
Small institutional network
mail server
to external
network
router web server
IP subnet
Link Layer: 6-33
Switches vs. routers application
transport
both are store-and-forward: datagram
frame
network
link
routers: network-layer devices (examine physical link frame
network-layer headers) physical
switches: link-layer devices (examine switch
link-layer headers) network datagram
link frame
both have forwarding tables: physical
routers: compute tables using routing application
algorithms, IP addresses transport
switches: learn forwarding table using network
link
flooding, learning, MAC addresses physical
6-34
Link Layer: 6-34