Internet Protocols Fall 2006 - Johns Hopkins University
Transcript of Internet Protocols Fall 2006 - Johns Hopkins University
Internet ProtocolsFall 2006
Lectures 5 and 6MAC Layer
Andreas Terzis
Outline
CS 349/Fall05 2
• 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
MAC Protocols
CS 349/Fall05 3
• 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
Goals of MAC Protocols
CS 349/Fall05 4
• 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– …
ALOHA
CS 349/Fall05 5
• 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
ALOHA Efficiency
CS 349/Fall05 6
• 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
ALOHA: Collision Probability
CS 349/Fall05 7
t0 t0+t t0+2t t0+3t
Vulnerable Interval
• Frame tx time:t• Vulnerable interval:2t• Prob[k arrivals]:
• P0=e-2G
• S=Ge-2G
• Max throughput is 0.184 when G=0.5
!2]Pr[
2
keGk
Gk −
=
Slotted ALOHA
CS 349/Fall05 8
• 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:
GG
k
kGG
kk eeekekPE ==−== −
∞
=
−−−∞
=∑∑ 1)1(
1
1
1
Comparison
CS 349/Fall05 9
CSMA (Carrier Sense Multiple Access)
CS 349/Fall05 10
CSMA: listen before transmit:• If channel sensed idle: transmit entire frame• If channel sensed busy, defer transmission
• Human analogy: don’t interrupt others!
CSMA collisions
CS 349/Fall05 11
collisions can still occur:propagation delay means two nodes may not heareach other’s transmission
collision:entire packet transmission time wasted
spatial layout of nodes
note:role of distance & propagation delay in determining collision probability
CSMA Variants
CS 349/Fall05 12
• 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
Performance
CS 349/Fall05 13
CSMA/CD (Collision Detection)
CS 349/Fall05 14
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
CSMA/CD collision detection
CS 349/Fall05 15
Ethernet uses CSMA/CD
CS 349/Fall05 16
• 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
• Before attempting a retransmission, adapter waits a random time, that is, random access
Ethernet CSMA/CD algorithm
CS 349/Fall05 17
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-thcollision, adapter chooses a K at random from {0,1,2,…,2m-1}. Adapter waits K*512 bit times and returns to Step 2
Ethernet’s CSMA/CD (more)
CS 349/Fall05 18
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}
CSMA/CD efficiency
CS 349/Fall05 19
Notation:• L : link length• B : link speed• c : speed of
light• F : frame size• τ : slot length
in bits
• Assume: k stations, prob transmit = p
cFBLeS
ceBLFF
eFF
AFFS
A
Aw
AA
keAkp
pkpA
j
k
211
222
2 interval contentionmean
1)1(=slots] j has interval contentionPr[
as 1then 1)1(=channel] acquires nodePr[
1
1
+=
+=
+≈
+=
=
=
−
∞→→=
−=
−
−
ττ
τ
Efficiency as a function of τ
CS 349/Fall05 20
Ethernet “Classic”
CS 349/Fall05 21
• 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
Newer Ethernet Variants: 10BaseT and 100BaseT
CS 349/Fall05 22
• 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
hub
nodes
Gbit Ethernet
CS 349/Fall05 23
• 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?
Token Ring Overview
CS 349/Fall05 24
• Examples– 16Mbps IEEE 802.5 (based on earlier IBM ring)– 100Mbps Fiber Distributed Data Interface (FDDI)– Resilient Packet Ring MAN (802.17)
Token Ring (cont)
CS 349/Fall05 25
• 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
Host
From previousMSAU
To nextMSAU
MSAU
Host
From previoushost
To nexthost
Relay(a)
Host
Host Host
From previoushost
To nexthost
Relay(b)
Timed Token Algorithm
CS 349/Fall05 26
• 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
Additional Features
CS 349/Fall05 27
• 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
Body ChecksumSrcaddr
Variable48Destaddr
48 32Enddelimiter
8Framestatus
8Framecontrol
8Accesscontrol
8Startdelimiter
8
Token Maintenance
CS 349/Fall05 28
• 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
Maintenance (cont)
CS 349/Fall05 29
• Monitor duties– Regenerate token if current one is destroyed– Remove corrupted or orphaned frames
When to send token?
CS 349/Fall05 30
Token
Frame
Token Frame
(a) (b)
Early Release Late Release
Relative advantages and drawbacks?
FDDI
CS 349/Fall05 31
• 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)
Wireless LANs
CS 349/Fall05 32
• IEEE 802.11• Bandwidth: 1 - 54 Mbps• Physical Media
– spread spectrum radio (2.4GHz)– diffused infrared (10m)
Spread Spectrum
CS 349/Fall05 33
• 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
Spread Spectrum (cont)
CS 349/Fall05 34
• 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
Random sequence: 0100101101011001
Data stream: 1010
XOR of the two: 1011101110101001
0
0
0
1
1
1
Collisions Avoidance
CS 349/Fall05 35
• Similar to Ethernet• Problem: hidden and exposed nodes
A B C D
CS 349/Fall05 36
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
Interconnecting LANs
CS 349/Fall05 37
• 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 38
An Ethernet Network
RouterRouter OutsideworldProblem:
Shared network limits throughput.Lots of collisions reduces efficiency.
CS 349/Fall05 39
Ethernet Switching
RouterRouter Outsideworld
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.
EthernetSwitch
One Ethernet Switch
CS 349/Fall05 40
A typical LAN (IP network)
CS 349/Fall05 41
Shared
Ethernet Switching
CS 349/Fall05 42
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.
Ethernet SwitchingLearning addresses
CS 349/Fall05 43
RouterRouter
OutsideworldEthernet
SwitchEthernetSwitch
EthernetSwitch
EthernetSwitch
A B C D E F G H
I J K L M N O P
Q1
2 345
6
J F
Switch learns that ‘F’ is reachable through port 5
CS 349/Fall05 44
Ethernet SwitchingLearning addresses
RouterRouter Outsideworld
EthernetSwitch
EthernetSwitch
EthernetSwitch
EthernetSwitch
A B C D E F G H
I J K L M N O P
Q1
2 345
6
Ethernet address Port
A 1
B 2
C 3
D 4
E, F, G, H, Q 5
I, J, K, L, M, N, O, P 6
Q: How do we prevent loops?
LAN Addresses and ARP
CS 349/Fall05 45
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
LAN Address (more)
CS 349/Fall05 46
• 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
ARP: Address Resolution Protocol
CS 349/Fall05 47
• 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)
Question: how to determineMAC address of Bknowing B’s IP address?
ARP protocol
CS 349/Fall05 48
• 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– frame sent to A’s MAC address
(unicast)
• 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”:– nodes create their ARP
tables without intervention from net administrator
ARP Protocol (II)
CS 349/Fall05 49
• 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?