CSE 123A Computer Networks Winter 2005 Lecture 5: Data-Link II: Media Access Some portions courtesy Srini Seshan or David Wetherall
Last Time Framing: How to translate a bitstream into separate packets 101010111 101010111001001111000010110 001001111 000010110 January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 2
Today: media access How to share a channel among different hosts? Approaches Channel partitioning» FDMA, TDMA, CDMA Random access» Contention-based Aloha CSMA, CSMA/CD, CSMA/CA Ethernet, 802.11» Contention-free Token-ring, FDDI January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 3
Channel partitioning Problem Have channel that can support 10Mbps Have 5 hosts, who want to send 2Mbps of data How to meet this need and use channel efficiently Solution Create 5 channels each 1/5 th the size Next question: how to split the channel January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 4
Frequency Division Multiple Access (FDMA) Divide channel with some bandwidth f Hz into n subchannels each with bandwidth f/n Hz Assign different hosts to different channels Easy to implement, but unused subchannels go idle Used by traditional analog cell phone service Amplitude Amplitude Frequency Frequency January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 5
Time Division Multiple Access (TDMA) Divide channel into time rounds of length t with n time slots in each round Assign different hosts to different time slots within a round Unused time slots are idle Used (in conjunction with FDM) in GSM cell phones Example, rounds of 1 second, with 4 timeslots (250ms) per round Host # 1 2 3 1 2 3 4 2 4 1 sec 1 sec 1 sec January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 6
Code Division Multiple Access Very different, spread spectrum coding All hosts use the whole channel all the time (?!?) Assign different hosts a unique spreading code which encodes transmitted data to cover the entire channel Receivers apply same code to extract the source signal they want out of the channel Used by cell phone networks using Qualcomm chipsets (e.g. Verizon, Sprint) Magic January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 7
Channel partitioning summary FDMA power frequency power TDMA time time time frequency CDMA power frequency Courtesy Takashi Inoue January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 8
Problem Not terribly well suited for random access usage. Why? New problem: how to do we share a single channel among different hosts who want to send different amounts of data at different times? January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 9
Aloha Designed in 1970 to explore wireless data connectivity between Hawaiian Islands Goal: distributed access control (no central arbitrator) over a shared broadcast channel Aloha protocol in a nutshell: When you have data send it If data doesn t get through (receiver sends acknowledgement) then retransmit after a random delay January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 10
Problem Any packet sent at t 0 collide with other pkts sent in [t 0-1, t 0 +1] January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 11
Slotted Aloha Time is divided into equal size slots (= pkt trans. time) Host wanting to transmit starts at start of next slot But requires time synchronization between hosts Success (S), Collision (C), Empty (E) slots January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 12
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: single node: S = p (1-p) (N-1) any of N nodes: S = Prob (only one transmits) S = N p (1-p) (N-1) (optimal p as N->infinity = 1/N) = 1/e =.37 0.4 0.3 0.2 0.1 At best: channel used for useful transmissions 37% of time! Slotted Aloha Pure Aloha 0.5 1.0 1.5 2.0 offered load = N X p January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 13
Carrier Sense Multiple Access (CSMA) Aloha transmits even if another host is transmitting (guaranteed collision) Can do better by listening first to make sure channel is idle Effective if # of pkts on the channel is small (bw*delay/packet size) Small (<<1) for LANs, large (>>1) for satellites January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 14
How long to wait if channel is busy? 1-persistent CSMA Send as soon as channel is idle Problem: blocked senders all try to send at once non-persistent CSMA Send after some random delay Problem: may incur larger delay when channel is idle p-persistent CSMA If idle, send packet with probability p; repeat Make sure p * number of hosts < 1 January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 15
CSMA with Collision Detection (CSMA/CD) Even with CSMA there can still be collisions. Why? For wired media we can detect all collisions and abort (CSMA/CD): A Time for B to detect A s transmission X collision (wire) Requires a minimum frame size ( acquiring the medium ) B must continue sending ( jam ) until A detects collision Tough for radio (hard to listen & xmit at same time) B January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 16
Ethernet First local area network (building in early 70s by Metcalfe and Boggs) Originally 1Mbps, now supports 10Mbps, 100Mbps, 1Gbps and 10Gbps flavots Currently the dominant LAN technology January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 17
Classic Ethernet IEEE 802.3 standard wired LAN (modified 1-persistent CSMA/CD) Classic Ethernet: 10 Mbps over coaxial cable All nodes share same wire Max length 2.5km, max between stations 500m Framing nodes (wire) Preamble, 32bit CRC, variable length data, min frame 64 bytes (why?), max 1500 bytes (why?) Unique 48-bit address per host (bcast & multicast addrs too) Preamble (8) Source (6) Dest (6) Len (2) Payload (var) Pad (var) CRC (4) January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 18
Ethernet improvements Jamming Send special 48 bit sequence to ensure collision detection by all hosts Exponential backoff Problems with random delay with fixed mean» Few senders = unnecessary delay» Many senders = unnecessary collisions Ethernet approach: balance delay w/load» First collision: wait 0 or 1 min frame times at random, retry» Second time: wait 0, 1, 2, or 3 times» Nth time (N<=10): wait 0, 1,, 2 N -1 times» Max wait 1023 frames, give up after 16 attempts January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 19
Capture Effect Randomized access scheme is not fair Stations A and B always have data to send They will collide at some time Suppose A wins and sends, while B backs off Next time they collide and B s chances of winning are halved! January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 20
Ethernet Performance Much better than Aloha or CSMA in practice Source of protocol inefficiency: collisions More efficient to send larger frames» Acquire the medium and send lots of data Less efficient if» More hosts more collisions needed to identify single sender» Smaller packet sizes more frequent arbitration» Longer links collisions take longer to observe, more wasted bandwidth January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 21
Contention-free Protocols Problem with channel partitioning Inefficient at low load (idle subchannels) Problem with contention-based protocols Inefficient at high load (collisions) Contention-free protocols Try to do both by explicitly taking turns Can potentially also offer guaranteed bandwidth, latency, etc. January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 22
Two contention-free approaches Polling Master node invites slave nodes to transmit in turn Request to Send (RTS), Clear to Send (CTS) messages Problems: Polling overhead Latency Single point of failure (master) Token Passing Control token passed from one node to next sequentially. Point-to-point links can be fast Problems: Token overhead Latency Single point of failure (token) January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 23
Token Ring (802.5) D C A B nodes Direction of transmission Token rotates permission to send around node Sender injects packet into ring and removes later Maximum token holding time (THT) bounds access time Early or delayed token release Round robin service, acknowledgments and priorities Monitor nodes ensure health of ring (alerts on failures) January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 24
FDDI (Fiber Distributed Data Interface) Roughly a large, fast token ring 100 Mbps and 200km vs 4/16 Mbps and local Dual counter-rotating rings for redundancy Complex token holding policies for voice etc. traffic Token ring advantages No contention, bounded access delay Support fair, reserved, priority access Disadvantages Complexity, reliability, scalability Break! January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 25
Why Did Ethernet Win? Failure modes Token rings network unusable Ethernet node detached Good performance in common case Volume lower cost higher volume. Adaptable To higher bandwidths (vs. FDDI) To switching (vs. ATM) Completely distributed, easy to maintain/administer Easy incremental deployment Cheap cabling, etc January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 26
Wireless Media Access Wireless is more complicated than wired Cannot detect collisions Transmitter swamps co-located receiver Collision avoidance Different transmitters have different coverage areas Asymmetries lead to hidden/exposed terminal problems Also use contention-free protocols (RTS/CTS) January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 27
Hidden Terminals A B C transmit range A and C can both send to B but can t hear each other A is a hidden terminal for C and vice versa CSMA will be ineffective want to sense at receiver January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 28
Exposed Terminals A B C D transmit range B, C can hear each other but can safely send to A, D January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 29
CSMA with Collision Avoidance (CSMA/CA) Since we can t detect collisions, we try to avoid them When medium busy, choose random interval (contention window) Wait for that many idle timeslots to pass before sending ( Remember p-persistence a refinement When a collision is inferred, retransmit with binary exponential backoff (like Ethernet) Use ACK from receiver to infer no collision Again, exponential backoff helps us adapt p as needed January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 30
RTS / CTS Protocols (MACA) A RTS B C D CTS Overcome exposed/hidden terminal problems with contention-free protocol 1. B stimulates C with Request To Send (RTS) 2. A hears RTS and defers to allow the CTS 3. C replies to B with Clear To Send (CTS) 4. D hears CTS and defers to allow the data 5. B sends to C January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 31
IEEE 802.11 Wireless LAN 802.11b 2.4-5 GHz unlicensed radio spectrum up to 11 Mbps direct sequence spread spectrum (DSSS) in physical layer» All hosts use same code Widely deployed, using base stations 802.11a 5-6 GHz range up to 54 Mbps 802.11g 2.4-5 GHz range up to 54 Mbps All use CSMA/CA for multiple access Optional RTS/CTS All have base-station and ad-hoc network versions January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 32
IEEE 802.11 Wireless LAN Wireless host communicates with a base station Base station = access point (AP) Basic Service Set (BSS) (a.k.a. cell ) contains: Wireless hosts Access point (AP): base station BSS s combined to form distribution system (DS) January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 33
Ad Hoc Networks Ad hoc network: IEEE 802.11 stations can dynamically form network without AP Theoretical Applications: Laptops meeting in conference room, car Interconnection of personal devices Rare in practice January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 34
802.11 Twists How to support different speeds on same channel? Physical layer header encoded at lowest bitrate and indicates bitrate of rest of packet Network Allocation Vector (NAV) Each frame contains field that indicates the amount of time that will be used for the communication (channel reservation) All receivers defer xmit for that time Allows for long or multi-frame exchange RTS/CTS used as function of packet size Why? January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 35
Misc issues Addressing January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 36
Misc issue: Addressing Alternatives On a broadcast channel all nodes receive all packets Addressing determines which packets are kept and which are packets are thrown away Packets can be sent to:» Unicast one destination» Multicast group of nodes (e.g. everyone playing Quake )» Broadcast everybody on wire Dynamic addresses (e.g. Appletalk) Pick an address at random Broadcast is anyone using address XX? If yes, repeat Static address (e.g. Ethernet, 802.11, TokenRing, etc) January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 37
IEEE addressing (Ethernet,etc( Ethernet,etc) Addresses: 6 bytes (48bits) Each adapter is given a globally unique address at manufacturing time ($$$)» Address space is allocated to manufacturers 24 bits identify manufacturer E.g., 0:0:15:* 3com adapter» Frame is received by all adapters on a LAN and dropped if address does not match Special addresses» Broadcast FF:FF:FF:FF:FF:FF is everybody» Range of addresses allocated to multicast Adapter maintains list of multicast groups node is interested in Practical problems: non-unique addresses January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 38
Summary Ways to share a channel Subdivide the channel into subchannels Contention-based protocols» Try and retry if it fails Contention-free protocols» Explicit control over who gets to send at each time Particular issues for wireless Hidden/exposed terminal problems Addressing For next time: bridging/switching, read 3.2, 3.1 First homework & programming assignment will be given out January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 39
Backup: End to End Delay in Ethernet c in cable = 60% * c in vacuum = 1.8 x 10^8 m/s Modern 10Mb Ethernet 2.5km, 10Mbps ~= 12.5us delay +Introduced repeaters (max 5 segments) Worst case 51.2us round trip time! Slot time = 51.2us = 512bits in flight After this amount, sender is guaranteed sole access to link 51.2us = slot time for backoff January 20, 2005 CSE 123A -- Lecture 5 Datalink II: Media Access 40