You are on page 1of 19

Chapter 5: DataLink Layer Chapter 5: The Data Link Layer

data-link layer has responsibility of


transferring frames from one node
Course on Computer Communication to adjacent node over a link
and Networks, CTH/GU
Our goals:
ˆ understand
d d principles
l behind
h dd data llink
k llayer
The slides are adaptation of the slides made
services:
available by the authors of the course’s main
 error detection, correction
textbook  sharing a broadcast channel: multiple access
Computer Networking:  link layer addressing
A Top Down Approach
5th edition.  reliable data transfer, flow control: done!
Jim Kurose, Keith Ross ˆ instantiation and implementation of various link
Addison-Wesley, 2009 layer technologies
5: DataLink Layer 5-1 5: DataLink Layer 5-2

Link Layer Link layer: context


ˆ Datagram transferred by different ˆ transportation analogy
link protocols over different links: ˆ trip from Princeton to Lausanne
ˆ 5.1 Introduction and LAN technology  e.g., Ethernet on first link, frame
relay on intermediate links, 802.11


limo: Princeton to JFK
plane: JFK to Geneva
services ˆ 5.5 Ethernet ˆ
on last link
Each link protocol provides
 train: Geneva to Lausanne
ˆ tourist = datagram
different services
ˆ Framing ˆ 5.6 Interconnection e.g., may or may not provide rdt over
ˆ transport segment =
communication link

link
ˆ 5.2 Error detection ˆ 5.4 Link-Layer ˆ transportation mode = link layer
protocol
p
and correction Add
Addressing
i ˆ travel agent = routing algorithm

ˆ 5.3Multiple access ˆ 5.7 PPP


protocols ˆ 5.9 A day in the life of a
web request
(5.8 Link Virtualization:
ATM and MPLS)

5: DataLink Layer 5-3 5: DataLink Layer 5-4

Where is the link layer implemented? Adaptors Communicating


ˆ in each and every host
ˆ link layer implemented in datagram datagram

“adaptor” (aka network host schematic


controller controller

interface card NIC) application


transport
 Ethernet card, 802.11 network cpu memory sending host receiving host
card
link
datagram

 implements link, physical host frame

layer
bus
controller (e.g., PCI)
ˆ sending side: ˆ receiving side
link
ˆ attaches into host’s physical
physical
 encapsulates datagram in  looks for errors, rdt, flow
system buses
transmission

frame control, etc


ˆ combination of network adapter
 adds error checking bits,  extracts datagram, passes
hardware, software,
card
rdt, flow control, etc. to upper layer at receiving
firmware side
5: DataLink Layer 5-5 5: DataLink Layer 5-6

1
Link Layer Services Link Layer Services (more)
ˆ Framing, link access:
ˆ Error Detection:
 encapsulate datagram into frame, adding header, trailer
 errors caused by signal attenuation, noise.
 channel access if shared medium
 receiver detects presence of errors:
 “MAC” addresses used in frame headers to identify source,
dest • signals sender for retransmission or drops frame
• different
diff tffrom IP address!
dd ! ˆ Error
E C
Correction:
ti :
ˆ Reliable delivery between adjacent nodes, flow ctrl  receiver identifies and corrects bit error(s) without
 Control when errors + pace between adjacent sending and
resorting to retransmission
receiving 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?
5: DataLink Layer 5-7 5: DataLink Layer 5-8

Link Layer Framing


ˆ 5.1 Introduction and LAN technology ˆ to detect possible bit stream errors in the
services ˆ 5.5 Ethernet physical layer, the data link layer groups bits from
ˆ Framing ˆ 5.6 Interconnection
the network layer into discrete frames
ˆ 5.2 Error detection ˆ the receiver must be able to detect the beginning
ˆ 5.4 Link-Layer
and correction Add
Addressing
i and the end of the frame
ˆ 5.3Multiple access ˆ 5.7 PPP
protocols ˆ 5.9 A day in the life of a
Example methods:
web request ˆ Clock-based + Character count : physical-clock
(5.8 Link Virtualization: synchronization: much dependent on clock drifts +
ATM and MPLS) the counter could be garbled up during
transmission

5: DataLink Layer 5-9 5: DataLink Layer 5-10

flag byte
Byte Stuffing pattern Framing techniques: examples (cont)
in data
to send
ˆ <01111110> delimits
beginning, end of frame ...
Physical layer coding violation: exploits
ˆ “data transparency”: data special encodings at the physical layer, e.g.
field must be allowed to
include <01111110> Manchester encoding g (see next …)
 Q: is received <01111110> flag byte pattern plus
data or flag? stuffed byte in
transmitted data
ˆ Sender: adds (“stuffs”) ˆ Receiver:
extra <01111110> byte after  two 01111110 bytes in a
each <01111110> data byte row: discard first byte,
continue data reception
 single 01111110: flag
byte
5: DataLink Layer 5-11 5: DataLink Layer 5-12

2
Encoding Link Layer
Problem: Simple binary encoding (aka Non-Return to
Zero, NRZ) introduces problems: ˆ 5.1 Introduction and LAN technology
ˆ consecutive 0’s or 1’s can lead to a situation called services ˆ 5.5 Ethernet
baseline wander (hard to distinguish signal values) ˆ Framing ˆ 5.6 Interconnection
ˆ hard to recover the clock ˆ 5.2 Error detection ˆ 5.4 Link-Layer
More robust
M b encoding:
di and correction Add
Addressing
i
ˆ Manchester: XOR NRZ with clock ˆ 5.3Multiple access ˆ 5.7 PPP
protocols ˆ 5.9 A day in the life of a
web request
(5.8 Link Virtualization:
ATM and MPLS)

5: DataLink Layer 5-13 5: DataLink Layer 5-14

Error Detection Parity Checking


EDC= Error Detection and Correction bits (redundancy)
Single Bit Parity: Two Dimensional Bit Parity:
D = Data protected by error checking, may include header fields Detect and correct single bit errors
Detect single bit errors

• Error detection not 100% reliable!


• protocol may miss some errors, but this should happen only
rarely
• larger EDC field yields better detection and correction

0 0

5: DataLink Layer 5-15 5: DataLink Layer 5-16

Internet checksums CRC Example


TCP (UDP)’s checksum: Cyclic redundancy check (CRC) Recall we want:
ˆ segment contents = • data bits, D = binary number D.2r XOR R = nG
sequence of 16-bit ˆ consider r+1 bit pattern (generator), G equivalently:
integers
ˆ checksum: addition (1’s
ˆ goal: compute r CRC bits, R, such that if we divide D.2r by
complement
p sum)) of
 <D,R> exactly divisible by G (modulo 2) G, want
 receiver
i k
knows GG, divides
di id <D,R>
DR b by G
G. If remainder R
segment contents
non-zero remainder: error detected!
ˆ sender puts checksum  can detect errors on less than r+1 bits
value into UDP (TCP)
checksum field
 International standards for G (CRC
polynomials)
D.2r
R = remainder[ ]
G

5: DataLink Layer 5-17 5: DataLink Layer 5-18

3
Multiple Access Links and Protocols
Link Layer
Two types of “links”:
ˆ 5.1 Introduction and LAN technology ˆ point-to-point
services ˆ 5.5 Ethernet  PPP for dial-up access
 point-to-point link between Ethernet switch and host
ˆ Framing ˆ 5.6 Interconnection
ˆ 5.2 Error detection ˆ broadcast (shared wire or medium)
ˆ 5.4 Link-Layer
 Ethernet
and correction Add
Addressing
i
 upstream HFC
ˆ 5.3Multiple access ˆ 5.7 PPP  802.11 wireless LAN
protocols ˆ 5.9 A day in the life of a
web request
(5.8 Link Virtualization:
ATM and MPLS)
humans at a
shared wire (e.g., shared RF shared RF cocktail party
cabled Ethernet) (e.g., 802.11 WiFi) (satellite) (shared air, acoustical)
5: DataLink Layer 5-19 5: DataLink Layer 5-20

Multiple Access protocols Ideal Mulitple Access Protocol


ˆ single shared broadcast channel
Broadcast channel of rate R bps
ˆ two or more simultaneous transmissions by nodes:
1. When one node wants to transmit, it can send at
interference
rate R.
 collision if node receives two or more signals at the same time
2. When M nodes want to transmit, each can send at
multiple access protocol
average rate R/M
ˆ distributed algorithm that determines how nodes
3. Fully decentralized:
share channel, i.e., determine when node can transmit
 no special node to coordinate transmissions
 communication about channel sharing must use channel itself!
• no out-of-band channel for coordination 4. Simple

5: DataLink Layer 5-21 5: DataLink Layer 5-22

Channel Partitioning MAC protocols:


MAC Protocols: a taxonomy
TDMA, FDMA
Three broad classes: TDMA: time division FDMA: frequency division
ˆ Channel Partitioning multiple access multiple access
ˆ access to channel in "rounds" ˆ each station assigned fixed
 divide channel into smaller “pieces” (time slots, frequency band
ˆ each station gets fixed length
frequency); allocate piece to node for exclusive use ˆ unused transmission time in
slot (length = pkt trans time) in
ˆ Random Access each round frequency bands goes idle
dle
ˆ unused slots go idle ˆ example: 6-station LAN, 1,3,4
 allow collisions; “recover” from collisions have pkt, frequency bands 2,5,6
 example: 6-station LAN, 1,3,4
ˆ “Taking turns” have pkt, slots 2,5,6 idle idle

 tightly coordinate shared access to avoid collisions


frequency bands

Recall goal: efficient, fair, simple, decentralized


5: DataLink Layer 5-23 5: DataLink Layer 5-24

4
Channel Partitioning CDMA Random Access Protocols
CDMA: Code Division Multiple Access ˆ When node has packet to send
ˆ allows each station to transmit over the entire frequency spectrum
 transmit at full channel data rate R.
all the time.
 no a priori coordination among nodes
ˆ simultaneous transmissions are separated using coding theory.
ˆ used mostly in wireless broadcast channels (cellular, satellite, etc) – we will ˆ two or more transmitting nodes ➜ “collision”,
study it in the wireless context
ˆ random access MAC protocol specifies:
ˆ has been ”traditionally” used in the military
 how to detect collisions

Observe:  how to recover from collisions (e.g., via delayed

MUX = speak person-to-person in designated space retransmissions)


CDMA = ”shout” using different languages: the ones who know the ˆ Examples of random access MAC protocols:
language will get what you say  slotted ALOHA
 ALOHA
 CSMA, CSMA/CD, CSMA/CA

5: DataLink Layer 5-25 5: DataLink Layer 5-26

Slotted ALOHA Slotted ALOHA

Assumptions: Operation:
ˆ all frames same size ˆ when node obtains fresh
ˆ time divided into equal frame, transmits in next
size slots (time to slot
transmit 1 frame)  if no collision: node can
send new frame in next Pross
P Cons
ˆ nodes start to transmit
slot ˆ single active node can ˆ collisions, wasting slots
only at slot beginning
 if collision: node continuously transmit ˆ idle slots
ˆ nodes are synchronized
ˆ if 2 or more nodes
retransmits frame in at full rate of channel ˆ nodes may be able to
transmit in slot, all each subsequent slot ˆ highly decentralized: detect collision in less
nodes detect collision with prob. p until than time to transmit
only slots in nodes
success packet
need to be in sync
ˆ clock synchronization
ˆ simple
5: DataLink Layer 5-27 5: DataLink Layer 5-28

Slotted Aloha efficiency Pure (unslotted) ALOHA


Efficiency : long-run
Q: max fraction of fraction of successful slots ˆ unslotted Aloha: simpler, no synchronization
(many nodes, all with many
successful transmissions? ˆ pkt needs transmission:
frames to send)
 send without awaiting for beginning of slot
A: Suppose N stations, each transmits in
ˆ collision probability increases:
slot with probability p
 p
pkt sent at t0 collide with other p
pkts sent in [t
[ 0-1, t0+1]]
 prob.
b successful
f l transmission
i i iis:

P[specific node succeeds]= p (1-p)(N-1)

At best: channel
P[any of N nodes succeeds]
use for useful
= N p (1-p)(N-1) transmissions 37%
of time!
Efficiency = 1/e = .37 LARGE N

5: DataLink Layer 5-29 5: DataLink Layer 5-30

5
Pure Aloha (cont.) CSMA: Carrier Sense Multiple Access

P(success by any of N nodes) = N p . (1-p)2N = CSMA: listen before transmit:


i.e. N p P(no other node transmits in [p0-1,p0] .
ˆ If channel sensed busy, defer transmission
P(no other node transmits in [p0,p0+1]
 back-off, random interval

=(as n -> infty …)


ˆ If/when channel sensed idle:
1/(2 ) = .18
1/(2e) 18  p persistent CSMA: transmit immediately with
p-persistent
probability p; with probablility 1-p retry after
0.4 random interval
 non-persistent CSMA: transmit after random
protocol constrains
0.3
Slotted Aloha interval
0.2 effective channel
throughput!
0.1
Pure Aloha
human analogy: don’t interrupt others!
0.5 1.0 1.5 2.0
G = offered load = #frames per frame-time
5: DataLink Layer 5-31 5: DataLink Layer 5-32

CSMA collisions spatial layout of nodes along ethernet


CSMA/CD (Collision Detection)
CSMA/CD: carrier sensing, deferral as in CSMA
collisions can occur: ˆ colliding transmissions aborted, reducing channel wastage
Due to propagation ˆ persistent or non-persistent retransmission
delay, two nodes may
not hear each other’s collision detection:
transmission
ˆ easy in wired LANs: measure signal
strengths,
t th compare transmitted,
t itt d
collision: received signals
entire packet transmission ˆ different in wireless LANs:
time wasted transmitter/receiver not “on”
simultaneously; collision at the
note: receiver matters, not the sender
role of distance and
propagation delay (d)in
determining collision human analogy: the polite
(collision-detection delay = 2d)
5: DataLink Layer 5-33
conversationalist 5: DataLink Layer 5-34

“Taking Turns” MAC protocols “Taking Turns” MAC protocols


Token passing:
channel partitioning MAC protocols:
ˆ control token-frame passed from one node to next
 share channel efficiently and fairly at high load
sequentially.
 inefficient at low load: delay in channel access,
ˆ not pure broadcast
1/N bandwidth allocated even if only 1 active
ˆ concerns:
node!
 token overhead
Random access MAC protocols
 latency
 efficient at low load: single node can fully  single point of failure (token)
utilize channel
 high load: collision overhead
“taking turns” protocols
look for best of both worlds!
5: DataLink Layer 5-35 5: DataLink Layer 5-36

6
IEEE 802.4 Standard IEEE Standard 802.5 (Token Ring)
(General Motors Token Bus) (not in must-study material)
(not in must-study material) Motivation: instead of complicated token-bus, have a physical ring
Contention systems limitation: worst-case delay Principle: Each bit arriving at an interface is copied into a 1-bit
buffer (inspected and/or modified); then copied out to the ring
until successful transmission is unlimited => not again.
suitable for real-time traffic  copying step introduces a 1-bit delay at each interface.
Solution: token-passing, round robin
ˆ token = special control frame; only the holding
station can transmit; then it passes it to another
station, i.e. for token bus, the next in the logical
ring
ˆ 4 priority classes of traffic, using timers
ˆ Logical ring-maintenance: distributed strategy
 Robust, somehow complicated though

5: DataLink Layer 5-37 5: DataLink Layer 5-38

Token Ring operation IEEE 802.5 Ring: Maintenance


(not in must-study material)

ˆ to transmit a frame, a station is required Centralised: a “monitor” station oversees the ring:
to seize the token and remove it from the ˆ generates token when lost
ring before transmitting. ˆ cleans the ring when garbled/orphan frames
appear
ˆ bits that have ppropagated
p g around the ring
g
are removed from the ring by the sender
If the monitor goes away, a convention protocol
(the receiver in FDDI). ensures that another station is elected as a
ˆ After a station has finished transmitting monitor (e.g. the one with highest identity)
the last bit of its frame, it must If the monitor gets ”mad”, though…..
regenerate the token.

5: DataLink Layer 5-39 5: DataLink Layer 5-40

IEEE 802.5 Ring: Priority Algorithm


(not in must-study material)
Reservation-based protocols
Distributed Polling – Bit-map protocol:
Station S ˆ time divided into slots
upon arrival of frame f: ˆ begins with N short reservation slots

set prior(f) := max{prior(f), prior(S)}  station with message to send posts reservation during its slot
 reservation seen by all stations
forward(f)
( )
 reservation
s ti sl
slott ti
time equall tto channel
h l end-end
d d propagation
ti
upon arrival of T delay (why?)
if prior(T)>prior(S) then forward(T) ˆ after reservation slots, message transmissions ordered by known
priority
else send own frame f with prior(f):=0
wait until f comes back
prior(T):=prior(f)
forward(T)

5: DataLink Layer 5-41 5: DataLink Layer 5-42

7
Summary of MAC protocols Link Layer
ˆ What do you do with a shared media? ˆ 5.1 Introduction and LAN technology
 Channel Partitioning, by time, frequency or code services ˆ 5.5 Ethernet
• Time Division, Frequency Division ˆ Framing ˆ 5.6 Interconnection
 Random partitioning (dynamic), ˆ 5.2 Error detection ˆ 5.4 Link-Layer
• ALOHA,
H S-ALOHA, H CSMA, CSMA/CD / D and correction Add
Addressing
i
• carrier sensing: easy in some technologies (wire), hard ˆ 5.3Multiple access ˆ 5.7 PPP
in others (wireless) protocols ˆ 5.9 A day in the life of a
• CSMA/CD used in Ethernet
web request
• CSMA/CA used in 802.11
 Taking Turns (5.8 Link Virtualization:
ATM and MPLS)
• polling, token passing
• Bluetooth, FDDI, IBM Token Ring
5: DataLink Layer 5-43 5: DataLink Layer 5-44

Ethernet Ethernet: uses CSMA/CD


“dominant” wired LAN technology:
A: sense channel, if idle
ˆ cheap $20 for 100Mbs!
then {
ˆ first widely used LAN technology transmit and monitor the channel;
ˆ Simpler, cheaper than token LANs and ATM If detect another transmission
then {
ˆ Kept
p upp with speed
p race: 10 Mbps
p – 10 Gbps
p
abort
b t and
nd ssend
nd jam
j m signal;
si n l;
update # collisions;
delay as required by exponential backoff algorithm;
goto A
Metcalfe’s Ethernet }
sketch
else {done with the frame; set collisions to zero}
}
else {wait until ongoing transmission is over and goto A}

5: DataLink Layer 5-45 5: DataLink Layer 5-46

Ethernet’s CSMA/CD (more) Ethernet (CSMA/CD) Limitation

Jam Signal: make sure all other transmitters are ˆ Recall: collision detection interval = 2*Propagation
aware of collision; 48 bits; delay along the LAN
Exponential Backoff: ˆ This implies a minimum frame size and/or a
ˆ Goal: adapt retransmission attempts to estimated maximum wire length
current load
 heavy load: random wait will be longer
ˆ first collision: choose K from {0,1}
 (delay is K x frame-transmission time)
Critical factor:
ˆ after second collision: choose K from {0,1,2,3}…
a = 2 * propagation_delay /frame_transmission_delay
ˆ after ten or more collisions, choose K from
{0,1,2,3,4,…,1023}

5: DataLink Layer 5-47 5: DataLink Layer 5-48

8
Star topology CSMA/CD efficiency
ˆ bus topology popular through mid 90s
 all nodes in same collision domain (can collide with each
other) ˆ Tprop = max prop between 2 nodes in LAN
ˆ today: star topology prevails (more bps, shorter ˆ ttrans = time to transmit max-size frame
distances)
 Hub or active switch in center 1
 (more in
n a while)
wh le) efficiencyy =
1 + 5t prop / ttrans
ˆ Much better than ALOHA, but still decentralized,
simple, and cheap

switch

bus: coaxial cable


star
5: DataLink Layer 5-49 5: DataLink Layer 5-50

Ethernet Frame Structure 802.3 Ethernet Standards: Link & Physical Layers

Sending adapter encapsulates IP datagram (or other ˆ many different Ethernet standards
network layer protocol packet) in Ethernet frame  common MAC protocol and frame format
 different speeds: 2 Mbps, 10 Mbps, 100 Mbps,
1Gbps, 10G bps
 different physical layer media: fiber, cable
Preamble: 7 bytes with pattern 10101010 followed by one byte
with pattern 10101011
 to synchronize receiver, sender clock rates
Addresses: 6 bytes, frame is received by all adapters on a LAN application
MAC protocol
and dropped if address does not match
and frame format
transport
Type: indicates the higher layer protocol, mostly IP but others network 100BASE-TX 100BASE-T2 100BASE-FX
may be supported (such as Novell IPX and AppleTalk) link 100BASE-T4 100BASE-SX 100BASE-BX
CRC: checked at receiver, if error is detected, the frame is physical
simply dropped
copper (twister fiber physical layer
5: DataLink Layer 5-51
pair) physical layer 5: DataLink Layer 5-52

Manchester encoding Ethernet: Unreliable, connectionless

ˆ connectionless: No handshaking between sending and


receiving NICs
ˆ unreliable: receiving NIC doesn’t send acks or nacks
to sending NIC
 stream of datagrams passed to network layer can have gaps
(missing datagrams)
ˆ Used in 10BaseT  gaps will be filled if app is using TCP
otherwise, app will see gaps
ˆ Each bit has a transition


ˆ Allows clocks in sending and receiving nodes to


synchronize to each other
 no need for a centralized, global clock among nodes!
ˆ Hey, this is physical-layer stuff!
5: DataLink Layer 5-53 5: DataLink Layer 5-54

9
Link Layer Interconnecting with hubs
Hubs are essentially physical-layer repeaters:
 bits coming from one link go out all other links
ˆ 5.1 Introduction and LAN technology  at the same rate (no frame buffering)
services ˆ 5.5 Ethernet ˆ no CSMA/CD at hub: adapters detect collisions (one large collision
domain)
ˆ Framing ˆ 5.6 Interconnection ˆ provides net management functionality (monitoring, statistics)
ˆ 5.2 Error detection ˆ 5.4 Link-Layer ˆ Extends distance between nodes
and correction Add
Addressing
i ˆ C
Can’t
’t iinterconnect
t t e.g. 10B
10BaseT
T & 100B
100BaseT
T
ˆ 5.3Multiple access ˆ 5.7 PPP
hub
protocols ˆ 5.9 A day in the life of a
web request
(5.8 Link Virtualization: hub hub
hub
ATM and MPLS)

5: DataLink Layer 5-55 5: DataLink Layer 5-56

Switch: allows multiple simultaneous Switches (bridges): cont.


transmissions ˆ Link Layer devices: operate on frames, examining header
and selectively forwarding frame based on its destination
A
 filtering: same-LAN-segment frames not forwarded to other seg’s
ˆ hosts may have dedicated, C’ B ˆ Advantages:
direct connection to switch  Isolates collision domains:

ˆ switches buffer packets • higher total max throughput


1 2
6 3 • no limit on number of nodes nor distances
ˆ Ethernet protocol used on  Can connect different net-types (translational, …)
4
each incoming link,
link but no 5  T
Transparent:
t no needd for
f any change
h to
t hosts
h t LAN adapters
d t
collisions; full duplex
C
 each link is its own collision forwarding: how to know LAN segment on which to forward
domain
B’ frame?
A’
ˆ switching: A-to-A’ and B-  looks like a routing problem…
switch
to-B’ simultaneously, switch with six interfaces
without collisions (1,2,3,4,5,6)
 not possible with dumb hub

5: DataLink Layer 5-57 5: DataLink Layer 5-58

Switch: frame filtering/forwarding


Switch: self-learning Source: A
Dest: A’

A A A’ When frame received:


ˆ switch learns which hosts
C’
can be reached through B 1. record link associated with sending host
which interfaces 2. index switch table using MAC dest address
1 2
 when frame received, 3
switch “learns” location of
6 3. if entry found for destination
5 4 then {
sender:
d iincoming
i LAN
segment if dest on segment from which frame arrived
C
 records sender/location then drop the frame
pair in switch table B’ A’ else forward the frame on interface indicated
MAC addr interface TTL }
A 1 60 Switch table else flood forward on all but the interface
(initially empty)
on which the frame arrived
5: DataLink Layer 5-59 5: DataLink Layer 5-60

10
Switch Learning: example Switch: traffic isolation
Suppose C sends a frame to D and D replies with a frame to C ˆ switch installation breaks subnet into LAN
segments
ˆ switch filters packets:
 same-LAN-segment frames not usually
switch forwarded onto other LAN segments
 segments become separate collision domains

ˆ C sends frame, switch has no info about D, so floods switch


 switch notes that C is on port 1
collision
 frame ignored on upper LAN
domain
 frame received by D
ˆ D generates reply to C, sends hub
hub hub
 switch sees frame from D
 switch notes that D is on interface 2
 switch knows C on interface 1, so selectively forwards frame out
collision domain collision domain
via interface 1
5: DataLink Layer 5-61 5: DataLink Layer 5-62

Switches vs. Routers Routers vs. Bridges/Switches


ˆ both store-and-forward devices
 routers: network layer devices (examine network layer Bridges/Switches Routers
headers) + Bridge operation is simpler + arbitrary topologies can be
requiring less processing supported, cycling is limited
 Switches (bridges) are Link Layer devices
bandwidth by good routing protocols
ˆ routers maintain routing tables, implement routing - Topologies are restricted + provide firewall protection
algorithms
g with bridges (a spanning against broadcast storms
tree must be built
l to avoid
d
ˆ switches maintain filtering tables, implement cycle) - require detailed configuration
(not plug and play) and higher
filtering, learning (and spanning tree) algorithms - Bridges do not offer processing capacity
protection from broadcast
storms (endless
broadcasting by a host will
be forwarded by a bridge)

Bridges/switches do well in small (few hundred hosts) while


Switch 5: DataLink Layer 5-63 routers used in large networks (thousands of hosts) 5: DataLink Layer 5-64

Summary comparison Institutional network

hubs routers switches to external


mail server

network
web server
traffic no yes yes router

solat on
isolation
plug & play yes no yes IP subnet

optimal no yes no
routing
cut yes no yes
through
5: DataLink Layer 5-65 5: DataLink Layer 5-66

11
VLANs: motivation VLANs Port-based VLAN: switch ports grouped
(by switch management software) so
that single physical switch ……

What’s “wrong” with this picture? What happens if:


1 7 9 15

Virtual Local 2 8 10 16

ˆ CS user moves office to EE, Area Network


but wants connect to CS … …
switch? Switch(es) supporting
VLAN capabilities can Electrical Engineering Computer Science
ˆ single broadcast domain:
be configured to
(VLAN ports 1 1-8)
8) (VLAN ports 9
9-15)
15)

 all layer-2 broadcast define multiple virtual … operates as multiple virtual switches
traffic (ARP, DHCP)
LANS over single
crosses entire LAN
Computer (security/privacy, physical LAN
Computer
infrastructure.
1 7 9 15
Science Electrical
Engineering Engineering efficiency issues) 2 8 10 16

ˆ each lowest level switch has


only few ports in use … …

Electrical Engineering Computer Science


(VLAN ports 1-8) (VLAN ports 9-16)

5: DataLink Layer 5-67 5: DataLink Layer 5-68

Port-based VLAN: VLANS spanning multiple switches


router
ˆ traffic isolation: frames
to/from ports 1-8 can 1 7 9 15 1 3 5 7

only reach ports 1-8


2 8 10 16 2 4 6 8

 can also define VLAN based on … …


MAC addresses of endpoints, 1 7 9 15

rather than switch port


2 8 10 16
Electrical Engineering Computer Science Ports 2,3,5 belong to EE VLAN
ˆ dynamic
d i membership:
b hi (VLAN ports 1 1-8)
8) (VLAN ports 9
9-15)
15) Ports 4,6,7,8
4 6 7 8 belong to CS VLAN
… …
ports can be dynamically
assigned among VLANs Electrical Engineering Computer Science ˆ trunk port: carries frames between VLANS defined
over multiple physical switches
(VLAN ports 1-8) (VLAN ports 9-15)

ˆ forwarding between VLANS:


 frames forwarded within VLAN between switches can’t be
done via routing (just as with vanilla 802.1 frames (must carry VLAN ID info)
separate switches)  802.1q protocol adds/removed additional header fields for
 in practice vendors sell combined frames forwarded between trunk ports
switches plus routers
5: DataLink Layer 5-69 5: DataLink Layer 5-70

802.1Q VLAN frame format Link Layer


Type

ˆ 5.1 Introduction and LAN technology


802.1 frame
services ˆ 5.5 Ethernet
ˆ Framing ˆ 5.6 Interconnection
802.1Q frame ˆ 5.2 Error detection ˆ 5.4 Link-Layer
and correction Add
Addressing
i
ˆ 5.3Multiple access ˆ 5.7 PPP
2-byte Tag Protocol Identifier
(value: 81-00)
Recomputed protocols ˆ 5.9 A day in the life of a
CRC
web request
Tag Control Information (12 bit VLAN ID field,
(5.8 Link Virtualization:
3 bit priority field like IP TOS) ATM and MPLS)

5: DataLink Layer 5-71 5: DataLink Layer 5-72

12
LAN Addresses LAN Address (more)
32-bit IP address:
ˆ network-layer address ˆ MAC address allocation administered by IEEE
ˆ used to get datagram to destination network (recall IP
ˆ manufacturer buys portion of MAC address space (to
network definition)
assure uniqueness)
LAN (or MAC or physical) address: Broadcast address =
FF-FF-FF-FF-FF-FF
ˆ to g
get datagram
g from
Analogy:
A l
one interface to another
physically-connected (a) MAC address: like People’s Names or PersonalNum’s
interface (same network) (b) IP address: like postal address
ˆ 48 bit MAC address ˆ MAC flat address => portability
(for most LANs)  can move LAN card from one LAN to another
burned in NIC’s ROM ˆ IP hierarchical address NOT portable
(sometimes resettable)  depends on network to which one attaches

5: DataLink Layer 5-73 5: DataLink Layer 5-74

Recall earlier routing discussion ARP: Address Resolution Protocol


Question: how to determine ˆ Each IP node (Host, Router) on
Starting at A, given IP A 223.1.1.1 MAC address of B LAN has ARP module, table
datagram addressed to B: given B’s IP address?  ARP Table: IP/MAC address mappings
223.1.2.1 < IP address; MAC address; TTL>
ˆ look up net. address of B, find B 223.1.1.2
< ………………………….. >
on same net. as A 223.1.1.4 223.1.2.9
B • TTL (Time To Live): time to cache
ˆ link layer send datagram to B
223.1.3.27
223.1.2.2
E (typically 20 min); afterwards:
inside link
link-layer
layer frame
223.1.1.3
 A broadcasts
b d t ARP query pkt,
kt containing
t i i
223.1.3.1 223.1.3.2 B's IP address
frame source, datagram source,  B receives ARP packet, replies to A with
dest address dest address its (B's) physical layer address
 A caches (saves) IP-to-physical address
A’s MAC B’s MAC A’s IP B’s IP pairs until they times out
IP payload
addr addr addr addr • soft state: information that times out
(goes away) unless refreshed
datagram
frame
5: DataLink Layer 5-75 5: DataLink Layer 5-76

Addressing: routing to another LAN ˆ A creates IP datagram with source A, destination B


ˆ A uses ARP to get R’s MAC address for 111.111.111.110
ˆ A creates link-layer frame with R's MAC address as dest,
walkthrough: send datagram from A to B via R
frame contains A-to-B IP datagram
This is a really important
assume A knows B’s IP address ˆ A’s NIC sends frame example – make sure you
74-29-9C-E8-FF-55 88-B2-2F-54-1A-0F
ˆ R’s NIC receives frame understand!
A E6-E9-00-17-BB-4B ˆ R removes IP datagram from Ethernet frame, sees its
destined to B
222.222.222.221
1A-23-F9-CD-06-9B
111.111.111.111
ˆ R uses ARP to g
get B’s MAC address
ˆ R creates frame containing A-to-B IP datagram sends to B
222.222.222.220 222.222.222.222
111.111.111.110
B
R
111.111.111.112 74-29-9C-E8-FF-55 88-B2-2F-54-1A-0F

49-BD-D2-C7-56-2A A
E6-E9-00-17-BB-4B
CC-49-DE-D0-AB-7D 222.222.222.221
1A-23-F9-CD-06-9B
111.111.111.111

ˆ two ARP tables in router R, one for each IP 222.222.222.220 222.222.222.222

network (LAN) 111.111.111.110 B


111.111.111.112
R 49-BD-D2-C7-56-2A

CC-49-DE-D0-AB-7D
5: DataLink Layer 5-77 5: DataLink Layer 5-78

13
Link Layer Point to Point Data Link Control
ˆ one sender, one receiver, one link: easier than
ˆ 5.1 Introduction and LAN technology
broadcast link:
services ˆ 5.5 Ethernet
 no Media Access Control
ˆ Framing ˆ 5.6 Interconnection
 no need for explicit MAC addressing
ˆ 5.2 Error detection ˆ 5.4 Link-Layer
and correction  e.g.,
e g dialup link
link, ISDN line
Add
Addressing
i
ˆ 5.3Multiple access ˆ popular point-to-point DLC protocols:
ˆ 5.7 PPP
protocols  PPP (point-to-point protocol)
ˆ 5.9 A day in the life of a
web request  HDLC: High level data link control

(5.8 Link Virtualization:


ATM and MPLS)

5: DataLink Layer 5-79 5: DataLink Layer 5-80

PPP Design Requirements [RFC 1557]


PPP non-requirements
ˆ packet framing: encapsulation of network-layer
ˆ no error correction/recovery
datagram in data link frame
ˆ no flow control
ˆ carry network layer data of any network layer
protocol (not just IP) ˆ “out of order” delivery OK
ˆ bit transparency: no constraints on bit pattern in
the data field
ˆ error detection (no correction)
ˆ connection liveness: detect, signal link failure to Error recovery, flow control, data re-ordering
network layer all relegated to higher layers!
ˆ network layer address negotiation: endpoint can
learn/configure each other’s network address

5: DataLink Layer 5-81 5: DataLink Layer 5-82

PPP Data Frame Framing method: Byte Stuffing


ˆ Flag: delimiter (framing; hence “stuffing” in payload) ˆ “data transparency” requirement: data field must
ˆ Address: does nothing (only one option) be allowed to include flag pattern <01111110>
ˆ Control: does nothing; in the future possible multiple  Q: is received <01111110> data or flag?
control fields
ˆ Protocol: upper layer protocol to which frame delivered
(
(eg, PPP
PPP-LCP,
LCP IP
IP, IPCP,
IPCP etc)) ˆ Sender: adds (“stuffs”) extra < 01111110> byte
ˆ info: upper layer data being carried after each < 01111110> data byte
ˆ check: cyclic redundancy check for error detection ˆ Receiver:
 two 01111110 bytes in a row: discard first byte,
continue data reception
 single 01111110: flag byte

5: DataLink Layer 5-83 5: DataLink Layer 5-84

14
Byte Stuffing PPP Data Control Protocol
Before exchanging network-
layer data, data link peers
flag byte
pattern must
in data ˆ configure PPP link (max.
to send
frame length,
authentication)
ˆ learn/configure network
layer information
 for IP: carry IP Control
Protocol (IPCP) msgs
flag byte pattern plus
stuffed byte in
(protocol field: 8021) to
transmitted data configure/learn IP
address
5: DataLink Layer 5-85 5: DataLink Layer 5-86

Link Layer Synthesis: a day in the life of a web request

ˆ journey down protocol stack complete!


ˆ 5.1 Introduction and LAN technology
 application, transport, network, link
services ˆ 5.5 Ethernet
ˆ Framing ˆ 5.6 Interconnection
ˆ putting-it-all-together: synthesis!
ˆ 5.2 Error detection ˆ 5.4 Link-Layer
 goal: identify, review, understand protocols (at
and correction Add
Addressing
i all layers) involved in seemingly simple scenario:
ˆ 5.3Multiple access
requesting www page
ˆ 5.7 PPP
protocols  scenario: student attaches laptop to campus
ˆ 5.9 A day in the life of a
network, requests/receives www.google.com
web request
(5.8 Link Virtualization:
ATM and MPLS)

5: DataLink Layer 5-87 5: DataLink Layer 5-88

A day in the life… connecting to the Internet


A day in the life: scenario
DHCP DHCP ˆ connecting laptop needs to
UDP
DNS server get its own IP address,
browser DHCP
DHCP IP
Comcast network DHCP Eth addr of first-hop router,
68.80.0.0/13 Phy addr of DNS server: use
DHCP
DHCP
ˆ DHCP request encapsulated
school network DHCP DHCP in UDP, encapsulated in IP,
68.80.2.0/24 DHCP UDP encapsulated in 802.1
802 1
DHCP IP Ethernet
DHCP Eth router
web page ˆ Ethernet frame broadcast
Phy (runs DHCP)
(dest: FFFFFFFFFFFF) on LAN,
received at router running
DHCP server
web server Google’s network
64.233.169.105 64.233.160.0/19 ˆ Ethernet demux’ed to IP
demux’ed, UDP demux’ed to
DHCP
5: DataLink Layer 5-89 5: DataLink Layer 5-90

15
A day in the life… connecting to the Internet A day in the life… ARP (before DNS, before HTTP)
DHCP DHCP ˆ DHCP server formulates DNS DNS ˆ before sendingHTTP request,
DHCP UDP DHCP ACK containing DNS UDP need IP address of www.google.com:
DHCP IP client’s IP address, IP DNS IP DNS
address of first-hop
ARP
DHCP Eth ARP query Eth
Phy router for client, name & Phy ˆ DNS query created, encapsulated
IP address of DNS server in UDP, encapsulated in IP,
ˆ encapsulation at DHCP encasulated in Eth. In order to
server, frame forwarded ARP
send frame to router, need MAC
DHCP DHCP (switch learning)
g through
g ARP reply Eth address of router interface: ARP
DHCP UDP LAN, demultiplexing at Phy
DHCP IP client ˆ ARP query broadcast, received
DHCP Eth router ˆ DHCP client receives DHCP by router, which replies with
DHCP
Phy (runs DHCP) ACK reply ARP reply giving MAC address
of router interface
ˆ client now knows MAC address
of first hop router, so can now
Client now has IP address, knows name & addr of DNS send frame containing DNS
server, IP address of its first-hop router query

5: DataLink Layer 5-91 5: DataLink Layer 5-92

A day in the life… using DNS DNS A day in the life… TCP connection carrying HTTP
DNS UDP DNS server
DNS IP HTTP
DNS DNS DNS Eth HTTP
DNS UDP DNS Phy
SYNACK
SYN TCP
DNS IP SYNACK
SYN IP
DNS Eth SYNACK
SYN Eth
Phy Phy
DNS
Comcast network
68.80.0.0/13
ˆ to send HTTP request,
client first opens TCP
socket to web server
ˆ IP datagram forwarded from
ˆ TCP SYN segment (step 1
campus network into comcast
network, routed (tables created SYNACK
SYN TCP in 3-way handshake) inter-
ˆ IP datagram containing DNS
by RIP, OSPF and BGP routing SYNACK
SYN IP domain routed to web
query forwarded via LAN protocols) to DNS server SYNACK
SYN Eth server
switch from client to 1st hop Phy ˆ web server responds with
router TCP SYNACK (step 2 in 3-
ˆ demux’ed to DNS server way handshake)
web server
ˆ DNS server replies to 64.233.169.105 ˆ TCP connection established!
client with IP address of
www.google.com 5: DataLink Layer 5-93 5: DataLink Layer 5-94

A day in the life… HTTP request/reply


ˆ web page finally (!!!)
Link Layer
displayed
HTTP
HTTP HTTP
HTTP
HTTP TCP
IP
ˆ 5.1 Introduction and ˆ 5.6 Hubs and switches
HTTP
HTTP

Eth
services
HTTP
HTTP
Phy ˆ 5.7 PPP
ˆ 5.2 Error detection ˆ A day in the lifetime of
and correction a web-request
q
ˆ HTTP request sent into
TCP socket ˆ 5 3Multiple access
5.3Multiple ˆ 5.8
5 8 Link
Li k Vi
Virtualization
t li ti
ˆ IP datagram containing
protocols
HTTP HTTP
TCP
HTTP request routed to ˆ 5.4 Link-Layer
www.google.com
HTTP
HTTP IP Addressing
Eth ˆ web server responds with
5.5 Ethernet
HTTP

Phy HTTP reply (containing ˆ


web page)
web server
ˆ IP datgram containing
64.233.169.105
HTTP reply routed back to
client 5: DataLink Layer 5-95 5: DataLink Layer 5-96

16
Link Layer The Internet: virtualizing networks
1974: multiple unconnected … differing in:
ˆ 5.1 Introduction and LAN technology
nets  addressing conventions
services ˆ 5.5 Ethernet
 ARPAnet  packet formats
ˆ Framing ˆ 5.6 Interconnection  data-over-cable networks  error recovery
ˆ 5.2 Error detection ˆ 5.4 Link-Layer  packet satellite network (Aloha)  routing
and correction Add
Addressing
i  packet
k radio
d network k
ˆ 5.3Multiple access ˆ 5.7 PPP
protocols ˆ 5.9 A day in the life of a
web request
(5.8 Link Virtualization:
ATM and MPLS)
ARPAnet satellite net
"A Protocol for Packet Network Intercommunication",
V. Cerf, R. Kahn, IEEE Transactions on Communications,
5: DataLink Layer 5-97 5: DataLink Layer 5-98
May, 1974, pp. 637-648.

The Internet: virtualizing networks Cerf & Kahn’s Internetwork Architecture


Internetwork layer (IP): Gateway:
ˆ addressing: internetwork ˆ “embed internetwork packets in What is virtualized?
appears as single, uniform local packet format or extract
entity, despite underlying local them” ˆ two layers of addressing: internetwork and local
network heterogeneity ˆ route (at internetwork level) to
network
ˆ network of networks next gateway
ˆ new layer (IP) makes everything homogeneous at
internetwork layer
ˆ underlying local network technology
cable
gateway satellite
 56K telephone modem
 today: ATM, MPLS

ARPAnet satellite net … “invisible” at internetwork layer. Looks like a link


layer technology to IP!
5: DataLink Layer 5-99 5: DataLink Layer 5-100

ATM and MPLS On ATM: Asynchronous Transfer Mode nets

ˆ 1980’s telco’s proposal for future networking


ˆ ATM, MPLS separate networks in their own
ˆ Smart core, simple terminals
right
 different service models, addressing, routing
ˆ small (48 byte payload, 5 byte header) fixed length cells (like
from Internet packets)
p
ˆ viewed by Internet as logical link connecting  fast switching (pipelined/cut-through)
IP routers  small size good for voice
ˆ virtual-circuit network: switches maintain state for each “call”
 just like dialup link is really part of separate
network (telephone network)
ˆ well-defined interface between “network” and “user” (think of
ˆ ATM, MPLS: of technical interest in their telephone company):
own right  several transport (Adaptation)-layer protocols, one per expected type of
traffic

5: DataLink Layer 5-101 1: Introduction 102

17
IP-Over-ATM IP-Over-ATM
IP over ATM
Classic IP only ˆ replace “network” app
ˆ 3 “networks” (e.g., (e.g., LAN segment) app transport
LAN segments) with ATM network transport IP IP
IP AAL AAL
ˆ MAC (802.3) and IP ˆ ATM addresses, IP Eth Eth ATM
ATM
addresses addresses phy phy phy ATM phy
ATM
phy
p y
ATM
network phy

Ethernet Ethernet
LANs LANs
5: DataLink Layer 5-103 5: DataLink Layer 5-104

Datagram Journey in IP-over-ATM Network IP-Over-ATM


ˆ at Source Host:
 IP layer maps between IP, ATM dest address (using ARP) Issues: ATM
 passes datagram to AAL5 ˆ IP datagrams into network
 AAL5 encapsulates data, segments cells, passes to ATM layer ATM AAL5 PDUs
ˆ ATM network: moves cell along VC to destination ˆ from IP addresses
ˆ at Destination Host: to ATM
TM addresses
dd
 AAL5 reassembles cells into original datagram  just like IP

 if CRC OK, datagram is passed to IP addresses to


Ethernet
802.3 MAC LANs
addresses!

5: DataLink Layer 5-105 5: DataLink Layer 5-106

Multiprotocol label switching (MPLS) MPLS capable routers


ˆ initial goal: speed up IP forwarding by using fixed ˆ a.k.a. label-switched router
length label (instead of IP address) to do ˆ forwards packets to outgoing interface based
forwarding only on label value (don’t inspect IP address)
 borrowing ideas from Virtual Circuit (VC) approach
 MPLS forwarding table distinct from IP forwarding
but IP datagram
g still keeps
p IP address!

tables
ˆ signaling protocol needed to set up forwarding
PPP or Ethernet
MPLS header IP header remainder of link-layer frame  RSVP-TE
header
 forwarding possible along paths that IP alone would
not allow (e.g., source-specific routing) !!
 use MPLS for traffic engineering
label Exp S TTL
ˆ must co-exist with IP-only routers
20 3 1 5
5: DataLink Layer 5-107 5: DataLink Layer 5-108

18
MPLS forwarding tables Chapter 5: Summary
in out out
ˆ principles behind data link layer services:
label label dest interface  error detection, correction
10 A 0 in out out  sharing a broadcast channel: multiple access
label label dest interface
12 D 0  link layer addressing
8 A 1 10 6 A 1
12 9 D 0 ˆ instantiation and implementation of various link
llayer technologies
t h l i
 Ethernet
R6
0 0
D
1 1
 switched LANS
R4 R3
R5  PPP
0 0
A  Link Virtualization: ATM and MPLS
R2 in outR1 out
label label dest interface
in out out
label label dest interface 6 - A 0
8 6 A 0
5: DataLink Layer 5-109 5: DataLink Layer 5-110

19

You might also like