0% found this document useful (0 votes)
57 views42 pages

15 - Data Link LayerV2

The document discusses link layer concepts including framing, MAC addressing, ARP, and local area networks like Ethernet. It describes functions of the link layer such as framing, link access, reliable delivery, error detection, flow control, and half/full duplex modes. The document also discusses where the link layer is implemented and types of MAC addresses including unicast, multicast, and broadcast addresses.

Uploaded by

Showmick Kar
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)
57 views42 pages

15 - Data Link LayerV2

The document discusses link layer concepts including framing, MAC addressing, ARP, and local area networks like Ethernet. It describes functions of the link layer such as framing, link access, reliable delivery, error detection, flow control, and half/full duplex modes. The document also discusses where the link layer is implemented and types of MAC addresses including unicast, multicast, and broadcast addresses.

Uploaded by

Showmick Kar
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/ 42

Data Link Layer

CSE421 –Computer Networks


Department of Computer Science and Engineering
School of Data & Science
Based on Chapter 6
The Link Layer and LANs

Computer
Networking: A Top
• The slides are adapted from Kurose and Ross, Down Approach
Computer Networks 7th edition, Kurose and 7th edition
Ross. Jim Kurose, Keith Ross
Pearson/Addison Wesley
All material copyright 1996-2016 April 2016 2
J.F Kurose and K.W. Ross, All Rights Reserved
Chapter 6: Link layer and LANs

Objectives:
•understand principles behind link layer services:
•error detection, correction (done in CSE320)
•sharing a broadcast channel: multiple access (done in
CSE320)
•Framing - link layer addressing
•ARP
•local area networks: Ethernet 3
Application
Presentation
Session
Transport
Network Introduction to Link Layer
Data link
Physical

4
Link Layer Terminology
•Nodes : hosts and routers
•Links:
•wired links
•wireless links
• Frame : layer-2 packet
data-link layer has responsibility of
transferring datagram from one node
to physically adjacent node over a link 5
Link layer: context
Transportation analogy:

• trip from Home to Cox’s Bazaar


WAN Protocol : Frame Relay
•datagram transferred by • Uber Car : Home to Dhaka Airport
Ethernet
Ethernet
different link protocols • Plane: Dhaka to Chittagong
802.11
over different links: • Bus: Chittagong to Cox’s Bazaar
• e.g., Ethernet on first link, • tourist = datagram
frame relay on intermediate
links, 802.11 on last link
• transport segment =
communication link
•each link protocol • transportation mode = link layer
provides different services protocol
6

• travel agent = routing algorithm


Link layer functions/services
• Framing
• encapsulate datagram into frame, adding header, trailer
• Various information added such as the various protocols
• “MAC” addresses used in frame headers to identify source, destination
• different from IP address!
• Link access:
• how to send a frame to the link
• channel access if shared medium
• Control/Avoid clashes in multi-access networks!
• rules to follow when sending the link

• Reliable delivery between adjacent nodes


• we learned how to do this already (Transport Layer)
• seldom used on low bit-error link (fiber, some twisted pair) 7

• wireless links: high error rates


• Q: why both link-level and end-end reliability?
Link layer services (more)
• 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 (there are various protocols)

• flow control:
• pacing between adjacent sending and receiving nodes
• half-duplex and full-duplex
• with half duplex, nodes at both ends of link can transmit, but not at same 8

time
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
transport
chip network cpu
memor
y
link
• Ethernet card, 802.11 card; Ethernet
chipset host
control bus
ler (e.g., PCI)
• implements link, physical layer link
physical
physical
transmission
• attaches into host’s system
buses network adapter
card

• combination of hardware, 9

software, firmware
Objectives – Part 1
Our objectives
•Link Layer Addressing
•MAC Address
•Types of MAC Addresses
•ARP
•ARP within LAN
•LAN Switch
10
Link Layer Addressing

11
IP address IP Address vs MAC Address
MAC address
•32 bits • 48 bits
•Dotted decimal notation • 12 Hexadecimal digits
• Example : 192.168.10.1 • Example : 1A-2F-BB-76-09-AD
• Network-layer address for • Data Link-layer address for
interface interface

• Hierarchal • Flat
• Not portable • portable
• Function
• Function 12
MAC or LAN or Physical or Ethernet
addresses (more)
• 48 bits MAC address (for most LANs) burned in NIC ROM, also
sometimes software settable

• MAC address allocation administered by IEEE


• Manufacturer buys portion of MAC address space (to assure
uniqueness)

• Analogy:
• MAC address: like National ID
• IP address: like Postal Address 13
MAC Address
• 48 bits MAC address (for most LANs) burned in NIC ROM, also sometimes
software settable 0000 1100

hexadecimal (base 16) notation


(each “numeral” represents 4 bits)

14
Types of MAC Address

MAC Address
Unicast
Multicast
Broadcast
15
Unicast MAC Addresses
• The unique address used when a frame is sent from a single
transmitting device to a single destination device.

16
Multicast MAC Addresses
• “ 01-00-5E” in an IPv4 multicast packet

17
Broadcast MAC Address
• A destination MAC address of FF-FF-FF-FF-FF-FF
• To be processed by all devices in the network

18
LAN addresses and ARP
each adapter on LAN has unique LAN 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
19
ARP: address resolution protocol
Question: how to determine • ARP
interface’s MAC address,
knowing its IP address? • Mapping _IP Add___ to
_MAC Add____
137.196.7.78

1A-2F-BB-76-09-AD • ARP table


137.196.7.23
137.196.7.14
• IP
LAN
71-65-F7-2B-08-53
• MAC address
58-23-D7-FA-20-B0

• TTL (Time To Live) Or Age


0C-C4-11-6F-E3-98
137.196.7.88 • time after which address 20

mapping will be forgotten


(typically 20 min)
ARP Tables

Host or PC

21

Router
ARP: address resolution protocol

137.196.7.78
X A wants to send datagram to B
1A-2F-BB-76-09-AD
137.196.7.23
ARP 137.196.7.14

A ARP
LAN
ARP
ARP
ARP
Reply
B ✔
71-65-F7-2B-08-53
58-23-D7-FA-20-B0

0C-C4-11-6F-E3-98
137.196.7.88
X
71-65-F7-2B-08-53 58-23-D7-FA-20-B0 137.196.7.23 137.196.7.14 ARP Reply
22
FF-FF-FF-FF-FF-FF 71-65-F7-2B-08-53 137.196.7.14 137.196.7.23 ARP Request
Dest MAC Source MAC Dest IP Add Source IP Add ARP Req/Reply
ARP protocol: same LAN
• A wants to send datagram to B
• B’s MAC address not in A’s ARP
table.
•A caches (saves) IP-to-MAC
• A broadcasts ARP query address pair in its ARP table
packet, containing B's IP
address •Soft state: information that times
• destination MAC address = out (goes away) unless refreshed
FF-FF-FF-FF-FF-FF

• all nodes on LAN receive ARP •ARP is “plug-and-play”:


query
•nodes create their ARP tables
• B receives ARP packet, replies without intervention from net
to A with its (B's) MAC address administrator
23
• frame sent to A’s MAC address
(unicast)
Addressing: routing to another LAN
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 ARP- To know B’s
MAC address as
▪What will be the destination MAC Address? B’s IP address is
Routers never forward broadcast packets! known

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

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

Default Gateway’s
??? MAC 74-29-9C-E8-FF-55 222.222.222.222 111.111.111.111 A to B Packet
Address
Dest MAC Source MAC Dest IP Add Source IP Add Packet Type
Addressing: routing to another LAN
Send datagram from A to B via R
▪Does A know the IP address of first hop router, R which is
also known as Default Gateway? (how?)
▪Will A know R’s MAC address?
ARP

A B
R
111.111.111.111 ARP
ARP
ARP Reply 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

E6-E9-00-17-BB-4B 74-29-9C-E8-FF-55 222.222.222.222 111.111.111.111 A to B Packet


Link Layer and LANs 6-25
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 destination
address, 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
1A-23-F9-CD-06-9B

222.222.222.220
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
Addressing: routing to another LAN
▪ frame sent from A to R
▪ frame received at R, datagram 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 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
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
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 destination address,
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
Phy

A ARP
Reply
B
R
111.111.111.111
ARP 222.222.222.222
74-29-9C-E8-FF-55 ARP
ARP 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
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 destination address,
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
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
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

* Check out the online interactive exercises for more


examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Objectives

•Switch
•Characteristics of a switch
•Role of switch in a LAN
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
Switch: multiple simultaneous transmissions
• hosts have dedicated, direct A
connection to switch
C’ B
• switches buffer packets
6 1 2
• Ethernet protocol used on each
incoming link, but no collisions; full 5 4 3
duplex
B’ C
• each link is its own collision
domain A’

• switching: A-to-A’ and B-to-B’ can switch with six interfaces


(1,2,3,4,5,6)
transmit simultaneously, without
collisions
Switch forwarding table
Q: how does switch know A’
A
reachable via interface 4, B’
B
reachable via interface 5? C’
▪ A: each switch has a switch
6 1 2
table, each entry:
▪ (MAC address of host, interface 5 4 3
to reach host, time stamp) B’ C
▪ looks like a routing table!
Q: how are entries created,
maintained in switch table? A’
▪ something like a routing switch with six interfaces
protocol? (1,2,3,4,5,6)
Switch: self-learning Source: A
Dest: A’

• The table is empty initially A A A’

• switch learns which hosts can C’ B


be reached through which
interfaces 6 1 2

• when frame received, 5 4 3


switch “learns” location of
sender: incoming LAN B’ C
segment
• records sender/location A’
pair in switch table
MAC addr interface TTL
A 1 60 Switch table
(initially empty)
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 */
Self-learning, forwarding: example Source: A
Dest: A’

A A A’

• frame destination, A’, C’ B


location unknown: floo
d
▪ 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)
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!)
Self-learning multi-switch example

S4

S1
S3
A S2
F
D I
B C
G H
E
Suppose C sends frame to I, I responds to C

▪ Q: show switch tables and packet forwarding in S1, S2, S3, S4


Institutional network

mail server
to external
network
router web server

IP subnet
Switches vs. routers
application
transport
both are store-and-forward: datagram network
▪ routers: network-layer frame link
physical link frame
devices (examine
physical
network-layer headers)
▪ switches: link-layer devices switch
(examine link-layer headers)
network datagram
link frame
both have forwarding tables: physical
▪ routers: compute tables
using routing algorithms, IP application
addresses transport
▪ switches: learn forwarding network
table using flooding, learning, link
MAC addresses physical
THE END!

You might also like