Download ppt

Document related concepts

Backpressure routing wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

AppleTalk wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

RapidIO wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Deep packet inspection wikipedia , lookup

Internet protocol suite wikipedia , lookup

IEEE 802.11 wikipedia , lookup

Code-division multiple access wikipedia , lookup

Serial digital interface wikipedia , lookup

CAN bus wikipedia , lookup

UniPro protocol stack wikipedia , lookup

IEEE 1355 wikipedia , lookup

Transcript
CSE401N:Computer Networks
Lecture-15
Data Link Layer
EDC
MAC
Preview: The Data Link Layer
Our 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
2
Link Layer: setting the context
CSE 401N DLL
3
Link Layer: setting the context
 two physically connected devices:
 host-router, router-router, host-host
 unit of data: frame
M
Ht M
Hn Ht M
Hl Hn Ht M
application
transport
network
link
physical
data link
protocol
phys. link
adapter card
network
link
physical
Hl Hn Ht M
frame
CSE 401N DLL
4
Link Layer: Introduction
“link”
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
CSE 401N DLL
5
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:

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
e.g., Ethernet on first link,
frame relay on
intermediate links, 802.11
on last link
CSE 401N DLL
6
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 reliability?
CSE 401N DLL
7
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
8
Adaptors Communicating
datagram
sending
node
rcving
node
link layer protocol
frame
adapter
 {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.
frame
adapter
 receiving side
 looks for errors, rdt, flow
control, etc
 extracts datagram, passes
to rcving node
 adapter is semi-
autonomous
 link & physical layers
CSE 401N DLL
9
OSI
TCP/IP
Application
Presentation
Application
Session
Transport
Transport
Network
Internet
Data Link
Physical
Network
Interface
CSE 401N DLL
10
Outline
 Link layer overview
 Error detection and correction
CSE 401N DLL
11
Error Detection
EDC= 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
12
Error Detection: Parity Checking
Single Bit Parity:
Detect single bit errors
Two Dimensional Bit Parity:
Detect and correct single bit errors
1
Errors are generally
bursty, i.e. several
consecutive bits are
flipped: column parity.
0
0
CSE 401N DLL
13
Internet Checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment (note: used at transport layer only)
Sender:
Receiver:
contents as sequence
of 16-bit integers
 checksum: addition
(1’s complement sum)
of segment contents
 sender puts checksum
value into checksum
field
received segment
 check if computed checksum
equals checksum field value:
 NO - error detected
 YES - no error detected
 treat segment
 compute checksum of
CSE 401N DLL
14
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
15
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)
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
CSE 401N DLL
16
CRC: Steps and an Example
1.
2.
3.
4.
5.
Suppose the degree of
G(x) is r
Append r zero to D(x),
i.e. consider D(x)xr
Divide D(x)xr by G(x).
Let R(x) denote the
reminder
Send <D, R> to the
receiver
CSE 401N DLL
17
CRC Example
Example: D=101110, G=1001, r=3
Want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r by G,
remainder is R
R = remainder[
D.2r
G
]
In CRC calculations, addition and
subtraction are equivalent to
bitwise exclusive-or (XOR)
Sender transmit: 101110 011
CSE 401N DLL
18
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
19
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
20
Part-2
CSE 401N DLL
21
Outline
 Media access control (MAC) protocols:
overview
 Random MAC protocols
CSE 401N DLL
22
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
23
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
24
Ideal Mulitple Access Protocol
Broadcast channel of rate R bps
1. 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/M
3. Decentralized:


no special node to coordinate transmissions
no synchronization of clocks
4. Simple
CSE 401N DLL
25
Multiple Access protocols
 claim: humans use multiple access protocols
all the time
 class can "guess" multiple access protocols
multiaccess protocol
 multiaccess protocol
 multiaccess protocol
 multiaccess protocol

1:
2:
3:
4:
CSE 401N DLL
26
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
27
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
28
Channel Partitioning MAC protocols: FDMA
FDMA: 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
frequency bands
bands 2,5,6 idle
1
2
3
4
5
6
CSE 401N DLL
29
FDMA and TDMA
Example:
FDMA
4 users
frequency
time
TDMA
frequency
time
CSE 401N DLL
30
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
31
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
32
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 bitby-bit product) of encoded signal and
chipping sequence

if inner-product > threshold, the data is 1; else -1
CSE 401N DLL
33
CDMA Encode/Decode
Code:
1 1 1 -1 1 -1 -1 -1
CSE 401N DLL
34
CDMA: Deal with Multiple-User Interference
 Two codes Ci and Cj are orthogonal, if
 c j  ci  0, where we use “.”
 to denote inner product,
e.g.
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
 If codes are orthogonal, multiple users can
“coexist” and transmit simultaneously with
minimal interference:
( d j  c j )  ci  d i ci
j
Analogy: Speak in different languages!
CSE 401N DLL
35
CDMA: Two-Sender Interference
Code 1: 1 1 1 -1 1 -1 -1 -1
Code 2: 1 -1 1 1 1 -1 1 1
.
. . .
CSE 401N DLL
36
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
37
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
38
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
39
Slotted Aloha Efficiency
Q: 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
40
Maximum Efficiency vs. N
0.4
1/e = 0.37
maximum efficiency
0.35
0.3
0.25
0.2
At best: channel
use for useful
transmissions 37%
of time!
0.15
0.1
0.05
0
2
7
12
17
N
CSE 401N DLL
41
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
42
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
0.4
0.3
Slotted Aloha
0.2
0.1
protocol constrains
effective channel
throughput!
Pure Aloha
0.5
1.0
1.5
2.0
G = offered load = Np
CSE 401N DLL
43
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
44
CSMA collisions
spatial layout of nodes along Ethernet
collisions can occur:
propagation delay means
two nodes may not year
hear each other’s
transmission
collision:
entire packet transmission
time wasted
note:
role of distance and
propagation delay in
determining collision prob.
CSE 401N DLL
45
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
46
CSMA/CD Collision Detection
instead of wasting the whole packet
transmission time, abort after detection.
CSE 401N DLL
47
MAC Rules & Collision Detection/Backoff
CSE 401N DLL
48
MAC Rules and Collision Detection/Backoff
CSE 401N DLL
49
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.
P/C
P: packet size, e.g. 1000 bits
C: link capacity, e.g. 10Mbps
 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
CSE 401N DLL
50
Efficiency of CSMA/CD
 The efficiency (the percentage of useful
time) is
P/C
P / C 5T
 151T / P  115a , where a  TC
P
C
 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?
CSE 401N DLL
51
Outline
 Review
 CSMA protocols
 “Take-turn” MAC protocols
 Example protocols
CSE 401N DLL
52
“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
53
“Taking Turns” MAC protocols
Polling:
 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
54
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
55
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
56
Token Passing: Illustration
Listen:
Talk:
data
l4
l1
l3
l2
token/data
CSE 401N DLL
57
Token Ring: Two Variants
 Release After Reception
(RAR)
 Example: IEEE 802.5
Token Rings (4Mbps)
station 1 station 2 station N station 1
Packet 1
token
 Release After
Transmissions (RAT)

Example: Fiber
Distributed Data
Interface (FDDI)
(100Mbps)
station 1 station 2 station N station 1
Packet 1
Packet 2
Packet 2
CSE 401N DLL
58
Efficiency of Token Ring: RAR
 Release After Reception (RAR)
 maximum efficiency RAR achieved when a station
continuously transmits:
1
2
N
1
Figure assumes
- packet time is 1
- end-to-end
propagation delay a
a
Packet 1
1
 RAR 
Packet 2

1
1 a
where
a:
E - 2 - E propagatio n delay
Packet Transmissi on time
if the sender always releases its token after a data
transmission:
1
2
n
1
Packet 1
a/N
Packet 2
a
1
 RAR 
1
1  NN1 a
1

1 a
Assume token very small, stations
equally spaced
where
a:
E - 2 - E propagatio n delay
Packet Transmissi on time
N: number
of401N
hosts
CSE
DLL
59
Efficiency of Token Ring: RAT
 Release After Transmission (RAT)
 maximum efficiency achieved when a station continuously
transmits:
1
2
n
Packet 1
1
a
1
Packet 2

Therefore, the efficiency is
approaching 1
assume a station always releases its token after a packet
transmission:
Assume token very small, stations
1
Time 0
2
3 n
1
a/N
a
Packet 1
Time 1+a/N
Time 2+2a/N
Packet 2
Packet 3
equally spaced
 RAT
1

1 a / N
where
a:
E - 2 - E propagatio n delay
Packet Transmissi on time
N: number
of hosts
CSE 401N
DLL
60
Comparison of Efficiency
CSMA / CD 
1
1  5a
1
1 a
1

1 a / N
where
E - 2 - E propagatio n delay
Packet Transmissi on time
 RAR 
a:
 RAT
N: number of hosts
CSE 401N DLL
61
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
62
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

Older declining technology
• Token controls traffic
 FDDI (IEEE 802.5)



Fiber Distributed Data
Interface
Logical ring topology
Physical dual-ring topology
Deterministic

Near-end-of-life technology

• Token controls traffic
CSE 401N DLL
63
THANX
 HOME WORK:

What is inside the Router?
 CSE 402N:QUIZ
 3rd May, 2006
CSE 401N DLL
64