Chapter 4 The Medium Access Control Sublayer • • • • Medium Access Control (MAC) Sublayer Basic Problem in broadcast networks: Many stations and a single medium Who sends what and when? Also known as multiaccess channel problem Idea of multiaccess channels is relatively young (1973) ISO included it relatively late in its reference model • MAC is seen as part of layer 2 • (Others see it rather as part of layer 1) Anyway, it deals with transmission of packets (rather frames) between flat stations Station Am I meant as a receiver? Multiaccess Channel (Medium) May I send now? MAC Sublayer • Multiaccess channel problem arises in: • LANs (1000 m range) • Bus-based • Ring distributed solution of the MAC problem • Similar problem when accessing system bus in a computer central solution using bus arbiter • Radio networks (50 km range) No problem for microwave bridges Typically FDM/TDM MAC Sublayer • • Satellite networks • Also have the multiaccess channel problem • Except satellite channels in telephone networks, which use sometimes FDM (like radio networks) Problem of FDM/TDM: • Let E[B] be the mean frame/packet time if channel was idle max. throughput C = 1/[B] • Let E[T] the mean frame time and l the frame arrival rate • Then: E[T] = E[B]/(1 – l/C) = E[B]/(1 – l E[B]) = 1/(1/E[B] – l) = 1/(C – l) • With N chunks of channel (FDM/TDM): E[TMUX] = 1/(C/N – l/N) = NxE[T] Multiplexing is inherently inefficient MAC Sublayer Multiple Access Protocols Random Access Without sensing of medium Pure Aloha With reservation With sensing of medium (CS: carrier sensing) Slotted Aloha P-persistent Unslotted CSMA Slotted CSMA Token ring Token bus Static Stiff FDM Non-persistent Unslotted Slotted Further classification based on collision detection/handling Priority after conflict Dynamic Stiff TDM Reservation Aloha CFMA (Conflict Free Multi Access) MLMA (Multi Level Multi Access) BRAM (Broadcast Recognition Access Method) … MAC Sublayer • • Criteria for Multiple Access Protocols: • Reservation or at a venture • Slotted time or continuous time • Carrier sense or no carrier sense • Priority or fairness • Load dependency • Time until a frame is transmitted (potentially after collisions) • Throughput • …. Main assumptions: • Single shared channel • Stations are independent • No way to contact other parties except through medium Protocols Without Reservation • • • ALOHA (hello!): • Each station sends as soon as it wants to • No positive ACK after timeout, then frame is retransmitted • Collision if frames overlap at the central station • Only central station can detect a collision; if so then no positive ACKs Similar situation if multiple access uses a satellite: Comparison of the sent message with the message from the satellite Performance of ALOHA: • X: delay (before sending a frame anew) • k: collision probability • E[D]: mean frame/packet throughput • Main parts of system model: • A: whole system (Aloha) • X: delay unit • M: medium ALOHA • System model: A Delay X k Medium M E[DM] • • • • • E[DA] 1-k E[N] = E[D].E[T] (Number of frames [frame] = Rate [frame/sec] x Time [sec] ) E[NA] = E[DA].E[TA] = E[NM] + E[NX] E[NX] = E[DX].E[TX] = k.E[DM].E[TX] E[NM] = E[DM].p (p: packet time) E[DA] = (1 – k).E[DM] E[TA] = p/(1 – k) + E[TX].k/(1 – k) This is the time needed by a packet in order to be sent after potential collisions ALOHA • • • Again: E[TA] = p/(1 – k) + E[TX].k/(1 – k) In words: Time through Aloha = 1/(1-k) times time in medium + k/(1-k) times delay time Hence: • Packet visits the medium vm =1/(1-k) times (number of sending trials) • Packet visits the delay unit vd = k/(1-k) = vm -1 times (intended waiting after late ACK) What is the value of the collision probability k? two cases • Pure ALOHA: Send anytime (continuous time) • Slotted ALOHA: Time segmented in slots with length equal to packet time. Sending starts only at the beginning of a slot (discrete time) • Assumption: Inter-arrival time A of packets has the following distribution: P[A <= t] = 1 – e –lt with l = E[DM] (i.e. exponential distribution) ALOHA • Let us determine the collision probability k: pure Aloha slotted Aloha our packet p p time time p Latest previous packet 2p k = P[A <= 2p] k = 1 – e –2 pE[DM] Earliest next packet Collision-free if no packet arrival in previous slot k = P[A <= p] k = 1 – e – pE[DM] ALOHA • Throughput of Aloha: • E[DA] = (1 – k).E[DM] • Pure Aloha: k = 1 – e –2 pE[DM] E[DA] = (1 – (1 – e –2 pE[DM])).E[DM] = E[DM].e –2 pE[DM] • Slotted Aloha: k = 1 – e – pE[DM] E[DA] = (1 – (1 – e – pE[DM])).E[DM] = E[DM].e – pE[DM] E[DA] Maximum throughput c if packet alone (c = 1/p) 1/p slotted Aloha 1/ep 1/2ep pure Aloha 1/2p 1/p 3/2p E[DM] Utilization of channel r = E[DA]/C, thus r <= 1/2e = 18% (pure) and r <=1/e = 36% (slotted) ALOHA • What is the time until packet is successfully transmitted? (= TA) • E[TA] = p/(1 – k) + E[TX].k/(1 – k) • Pure Aloha (slotted similar): k = 1 – e –2 pE[DM] E[TA] = p/ e –2 pE[DM] + E[TX]. (1 – e –2 pE[DM]) / e –2 pE[DM] = = (p + E[TX]. (1 – e –2 pE[DM])).e 2 pE[DM]] Since: E[DM] = E[DA]./(1-k) The time rises more than exponentially with p.E[DA] E[TA] Most beautiful thing in Aloha is its name Drawback (in general for all protocols at a venture) is that no maximum transmission time can be guaranteed (bad for real-time processing). p p.E[DA] = utilization of A CSMA (carrier sensing – multiple access) • • • • A better idea: Do not send if a foreign transmission has already begun. Sense the medium before sending Problems: • The stations cannot “hear” each other (satellite/radio network) • Because of the distribution, a foreign transmission may have begun before our station recognizes it. Should we send now, then a collision is sure. Shared channel is particularly natural for LANs with bus structure (Ethernet). The second problem, however, should be considered in LANs, too. message time A B g Should B have begun here, A could have recognized it g In this 2g interval B is allowed to send though it will collide with A g: propagation delay g = distance/v0 v0: speed of light Now A is sure that Now B is allowed everything is ok to send (end of risk time) (without collision with A) CSMA • • • • For effectiveness (collision protection, utilization) is obviously required that: message time >> maximum propagation time of the network This means: m / c >> distance / v0 (length in bits, c: max.throughput) (technical improvement increases c and distance) Important parameter: Conflict parameter: a = propagation time / message time should be << 1 Example: LAN MAN m 1000 b 1000 b c 107 bps 108 bps distance 500 m 50 km v0 108 m/sec 108 m/sec a 0.017 17 CSMA • • • In particular, a sender risks a collision if it sends 2 (more) consecutive messages, because during the first message more than one station may have become ready to send. Variants of CSMA regulate the behavior after a collision has been detected: • If not free, persist or wait for a while • If free, send immediately or wait for a while Types: • CSMA persistent: persist, as soon as free send immediately with probability p • 1-persistent: persist, send as soon as medium is free (p=1) good transmission time if load low, high collision risk if load high • p-persistent (p <1): persist, perhaps send worse transmission time, less risk • CSMA non-persistent: do not persist (wait for a while) if medium is occupied, but send if medium is found free CSMA • CSMA Algorithm: Ready to send Free In use p-persistent Type? Nonpersistent Carrier sense? p-persistent p Type? Non-persistent 1-p Probability? Wait Send Yes Wait Wait Collision? No End CSMA E[DAloha/CSMA] Like so often the strategy used is not important if load is low E[DM] E[DAloha/CSMA] c = 1/p 1/p Slotted persistent 0.8/p Non-persistent CSMA 0.6/p 1-persistent 0.4/p Slotted Aloha Aloha Pure Aloha 0.2/p 0 0.001 0.01 0.1 1 Conflict parameter: a CSMA • • • • The CSMA multi-channel access protocols are further refined by collision detection and abortion. CSMA-CD: (CD: Collision Detection) As soon as a station detects (by monitoring the voltage characteristics, not using checksums an so on) that different transmissions have overlapped, it triggers a warning signal (jamming). All senders interrupt their transmission, if they receive a jamming signal. CSMA-CD 1-persistent is the basis of ISO standard 8802 and IEEE 802.3, which is known under the product name Ethernet (Xerox, 1976) Where in OSI? Ethernet Manchester Encoding PSK Ethernet Ethernet • Segmentation: to overcome distance limitation Ethernet • Topology of 10Base2: Ethernet • Topology of 10Base-T: Ethernet • Topology of 1Base5: Other Ethernet Implementations • Switched Ethernet • • • • Idea: Switch instead of hub Hub broadcasts/Switch unicasts Bandwidth x N (N stations) Fast Ethernet • • • • • Idea: Reduce maximum distance md (station to switch/hub) collision detected earlier higher offered bandwidth 100Base-T4 : 4 pairs of UTP, md =100 m 100Base-TX: 2 Pairs of UTP or STP, md =100 m 100Base-FX: 2 optical fibers, md = 2000 m Gigabit Ethernet • • • • • • Idea: Like Fast Ethernet Rather for optical fibers (e.g. backbone between Fast Ethernets) 1000Base-SX: short wave laser, 550 m 1000Base-LX: long-wave laser, 550 m (multimode) 5000 m (single mode) 1000Base-CX: STP, electrical, 25 m 1000Base-T : UTP, electrical, 25 m Token Ring 2 1 3 4 Token Ring • Rules for the stations ( also for Token Bus = Logical Ring) • • • • • • Recognize packet start (address), destination copies packet into local buffer. If station not sender, forward packet. If sender, get packet with ACK of receiver and generate a new token. To send, first get token (bit pattern) from ring. If not ready to send, token is forwarded. Main advantages • • • • Maximum waiting time is guaranteed. Maximum utilization 100% (almost) achievable. No collisions. Disadvantages • • • • If load low, waiting time is determined by token round-trip time (not zero). More complex than CSMA. Sensitive to failures. Problems • • • • • Station crash: might ruin the ring, however, switches are used. Token loss: monitor creates a new one. More than one token: monitor cancels one. Monitor crash: new one is elected. Rotating packet: monitor marks and “absorbs” it next time. Token Ring • Topology of a ring • Analysis of token ring • • • • • • r: circulation time of token (load dependent) g: propagation time of signals (in whole ring) p: packet time N: number of stations U: utilization of medium E[T]: “mean” packet transfer time Token Ring • Analysis of token ring (contd) Node p g 1 t0: 2 wants to send t1: 2 gets token t1 - t0: waiting time for token t2: 2 is sending t3: 2 generates new token 4 3 circulating token 2 packet being sent 1 time t0 t1 t2 t 3 Node r = N.p + g U = N.p/(N.p + g) 1 4 3 2 1 time Token Ring • Analysis of token ring (contd) • • • • Transfer time for a packet with highest priority (no queuing time): E[Tmin] = r/2 + g/2 + p Why? r/2: mean time in order to get the token g/2: mean time for propagation p: packet time itself In order to guarantee E[Tmin] – p, each node is assigned a fixed time q in which data can be sent: r N.q + g Hence: E[Tmin] N.q/2 + g + p or E[Tmin] – p N.q/2 + g Main advantage for real-time processing: token ring guarantees maximum waiting time (for token) for highest priority packets (in CSMA not possible because of collisions). Mean transfer time E[T]: E[Tring] > E[Tcsma] for low load, E[Tring] < E[Tcsma] for high load. E[T] csma ring U = N.p/(N.p+g) gring gcsma p U 0 100% Basic Reservation Protocols • Bit-map protocol • • • • 2 Phases: (1) Reservation (2) Transmission Collision-free Number of slots per cycle = Number of stations (= N) U = p/(p + if heavy traffic then s else N.s) (s: slot time, p: packet time) packets • s p Broadcast Recognition Access Method (BRAM) • • • • 0 Reservation slots are cyclically (and deterministically) assigned to stations Also collision-free Channel utilization: U = p/(s + p) Better waiting time in light traffic than bit-map protocol (N/2 instead of N) 1 1 2 3 (1) 1 p s 5 (3) 6 7 1 0 (7) 1 1 2 (1) 3 4 5 1 6 (5) 7 0 1 2 1 (2) Binary Countdown • • • • • • • • • Bit-map protocol not scalable for high N Rules Stations are numbered in binary (addresses) Stations wanting to send broadcast their addresses starting from the leftmost bit Bits of addresses of different stations are Boolean ORed Any station having 0 in the current position gives up if it sees a (foreign) 1 on same position The winner is offered the medium for transmission Consequence: Higher-numbered stations have higher priority (always win the competition) Because contention only “during” the binary representation of N: U = p/(p + s.log(N)) Reservation Aloha • Again 2 phases: • • • • Reservation phase In this phase, the stations use slotted Aloha to transmit a very small (relative to average data frame size) reservation frames. The station that is able to transmit its reservation frame successfully (without collision) reserves the channel for subsequent data frame transmission. This slotted-time reservation phase lasts as long as it takes to transmit a reservation frame successfully. On average, the peak effective channel utilization efficiency is 36% for reservation Aloha (see slotted Aloha). Data Transmission In this phase, the station can transmit the data frame without contention because the channel is reserved for it. Utilization: U = p/(p + s/0.36) Other variations exist (e.g. TDM for heavy traffic and Aloha for light traffic) Limited-Contention Protocols p (1-1/k)k-1 k Acquisition probability for a symmetric contention channel. • • • • • • • General problem: Collision-free protocols (e.g. bit-map protocol) work well for large k Protocols with collision (e.g. slotted Aloha) work well for small k How to combine them? Limited-contention Protocols: Try to solve above problem Basic idea: • If k too high lower it in order to maximize p • How? Use of groups of stations Limited-Contention Protocols • Adaptive Tree Walk Protocol: • Tree(x) = subtree under node x • Algorithm(Tree) { Let all stations in Tree try to reserve the channel; if (no collision) return; currentSlot++; Algorithm(left(Tree)); currentSlot++; Algorithm(right(Tree)); } • Level 0 Level 1 Level 2 How to call algorithm()? • Method M1: • • Begin with the root //{currentSlot := 0; Algorithm(Tree(1));} • M1 bad if load is heavy (because slot 0 will always include a collision) Method M2: • • • • Let q be an estimate for the number of stations that are ready to send E(i) = q/2i is expected number of them under a node at level i E(i) = 1 minimizes the E(i) for i = log(q) begin with nodes at level log(q) Other optimizations exist (e.g. {G, H} ready to send, slot 2 for Tree(6) not for Tree(3)) The 802.11 MAC Sublayer Protocol • Main Differences to Fixed LANs (i.e. Ethernet): • • • Carrier sensing (and transmission) not reliable. CSMA not sufficient! Different data flows possible if they do not interfere. New Problems: (a) The hidden station problem. (b) The exposed station problem. The 802.11 MAC Sublayer Protocol • Basic Idea: The MACA (Multiple Access with Collision Avoidance) protocol. (a) A sending an RTS (Request To Send) to B. (b) B responding with a CTS (Clear To Send) to A. The 802.11 MAC Sublayer Protocol • CSMA/CA (CSMA with Collision Avoidance): • • Standard 802.11 protocol in the distributed case (without base station) Mode 1: Ready to send Free In use Carrier sense? Wait until free Send Collision? Yes Wait • Mode 2: • Based on MACA • Uses virtual channel sensing No End Collision detected e.g. if no ACK after timeout The 802.11 MAC Sublayer Protocol • CSMA/CA Mode 2 (contd): The use of virtual channel sensing using CSMA/CA. 1. RTS: A asks B to send 2. CTS: B says ok 3. Data: A sends a data frame to B 4. NAV (Network Allocation Vector): 4.1. C sees RTS, so it keeps quiet until ACK 4.2. D sees CTS, so it keeps quiet until ACK (in 4.x, time to sleep part of information in RTS/CTS) The 802.11 MAC Sublayer Protocol (3) • CSMA/CA Mode 2 (contd): • • To minimize effect of noise and increase throughput, frames are fragmented. In principle, NAV until last ACK A fragment burst. Networking and Internetworking Devices • Connecting Devices and the OSI Model: • • • • • Repeaters and hubs: operate on layer 1 only. Bridges and switches: operate mostly on layer 2 (and also on layers < 2). Routers: operate mostly on layer 3 (and also on layers < 3). Gateway: operate mostly on layer 7 (and also only layers < 7). Gateway is the general term: • • • Repeaters and hubs = Layer-1 gateways Bridges and switches = Layer-2 gateways Routers = Layer-3 gateways Application Gateway Application Presentation Presentation Session Session Transport Transport Network Router Network Data Link Bridge, Switch Data Link Physical Repeater, Hub Physical Networking and Internetworking Devices • • Repeaters in the OSI Model: Main Characteristics of a Repeater: • Analog device (has no ideas about protocols etc.) • Regeneration of signals • Mainly used to connect 2 or more cable segments (as in Ethernet). Networking and Internetworking Devices • Repeater (contd): • It is tempting to compare a repeater to an amplifier • However, comparison not correct, since: • Amplifier amplifies input signals (including noise!) only • Repeater really regenerates the signal (hence removing effect of noise) • Signal Regeneration: Repeater Regenerated signal Corrupted signal • Hub: • Connects a number of input lines as a star • Broadcasts any input (frame) to all other lines (in general without regeneration) A E B F C D Hub G Networking and Internetworking Devices • Switch: • • • • • • • Joins a number of stations in a star (similar to hub) More intelligent than a hub, because it understands layer-2 addresses Traditionally, includes buffers for each line Any input frame is actively forwarded to its destination only (no broadcast) Terms switch and bridge are used interchangeably Cut-trough switch: • Begins to forward a frame as soon as its destination has been scanned • No buffering (not a store-and-forward switch) • In general implemented in hardware Store-and-forward switch: • Has buffers (problem of buffer overflow!) • In general implemented in software (real computer) A E B F C Switch G Networking and Internetworking Devices • Bridge: • • • • • Joins a number of LANs Includes a lookup table for localizing the output of a specific destination: {(station, line, arrival time)} Algorithm in a Bridge: Get next frame with destination d from input line i; Get current time t; Get source s of frame and insert (s, i, t) in lookup table; // backward learning Search in lookup table the output line j corresponding to d; if(found) then // known destination Bridge LAN i if(i = j) then // input LAN = output LAN Discard frame; A B S K else Forward frame to j; else Forward frame to all lines except i (Flooding); The backward learning step is needed to build up (and update) the lookup table (which is initially empty) Also (in another thread) the lookup table is periodically scanned and entries that are more than x time units old are discarded (x parameter of bridge) LAN j F D H Networking and Internetworking Devices • Issues if a Bridge Connects Different LANs: • • • • • • Example Wireless LAN and Ethernet or Token Ring Frame Format Bridge should be able to transform one format to another Payload Size Maximum allowed size of a frame varies from a LAN to another. Problem arises when input frame is larger than maximum allowed size of output LAN (fragmentation does not help, since layer 2 does not do that in general). Data Rate Different LANs allow different data rates. The bridge should be able to cope with that (e.g. a Gigabit Ethernet may overwhelm a bridge connecting to a 10 Mbps LAN). Checksum Recalculation Is needed, since the destination LAN may use another generator polynomial Security The destination LAN (e.g. Ethernet) may not provide security measures whereas the source LAN (e.g. wireless LANs) may include security. Bridge would forward frame without security measures. If frame is in plaintext, this would lead to insecure communication. If not, frame is forwarded but it is useless for receiver, since receiver (layer 2) cannot decrypt it. (Solution may be to do encryption solely in higher layers, but standards do not adhere to that) Networking and Internetworking Devices • Reliability of Bridges: • • • What a bridge can perform is much-needed However, what if a bridge is down? ( no inter-LAN communication is possible!) Solution: Use of redundant bridges D S • Problem: Frame F will be infinitely forwarded by the two bridges (if both up) Why? 1. B1 receives F and forwards it to LAN2 (suppose destination D unknown) 2. B2: 2.1 Receives F1 and forwards it to LAN1 2.2 Side effect: B2 will falsely assume that S is in LAN2 and updates its table 3. B1 receives F1 and forwards it again to LAN2 4. … Networking and Internetworking Devices • Solution for the Endless Forwarding Problem of Bridges: • • Do not allow cycles in the network; use all LANs and as many bridges as possible (for redundancy). Spanning Tree: • Idea: Construct a tree of bridges by eliminating cycles in the network (i.e. eliminating bridges). • Assumptions: • Group address in order to address all bridges in the network. • Unique bridge IDs and unique port IDs in each bridge. • Path costs in each port of a bridge (e.g. number hops, sum 1/bit rates). • Algorithm: 1. Determining the root bridge (root of tree). 1.1 Initially, each bridge thinks it is the root bridge. 1.2 Then minimum ID of the bridges decides: 1.2.1 (Current) root bridges periodically broadcast frames containing their IDs. 1.2.2 Any bridge that receives a frame with a lower ID subordinates itself to root (i.e. it desists from sending frames). 2. Determining the root port for each bridge: 2.1 For each port determine path with minimum costs to root. 2.2 Root port is port with minimum costs to root. 3. Determining the designated ports for each bridge: 3.1 For each LAN the port connecting to the bridge with minimum path (to root) from its root port is observed as a designated port. 3.2 All ports of the root bridge are designated ports. 4. Eliminating bridges: All remaining ports are blocking ports (i.e. bridges do not forward frames along them). Networking and Internetworking Devices • Example for a Spanning Tree: LAN1 ID = 23 ID = 77 B1 B2 ID = 11 ID = 58 LAN3 B3 LAN4 B4 ID = 34 ID = 101 B5 LAN2 LAN5 B6 LAN6 Designated port Root port Blocking port Root bridge Networking and Internetworking Devices • Routers: • • • • Are not frame-based: do not use physical addresses (e.g. Ethernet 48 Bit address) Are packet-based: use network addresses included in the payload of a frame Are in general powerful computers with considerable amount of software Main function: connect different networks • Routers in OSI Model: Networking and Internetworking Devices • Gateway: • • • • • Is a protocol converter (in any layer) Transport gateway: e.g. converts from TCP to ATM Application gateway: e.g. email over ftp Usually software resides in a router Other devices: • • Multiprotocol router: can handle more than one network protocol e.g. IP and IPX packets Brouter: a bridge/router, acts as both, if it understands packet format it acts as a router, otherwise as a bridge (processing whole frame)