Chapter 5 Link Layer
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 5 Link Layer Computer Networking: A Top Down Approach th 6 edition Jim Kurose, Keith Ross Addison-Wesley March 2012 All material copyright 1996-2012 J.F Kurose and K.W. Ross, All Rights Reserved Link Layer 5-1 Chapter 5: Link layer our goals: v understand principles behind link layer services: § error detection, correction § sharing a broadcast channel: multiple access § link layer addressing § local area networks: Ethernet, VLANs v instantiation, implementation of various link layer technologies Link Layer 5-2 Link layer, LANs: outline 5.1 introduction, services 5.5 link virtualization: 5.2 error detection, MPLS correction 5.6 data center 5.3 multiple access networking protocols 5.7 a day in the life of a 5.4 LANs web request § addressing, ARP § Ethernet § switches § VLANS Link Layer 5-3 Link layer: introduction terminology: v hosts and routers: nodes global ISP v communication channels that connect adjacent nodes along communication path: links § wired links § wireless links § LANs v layer-2 packet: frame, encapsulates datagram data-link layer has responsibility of transferring datagram from one node to physically adjacent node over a link Link Layer 5-4 Link layer: context v datagram transferred by transportation analogy: different link protocols over v trip from Princeton to Lausanne different links: § limo: Princeton to JFK § e.g., Ethernet on first link, § plane: JFK to Geneva frame relay on § train: Geneva to Lausanne intermediate links, 802.11 v tourist = datagram on last link v transport segment = v each link protocol provides communication link different services v transportation mode = link § e.g., may or may not layer protocol provide rdt over link v travel agent = routing algorithm Link Layer 5-5 Link layer services v framing, link access: § encapsulate datagram into frame, adding header, trailer § channel access if shared medium § “MAC” addresses used in frame headers to identify source, dest • different from IP address! v reliable delivery between adjacent nodes § we learned how to do this already (chapter 3)! § seldom used on low bit-error link (fiber, some twisted pair) § wireless links: high error rates • Q: why both link-level and end-end reliability? Link Layer 5-6 Link layer services (more) v flow control: § pacing between adjacent sending and receiving nodes v error detection: § errors caused by signal attenuation, noise. § receiver detects presence of errors: • signals sender for retransmission or drops frame v error correction: § receiver identifies and corrects bit error(s) without resorting to retransmission v half-duplex and full-duplex § with half duplex, nodes at both ends of link can transmit, but not at same time Link Layer 5-7 Where is the link layer implemented? v in each and every host v link layer implemented in “adaptor” (aka network interface card NIC) or on a chip application transport § Ethernet card, 802.11 network cpu memory card; Ethernet chipset link § implements link, physical host bus layer controller (e.g., PCI) link v attaches into host’s system physical physical buses transmission v combination of hardware, network adapter software, firmware card Link Layer 5-8 Adaptors communicating datagram datagram controller controller sending host receiving host datagram frame v sending side: v receiving side § encapsulates datagram in § looks for errors, rdt, frame flow control, etc § adds error checking bits, § extracts datagram, passes rdt, flow control, etc. to upper layer at receiving side Link Layer 5-9 Link layer, LANs: outline 5.1 introduction, services 5.5 link virtualization: 5.2 error detection, MPLS correction 5.6 data center 5.3 multiple access networking protocols 5.7 a day in the life of a 5.4 LANs web request § addressing, ARP § Ethernet § switches § VLANS Link Layer 5-10 Error detection EDC= Error Detection and Correction bits (redundancy) D = Data protected by error checking, may include header fields • Error detection not 100% reliable! • protocol may miss some errors, but rarely • larger EDC field yields better detection and correction otherwise Link Layer 5-11 Parity checking single bit parity: two-dimensional bit parity: v detect single bit v detect and correct single bit errors errors 0 0 Link Layer 5-12 Internet checksum (review) goal: detect “errors” (e.g., flipped bits) in transmitted packet (note: used at transport layer only) sender: receiver: v treat segment contents v compute checksum of as sequence of 16-bit received segment integers v check if computed v checksum: addition (1’s checksum equals checksum complement sum) of field value: segment contents § NO - error detected v sender puts checksum § YES - no error detected. value into UDP But maybe errors checksum field nonetheless? Link Layer 5-13 Cyclic redundancy check v more powerful error-detection coding v view data bits, D, as a binary number v choose r+1 bit pattern (generator), G v goal: choose r CRC bits, R, such that § <D,R> exactly divisible by G (modulo 2) § receiver knows G, divides <D,R> by G. If non-zero remainder: error detected! § can detect all burst errors less than r+1 bits v widely used in practice (Ethernet, 802.11 WiFi, ATM) Link Layer 5-14 CRC example G D r = 3 101000! ! want: 1001!101110000! D.2r XOR R = nG 1001! equivalently: 101! . r 000! D 2 = nG XOR R 1010! equivalently: 1001! if we divide D.2r by 110! 000! G, want remainder R 1100! to satisfy: 1001! 0101! D.2r 000! R = remainder[ ] R G 1010! 1001! 0011! Link Layer 5-15 Link layer, LANs: outline 5.1 introduction, services 5.5 link virtualization: 5.2 error detection, MPLS correction 5.6 data center 5.3 multiple access networking protocols 5.7 a day in the life of a 5.4 LANs web request § addressing, ARP § Ethernet § switches § VLANS Link Layer 5-16 Multiple access links, protocols two types of “links”: v point-to-point § PPP for dial-up access § point-to-point link between Ethernet switch, host v broadcast (shared wire or medium) § old-fashioned Ethernet § upstream HFC § 802.11 wireless LAN shared wire (e.g., shared RF shared RF humans at a cabled Ethernet) (e.g., 802.11 WiFi) (satellite) cocktail party (shared air, acoustical) Link Layer 5-17 Multiple access protocols v single shared broadcast channel v two or more simultaneous transmissions by nodes: interference § collision if node receives two or more signals at the same time multiple access protocol v distributed algorithm that determines how nodes share channel, i.e., determine when node can transmit v communication about channel sharing must use channel itself! § no out-of-band channel for coordination Link Layer 5-18 An ideal multiple access protocol given: broadcast channel of rate R bps desiderata: 1. when one node wants to transmit, it can send at rate R. 2. when M nodes want to transmit, each can send at average rate R/M 3. fully decentralized: • no special node to coordinate transmissions • no synchronization of clocks, slots 4. simple Link Layer 5-19 MAC protocols: taxonomy three broad classes: v channel partitioning § divide channel into smaller “pieces” (time slots, frequency, code) § allocate piece to node for exclusive use v random access § channel not divided, allow collisions § “recover” from collisions v “taking turns” § nodes take turns, but nodes with more to send can take longer turns Link Layer 5-20 Channel partitioning MAC protocols: TDMA TDMA: time division multiple access v access to channel in "rounds" v each station gets fixed length slot (length = pkt trans time) in each round v unused slots go idle v example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle 6-slot 6-slot frame frame 1 3 4 1 3 4 Link Layer 5-21 Channel partitioning MAC protocols: FDMA FDMA: frequency division multiple access v channel spectrum divided into frequency bands v each station assigned fixed frequency band v unused transmission time in frequency bands go idle v example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle time FDM cable frequency bands Link Layer 5-22 Random access protocols v when node has packet to send § transmit at full channel data rate R. § no a priori coordination among nodes v two or more transmitting nodes ➜ “collision”, v random access MAC protocol specifies: § how to detect collisions § how to recover from collisions (e.g., via delayed retransmissions) v examples of random access MAC protocols: § slotted ALOHA § ALOHA § CSMA, CSMA/CD, CSMA/CA Link Layer 5-23 Slotted ALOHA assumptions: operation: v all frames same size v when node obtains fresh v time divided into equal size frame, transmits in next slot slots (time to transmit 1 § if no collision: node can send frame) new frame in next slot v nodes start to transmit only § if collision: node retransmits slot beginning frame in each subsequent v nodes are synchronized slot with prob. p until v if 2 or more nodes transmit success in slot, all nodes detect collision Link Layer 5-24 Slotted ALOHA node 1 1 1 1 1 node 2 2 2 2 node 3 3 3 3 C E C S E C E S S Pros: Cons: v single active node can v collisions, wasting slots continuously transmit at v idle slots full rate of channel v nodes may be able to v highly decentralized: only detect collision in less slots in nodes need to be in sync than time to transmit packet v simple v clock synchronization Link Layer 5-25 Slotted ALOHA: efficiency efficiency: long-run v max efficiency: find p* that maximizes fraction of successful slots N-1 (many nodes, all with many Np(1-p) frames to send) v for many nodes, take limit of Np*(1-p*)N-1 as N goes v suppose: N nodes with to infinity, gives: many frames to send, each max efficiency = 1/e = .37 transmits in slot with probability p v prob that given node has at best: channel success in a slot = p(1- used for useful p)N-1 transmissions 37% of time! ! v prob that any node has a success = Np(1-p)N-1 Link Layer 5-26 Pure (unslotted) ALOHA v unslotted Aloha: simpler, no synchronization v when frame first arrives § transmit immediately v collision probability increases: § frame sent at t0 collides with other frames sent in [t0-1,t0+1] Link Layer 5-27 Pure ALOHA efficiency P(success by given node) = P(node transmits) .