1 / 114

Chapter 5: The Data Link Layer

Our goals: understand principles behind data link layer services: error detection, correction sharing a broadcast channel: multiple access link layer addressing reliable data transfer, flow control: done! instantiation and implementation of various link layer technologies.

hayfa-david
Download Presentation

Chapter 5: The Data Link Layer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Our goals: understand principles behind data link layer services: error detection, correction sharing a broadcast channel: multiple access link layer addressing reliable data transfer, flow control: done! instantiation and implementation of various link layer technologies Chapter 5: The Data Link Layer 5: DataLink Layer

  2. 5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay Chapter 5 outline 5: DataLink Layer

  3. Some terminology: hosts and routers are nodes communication channels that connect adjacent nodes along communication path are links wired links wireless links LANs 2-PDU is a frame,encapsulates datagram “link” Link Layer: Introduction data-link layer has responsibility of transferring datagram from one node to adjacent node over a link 5: DataLink Layer

  4. Datagram transferred by different link protocols over different links: e.g., Ethernet on first link, frame relay on intermediate links, 802.11 on last link Each link protocol provides different services e.g., may or may not provide reliable data transfer over link Link layer: context 5: DataLink Layer

  5. Link Layer Services • Framing: • encapsulate datagram into frame, adding header, trailer • ‘physical addresses’ used in frame headers to identify source, dest • different from IP addresses! • Link access: • Media Access Control (MAC) protocols coordinate frame transmissions of nodes that share a broadcast link • Reliable delivery between adjacent nodes • we learned how to do this already (chapter 3)! • seldom used on low bit-error links (fiber, coax, twisted pair) • often used for wireless links: high error rates 5: DataLink Layer

  6. Link Layer Services (more) • Flow Control: • pacing between adjacent sending and receiving nodes • Error Detection: • errors caused by signal attenuation, noise. • sender includes error-detection bits in frame • receiver detects presence of errors: • signals sender for retransmission or drops frame • Error Correction: • receiver identifies and corrects bit error(s) without resorting to retransmission • Half-duplex and full-duplex • with half duplex, nodes at both ends of link can transmit, but not at same time 5: DataLink Layer

  7. link layer implemented in “adaptor” (aka NIC) Ethernet card, 802.11 card sending side: encapsulates datagram in a frame adds error checking bits, rdt, flow control, random access, etc. receiving side error checking, rdt, flow control, random access, etc extracts datagram, passes to network layer frame frame Adaptors Communicating datagram rcving node link layer protocol sending node adapter adapter 5: DataLink Layer

  8. 5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay Chapter 5 outline 5: DataLink Layer

  9. 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 5: DataLink Layer

  10. Parity Check Two Dimensional Parity Bit: Detect and correct single bit errors Single Parity Bit: • suppose d bits of data • even/odd parity: add one additional bit such that the total number of 1’s in the d+1 bits is even/odd • can detect an odd number of bit errors; can not detect an even number of bit errors Example of even parity 0111000110101011 1 o o d data bits parity bit 5: DataLink Layer

  11. Sender: treat data as sequence of 16-bit integers compute 1’s complement sum of data add carry-out (17th bit) back into the lowest significant bit put 1's complement of the sum into checksum field Receiver: compute 1’s complement sum of received data, including the checksum field check if the result contains all 1 bits: NO - error detected YES - no error detected; but may be errors nonetheless. Internet checksum (RFC 1071) Goal: detect “errors” (e.g., flipped bits) in transmitted segment (used at transport layer) 5: DataLink Layer

  12. Cyclic Redundancy Check (CRC) • often used in link layer • view data bits, D, as a binary number • sender, receiver agree on an r+1 bit pattern (generator), G, leftmost bit of G must be 1 • 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! 5: DataLink Layer

  13. CRC Example Example: D=101110, G=1001, r=3 Want: D.2r XOR R = nG equivalently: D.2r = nG XOR R equivalently: if we divide D.2r by G, remainder is R D.2r G R = remainder[ ] In CRC calculations, addition and subtraction are equivalent to bitwise exclusive-or (XOR) Sender transmit: 101110 011 5: DataLink Layer

  14. Common generators CRC-8: 100000111 CRC-12: 1100000001101 CRC-16: 1100000000000101 CRC-32: 100000100110000010001110110110111 • Can detect burst errors of less than r+1 bits • Can detect any odd number of bit errors 5: DataLink Layer

  15. 5.1 Introduction and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay Chapter 5 outline 5: DataLink Layer

  16. Multiple Access Links Two types of “links”: • point-to-point • single sender, single receiver • link between two routers, or between a dial-up modem and an ISP router • broadcast (shared wire or medium) • multiple sending and receiving nodes connected to single shared channel • Ethernet, 802.11 wireless LAN 5: DataLink Layer

  17. Multiple Access protocols • single shared broadcast channel • two or more simultaneous transmissions by nodes: collision • only one node can send successfully at a time multiple access protocol • determine how nodes share channel, i.e., determine when node can transmit 5: DataLink Layer

  18. Ideal Multiple Access Protocol Broadcast channel of rate R bps 1. When only 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 4. Simple 5: DataLink Layer

  19. Multiple Access Protocols: a taxonomy Three broad classes: • Channel Partitioning Protocols • divide channel into smaller “pieces” (time slots, frequency, code) • allocate piece to node for exclusive use • Random Access Protocols • channel not divided, allow collisions • “recover” from collisions • Taking-turns Protocols • tightly coordinate shared access to avoid collisions 5: DataLink Layer

  20. Channel Partitioning: TDMA TDMA: time division multiple access • divide time into time frames and divide each time frame into fixed length time slots (length = pkt trans time) • each station gets one slot in each frame • unused slots go idle • example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle 5: DataLink Layer

  21. Channel Partitioning: TDMA • Pros: • No collisions • Fair: each node gets a dedicated transmission rate of R/N bps • Cons: • inefficient at low load: delay in channel access, 1/N bandwidth allocated even if only 1 active node! 5: DataLink Layer

  22. Channel Partitioning: FDMA FDMA: frequency division multiple access • channel spectrum divided into frequency bands • each station assigned a frequency band • unused transmission time in frequency bands go idle • example: 6-station LAN, 1,3,4 have pkt, frequency bands 2,5,6 idle time 1 • Pros: • no collisions, fair • Cons: • inefficient at low load: 1/N bandwidth allocated even if only 1 active node! 2 3 frequency bands 4 5 6 5: DataLink Layer

  23. Channel Partitioning: CDMA CDMA: Code Division Multiple Access • used mostly in wireless broadcast channels (cellular, satellite, etc) • all users share same frequency, but each user assigned unique code to encode data • encoded signal = original bit X M-bit code • decoding: • original bit = normalized inner-product of encoded signal S and code C i.e., original bit = 5: DataLink Layer

  24. CDMA Encode/Decode 5: DataLink Layer

  25. CDMA: two-sender interference allows multiple users to transmit simultaneously with no interference if codes are “orthogonal” • two codes are orthogonal if their normalized inner-product is 0. • e.g. (1,1,1,-1,1,-1,-1,-1) and (1,-1,1,1,1,-1,1,1) are orthogonal 5: DataLink Layer

  26. Random Access Protocols • When node has packet to send • transmit at full channel data rate R. • no a priori coordination among nodes • two or more transmitting nodes -> “collision”, • random access protocol specifies: • how to recover from collisions (e.g., via delayed retransmissions) • Examples of random access protocols: • slotted ALOHA • ALOHA • CSMA, CSMA/CD, CSMA/CA 5: DataLink Layer

  27. Assumptions all frames same size time is divided into equal sized slots, a slot equals the time to transmit one frame nodes start to transmit frames only at beginning of slots nodes are synchronized if two or more nodes transmit in a slot, all nodes detect collision before the slot ends Operation when node has a fresh frame to send, it transmits in next slot no collision, node can send new frame in next slot if it has one if collision, node retransmits frame in each subsequent slot with probability p until success Slotted ALOHA 5: DataLink Layer

  28. Pros single active node can continuously transmit at full rate of channel highly decentralized: each node independently decides when to retransmit, only slots in nodes need to be in sync Simple Cons collisions waste slots idle slots Slotted ALOHA C = collision slot, E = empty slot, S = successful slot 5: DataLink Layer

  29. Suppose N nodes with many frames to send, each transmits in slot with probability p prob that a given node has success in a slot = p(1-p)N-1 prob that any node has a success= Np(1-p)N-1 For max efficiency with N nodes, find p* (=1/N) that maximizes Np(1-p)N-1 For many nodes, take limit of Np*(1-p*)N-1 as N goes to infinity, gives 1/e = .37 Slotted Aloha efficiency Efficiency is the long-run fraction of successful slots when there are many nodes, each with many frames to send At best: channel used for useful transmissions 37% of time! 5: DataLink Layer

  30. Pure (unslotted) ALOHA • unslotted Aloha: simpler, no synchronization • when frame first arrives: transmit immediately • If collision, retransmit with prob. P, or wait for a frame transmission time with prob. 1-p • collision probability increases: • frame sent at t0 collides with other frames sent in [t0-1,t0+1] 5: DataLink Layer

  31. Pure Aloha efficiency P(success by given node) = P(node transmits) . P(no other node transmits in [t0-1,t0] . P(no other node transmits in [t0,t0 +1] = p . (1-p)N-1 . (1-p)N-1 = p . (1-p)2(N-1) … choosing optimum p and then letting n -> infty ... = 1/(2e) = .18 Even worse ! Price paid for a fully decentralized protocol. 5: DataLink Layer

  32. CSMA (Carrier Sense Multiple Access) CSMA: listen before transmit: • If channel sensed idle: transmit entire frame • If channel sensed busy, wait a random amount of time and sense the channel again • Human analogy: don’t interrupt others! 5: DataLink Layer

  33. CSMA collisions spatial layout of nodes 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 propagation delay in determining collision probability: The longer is propagation delay, the larger is the chance that a carrier-sensing node is not able to sense a transmission that has already begun at another node 5: DataLink Layer

  34. CSMA/CD (Collision Detection) CSMA/CD: carrier sensing, deferral as in CSMA • Listen to channel while transmitting • If collision detected, stop transmitting, reducing channel wastage 5: DataLink Layer

  35. “Taking Turns” protocols channel partitioning protocols: • share channel efficiently and fairly at high load • inefficient at low load: 1/N bandwidth allocated even if only 1 active node Random access protocols • efficient at low load: single node can fully utilize channel • high load: collision overhead “taking turns” protocols look for best of both worlds! 5: DataLink Layer

  36. “Taking Turns” protocols Token passing: • decentralized: no master node • token passed from one node to next sequentially. • when receive a token: • send up to a maximum number of frames if has frames to send • forward token to next node • concerns: • latency • single point of failure (token) Polling: • master node “invites” each node to transmit in turn • concerns: • polling delay • single point of failure (master node) 5: DataLink Layer

  37. Summary of multiple access protocols • What do you do with a shared media? • Channel Partitioning, by time, frequency or code • Time Division, Frequency Division, Code Division • Random access • ALOHA, Slotted-ALOHA, CSMA, CSMA/CD • Taking-turns • polling from a master node, token passing 5: DataLink Layer

  38. LAN technologies • addressing • Ethernet • hubs, bridges, switches • 802.11 5: DataLink Layer

  39. LAN Addresses 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 adaptor to another physically-connected adaptor (same network) • 48 bit MAC address (for most LANs) burned in the adapter ROM 5: DataLink Layer

  40. LAN Addresses Each adapter on LAN has unique LAN address 5: DataLink Layer

  41. LAN Address (more) • MAC address allocation administered by IEEE • manufacturer buys portion of MAC address space (to assure uniqueness) • MAC flat address => portability • does not change no matter where the adaptor goes • IP hierarchical address NOT portable • depends on IP network to which node is attached • Analogy: (a) MAC address: like Social Security Number (b) IP address: like postal address 5: DataLink Layer

  42. 223.1.1.1 223.1.2.1 E B A 223.1.1.2 223.1.2.9 223.1.1.4 223.1.2.2 223.1.3.27 223.1.1.3 223.1.3.2 223.1.3.1 Recall earlier routing discussion Starting at A, given IP datagram addressed to B: • look up net. address of B, find B on same net. as A • link layer send datagram to B inside link-layer frame frame dest, source address datagram source, dest address A’s IP addr B’s IP addr B’s MAC addr A’s MAC addr IP payload datagram frame • When adaptor in B receives the frame, pass datagram to IP • Other adaptors discard the frame 5: DataLink Layer

  43. Question: how to determine MAC address of B knowing B’s IP address? ARP: Address Resolution Protocol (RFC826) • Each IP node (Host, Router) on LAN has an 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) 5: DataLink Layer

  44. A wants to send a datagram to B on the same LAN Suppose B’s MAC address is not in A’s ARP table A broadcasts (using broadcast address FF-FF-FF-FF-FF-FF) an ARP request packet, containing A’s IP address, A’s MAC address and B's IP address All adaptors on LAN receive ARP request Every node: if A’s IP-to-MAC mapping is in table, update table B: replies to A (unicast) with its MAC address, also adds A into its ARP table if it’s not there A receives the ARP reply, adds B's IP and MAC addresses to its ARP table. Soft state: IP-to-MAC address pair in ARP table times out (goes away) unless refreshed ARP is “plug-and-play”: nodes create their ARP tables without intervention from network administrator ARP resolves IP addresses only for nodes on the same LAN ARP protocol 5: DataLink Layer

  45. Routing to another LAN walkthrough: send datagram from A to B via R assume A knows B’s IP address • Two ARP tables in router R, one for each IP network (LAN) A R B 5: DataLink Layer

  46. A creates datagram with source A, destination B • A uses ARP to get R’s MAC address for 111.111.111.110 • A creates link-layer frame with R's MAC address as dest, frame contains A-to-B IP datagram • A’s data link layer sends frame • R’s data link layer receives frame • R removes IP datagram from Ethernet frame, sees it’s destined to B • R uses ARP to get B’s MAC address • R creates frame containing A-to-B IP datagram, sends to B A R B 5: DataLink Layer

  47. Ethernet (IEEE 802.3) “dominant” LAN technology: • first widely deployed LAN technology • simpler, cheaper than token ring, FDDI, and ATM • Lesson learned: KISS (Keep It Simple, Stupid) • kept up with speed race: 10, 100, 1000 Mbps Metcalfe’s Ethernet sketch 5: DataLink Layer

  48. Ethernet Frame Structure Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame Preamble: • 7 bytes with pattern 10101010 followed by one byte with pattern 10101011 • used to synchronize receiver, sender clock rates 5: DataLink Layer

  49. Ethernet Frame Structure (more) • Addresses: 6 bytes each • if adapter receives frame with matching destination address, or with broadcast address (e.g. ARP request), it passes data in frame to network layer • otherwise, adapter discards frame • Type (2 bytes): indicates the higher layer protocol, mostly IP but others may be supported (such as Novell IPX and AppleTalk) • Data (46-1500 bytes): MTU is 1500 bytes, MIN frame size = 46 + 18 = 64 bytes = 512 bits • CRC (4 bytes): checked at receiver, if error is detected, the frame is simply dropped 5: DataLink Layer

  50. Unreliable, connectionless service • Connectionless: No handshaking between sending and receiving adapter. • Unreliable: receiving adapter doesn’t send ACKs or NAKs to sending adapter • stream of datagrams passed to network layer can have gaps • gaps will be filled if app is using TCP • otherwise, app will see the gaps 5: DataLink Layer

More Related