0% found this document useful (0 votes)
79 views35 pages

Link Layer: Computer Networking: A Top Down Approach

Uploaded by

Chayon Ghosh
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)
79 views35 pages

Link Layer: Computer Networking: A Top Down Approach

Uploaded by

Chayon Ghosh
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/ 35

Chapter 5

Link Layer

A note on the use of these ppt slides: Computer


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, Networking: A
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 Top Down
ask the following:
 If you use these slides (e.g., in a class) that you mention their source Approach
(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
6th edition
from (or perhaps identical to) our slides, and note our copyright of this Jim Kurose, Keith Ross
material. Addison-Wesley
Thanks and enjoy! JFK/KWR March 2012
All material copyright 1996-2012
J.F Kurose and K.W. Ross, All Rights Reserved

Link Layer 5-1


Chapter 5: Link layer
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
 instantiation, implementation of various link
layer technologies

Link Layer 5-2


Link layer: introduction
terminology:
 hosts and routers: nodes
global ISP
 communication channels that
connect adjacent nodes along
communication path: links
 wired links
 wireless links
 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-3
Link Layer Frame

Data Link Layer


Link layer services
 framing, link access:
 encapsulate datagram into frame, adding header
 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-5


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

Link Layer 5-6


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

card host
 implements link, physical controller
bus
(e.g., PCI)
layer link
physical
physical
 attaches into host’s system transmission
buses
 combination of hardware, network adapter
card
software, firmware

Link Layer 5-7


MAC addresses and ARP
 32-bit IP address:
 network-layer address for interface
 used for layer 3 (network layer) forwarding
 MAC (or LAN or physical or Ethernet) address:
 function: used ‘locally” to get frame from one interface to
another physically-connected interface

 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 “number” represents 4 bits)
Link Layer 5-8
MAC addresses and ARP
each adapter on LAN has unique MAC address

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

LAN
(wired or adapter
wireless)
71-65-F7-2B-08-53
58-23-D7-FA-20-B0

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

Link Layer 5-9


MAC addresses (more)
 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

Link Layer 5-10


ARP: address resolution protocol
Question: how to determine ARP table: each IP node (host,
interface’s MAC address, router) on LAN has table
knowing its IP address?  IP/MAC address mappings
for some LAN nodes:
B  TTL (Time To Live): time
137.196.7.78 after which address mapping
will be forgotten (typically 20
1A-2F-BB-76-09-AD min)
137.196.7.23
137.196.7.14
 ARP Table of Node A
A
LAN
71-65-F7-2B-08-53
58-23-D7-FA-20-B0 IP MAC TTL
137.196.7 1A-2F-BB-76-09- 20 min
0C-C4-11-6F-E3-98 .78 AD
137.196.7.88 … … …

Link Layer 5-11


Data Link Layer
ARP protocol: same LAN
 A wants to send a frame to B
 B’s MAC address not in A’s ARP
table.
 A broadcasts ARP query frame,
containing B's IP address. The
format is:
Source Dest. Source Dest. IP
MAC MAC IP
71-65-F7- 137.196. 137.196.7
2B-08-53 7.23 .78

Link Layer 5-13


ARP protocol: same LAN
 A wants to send a frame to B
 B’s MAC address not in A’s ARP
table.
 A broadcasts ARP query frame,
containing B's IP address. The
format is:
Source Dest. Source Dest. IP
MAC MAC IP
71-65- FF-FF-FF- 137.196. 137.196.7
F7-2B- FF-FF-FF 7.23 .78
08-53 ARP Response Frame:
Source Dest. Source Dest. IP
 B receives ARP Query frame, MAC MAC IP
replies to A with its (B's) MAC
1A-2F- 71-65- 137.196. 137.196.
address BB-76- F7-2B- 7.78 7.23
 frame sent to A’s MAC address 09-AD 08-53
(unicast)
Link Layer 5-14
Notes on ARP
 A caches (saves) IP-to-
MAC address pair in its
ARP table until
information becomes old
(times out)
 soft state: information that
times out (goes away)
unless refreshed
 ARP is “plug-and-play”:
 nodes create their ARP
tables without intervention
from net administrator

Data Link Layer


Addressing: routing to another LAN
walkthrough: send datagram from A to B via R
 focus on addressing – at IP (datagram) and MAC layer (frame)
 assume A knows B’s IP address
 assume A knows IP address of first hop router, R (how?)
 assume A knows R’s MAC address (how?)

A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Link Layer 5-16


Addressing: routing to another LAN
 A creates IP datagram with IP source A, destination B
 A creates link-layer frame with R's MAC address as dest, frame
contains A-to-B IP datagram
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
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Link Layer 5-17


Addressing: routing to another LAN
 frame sent from A to R
 frame received at R, link layer header removed, passed up to IP

MAC src: 74-29-9C-E8-FF-55


MAC dest: E6-E9-00-17-BB-4B
IP src: 111.111.111.111
IP src: 111.111.111.111
IP dest: 222.222.222.222
IP dest: 222.222.222.222
IP IP
Eth Eth
Phy Ph
y
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Link Layer 5-18


Addressing: routing to another LAN
 R forwards datagram with IP source A, destination B
 R creates link-layer frame with B's MAC address as dest, frame
contains A-to-B IP datagram
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
IP Eth
Eth Phy
Ph
y
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Link Layer 5-19


Addressing: routing to another LAN
 R forwards datagram with IP source A, destination B
 R creates link-layer frame with B's MAC address as dest, frame
contains A-to-B IP datagram

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
IP Eth
Eth Phy
Ph
y
A B
R
111.111.111.111
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Link Layer 5-20


Addressing: routing to another LAN
 R forwards datagram with IP source A, destination B
 R creates link-layer frame with B's MAC address as dest, frame
contains A-to-B IP datagram
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
222.222.222.222
74-29-9C-E8-FF-55
49-BD-D2-C7-56-2A
222.222.222.220
1A-23-F9-CD-06-9B

111.111.111.112 111.111.111.110 222.222.222.221


CC-49-DE-D0-AB-7D E6-E9-00-17-BB-4B 88-B2-2F-54-1A-0F

Link Layer 5-21


Ethernet switch
 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 are unaware of presence of switches
 plug-and-play, self-learning
 switches do not need to be configured

Link Layer 5-22


Switch: multiple simultaneous transmissions
 hosts have dedicated, direct A
connection to switch
C’ B
 switches buffer frames
 Ethernet protocol used on each 6 1 2
incoming link, but no collisions;
full duplex 5 4 3

B’ C
 switching: A-to-A’ and B-to-B’
can transmit simultaneously,
without collisions A’
switch with six interfaces
(1,2,3,4,5,6)

Link Layer 5-23


Switch forwarding table
Q: how does switch know A’ A
reachable via interface 4, B’
C’ B
reachable via interface 5?
 A: each switch has a switch 6 1 2
table, each entry:
5 4 3
 (MAC address of host, interface
to reach host, time stamp) B’ C

 looks like a routing table!


A’
Q: how are entries created, switch with six interfaces
maintained in switch table? (1,2,3,4,5,6)
 something like a routing
protocol?
Link Layer 5-24
Switch: self-learning Source: A
Dest: A’
 switch learns which hosts A A A’
can be reached through
which interfaces C’ B

Step-1: Initially the table 6 1 2


is empty A A’
Step-2: When frame 5 4 3
received, switch “learns” B’ C
the followings:

a) location of sender by A’
Switch table
incoming LAN segment b)
MAC addr interface TTL (initially empty)
Source MAC
A 1 60
Switch records the pair in
table if it is not already
there. Link Layer 5-25
Switch: frame filtering/forwarding
When a frame received at switch:

1. Index(Search) switch table using MAC destination address


2. If entry found for destination
then
{
If the outgoing interface in the table is the same from
which frame arrived
then filter the frame
Else forward frame on interface indicated by entry
}
Else
Broadcast it/* forward on all interfaces except arriving
interface */
Link Layer 5-26
Self-learning, forwarding: example Source: A
Dest: A’

A A A’
 frame destination, A’,
locaton unknown: flood C’ B

 destination A location 6 1 2

known: selectively send A A’


5 4 3
on just one link
B’ C
A’ A

A’

MAC addr interface TTL


A 1 60 switch table
A’ 4 60 (initially empty)

Link Layer 5-27


Data Link Layer
A day in the life: scenario

browser DNS server


Comcast network
68.80.0.0/13

school network
68.80.2.0/24

web page

web server Google’s network


64.233.169.105 64.233.160.0/19

Link Layer 5-29


A day in the life… connecting to the Internet
DHCP DHCP  connecting laptop needs to
UDP
DHCP
DHCP IP
get its own IP address, addr
DHCP Eth of first-hop router, addr of
Phy DNS server: use DHCP
DHCP

 DHCP request encapsulated


in UDP, encapsulated in IP,
DHCP
DHCP
DHCP UDP
encapsulated in 802.3
DHCP IP Ethernet
DHCP Eth router
Phy (runs DHCP)  Ethernet frame broadcast
(dest: FFFFFFFFFFFF) on
LAN, received at router
running DHCP server
 Ethernet demuxed to IP
demuxed, UDP demuxed to
DHCP
5-30
Link
A day in the life… connecting to the Internet
DHCP DHCP DHCP server formulates
DHCP UDP DHCP ACK containing
DHCP IP client’s IP address, IP
DHCP Eth address of first-hop router
Phy for client, name & IP
address of DNS server
 encapsulation at DHCP
DHCP DHCP server, frame forwarded
DHCP UDP (switch learning) through
DHCP IP LAN, demultiplexing at
DHCP Eth router client
Phy (runs DHCP)
DHCP  DHCP client receives
DHCP ACK reply

Client now has IP address, knows name & addr of DNS


server, IP address of its first-hop router

5-31
Link
A day in the life… ARP (before DNS, before HTTP)
DNS DNS  before sending HTTP request, need
DNS UDP IP address of www.google.com:
DNS
ARP
IP DNS
ARP query Eth
Phy  DNS query created, encapsulated in
UDP, encapsulated in IP,
encapsulated in Eth. To send frame
ARP
to router, need MAC address of
ARP reply Eth
Phy router interface: ARP
router  ARP query broadcast, received by
(runs DHCP) 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

5-32
Link
A day in the life… using DNS DNS
DNS UDP DNS server
DNS IP
DNS DNS DNS Eth
DNS UDP DNS Phy
DNS IP
DNS Eth
Phy
DNS
Comcast network
68.80.0.0/13

router
 IP datagram forwarded from
(runs DHCP) campus network into comcast
 IP datagram containing DNS network, routed (tables created by
query forwarded via LAN RIP, OSPF, IS-IS and/or BGP
switch from client to 1st hop routing protocols) to DNS server
router  demux’ed to DNS server
 DNS server replies to client
with IP address of
www.google.com
5-33
Link
A day in the life…TCP connection carrying HTTP
HTTP
HTTP
SYNACK
SYN TCP
SYNACK
SYN IP
SYNACK
SYN Eth
Phy

 to send HTTP request,


client first opens TCP
socket to web server
router  TCP SYN segment (step 1 in 3-
(runs DHCP)
SYNACK
SYN TCP way handshake) inter-domain
SYNACK
SYN IP routed to web server
SYN
SYNACK Eth
Phy  web server responds with TCP
SYNACK (step 2 in 3-way
web server handshake)
64.233.169.105  TCP connection established!

5-34
Link
A day in the life… HTTP request/reply
HTTP
HTTP HTTP  web page finally (!!!) displayed
HTTP
HTTP TCP
HTTP
HTTP IP
HTTP
HTTP Eth
Phy

 HTTP request sent into TCP


socket
router  IP datagram containing HTTP
HTTP HTTP (runs DHCP)
HTTP TCP
request routed to
HTTP IP www.google.com
HTTP Eth  web server responds with
Phy HTTP reply (containing web
page)
web server
64.233.169.105
 IP datagram containing HTTP
reply routed back to client

5-35
Link

You might also like