Lecture-2012-15 - Datalink-Layer - Part 1
Lecture-2012-15 - Datalink-Layer - Part 1
Layer
Our goals: Overview:
understand principles link layer services
behind data link layer error detection, correction
services:
multiple access protocols
error detection,
correction and LANs
sharing a broadcast link layer addressing, ARP
channel: multiple access specific link layer
link layer addressing technologies:
reliable data transfer, Ethernet
flow control: done!
hubs, bridges, switches
instantiation and
IEEE 802.11 LANs
implementation of
various link layer
PPP
technologies
5: DataLink Layer 1
Link Layer: setting the context
Different link-layer protocols on the
different links in the path
• Ethernet
Node: Host/Router
• Link-layer WAN protocol
• PPP
Network Layer: End-to-End job of moving transport-layer segments from source host to
destination host
Link-Layer Protocol: Node-to-Node job of moving network-layer datagrams over a single-
2
link in the path 5: DataLink Layer
Link Layer: setting the context
two physically connected devices:
host-router, router-router, host-host
M application
Ht M transport
Hn Ht M network data link network
protocol
Hl Hn Ht M link link Hl Hn Ht M
physical physical frame
phys. link
adapter card
5: DataLink Layer 3
Link Layer Services Parallels transport layer
services
Framing, link access:
encapsulate datagram into frame, adding header, trailer
implement channel access if shared medium,
‘physical addresses’ used in frame headers to identify
source, destination
Catch the error on the link
• different from IP address! where it occurs
Reliable delivery between two physically
connected devices: Mechanisms: Seq.Nos,
we learned how to do this already (chapter 3)! Timers, ACKs
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 4
Link Layer Services (more)
Flow Control:
pacing between sender and receivers
Error Detection: More sophisticated; hardware-implemented
errors caused by signal attenuation &
electromagnetic noise.
Sender sets error-detection bits in the
frame; receiver detects presence of errors:
• signals sender for retransmission or drops frame
Error Correction:
receiveridentifies and corrects bit error(s)
without resorting to retransmission
5: DataLink Layer 5
Link Layer: Implementation
Network Interface Card
implemented in adapter (NIC)
e.g., PCMCIA card, Ethernet card
typically includes: RAM, DSP chips, host bus
interface, and link interface
M application
Ht M transport
Hn Ht M network data link network
protocol
Hl Hn Ht M link link Hl Hn Ht M
physical physical frame
phys. link
adapter card 6
5: DataLink Layer
Error Detection
EDC= Error Detection and Correction bits (redundancy)
D = Data protected by error checking, may include header
fields
5: DataLink Layer 7
Immediate error
correction at the receiver
Parity Checking (Forward Error
Correction) or FEC
Commonly used in 0 0
Audio storage &
playback devices
5: DataLink Layer 8
Software-implemented; requires
relatively little packet overhead but
Internet checksum weaker protection against errors as
compared to CRC
1011
0101
1110
Want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r by
G, want reminder R
D
R = remainder[
.2r
]
G We are interested only in the
remainder. 11
5: DataLink Layer
END OF SESSION
5: DataLink Layer 12
Multiple Access Links and Protocols
5: DataLink Layer 13
Multiple Access protocols (MAC)
Regulates node transmission over shared broadcast channel
single shared communication channel
two or more simultaneous transmissions by nodes:
interference
only one node can send successfully at a time
multiple access protocol:
distributed algorithm that determines how stations share
channel, i.e., determines when the station can transmit
communication about channel sharing must use channel
itself!
what to look for in multiple access protocols:
• synchronous or asynchronous
• information needed about other stations
• robustness (e.g., to channel errors)
• performance 14
5: DataLink Layer
MAC Protocols: a taxonomy
Three broad classes:
Channel Partitioning Protocols
divide channel into smaller pieces (time slots,
frequency bands, multiple access codes)
allocate piece to node for exclusive use
Random Access Protocols
allowcollisions
recover from collisions
Taking turns Protocols
tightly coordinate shared access to avoid collisions
Animation
5: DataLink Layer 15
MAC Protocols
Goal: efficient, fair, simple, decentralized
DESIRABLE CHARACTERISTICS
For a broadcast channel of R bps:
• For only one sending node: throughput = R bps
• For M sending nodes: throughput = R/M bps
-not instantaneous transmission rate, but average transmission rate of
R/M bps over some suitably defined time interval
• Decentralized
• Simple, inexpensive to implement
5: DataLink Layer 16
Channel Partitioning MAC protocols:
TDMA
Divide time into Frames, and
TDMA: Time Division Multiple Access further divide Frames into N time
access to channel in rounds slots
each station gets fixed length slot (length = pkt trans
time) in each round
Drawback: unused slots go idle
example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle
5: DataLink Layer 17
See more slides
Channel Partitioning MAC protocols:
FDMA: Frequency Division Multiple Access
5: DataLink Layer 18
TDM & FDM
Suppose that a channel supports N nodes, with transmission rate of R
bps
DRAWBACKS
• A NODE is limited to a bandwidth of R/N when it is the only node
with packets to send
• (Only for TDM) A NODE must always wait for its turn in the
transmission sequence, even when it is the only node with a packet to
send
5: DataLink Layer 19
Random Access protocols
When node has packet to send
transmit at full rate (R) of channel
no a priori coordination among nodes
RULES:
•Listen before speaking (carrier sensing)
Animation • If someone else begins talking at the same
time, stop talking (collision detection)
5: DataLink Layer 21
Channel propagation
CSMA collisions delay
4 nodes attached to a linear broadcast
spatial layout of nodes along ethernet
bus; Horizontal axis shows position of
each node in space
collisions can
occur:
propagation delay
means
two nodes may not
yet
collision:
hear each other's
entire packet
transmission
transmission
time wasted D senses the channel is
idle at t1
note:
role of distance and
propagation delay in
determining collision
prob.
5: DataLink Layer 22
CSMA/CD (Collision Detection)
CSMA/CD: carrier sensing, deferral as in CSMA
collisions detected within short time
colliding transmissions aborted, reducing
channel wastage
persistent or non-persistent retransmission
collision detection:
easy in wired LANs: measure signal strengths,
compare transmitted, received signals
difficult in wireless LANs: receiver shut off while
transmitting
human analogy: the polite conversation
5: DataLink Layer 23
CSMA/CD collision detection
4 nodes attached to a
linear broadcast bus
5: DataLink Layer 24
Slotted Aloha
Pros Cons
• single active node can • collisions, wasting slots
continuously transmit at • idle slots
full rate of channel • nodes may not be able to
• highly decentralized: only detect collision in less
slots in nodes need to be than time to transmit
packet
in sync
• clock synchronization
• simple
5: DataLink Layer 27
Pure (unslotted) ALOHA
FULLY DECENTRALIZED PROTOCOL
unslotted Aloha: simpler, no synchronization
If pkt needs transmission:
sends immediately without waiting for the beginning
of slot
If there’s a collision after transmission:
Retransmit frame with probability p
5: DataLink Layer 28
Pure Aloha (cont.)
P(success by given node) = P(node transmits a frame) .
P(no other node transmits in [t0-
1,t0] .
P(no other node transmits in [t0,
t0+1]
= p . (1-p)(N-1) . (1-p)(N-1)
P(success by any of N nodes) = N p . (1-p) 2(N-1)
0.4
… choosing optimum p as n -> infinity ...
S = throughput =
(success rate)
throughput!
0.1
Pure Aloha
M mini slots
are assigned
to each data
bit
5: DataLink Layer 31
CDMA: two-sender interference
Assumption: interfering
bit signals are additive
5: DataLink Layer 32
Taking Turns MAC protocols
by known priority
Nodes can transmit only up to a max number of frames
5: DataLink Layer 35
Summary of MAC protocols
5: DataLink Layer 36
END OF SESSION
5: DataLink Layer 37
LAN technologies
Data link layer so far:
services, error detection/correction, multiple
access
Next: LAN technologies
addressing
Ethernet
hubs,bridges, switches
802.11
5: DataLink Layer 38
LAN Addresses and ARP
Recall
32-bit IP address:
network-layer address
used to get datagram to destination network
(recall IP network definition)
LAN or Media Access Control (MAC) or
physical address:
used to get datagram from one interface to
another physically-connected interface (same
network)
48 bit MAC address (for most LANs)
burned in the adapter ROM
5: DataLink Layer 39
LAN Addresses and ARP
Each adapter on LAN has unique LAN address
5: DataLink Layer 40
LAN Address (more)
MAC address allocation administered by IEEE
manufacturer buys portion of MAC address
space (to assure uniqueness)
Analogy:
(a) MAC address: like Social Security
Number
(b) IP address: like postal address
MAC flat address => portability
can move LAN card from one LAN to another
IP hierarchical address NOT portable
depends on network to which one attach to
5: DataLink Layer 41
Recall earlier routing discussion
Starting at A, given IP A 223.1.1.1
datagram addressed to
223.1.2.1
B: 223.1.1.2
look up net. address of B, 223.1.1.4 223.1.2.9
B
find B on same net. as A 223.1.2.2
link layer send datagram to B
223.1.1.3 223.1.3.27 E
datagram
frame
5: DataLink Layer 42
ARP:
Address Resolution Protocol
Question: how to determine Each IP node (Host,
MAC address of B Router) on LAN has an
given B's IP address? ARP module, table
ARP 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)
We have an example later Layer
5: DataLink 43
ARP protocol
We have an example later
A knows B's IP address, wants to learn physical
address of B
A broadcasts ARP query pkt, containing B's IP
address
all machines on LAN receive ARP query
B receives ARP packet, replies to A with its
(B's) physical layer address
A caches (saves) IP-to-physical address pairs
until information becomes old (times out)
soft state: information that times out (goes
away) unless refreshed
5: DataLink Layer 44
Routing to another LAN
routing from A to B via R
R
B
5: DataLink Layer 45
A creates IP packet with source A, destination B
A uses ARP to get R's physical layer address for
111.111.111.110
A creates Ethernet frame with R's physical address as
dest, Ethernet frame contains A-to-B IP datagram
A's data link layer sends Ethernet frame
R's data link layer receives Ethernet frame
R removes IP datagram from Ethernet frame, sees its
destined to B
R uses ARP to get B's physical layer address
R creates frame containing A-to-B IP datagram sends to B
R
B
5: DataLink Layer 46
DHCP: Dynamic Host Configuration
Protocol
Goal: allow host to dynamically obtain its IP address from
network server when it joins network
Can renew its lease on address in use
Allows reuse of addresses (only hold address while connected and “on”
Support for mobile users who want to join network (more shortly)
DHCP overview:
host broadcasts “DHCP discover” msg
DHCP server responds with “DHCP offer” msg
host requests IP address: “DHCP request” msg
DHCP server sends address: “DHCP ack” msg
5: DataLink Layer 47
DHCP client-server scenario
A DHCP 223.1.2.1
223.1.1.1
server
223.1.1.2
223.1.1.4 223.1.2.9
B
223.1.2.2 arriving DHCP
223.1.1.3 223.1.3.27 E client needs
address in this
223.1.3.1 223.1.3.2
network
5: DataLink Layer 48
DHCP client-server scenario
DHCP server: 223.1.2.5 arriving
DHCP discover
client
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
time Lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
5: DataLink Layer 49