Date post: | 20-Dec-2015 |
Category: |
Documents |
View: | 217 times |
Download: | 0 times |
CSE 401N DLL 2
Preview: The Data Link LayerOur goals:
Understand principles behind data link layer services: error detection,
correction done! sharing a broadcast
channel: multiple access
reliable data transfer, flow control: done!
link layer forwarding
Instantiation and implementation of various link layer technologies
Overview: link layer services error detection, correction multiple access protocols
and LANs link layer addressing, ARP specific link layer
technologies: Ethernet hubs, bridges, switches IEEE 802.11 LANs and
wireless PPP ATM
CSE 401N DLL 4
Link Layer: setting the context two physically connected devices:
host-router, router-router, host-host unit of data: frame
applicationtransportnetwork
linkphysical
networklink
physical
M
M
M
M
Ht
HtHn
HtHnHl MHtHnHl
framephys. link
data linkprotocol
adapter card
CSE 401N DLL 5
Link Layer: Introduction
Some terminology: hosts and routers are nodes (bridges and switches too) communication channels
that connect adjacent nodes along communication path are links wired links wireless links LANs
2-PDU is a frame, encapsulates datagram
“link”
CSE 401N DLL 6
Link layer: Context
Data-link layer has responsibility of transferring datagram from one node to adjacent node over a link
Datagram transferred by different link protocols over different links: e.g., Ethernet on first link,
frame relay on intermediate links, 802.11 on last link
transportation analogy trip from New Haven to San
Francisco taxi: home to union
station train: union station to JFK plane: JFK to San
Francisco airport limo: airport to hotel
CSE 401N DLL 7
Link 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, dest • different from IP address!
Reliable delivery between two physically connected devices: 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 reliabilityQ: why both link-level and end-end reliability?
CSE 401N DLL 8
Link Layer Services (more)
Flow Control: pacing between adjacent sending and receiving nodes
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
Half-duplex and full-duplex with half duplex, nodes at both ends of link can
transmit, but not at same time
CSE 401N DLL 9
Adaptors Communicating
{RAM, DSP Chips, a host bus interface, link interface}
link layer implemented in “adaptor” (aka NIC) Ethernet card, PCMCI card,
802.11 card sending side:
encapsulates datagram in a frame
adds error checking bits, rdt, flow control, etc.
receiving side looks for errors, rdt, flow
control, etc extracts datagram,
passes to rcving node
adapter is semi-autonomous
link & physical layers
sendingnode
frame
rcvingnode
datagram
frame
adapter adapter
link layer protocol
CSE 401N DLL 10
OSIApplication
Presentation
Session
Transport
Network
Data Link
Physical
TCP/IP
Application
Transport
Internet
Network Interface
CSE 401N DLL 12
Error DetectionEDC= Error Detection and Correction bits (redundancy)D = Data protected by error checking, may include header fields
• Error detection not 100% reliable!• protocol may miss some errors, but rarely• larger EDC field yields better detection and correction
CSE 401N DLL 13
Error Detection: Parity CheckingSingle Bit Parity:Detect single bit errors
Two Dimensional Bit Parity:Detect and correct single bit errors
0 0
Errors are generally bursty, i.e. several consecutive bits are flipped: column parity.
1
CSE 401N DLL 14
Internet Checksum
Sender: treat segment
contents as sequence of 16-bit integers
checksum: addition (1’s complement sum) of segment contents
sender puts checksum value into checksum field
Receiver: compute checksum of
received segment check if computed
checksum equals checksum field value: NO - error detected YES - no error detected
Goal: detect “errors” (e.g., flipped bits) in transmitted segment (note: used at transport layer only)
CSE 401N DLL 15
Cyclic Redundancy Check: Background Widely used in practice (ATM, Ethernet,
HDCL,) For a given data D, consider it as a
polynomial D(x) consider the string of 0 and 1 as the
coefficients of a polynomial• e.g. consider string 10011 as x4+x+1
addition and subtraction are modular 2, thus the same as xor
Choose generator polynomial G(x) with r+1 bits, where r is called the degree of G(x)
CSE 401N DLL 16
Cyclic Redundancy Check: Objective Given data G(x) and D(x), choose R(x) with r
bits, such that D(x)xr+R(x) is exactly divisible by G(x)
The bits correspond to D(x)xr+R(x) are sent to the receiver
Since G(x) is global, when the receiver receives the transmission T’(x), it divides T’(x) by G(x) If non-zero remainder: error detected! If zero remainder, assumes no error
+x
CSE 401N DLL 17
CRC: Steps and an Example1. Suppose the degree
of G(x) is r2. Append r zero to D(x),
i.e. consider D(x)xr
3. Divide D(x)xr by G(x). 4. Let R(x) denote the
reminder5. Send <D, R> to the
receiver
CSE 401N DLL 18
CRC ExampleWant:
D.2r XOR R = nGequivalently:
D.2r = nG XOR R equivalently: if we divide D.2r by G,
remainder is R
R = remainder[ ]D.2r
G
Example: D=101110, G=1001, r=3
In CRC calculations, addition and subtraction are equivalent to bitwise exclusive-or (XOR) Sender transmit: 101110 011
CSE 401N DLL 19
The Power of CRC Let T(x) denote D(x)xr+R(x), and E(x) the polynomial of the
error bits The received signal is T(x)+E(x)
Since T(x) is divisible by G(x), we only need to consider E(x) divided by G(x)
A single bit of error: E(x) = xi
If G(x) contains two or more terms, E(x) is not divisible by G(x)
An odd number of errors: E(x) has an odd number of terms: Lemma: if E(x) has an odd number of terms, E(x) cannot be
divisible by (x+1)• suppose E(x) = (x+1)F(x), let x=1, the left hand will be 1, while the
right hand will be 0 If G(x) contains x+1 as a factor, E(x) will not be divided by G(x)
Many more errors can be detected by designing the right G(x)
CSE 401N DLL 20
Example G(x)
CRC-16: x16+x15+x2+1 CRC-CCITT: x16+x12+x5+1 Both can catch
all single or double bit errors all odd number of bit errors All burst errors of length 16 or less >99.99% of the 17 or 18 bits burst errors
CSE 401N DLL 23
Multiple Access Links and Protocols
Two types of “links”: point-to-point
PPP for dial-up access point-to-point link between Ethernet switch and host
broadcast (shared wire or medium) traditional Ethernet 802.11 wireless LAN satellite
CSE 401N DLL 24
Multiple Access Protocols Single shared broadcast channel Two or more simultaneous transmissions by nodes:
interference only one node can send successfully at a time (see CDMA for
an exception)
multiple access protocol Algorithm that determines how nodes share channel, i.e.,
determines when node 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
CSE 401N DLL 25
Ideal Mulitple Access Protocol
Broadcast channel of rate R bpsrate R bps1. Efficiency: when one node wants to transmit,
it can send at rate R.2. Fairness: when M nodes want to transmit,
each can send at average rate R/M3. Decentralized:
no special node to coordinate transmissions no synchronization of clocks
4. Simple
CSE 401N DLL 26
Multiple Access protocols
claim: humans use multiple access protocols all the time
class can "guess" multiple access protocols multiaccess protocol 1: multiaccess protocol 2: multiaccess protocol 3: multiaccess protocol 4:
CSE 401N DLL 27
MAC Protocols: a Taxonomy
Three broad classes: Channel Partitioning
divide channel into smaller “pieces” (time slots, frequency)
allocate piece to node for exclusive use
Random Access allow collisions “recover” from collisions
“Taking-turns” tightly coordinate shared access to avoid collisions
Goal: efficient, fair, decentralized, simple
CSE 401N DLL 28
Channel Partitioning MAC protocols: TDMA
TDMA: time division multiple access 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
CSE 401N DLL 29
Channel Partitioning MAC protocols: FDMAFDMA: frequency division multiple access 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
frequ
ency
bands time
5
1
4
3
2
6
CSE 401N DLL 31
TDMA and FDMA
Often combined in practice, for example, in cellular phone networks: TDMA cellular phones
use 30 KHz channels, with each channel divided into three time slots. A single handset uses one timeslot for sending and the other for receiving.
• e.g. Cingular (Nokia 8265, TDMA 800/ 1900 MHz, AMPS 800 mHz ), AT&T Wireless
GSM uses 200 KHz channels divided into eight time slots. A single handset uses one slot in two channels for sending and receiving.
• Cingular, T-Mobile, AT&T are converting to it
CSE 401N DLL 32
Channel Partitioning (CDMA)
CDMA (Code Division Multiple Access) Used mostly in wireless broadcast
channels (cellular, satellite, etc) Unique “code” assigned to each user; i.e.,
code set partitioning All users share same frequency, but each
user has its own “chipping” sequence (i.e., code) to encode data e.g. code = 1 1 1 1 -1 -1 1 1
Examples: MetroPCS, Sprint and Verizon
CSE 401N DLL 33
CDMA: Encoding and Decoding
Assume original data are represented by 1 and -1
Encoded signal = (original data) x (chipping sequence)
Decoding: inner-product (summation of bit-by-bit product) of encoded signal and chipping sequence if inner-product > threshold, the data is 1; else
-1
CSE 401N DLL 35
CDMA: Deal with Multiple-User Interference
Two codes Ci and Cj are orthogonal, if , where we use “.” to denote inner
product, e.g.
If codes are orthogonal, multiple users can “coexist” and transmit simultaneously with minimal interference:
iiij
jj cdccd )(
0 ij cc
C1: 1 1 1 -1 1 -1 -1 -1 C2: 1 -1 1 1 1 -1 1 1-----------------------------------------C1 . C2 = 1 +(-1) + 1 + (-1) +1 + 1+ (-1)+(-1)=0
Analogy: Speak in different languages!
CSE 401N DLL 36
CDMA: Two-Sender Interference
Code 1: 1 1 1 -1 1 -1 -1 -1Code 2: 1 -1 1 1 1 -1 1 1 . . . .
CSE 401N DLL 37
Outline
Media access control (MAC) protocols: overview
Random MAC protocols Random Access
• Compete for each packet• Aloha, CSMA, CSMA/CD
“Taking-turns”
CSE 401N DLL 38
Random Access Protocols
When node has packets to send transmit at full channel data rate R. no a priori coordination among nodes
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) Examples of random access MAC protocols:
slotted ALOHA and pure ALOHA CSMA and CSMA/CD, CSMA/CA
CSE 401N DLL 39
Slotted Aloha
Time is divided into equal size slots (= pkt trans. time)
Node with new arriving pkt: transmit at beginning of next slot
If collision: retransmit pkt in future slots with probability p, until successful.
Success (S), Collision (C), Empty (E) slots
CSE 401N DLL 40
Slotted Aloha EfficiencyQ: What is the fraction of successful slots?A: Suppose N stations have packets to send
each transmits in a slot with probability p prob. successful transmission S(p) is:
by single node: S(p)= p (1-p)(N-1)
by any one of the N nodes
S(p) = Prob (only one transmits) = N p (1-p)(N-1)
when p=1/N, S(p) achieves the maximum (1-1/N)(N-1)
CSE 401N DLL 41
Maximum Efficiency vs. N
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
2 7 12 17 N
max
imu
m e
ffic
ien
cy1/e = 0.37
At best: channeluse for useful transmissions 37%of time!
CSE 401N DLL 42
Pure (unslotted) Aloha Unslotted Aloha: simpler, no synchronization Whenever pkt needs transmission:
send without awaiting for the beginning of slot
Collision probability increases: pkt sent at t0 collide with other pkts sent in [t0-1,
t0+1]
CSE 401N DLL 43
Pure Aloha (cont.)P(success by given node) = P(node transmits) .
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)N-1 . (1-p)N-1
Bound: 1/(2e) = .18
S =
thro
ughput
=
“goodput”
(
succ
ess
rate
)
G = offered load = Np0.5 1.0 1.5 2.0
0.1
0.2
0.3
0.4
Pure Aloha
Slotted Alohaprotocol constrainseffective channelthroughput!
CSE 401N DLL 44
CSMA: Carrier Sense Multiple Access
CSMA: listen before transmit: If channel sensed idle: transmit entire pkt If channel sensed busy, defer transmission
Persistent CSMA: retry immediately with probability p when channel becomes idle (may cause instability)
Non-persistent CSMA: retry after random interval human analogy: don’t interrupt others!
CSE 401N DLL 45
CSMA collisions
collisions can occur:propagation delay means two nodes may not yearhear each other’s transmissioncollision:entire packet transmission time wasted
spatial layout of nodes along Ethernet
note:role of distance and propagation delay in determining collision prob.
CSE 401N DLL 46
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 conversationalist
CSE 401N DLL 47
CSMA/CD Collision Detection
instead of wasting the whole packettransmission time, abort after detection.
CSE 401N DLL 50
Efficiency of CSMA/CD Given collision detection, instead of wasting the
whole packet transmission time (a slot), we only waste the time needed to detect collision.
In the normal case, we try approximately e times before each successful transmission, then for each successful transmission, which takes P/C, we waste a total of 2eT (5T) seconds on collision, where T is one-way propagation delay
P/C
P: packet size, e.g. 1000 bitsC: link capacity, e.g. 10Mbps
CSE 401N DLL 51
Efficiency of CSMA/CD The efficiency (the percentage of useful
time) is
The value of a plays a fundamental role in the efficiency of CSMA/CD protocols.
Question: you want to increase the bandwidth of the network, but still want to maintain the same efficiency, what do you do?
PTC
aTTCPCP a
CP where,51
1/51
15/
/
CSE 401N DLL 53
“Taking Turns” MAC Protocols Channel partitioning MAC protocols:
share channel efficiently and fairly at high load inefficient at low load: delay in channel access,
1/N bandwidth allocated even if only 1 active node!
Random access MAC protocols efficient at low load: single node can fully
utilize channel high load: collision overhead
“Taking turns” protocols look for the best of both worlds!
CSE 401N DLL 54
“Taking Turns” MAC protocolsPolling: master node
“invites” slave nodes to transmit in turn
reserve or request/reply
concerns: polling overhead latency single point of
failure (master)
Token passing: control token passed
from one node to next sequentially
token message concerns:
token overhead latency single point of failure
(token)
CSE 401N DLL 55
Polling Example: 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 reservation slots, message transmissions ordered by
known priority
CSE 401N DLL 56
Token Passing Example: Token Ring A token rotates around a ring to each node in
turn All nodes (computers, routers, etc.) copy all
data and tokens, and repeat them along the link of the stations
When a node wishes to transmit packet(s), it grabs the token as it passes
It holds the token while it transmits When it is done, it releases the token and
sends it on its way
CSE 401N DLL 58
Token Ring: Two Variants
Release After Reception (RAR) Example: IEEE 802.5
Token Rings (4Mbps)
Release After Transmissions (RAT) Example: Fiber
Distributed Data Interface (FDDI) (100Mbps)
station 1 station 1station 2 station N
Packet 1
Packet 2
station 1 station 1station 2 station N
Packet 1
Packet 2token
CSE 401N DLL 59
Efficiency of Token Ring: RAR Release After Reception (RAR)
maximum efficiency RAR achieved when a station continuously transmits:
if the sender always releases its token after a data transmission:
1 12 N
Packet 1
Packet 2
where
a: on timeTransmissiPacket
delayn propagatio E-2-E
1 12 n
Packet 1
Packet 2
where
a: on timeTransmissiPacket
delayn propagatio E-2-E
aRAR
1
1
a
aNNRAR
1
1
1
11
N: number of hosts
1
a
1
a
a/N
Figure assumes- packet time is 1- end-to-end propagation delay a
Assume token very small, stations equally spaced
CSE 401N DLL 60
Efficiency of Token Ring: RAT Release After Transmission (RAT)
maximum efficiency achieved when a station continuously transmits:
assume a station always releases its token after a packet transmission:
1 12 n
Packet 1
Packet 2
1 12 n
Packet 1
Packet 2Therefore, the efficiency is approaching 1
NaRAT /1
1
where
a:
N: number of hosts
on timeTransmissiPacket
delayn propagatio E-2-E
1
a
aa/NTime 0
Time 1+a/N
Packet 3
3
Time 2+2a/N
Assume token very small, stations equally spaced
CSE 401N DLL 61
Comparison of Efficiency
Na
a
a
RAT
RAR
CDCSMA
/1
11
151
1/
where
a:
N: number of hosts
on timeTransmissiPacket
delayn propagatio E-2-E
CSE 401N DLL 62
Summary of MAC Protocols
How do you access a shared media? Channel Partitioning, by time, frequency or
code• Time Division, Code Division, Frequency Division
Random partitioning (dynamic), • ALOHA, S-ALOHA, CSMA, CSMA/CD
“Taking-turns”• polling• token passing
CSE 401N DLL 63
Media Access Control (MAC) Protocols
Ethernet (IEEE 802.3) Logical bus topology Physical star or extended
star Nondeterministic
• First-come, first-served Token Ring (IEEE 802.5)
Logical ring Physical star topology Deterministic
• Token controls traffic Older declining technology
FDDI (IEEE 802.5) Fiber Distributed Data
Interface Logical ring topology Physical dual-ring topology Deterministic
• Token controls traffic Near-end-of-life technology