Download lec5-6 - JHU CS

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Multiprotocol Label Switching wikipedia , lookup

Computer network wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

IEEE 802.11 wikipedia , lookup

IEEE 1355 wikipedia , lookup

I²C wikipedia , lookup

Power over Ethernet wikipedia , lookup

Zero-configuration networking wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

AppleTalk wikipedia , lookup

Wake-on-LAN wikipedia , lookup

CAN bus wikipedia , lookup

Point-to-Point Protocol over Ethernet wikipedia , lookup

Transcript
Internet Protocols
Fall 2006
Lectures 5 and 6
MAC Layer
Andreas Terzis
Outline
• MAC Protocols
– MAC Protocol Examples
• Channel Partitioning
– TDMA/FDMA
– Token Ring
• Random Access Protocols
– Aloha and Slotted Aloha
– CSMA(/CD)
– CSMA/CA
• Connecting Layer 2 networks
• Interface to layer 3
CS 349/Fall05
2
MAC Protocols
• Problem: How to share medium among
multiple senders
• Different Solutions
– Channel Partitioning (FDMA, TDMA,CDMA)
– Taking Turns (Token Ring)
– Random Access (Aloha, CSMA, CSMA/CD,
CSMA/CA)
• Parameters
– Physical medium characteristics
– End-point capabilities
CS 349/Fall05
3
Goals of MAC Protocols
• MAC Protocols arbitrate access to a common
shared channel among a population of users
• Goals
–
–
–
–
–
–
–
Fairness
High efficiency
Low delay
Fault tolerance
Low overhead
Low complexity
…
CS 349/Fall05
4
ALOHA
• Packet radio network created by the
University of Hawaii in the 70’s
– Star topology
– Two channels: Broadcast channel, Random Access
channel
• Basic Idea:
– Let a node transmit when it has data to send
– If frame was destroyed then retransmit after a
random period of time
• Feedback about packet reception status is sent over the
broadcast channel
CS 349/Fall05
5
ALOHA Efficiency
• Assumptions
– Infinite number of users
– Frame arrivals are modeled by a Poisson process
with rate λ
– Retransmissions can also be modeled by a Poisson
process with rate G > λ
– Throughput S=GP0
• P0 = probability frame does not suffer a collision
CS 349/Fall05
6
ALOHA: Collision Probability
• Frame tx time:t
• Vulnerable interval:2t
• Prob[k arrivals]:
2G k e −2G
Pr[k ] =
k!
• P0=e-2G
• S=Ge-2G
• Max throughput is
0.184 when G=0.5
t0
t0+t
t0+2t
t0+3t
Vulnerable Interval
CS 349/Fall05
7
Slotted ALOHA
• Time is divided into slots equal to the frame
transmission time
– Central station sends clock tick signal
– Satellite stations are allowed to send only
immediately after hearing clock tick
• Vulnerable time is equal to t
• Throughput S=Ge-G (max =0.37, G=1)
• Expected number of transmissions:
∞
∞
E = ∑ kPk = ∑ ke −G (1 − e −G ) k −1 = 1
k =1
k =1
CS 349/Fall05
e −G
= eG
8
Comparison
CS 349/Fall05
9
CSMA (Carrier Sense Multiple Access)
CSMA: listen before transmit:
• If channel sensed idle: transmit entire frame
• If channel sensed busy, defer transmission
• Human analogy: don’t interrupt others!
CS 349/Fall05
10
CSMA collisions
collisions can still occur:
spatial layout of nodes
propagation delay means
two nodes may not hear
each other’s transmission
collision:
entire packet transmission
time wasted
note:
role of distance & propagation
delay in determining collision
probability
CS 349/Fall05
11
CSMA Variants
• Persistent CSMA: Backlogged nodes will
immediately transmit after channel becomes
idle
– Higher probability of collisions at high loads
• P-Persistent CSMA: After channel is idle
transmit with probability p
– Higher delay at low loads
• Non-persistent CSMA: Transmit with
probability p even when the channel is idle
CS 349/Fall05
12
Performance
CS 349/Fall05
13
CSMA/CD (Collision Detection)
CSMA/CD: carrier sensing, deferral as in CSMA
– Collisions detected within short time
– Colliding transmissions aborted, reducing channel
wastage
• 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
CS 349/Fall05
14
CSMA/CD collision detection
CS 349/Fall05
15
Ethernet uses CSMA/CD
• Adapter doesn’t transmit if
it senses that some other
adapter is transmitting,
that is, carrier sense
• Transmitting adapter
aborts when it senses that
another adapter is
transmitting, that is,
collision detection
CS 349/Fall05
• Before attempting a
retransmission,
adapter waits a
random time, that
is, random access
16
Ethernet CSMA/CD algorithm
1. Adapter gets datagram
from upper layer and
creates frame
2. If adapter senses channel
idle, it starts to transmit
frame. If it senses channel
busy, waits until channel
idle and then transmits
3. If adapter transmits entire
frame without detecting
another transmission, the
adapter is done with frame
!
4. If adapter detects another
transmission while
transmitting, aborts and
sends jam signal
5. After aborting, adapter
enters exponential
backoff: after the m-th
collision, adapter chooses a
K at random from
{0,1,2,…,2m-1}. Adapter
waits K*512 bit times and
returns to Step 2
CS 349/Fall05
17
Ethernet’s CSMA/CD (more)
Jam Signal: make sure all other
transmitters are aware of
collision; 48 bits;
Bit time: .1 microsec for 10
Mbps Ethernet ;
for K=1023, wait time is
about 50 msec
Exponential Backoff:
• Goal: adapt retransmission
attempts to estimated
current load
– heavy load: random wait
will be longer
• 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 collisions, choose K
from {0,1,2,3,4,…,1023}
CS 349/Fall05
18
CSMA/CD efficiency
• Assume: k stations, prob transmit = p
Pr[node acquires channel] = A = kp(1 − p ) k −1
p = 1 then A → 1 as k → ∞
k
e
Pr[contention interval has j slots] = A(1 − A) j −1
w= 1
A
mean contention interval = 2τ
S=
S=
F
F + 2τ
A
1
1 + 2 BLe
A
F
F
≈
=
F + 2eτ F + 2eBL c
Notation:
• L : link length
• B : link speed
• c : speed of
light
• F : frame size
• τ : slot length
in bits
cF
CS 349/Fall05
19
Efficiency as a function of τ
CS 349/Fall05
20
Ethernet “Classic”
• 10Base2, 10Base5
• 10: 10Mbps; 2: under 200 meters max cable length
• thin coaxial cable in a bus topology
•
• Repeaters used to connect up to multiple segments
• Repeater repeats bits it hears on one interface to its other
interfaces: physical layer device only!
• Has become a legacy technology
CS 349/Fall05
21
Newer Ethernet Variants: 10BaseT
and 100BaseT
• 10/100 Mbps rate; latter called “fast ethernet”
• T stands for Twisted Pair
• Nodes connect to a hub: “star topology”; 100 m max
distance between nodes and hub
• Hubs are essentially physical-layer repeaters:
–
–
–
–
bits coming in one link go out all other links
no frame buffering
no CSMA/CD at hub: adapters detect collisions
provides net management functionality
CS 349/Fall05
nodes
hub
22
Gbit Ethernet
• Use standard Ethernet frame format
• Allows for point-to-point links and shared broadcast
channels
• In shared mode, CSMA/CD is used; short distances
between nodes to be efficient
• Uses hubs, called here “Buffered Distributors”
• Full-Duplex at 1 Gbps for point-to-point links
• 10 Gbps now
• Q: Who needs all this bandwidth?
CS 349/Fall05
23
Token Ring Overview
• Examples
– 16Mbps IEEE 802.5 (based on earlier IBM ring)
– 100Mbps Fiber Distributed Data Interface (FDDI)
– Resilient Packet Ring MAN (802.17)
CS 349/Fall05
24
Token Ring (cont)
• Idea
–
–
–
–
Frames flow in one direction: upstream to downstream
special bit pattern (token) rotates around ring
must capture token before transmitting
release token after done transmitting
• immediate release
• delayed release
– remove your frame when it comes back around
– stations get round-robin service
Host
Host
Host
MSAU
Host
From previous
host
Host
To next
host
From previous
host
Relay
(a)
Host
Host
To next
host
Relay
(b)
From previous
MSAU
To next
MSAU
CS 349/Fall05
Host
25
Timed Token Algorithm
• Token Holding Time (THT)
– Upper limit on how long a station can hold
the token
• Token Rotation Time (TRT)
– Upper limit on how long it takes the token
to traverse the ring
– TRT <= ActiveNodes x THT + RingLatency
CS 349/Fall05
26
Additional Features
• Successful delivery notification
– Frame returning to sending host contains ACK
• Different levels of service
– Token contains priority field (3-bit)
– Only frames with at least as high priority can be
transmitted
– Priority field is adjusted through reservation
mechanism
8
8
8
48
48
Start
delimiter
Access
control
Frame
control
Dest
addr
Src
addr
Variable
Body
CS 349/Fall05
32
8
8
Checksum
End
delimiter
Frame
status
27
Token Maintenance
• Lost Token
– No token when initializing ring
– Bit error corrupts token pattern
– Node holding token crashes
• Generating a Token (and agreeing on monitor)
– Execute when join ring or suspect a failure
– Send a claim frame that includes the node’s MAC address
– When receive claim frame forward if local MAC address
smaller
– If your claim frame makes it all the way around the ring:
• Your are the ring monitor
• You insert new token
CS 349/Fall05
28
Maintenance (cont)
• Monitor duties
– Regenerate token if current one is destroyed
– Remove corrupted or orphaned frames
CS 349/Fall05
29
When to send token?
Early Release
am
Fr
e
Late Release
Token
Token
Fra
me
(b)
(a)
Relative advantages and drawbacks?
CS 349/Fall05
30
FDDI
• Physical Properties
– 100 Mbps, commonly uses fiber (although CDDI exists)
– Two independent rings that transmit data in opposite directions
– Second ring is used only when primary ring fails
• Tolerate failure of a stations or single cable break
– 500 hosts max, 2 km between any pair of hosts, 100 km total
network size
(a)
(b)
CS 349/Fall05
31
Wireless LANs
• IEEE 802.11
• Bandwidth: 1 - 54 Mbps
• Physical Media
– spread spectrum radio (2.4GHz)
– diffused infrared (10m)
CS 349/Fall05
32
Spread Spectrum
• Idea
– spread signal over wider frequency band than
required
– originally designed to thwart jamming
• Frequency Hopping
– transmit over random sequence of frequencies
– sender and receiver share…
• pseudorandom number generator
• seed
– 802.11 uses 79 x 1MHz-wide frequency bands
CS 349/Fall05
33
Spread Spectrum (cont)
• Direct Sequence
–
–
–
–
for each bit, send XOR of that bit and n random bits
random sequence known to both sender and receiver
called n-bit chipping code
802.11 defines an 11-bit chipping code
1
0
Data stream: 1010
1
0
Random sequence: 0100101101011001
1
0
XOR of the two: 1011101110101001
CS 349/Fall05
34
Collisions Avoidance
• Similar to Ethernet
• Problem: hidden and exposed nodes
A
B
C
CS 349/Fall05
D
35
MACAW
• Sender transmits RequestToSend (RTS) frame
• Receiver replies with ClearToSend (CTS) frame
• Neighbors…
– see CTS: keep quiet
– see RTS but not CTS: ok to transmit
• Receive sends ACK when has frame
– neighbors silent until see ACK
• Collisions
– no collisions detection
– known when don’t receive CTS
– exponential backoff
CS 349/Fall05
36
Interconnecting LANs
• Bridges (aka Ethernet switches) were introduced to
allow the interconnection of several local area
networks (LANs) without a router.
• By partitioning a large LAN into multiple smaller
networks, there are fewer collisions, and more
parallel communications.
• It is now common for the port of an Ethernet switch
to connect to just one (or a small number of) hosts.
CS 349/Fall05
37
An Ethernet Network
Router
Router
Problem:
Outside
world
™Shared
network limits throughput.
™Lots of collisions reduces efficiency.
CS 349/Fall05
38
Ethernet Switching
Ethernet
Switch
Benefits:
Number of collisions is reduced. If only one computer per port,
no collisions can take place (each cable is now a self-contained
point-to-point Ethernet link).
™ Capacity is increased: the switch can forward multiple frames
to different computers at the same time.
™
CS 349/Fall05
Outside
Router
Router world
39
One Ethernet Switch
CS 349/Fall05
40
A typical LAN (IP network)
Shared
CS 349/Fall05
41
Ethernet Switching
1. Examines the header of each arriving frame.
2. If the Ethernet DA is in its table, it forwards the
frame to the correct output port(s).
3. If the Ethernet DA is not in its table, it broadcasts
the frame to all ports (except the one through
which it arrived).
4. The table is learned by examining the Ethernet SA
of arriving packets.
CS 349/Fall05
42
Ethernet Switching
Learning addresses
B
A
C
D
E
2 3
1
Ethernet
Switch
6
I
J
4
5
K
F
G
Ethernet
Switch
J F
Q Router
Router
Switch learns that ‘F’ is
reachable through port 5
L
M
N
H
O
Outside
world
P
Ethernet
Switch
Ethernet
Switch
CS 349/Fall05
43
Ethernet address
Port
A
1
B
2
C
3
Ethernet Switching
Learning addresses
B
A
C
D
4
E, F, G, H, Q
5
I, J, K, L, M, N, O, P
6
D
E
F
2 3
1
Ethernet
Switch
6
I
J
Ethernet
Switch
4
5
K
G
L
M
N
H
Outside
Q Router
Router world
O
P
Ethernet
Switch
Ethernet
Switch
Q: How do we prevent loops?
CS 349/Fall05
44
LAN Addresses and ARP
32-bit IP address:
• network-layer address
• used to get datagram to destination IP network (recall IP
network definition)
LAN (or MAC or physical or Ethernet) 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 EPROM
CS 349/Fall05
45
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 IP network to which node is attached
CS 349/Fall05
46
ARP: Address Resolution Protocol
Question: how to determine
MAC address of B
knowing B’s IP address?
• 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>
–
CS 349/Fall05
TTL (Time To Live): time
after which address mapping
will be forgotten (typically 20
min)
47
ARP protocol
•
•
•
•
A wants to send datagram to B,
and A knows B’s IP address.
Suppose B’s MAC address is not
in A’s ARP table.
A broadcasts ARP query packet,
containing B's IP address
– all machines on LAN receive
ARP query
B receives ARP packet, replies
to A with its (B's) MAC address
• A caches (saves) IP-to-MAC
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”:
– frame sent to A’s MAC address
(unicast)
CS 349/Fall05
– nodes create their ARP
tables without
intervention from net
administrator
48
ARP Protocol (II)
• Proxy ARP
– Reply on behalf of another node
• Gratuitous ARP
– Node sends ARP asking for its own IP
address
• Find out if address has been claimed
• Change the mapping between MAC<->IP addr
• Do you see any problem with this?
CS 349/Fall05
49