Computer Network Fundamentals Spring 2008 Week 3 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 344/Spring08 2
MAC Protocols Problem: How to share medium among multiple senders Alternatives 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 344/Spring08 3
ALOHA Packet radio network Univ. 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 344/Spring08 4
ALOHA Efficiency Assumptions Infinite number of users Frame arrivals are modeled by a Poisson process with aggregate rate λ Retransmissions can also be modeled by a Poisson process with rate G > λ Throughput S=GP 0 P 0 = probability frame does not suffer a collision CS 344/Spring08 5
ALOHA: Collision Probability Frame t x time:t Vulnerable interval:2t Prob[k arrivals]: P 0 =e -2G S=Ge -2G Max throughput is 0.184 when G=0.5 t 0 t 0 +t t 0 +2t t 0 +3t Vulnerable Interval CS 344/Spring08 6
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 after hearing clock tick Vulnerable time is equal to t Throughput S=Ge -G (max =0.37, G=1) Expected number of transmissions: CS 344/Spring08 7
Comparison CS 344/Spring08 8
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 344/Spring08 9
CSMA collisions collisions can still occur: 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 spatial layout of nodes CS 344/Spring08 10
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 344/Spring08 11
Performance CS 344/Spring08 12
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 344/Spring08 13
CSMA/CD collision detection CS 344/Spring08 14
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 Before attempting a retransmission, adapter waits a random time, that is, random access CS 344/Spring08 15
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,,2 m -1}. Adapter waits K*512 bit times and returns to Step 2 CS 344/Spring08 16
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 344/Spring08 17
CSMA/CD efficiency Assume: k stations, prob transmit = p Notation: L : link length B : link speed c : speed of light F : frame size τ : slot length in bits CS 344/Spring08 18
Efficiency as a function of τ CS 344/Spring08 19
Token Ring 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 CS 344/Spring08 20
Token Ring (cont.) Examples 16Mbps IEEE 802.5 (based on earlier IBM ring) 100Mbps Fiber Distributed Data Interface (FDDI) Resilient Packet Ring MAN (802.17) CS 344/Spring08 21
When to send token? Early Release Late Release Relative advantages and drawbacks? CS 344/Spring08 22
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 CS 344/Spring08 23
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 344/Spring08 24
Maintenance (cont) Monitor duties Regenerate token if current one is destroyed Remove corrupted or orphaned frames CS 344/Spring08 25
Wireless LANs IEEE 802.11 Bandwidth: 1-54 Mbps Physical Media spread spectrum radio (2.4GHz) diffused infrared (10m) CS 344/Spring08 26
Collisions Avoidance Similar to Ethernet Problem: hidden and exposed nodes CS 344/Spring08 27
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 Receiver sends ACK when has frame neighbors silent until see ACK Collisions no collisions detection known when don t receive CTS exponential backoff CS 344/Spring08 28
An Ethernet Network Problem: Shared network limits throughput. Lots of collisions reduces efficiency. Router Outside world CS 344/Spring08 29
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 344/Spring08 30
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. Router Outside world CS 344/Spring08 31
Ethernet Switching Learning addresses A B C D E F G H 1 Ethernet Switch 6 2 3 4 5 J F Switch learns that F is reachable through port 5 Ethernet Switch Q Router Outside world I J K L M N O P Ethernet Switch Ethernet Switch CS 344/Spring08 32
Ethernet address Port A 1 Ethernet Switching B 2 C 3 D 4 Learning E, F, G, H, Q addresses 5 I, J, K, L, M, N, O, P 6 A B C D E F G H 1 2 3 Ethernet Switch 6 4 5 Ethernet Switch Q Router Outside world I J K L M N O P Ethernet Switch Q: How do we prevent loops? Ethernet Switch CS 344/Spring08 33
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 344/Spring08 34
LAN Addresses and ARP 32-bit IP address: network-layer address used to get datagram to destination IP network 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 344/Spring08 35
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 344/Spring08 36
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> TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min) CS 344/Spring08 37
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 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 CS 344/Spring08 38
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 344/Spring08 39