Lecture-2012-15 - Datalink-Layer - Part 1
Lecture-2012-15 - Datalink-Layer - Part 1
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,
Timers, ACKs
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 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:
receiver identifies 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
Parity Checking
correction at the receiver
(Forward Error
Correction) or FEC
Commonly used in 0 0
Audio storage &
playback devices
5: DataLink Layer 8
Software-implemented; requires
Internet checksum
relatively little packet overhead but
weaker protection against errors as
compared to CRC
Sender: Receiver:
treat segment contents as compute checksum of
sequence of 16-bit received segment
integers check if computed checksum
checksum: 1's complement equals checksum field value:
of the sum of segment NO - error detected
contents YES - no error detected.
sender puts checksum But maybe errors
value into UDP checksum nonetheless? More later
field ….
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
R = remainder[ D.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
5: DataLink Layer 14
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
CSMA collisions
Channel propagation
delay
4 nodes attached to a linear broadcast
spatial layout of nodes along ethernet
bus; Horizontal axis shows position of
each node in space
collision:
entire packet 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)
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)
… choosing optimum p as n -> infinity ...
S = throughput = “goodput”
= 1/(2e) = .18
0.4
0.3
(success rate)
protocol constrains
Slotted Aloha
0.2 effective channel
throughput!
0.1
Pure Aloha
5: DataLink Layer 30
CDMA Encode/Decode
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
Animation
5: DataLink Layer 34
Reservation-based protocols
Distributed Polling:
time divided into slots
begins with N short reservation slots
reservation slot time equal to channel end-end propagation
delay
station with message to send posts reservation
reservation seen by all stations
after slot reservation, message transmissions are ordered 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 B:
223.1.2.1
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
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)
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
5: DataLink Layer 47
DHCP client-server scenario
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