15-441 Computer Networking p g Lecture 6 Data link Layer

advertisement
Datalink Functions
15-441 Computer
p
Networking
g
Lecture 6
Data link Layer – Access Control
z
Framing: encapsulating a network layer
datagram into a bit stream.
» Add header, mark and detect frame boundaries, …
z
Error control: error detection and correction
to deal with bit errors.
» May also include other reliability support, e.g.
retransmission
t
i i
z
z
Flow control: avoid sender overrunning
receiver.
Media access: controlling which frame should
be sent over the link next.
» Easy for point-to-point links
» Harder for multi-access links: who gets to send?
Based on slides by Peter Steenkiste
Copyright ©, Carnegie Mellon 2007-10
1
2
Lecture 6
So far …
15 441 © 2008
So far …
Can connect ttwo
o nodes
Can connect ttwo
o nodes
• … But what if we want more nodes?
• … But what if we want more nodes?
Wires for everybody!
Wires for everybody!
P-2-p
P
2p
shared
3
Lecture 6
15 441 © 2008
2
3
Lecture 6
15 441 © 2008
switches
4
4
Media Access Control
Datalink Architectures
z
z
How do we transfer packets between two
hosts connected to the same network?
Switches connected by point
point-to-point
to point links -store-and-forward.
» Used in WAN, LAN, and for home connections
» Conceptually similar to “routing”
– But at the datalink layer instead of the network layer
z
z
Point-Point with switches
z
Multiple access networks -- contention based.
» Multiple
p hosts are sharing
g the same transmission
medium
» Used in LANs and wireless
» Need to control access to the medium
Media access
control.
5
6
Lecture 6
Datalink Classification
z
Datalink
Virtual
Circuits
Packet
Switching
ATM,
ATM
framerelay
Bridged
B
id d
LANs
z
Multiple Access
Scheduled
Access
6
Switching
z
Switch-based
15 441 © 2008
Random
Access
Token
T
k ring,
i
Eh
Ethernet,
FDDI, 802.11 802.11, Aloha
z
Forward units of data based on address in header.
Many data-link technologies use switching.
» Virtual circuits: Frame Relay, ATM, X.25, ..
» Packets: Ethernet, MPLS, …
“Switching” also happens at the network layer.
» Layer 3: Internet protocol
» In
I this
thi case, address
dd
is
i an IP address
dd
» IP over SONET, IP over ATM, ...
» Otherwise,, operation
p
is very
y similar
Switching is different from SONET mux/demux.
» SONET channels statically configured - no addresses
7
Lecture 6
15 441 © 2008
7
8
Lecture 6
15 441 © 2008
8
A Switch
Switch-based
based Network
z
z
Switch Architecture
Switches are connected by point-point links.
Packets are forwarded hop
hop-by-hop
by hop by the
switches towards the destination.
z
» Forwarding is based on the address
z
z
z
» Same idea for bridges, switches,
routers: address look up differs
How does a switch
Ho
s itch work?
ork?
How do nodes exchange packets over a link?
How is the destination addressed?
Switch
z
Point-Point
link
PCs at
Work
Packets come in one
i t f
interface,
forwarded
f
d d to
t output
t t
interface based on address.
Control processor manages
the switch and executes
higher level protocols.
» E.g. routing, management, ...
z
PC at
Home
z
The switch
Th
it h fabric
f b i directs
di t the
th
traffic to the right output port.
The input and output ports
deal with
ith transmission and
reception of packets.
Control
Processor
Input
p
Port
Output
Port
Output
Port
Input
P t
Port
Output
p
Port
Input
Port
Switch
Fabric
Output
Port
Input
P t
Port
9
Lecture 6
15 441 © 2008
9
10
Lecture 6
15 441 © 2008
Connections or Not?
z
Connectionless
Two basic approaches to packet forwarding
»Connectionless
»(virtual) Circuit switched
z
10
When would y
you use?
z
Host can send anytime anywhere
z
No idea if resources are available to get to dest
z
Forwarding is independent for each packet
z
No setup time
z
Fault tolerant
Destination
Port
A
3
B
0
C
D
E
11
Lecture 6
15 441 © 2008
11
Lecture 6
F
12
15 441 © 2008
12
Virtual Circuit Switching
z
Setup assign VCIs
Setup,
Two stage process
»Setup connection (create VCIs)
p
»Send packets
z
RTT introduced before any
y data is sent
z
Per packet overhead can be smaller (VCI << adr)
z
Switch failures are hard to deal with
z
Reserves resources for connection
13
Lecture 6
15 441 © 2008
14
13
Packet Forwarding:
Address Lookup
Datalink Classification
Switch
Datalink
Switch-based
A
Address
Next Hop
B31123812508
38913C3C2137
A21023C90590
3
3
0
Info
f
13
-
z
» Absolute address (e.g. Ethernet)
» (IP address for routers)
» (VC identifier, e.g. ATM))
z
z
128.2.15.3 1
(2,34)
Address from header.
z
Next hop: output port for packet.
Info: priority,
priority VC id,
id ..
Table is filled in by protocol.
Virtual
Circuits
Packet
Switching
ATM,
ATM
framerelay
Bridged
B
id d
LANs
Multiple Access
Scheduled
Access
Random
Access
Token
T
k ring,
i
Eh
Ethernet,
FDDI, 802.11 802.11, Aloha
15
16
Lecture 6
15 441 © 2008
16
Problem: Sharing a Wire
Listen and Talk
Learned ho
how to connect hosts
z
yak yak…
… But what if we want more hosts?
z
»Works well in practice
Wires for everybody!
z
Natural scheme – listen before you talk…
Switches
Expensive! How can we share a wire?
18
17
Listen and Talk
Listen and Talk
yyada
yakk yak…
k
yada…
yada yada…
z
18
z
Natural scheme – listen before you talk…
Natural scheme – listen before y
you talk…
»Works well in practice
»Works well in practice
z
But sometimes this breaks down
»Why? How do we fix/prevent this?
19
19
20
20
Problem: Who is this packet for?
z
N d to
Need
t putt an address
dd
on the
th packet
k t
z
What should it look like?
z
How do you determine your own address?
z
How do you know what address you want to send it
to?
21
Outline
z
Ethernet MAC
z
Collisions
z
Ethernet Frames
22
22
Aloha – Basic Technique
When node has packet to send
z
» Transmit at full channel data rate R
» No a p
priori coordination among
g nodes
First random MAC developed
» For radio-based communication in Hawaii (1970)
Two or more transmitting nodes Æ “collision”
z Random access MAC p
protocol specifies:
p
z
» How to detect collisions
» How to recover from collisions (e.g., via delayed
retransmissions)
z
Aloha
21
Random Access Protocols
z
z
z
B i idea:
Basic
id
» When you are ready, transmit
» Receivers
R
i
send
d ACK ffor d
data
t
» Detect collisions by timing out for ACK
Examples of random access MAC protocols:
» Recover
R
ffrom collision
lli i by
b trying
t i after
ft random
d
delay
– Too short Æ large
g number of collisions
» Slotted ALOHA and ALOHA
» CSMA and CSMA/CD
– Too long Æ underutilization
23
23
24
24
Slotted Aloha
z
Pure (Unslotted) ALOHA
Time is divided into equal size slots
» Equal to packet transmission time
z
Node (w/ packet) transmits at beginning of next slot
z
If collision: retransmit pkt in future slots with
probability p, until successful
z
Unslotted Aloha: simpler, no synchronization
z
Pkt needs transmission:
» Send without awaiting for beginning of slot
z
C lli i probability
Collision
b bilit increases:
i
» Pkt sent at t0 collide with other pkts sent in [t0-1, t0+1]
Success (S), Collision (C), Empty (E) slots
25
26
25
Outline
26
Ethernet
First practical local area network, built at
X
Xerox
PARC in
i 70’s
70’
z “Dominant” LAN technology:
z
z
Aloha
z
Ethernet MAC
z
Collisions
z
Ethernet Frames
» Cheap
Ch
» Kept up with speed race: 10, 100, 1000 Mbps
Metcalfe’s Ethernet
sketch
k t h
27
27
28
28
Ethernet MAC – Collision
D t ti
Detection
Ethernet MAC – Carrier Sense
z
Basic idea:
z
» Listen to wire before
transmission
» Avoid collision with
active transmission
z
Hidden
St Louis
St.Louis
z
Basic idea:
» Listen while transmitting
» If you notice interference Æ assume collision
Chicago
C
cago
CMU
» In wireless, relevant
contention at the
receiver, not sender
» That was very slow and inefficient
Exposed
NY
Why
y didn’t ALOHA
have this?
But: ALOHA has collision detection also?
z
CMU
Chi
Chicago
Why didn’t ALOHA have this?
» Very difficult for radios to listen and transmit
» Signal strength is reduced by distance for radio
NY
– Much easier to hear “local, powerful” radio station
than one in NY
– You may not notice any “interference”
– Hidden terminal
– Exposed terminal
29
30
29
Ethernet CSMA/CD:
Making it word
Ethernet MAC (CSMA/CD)
z
Carrier Sense Multiple
p Access/Collision
Detection
Jam Signal:
g
make sure all other transmitters
are aware of collision; 48 bits;
Exponential Backoff:
z If deterministic delay after collision,
collision will occur again in lockstep
z Why not random delay with fixed mean?
Packet?
No
Sense
Carrier
Send
Detect
Collision
Yes
Discard
Packet
attempts < 16
» Few senders Æ needless waiting
» Too
T many senders
d
Æ too
t many collisions
lli i
Jam channel
b=CalcBackoff();
wait(b);
attempts++;
z
attempts == 16
31
30
31
Goal: adapt retransmission attempts to
estimated current load
» heavy load: random wait will be longer
32
32
Ethernet Backoff Calculation
z
Outline
Exponentially increasing random delay
»Infer senders from # of collisions
»More senders Æ increase wait time
z
z
z
First collision: choose K from {0,1}; delay is K
x 512 bit transmission times
After second collision: choose K from
{0,1,2,3}…
After ten or more collisions, choose K from
{0,1,2,3,4,…,1023}
33
Aloha
z
Ethernet MAC
z
Collisions
z
Ethernet Frames
34
33
Collisions
34
Minimum Packet Size
B
C
z
What if two people
p p
sent really small
packets
» How do you find
collision?
Tim
me
A
z
35
35
36
36
Ethernet Collision Detect
z
End to End Delay
c in cable = 60% * c in vacuum = 1.8 x 10^8
m/s
z
Modern 10Mb Ethernet
Min packet length > 2x max prop delay
»If A, B are at opposite sides of link,
and B starts one link prop delay after
A
z
z
» 2.5km, 10Mbps
» ~= 12.5us delay
Jam network for 32-48 bits after collision,
then stop sending
» +Introduced repeaters (max 5 segments)
» Worst case – 51.2us round trip time!
»Ensures
E
that
th t everyone notices
ti
collision
37
z
» After this amount, sender is guaranteed sole
access to link
» 51.2us = slot time for backoff
37
Packet Size
z
Slot time = 51.2us = 512bits in flight
38
38
10BaseT and 100BaseT
What about scaling? 3Mbit,
3Mbit 100Mbit,
100Mbit
1Gbit...
» Original 3Mbit Ethernet did not have minimum
packet size
z
10/100 Mbps rate; latter called “fast ethernet”
z
T stands for Twisted Pair (wiring)
z
Minimum packet size requirement
» Make network smaller Æ solution for 100BaseT
– Max length = 1Km and No repeaters
» For higher speeds must make network smaller,
minimum packet size larger or both
z
What about a maximum packet size?
» Needed to prevent node from hogging the
network
» 1500 bytes in Ethernet
39
39
40
40
Gbit Ethernet
z
Outline
Minimum packet size requirement
» Make network smaller?
z
Aloha
z
Ethernet MAC
z
Collisions
z
Ethernet Frames
– 512bits @ 1Gbps = 512ns
– 512ns * 1.8 * 10^8 = 92meters = too small !!
» Make min pkt size larger!
– Gigabit Ethernet uses collision extension for small pkts
and backward compatibility
z
M i
Maximum
packet
k t size
i requirement
i
t
» 1500 bytes is not really “hogging” the network
D fi
“j
“jumbo
b frames”
f
” (9000 b
bytes)
t ) for
f higher
hi h
» Defines
efficiency
41
42
41
Ethernet Frame Structure
z
42
Ethernet Frame Structure (cont.)
(cont )
Sending adapter encapsulates IP datagram (or other
network layer protocol packet) in Ethernet frame
z
Preamble: 8 bytes
»101010…1011
»Used to synchronize receiver,
sender clock rates
z
CRC: 4 bytes
»Checked at receiver, if error is
detected, the frame is simply
dropped
43
43
44
44
Ethernet Frame Structure (cont.)
(cont )
z
Addressing Alternatives
z
Each protocol layer needs to provide
some hooks to upper layer protocols
Broadcast Æ all nodes receive all packets
p
» Addressing determines which packets are kept and
which are packets are thrown away
» Packets
P k t can b
be sentt tto:
» Demultiplexing: identify which upper layer
protocol packet belongs to
– Unicast – one destination
– Multicast – group of nodes (e.g. “everyone playing Quake”)
– Broadcast – everybody on wire
» E.g.,
g , port
p
numbers allow TCP/UDP to identify
y
target application
z
» Ethernet uses Type field
z
Dynamic addresses (e.g. Appletalk)
» Pick an address at random
» Broadcast “is anyone using address XX?”
» If yes
yes, repeat
Type: 2 bytes
» Indicates the higher layer protocol, mostly IP
but others may be supported such as Novell
IPX and AppleTalk)
45
z
45
Static address (e.g. Ethernet)
z
Addresses: 6 bytes
» Ethernet – node detached
z
– Address space is allocated to manufacturers
24 bits identify manufacturer
z
E
E.g.,
0:0:15:*
0 0 15 * Æ 3com
3
adapter
d t
» Usually used at low load
z
Volume Æ lower cost Æ higher volume ….
z
Adaptable
» Special addresses
» To higher bandwidths (vs. FDDI)
» To switching (vs. ATM)
– Broadcast – FF:FF:FF:FF:FF:FF is “everybody”
– Range
R
off addresses
dd
allocated
ll
t d to
t multicast
lti
t
Adapter maintains list of multicast groups node is
interested in
47
Good performance in common case
» Deals well with bursty traffic
– Frame is received by all adapters on a LAN and
dropped if address does not match
z
Failure modes
» Token rings – network unusable
» Each adapter is given a globally unique
address at manufacturing
g time
z
46
Why Did Ethernet Win?
Ethernet Frame Structure (cont.)
(cont )
z
46
47
z
E
Easy
iincremental
t l deployment
d l
t
z
Cheap cabling, etc
48
48
Ethernet Problems:
Unstable at High Load
And .. It is Easy to Manage
z
z
You p
plug
g in the host and it basically
y works
Peak throughput worst with
» More hosts – more collisions to identify single
sender
» Smaller packet sizes – more frequent arbitration
» Longer links – collisions take longer to observe,
more wasted bandwidth
1/e = 37%
z But works well
in practice
» No configuration at the datalink layer
» Today: may need to deal with security
Protocol is fully distributed
z Broadcast-based.
z
» In part explains the easy management
» Some of the LAN protocols (e.g. ARP) rely on
broadcast
0.4
» Can improve
efficiency by
avoiding
above
conditions
– Networking would be harder without ARP
» Not having natural broadcast capabilities adds
l it to
t a LAN
complexity
– Example: ATM
49
z
z
z
» Limits the collision domain for the packet
host
host
host
z
host
host
2.0
50
CSMA/CD Æ carrier sense multiple access
with collision detection
Ethernet
» What is the purpose of different header fields?
» What do Ethernet addresses look like?
z
host
1.5
– How does this scale with speed?
host
Switch
host
1.0
» Why
y do we need exponential
p
backoff?
» Why does collision happen?
» Why do we need a minimum packet size?
Can bridge and route appropriately.
Broadcast p
packets stay
y within the virtual LAN.
host
Pure Aloha
Summary
Single physical LAN infrastructure that carries multiple
virtual LANs simultaneously
simultaneously.
“virtual”
Each virtual LAN has a LAN identifier in the packet.
host
0.1
G = offered load = N X p
» Switch keeps track of what nodes are on each segment and
what their virtual LAN id is
z
Slotted Aloha
0.2
0.5
49
Virtual LANs
z
03
0.3
host
host
51
51
What are some alternatives to Ethernet
design?
52
52
Outline
z
Random Access Analysis
EXTRA SLIDES
54
53
54
Pure Aloha (cont.)
(cont )
Slotted Aloha Efficiency
Q: What is max fraction slots successful?
A: Suppose N stations have packets to send
»Each transmits in slot with probability p
»Prob. successful transmission S is:
P(success by given node) = P(node transmits) X P(no other node
transmits in [p0-1,p
1 p0] X P(no other node transmits in [p0-1,p
1 p0]
= p X (1-p)(N-1) X (1-p)(N-1)
P(success
(
by
y any
y of N nodes)) = N p X ((1-p)
p)(N-1) X ((1-p)
p)(N-1) = 1/(2e) = .18
… choosing optimum p as N Æ infty Æ p = 1/2N …
(1-p)(N-1)
by single node: S = p
by any of N nodes
S = Prob (only one transmits)
(N 1)
= N p (1
(1-p))(N-1)
… choosing optimum p as N -> infty ...
0.4
At best: channel
use for useful
transmissions 37%
of time!
protocol constrains
effective channel
throughput!
0.3
Slotted Aloha
0.2
0.1
Pure Aloha
… p = 1/N
= 1/e = .37 as N -> infty
0.5
1.0
1.5
2.0
G = offered load = N X p
55
55
56
56
Simple Analysis of Efficiency
Ethernet Technologies: 10Base2
z
z
z
Key assumptions
10: 10Mbps; 2: under 185 (~200) meters cable length
Thin coaxial cable in a bus topology
»All packets are same, small size
– Packet size = size of contention slot
»All nodes always have pkt to send
»p is chosen carefully to be related to
N
– p is actually chosen by exponential
backoff
»Takes full slot to detect collision (I.e.
no “fast collision detection”) 57
z
57
z
Repeaters used to connect up to multiple segments
Repeater repeats bits it hears on one interface
to its58
58
other interfaces: physical layer device only!
Gbit Ethernet
z
Use standard Ethernet frame format
z
Allows for p
point-to-point
p
links and
shared broadcast channels
z
In shared mode, CSMA/CD is used;
short distances between nodes to be
efficient
z
Uses hubs, called here “Buffered
Distributors”
z
Full-Duplex at 1 Gbps for point-to-point
59
links
Datalink Layer Architectures
z
z
Packet forwarding.
Error and flow control.
z
z
59
Media access
control.
l
Scalability.
60
Datalink Classification
Multiple Access Protocols
z
Datalink
Switch-based
Virtual
Circuits
Packet
Switching
ATM
ATM,
framerelay
Bridged
B
id d
LANs
» If they do, we have a collision, and receivers will not be
able to interpret the signal
Multiple Access
Scheduled
Access
z
T k ring,
Token
i
Eh
Ethernet,
FDDI, 802.11 802.11, Aloha
61
62
Fiber Distributed Data Interface
(FDDI)
z
Other “Taking Turn”
Protocols
One token holder may send,
with
ith a time
ti
limit
li it
z
» Provides known upper bound on
delay.
z
z
z
z
Several classes of multiple access protocols.
» Partitioning the channel,
channel e.g.
e g frequency-division or time
division multiplexing
– With fixed partitioning of bandwidth –
– Not flexible;; inefficient for bursty
y traffic
» Taking turns, e.g. token-based, reservation-based
protocols, polling based
» Contention based protocols, e.g. Aloha, Ethernet
– Next lecture
Random
Access
61
Prevent two or more nodes from transmitting
at the same time over a broadcast channel.
Central entity polls stations, inviting them to
transmit
» Simple design – no conflicts
» Not very efficient – overhead of polling operation
» Example: the “Point Control Function” mode for 802.11
Optical version of 802
802.5
5 token
ring, but multiple packets may
travel in train: token released
at end of frame
100 Mbps, 100km
Optional dual ring for fault
tolerance
Concerns:
z
Stations reserve a slot for transmission
transmission.
» For example, break up the transmission time in
contention-based and reservation based slots
– Contention based slots can be used for short
messages or to reserve time slots
– Communication in reservation based slots only
allowed after a reservation is made
» Issues: fairness, efficiency
» Token overhead
» Latency
» Single point of failure
63
64
MAC Protocols - Discussion
z
z
z
Channel partitioning MAC protocols:
» Share channel efficiently at high load
» Inefficient at low load: delay in channel
access, 1/N bandwidth allocated even if
only 1 active node!
“Taking
Taking turns
turns” protocols
» More flexible bandwidth allocation, but
» Protocol can introduce unnecessary
overhead and access delay at low load
Random access MAC protocols (next lecture)
» Efficient at low load: single node can fully
utilize channel
» High load: collision overhead
Copyright (C), CMU
65
65
Download