Data Link Layer: 3516 - Computer Networks
Data Link Layer: 3516 - Computer Networks
Link Layer
5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-layer Addressing 5.5 Ethernet
5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
Hosts and routers are nodes Communication channels that connect adjacent nodes along communication path are links
Wired links Wireless links LANs
data-link layer has responsibility of transferring datagram from one node to adjacent node over link
Transportation analogy
Trip from Princeton to Lausanne limo: Princeton to JFK plane: JFK to Geneva train: Geneva to Lausanne
Tourist = datagram Transport hop = communication link Transportation mode = link layer protocol Travel agent = routing algorithm
Encapsulate datagram into frame, adding header, trailer Channel access if shared medium Medium Access Control (MAC) addresses used in frame headers to identify source and dest
Flow control
Pacing between adjacent sending and receiving nodes
Error detection
Errors caused by signal attenuation, noise. Receiver detects presence of errors
Error correction
Receiver identifies and corrects bit error(s) without resorting to retransmission With half duplex, nodes at both ends of link can transmit, but not at same time
cpu
memory
Attaches into hosts system buses Combination of hardware, software, and firmware
Adaptors Communicating
datagram controller datagram controller
sending host
datagram
receiving host
frame
Sending side:
Encapsulates datagram in frame Adds error checking bits, rdt, flow control, etc.
Receiving side
Looks for errors, rdt, flow control, etc. Extracts datagram, passes to upper layer
5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
Error Detection
EDC= Error Detection and Correction bits (redundancy) D = Data protected by error checking, may include header fields
Protocol may miss some errors, but rarely Larger EDC field yields better detection and correction
otherwise
Receiver:
Treat segment contents as sequence of 16-bit integers Checksum: addition (1s complement sum) of segment contents Sender puts checksum value into UDP checksum field
Compute checksum of received segment Check if computed checksum equals checksum field value: NO - error detected YES - no error detected.
View data bits, D, as a binary number Choose r+1 bit pattern (generator), G Goal: choose r CRC bits, R, such that
<D,R> exactly divisible by G (modulo 2) Receiver knows G, divides <D,R> by G.
Want:
.2r D R = remainder[ ] G
CRC Standards
Defined for 8, 12, 16 and 32 bit genrators (G) CRC-32 adopted by many IEEE link-layer
protocols uses generator:
Detects all errors burst less than 33 bits Detects all odd number bit errors Burst errors greater than 33 bits with
probability 1-0.5r
Gcrc-32 = 100000100110000010001110110110111
5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
shared RF (satellite)
Distributed algorithm determines how nodes share channel (i.e. determine when/who node can transmit) Communication about channel sharing must use channel itself!
no out-of-band channel for coordination
4. Simple
Channel Partitioning
Divide channel into smaller pieces (time slots, frequency) Allocate piece to node for exclusive use
Random Access
Channel not divided, allow collisions Recover from collisions
Taking turns
Nodes take turns, but nodes with more to send can perhaps take longer turns
Access to channel in "rounds" Each station gets fixed length slot (length = pkt trans time) in each round Unused slots go idle Example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle
6-slot frame 1 3 4
Channel spectrum divided into frequency bands Each station assigned fixed frequency band Unused transmission time in frequency bands go idle Example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle frequency bands
FDM cable
Two or more transmitting nodes collision Random access MAC protocol specifies:
How to detect collisions How to recover from collisions (e.g. via delayed retransmissions)
Slotted ALOHA
Assumptions: Operation: All frames same size When node obtains fresh Time divided into equal frame, transmits in next slot size slots (time to If no collision: node can transmit 1 frame) send new frame in next Nodes start to transmit slot only slot beginning If collision: node Nodes are synchronized retransmits frame in If 2 or more nodes each subsequent slot with prob p until success transmit in slot, all nodes detect collision
Slotted ALOHA
Pros Single active node can continuously transmit at full rate of channel Highly decentralized: only slots in nodes need to be in sync Simple
Cons Collisions, wasting slots Idle slots Nodes may be able to detect collision in less than time to transmit packet Clock synchronization
Suppose: N nodes with many frames to send, each transmits in slot with probability p Prob that given node has success in a slot =
p(1-p)N-1
Max efficiency: find p that maximizes Np(1-p)N-1 For many nodes, take limit of Np(1-p)N-1 as N goes to infinity, gives:
CSMA Collisions
spatial layout of nodes
Collision:
Note:
Collision detection:
Easy in wired LANs
received signals
Measure signal strengths, compare transmitted, Received signal strength overwhelmed by local
transmission strength
data poll
master
data
slaves
(nothing to send)
data
Taking turns
polling from central site, token passing Bluetooth, FDDI, IBM Token Ring
5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
MAC Addresses
32-bit IP address:
address:
LAN Addresses
Each adapter on LAN has unique LAN address
1A-2F-BB-76-09-AD
71-65-F7-2B-08-53
= adapter
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
MAC/LAN 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
Each IP node (host, router) on LAN has ARP 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)
LAN
71-65-F7-2B-08-53 58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98 137.196.7.88
A caches (saves) IP-toMAC 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
A
111.111.111.111
E6-E9-00-17-BB-4B 1A-23-F9-CD-06-9B
222.222.222.221
222.222.222.222
B
49-BD-D2-C7-56-2A
CC-49-DE-D0-AB-7D
A creates IP datagram with source A, destination B A uses ARP to get Rs MAC address for 111.111.111.110 A creates link-layer frame with R's MAC address as dest, frame contains A-to-B IP datagram This is a really important As NIC sends frame example make sure you Rs NIC receives frame understand! R removes IP datagram from Ethernet frame, sees its destined to B R uses ARP to get Bs MAC address R creates frame containing A-to-B IP datagram sends to B
74-29-9C-E8-FF-55 88-B2-2F-54-1A-0F
A
E6-E9-00-17-BB-4B 111.111.111.111 1A-23-F9-CD-06-9B 222.222.222.221
222.222.222.222
B
49-BD-D2-C7-56-2A
CC-49-DE-D0-AB-7D
5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
Ethernet
Dominant wired LAN technology: Cheap ($20) for NIC First widely used LAN technology Simpler, cheaper than token LANs and ATM Kept up with speed race: 10 Mbps 10 Gbps
Bus topology popular through mid 90s Today: star topology prevails
All nodes in same collision domain (can collide with each other) Active switch in center (contrast with hub) Each spoke runs a (separate) Ethernet protocol (nodes do not collide with each other)
switch
star
Preamble: 7 bytes with pattern 10101010 followed by one byte with pattern 10101011 Used to synchronize receiver, sender clock rates
Addresses: 6 bytes
If adapter receives frame with matching destination address or with broadcast address (e.g. ARP packet), it passes data in frame to network layer protocol otherwise, adapter discards frame
Type: indicates higher layer protocol (mostly IP but others possible, e.g., Novell IPX, AppleTalk) CRC: checked at receiver, if error is detected, frame is dropped
CSMA/CD Efficiency
Tprop = max prop delay between 2 nodes in LAN ttrans = time to transmit max-size frame
efficiency
1 1 5t prop /t trans
Efficiency goes to 1 Better performance than ALOHA: and simple, cheap, decentralized!
as tprop goes to 0 as ttrans goes to infinity
Common MAC protocol and frame format Different speeds: 2 Mbps, 10 Mbps, 100 Mbps, 1Gbps, 10G bps Different physical layer media: fiber, cable
application transport network link physical
MAC protocol and frame format
100BASE-TX 100BASE-T4 100BASE-T2 100BASE-SX 100BASE-FX
100BASE-BX
Manchester Encoding
Used in 10BaseT 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!
5.6 Link-layer switches, LANs, VLANs 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
Hubs
physical-layer (dumb) repeaters: bits coming in one link go out all other links at same rate
all nodes connected to hub can collide with one another no frame buffering no CSMA/CD at hub: host NICs detect collisions
twisted pair
hub
Switch
Transparent
Plug-and-play, self-learning
Hosts have dedicated, C direct connection to switch Switches buffer packets Ethernet protocol used on each incoming link, but no collisions; full duplex
B 6
1 2 5 4 C
Switch Table
A C
B 6
1 2 5 4 C
Switch: Self-learning
Source: A Dest: A
A A A
B 6
1 2 5 4 C
B
interface
TTL
A 60
Switch table (initially empty)
Source: A Dest: A
A A A C 1 2 3 6 A A 5 4 A A C
frame destination
unknown: flood
Destination A
B
MAC addr interface TTL A A
A
Switch table (initially empty)
1 4
60 60
Interconnecting Switches
Switches can be connected together S4 S1
A
B C
S2 D E
S3
F G
H
forward frame destined to F via S4 and S3? A: self learning! (works exactly the same as in single-switch case!)
A
B
F G
H
S2, S3, S4
Institutional Network
to external network
mail server router web server IP subnet
routers maintain routing tables, implement routing algorithms switches maintain switch tables, implement filtering, learning algorithms
5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
that differ from wired 802.11 (WiFi) as contrast to 802.3 (Ethernet) (Bits of Ch 6.1 6.3)
.384 .056
Indoor
10-30m
3G
2G
Outdoor
50-200m
BER
increase power increase SNR decrease BER Given SNR: choose physical layer that meets BER requirement, giving highest thruput
10
20
30
40
BPSK (1 Mbps)
C A
C
Cs signal strength
space
B, A hear each other B, C hear each other A, C can not hear each other means A, C unaware of their interference at B
Signal attenuation:
B, A hear each other B, C hear each other A, C can not hear each other interfering at B
802.11g
802.11n: multiple antennae
2.4-5 GHz range up to 200 Mbps
All use CSMA/CA for multiple access All have base-station and ad-hoc network versions
C A B
A
As signal strength
C
Cs signal strength
space
receiver
data
SIFS
ACK
Base station, mobile dynamically change transmission rate (physical layer modulation technique) as mobile moves, SNR varies
QAM256 (8 Mbps) QAM16 (4 Mbps) BPSK (1 Mbps) operating point
BER
SNR(dB)
1. SNR decreases, BER increase as node moves away from base station 2. When BER becomes too high, switch to lower transmission rate but with lower BER
More Wireless!
Link Layer
5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet
5.6 Link-layer switches 5.7 PPP 5.8 Link virtualization: MPLS 5.9 A day in the life of a web request
Putting-it-all-together: synthesis!
Application, Transport, Network, Data Link goal: identify, review, understand protocols (at all layers) involved in seemingly simple scenario: requesting www page scenario: student attaches laptop to campus network, requests/receives www.google.com
connecting laptop needs to get its own IP address, addr of first-hop router, addr of DNS server: use
DHCP
DHCP
Ethernet demuxed to IP
DHCP server formulates DHCP ACK containing clients IP address, IP address of first-hop router for client, name & IP address of DNS server Encapsulation at DHCP server, frame forwarded (switch learning) through LAN, demultiplexing at client DHCP client receives DHCP ACK reply
DHCP
DHCP
Client now has IP address, knows name & addr of DNS server, IP address of its first-hop router
Before sending HTTP request, need IP address of DNS query created, encapsulated in UDP, encapsulated in IP, encasulated in Eth. In order to send frame to router, need MAC address of router interface: ARP ARP query broadcast, received by 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
www.google.com: DNS
Eth Phy
DNS DNS
DNS DNS
DNS server
IP datagram containing DNS query forwarded via LAN switch from client to 1st hop router
IP datagram forwarded from campus network into comcast network, routed (tables created by RIP, OSPF, IS-IS and/or BGP routing protocols) to DNS server demuxed to DNS server DNS server replies to client with IP address of www.google.com
To send HTTP request, client first opens TCP socket to web server TCP SYN segment (step 1 in 3-way handshake) interdomain routed to web server Web server responds with TCP SYNACK (step 2 in 3way handshake)
HTTP request sent into TCP socket IP datagram containing HTTP request routed to www.google.com Web server responds with HTTP reply (containing web page) IP datgram containing HTTP reply routed back to client
Chapter 5: Summary
Principles behind data link layer services:
error detection, correction sharing a broadcast channel: multiple access link layer addressing
Instantiation and implementation of various link layer technologies Addressing Ethernet Switched LANS
(except PHY) Solid understanding of networking principles, practice .. could stop here . but lots of interesting topics!
Wireless Multimedia Security Network management