1 / 120

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.

yepa
Download Presentation

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 The Data Link Layer DataLink Layer

  2. Introduction and services Error detection and correction Multiple access protocols LAN addresses and ARP Ethernet Hubs, bridges, and switches Wireless links and LANs PPP ATM outline 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 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 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 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 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 DataLink Layer

  8. Framing • Data link breaks physical layer stream of bits into frames ...010110100101001101010010... • How does receiver detect boundaries? • Length count • Special characters • Bit stuffing • Special encoding DataLink Layer

  9. Length count • First field is length of frame • Count until end • Then, look for next frame • Problems? DataLink Layer

  10. Length Count Problems DataLink Layer

  11. Special Characters • Reserved characters for beginning and end • Beginning: • DLE STX (Data-Link Escape, Start of TeXt) • End: • DLE ETX (Data-Link Escape, End of TeXt) • Problems? • Solution? DataLink Layer

  12. Character Stuffing • Replace DLE in data with DLE DLE (reverse) • Not all architectures are character oriented! DataLink Layer

  13. Garbaged frames ok, just keep scanning Problem? Wasted bandwidth/processing How much in proj1? Bit Stuffing Frame delimiter: 01111110 DataLink Layer

  14. Lines becoming digital errors rare Copper the “last mile” errors infrequent Wireless errors common Errors are here for a while Plus, consecutive errors bursts Errors DataLink Layer

  15. 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 DataLink Layer

  16. 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 DataLink Layer

  17. 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) DataLink Layer

  18. 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! DataLink Layer

  19. 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 DataLink Layer

  20. 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 DataLink Layer

  21. Local Area Network Protocols 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 DataLink Layer

  22. 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 DataLink Layer

  23. 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 DataLink Layer

  24. Multiple Access Protocols: a taxonomy Three broad classes: • Channel Partitioning Protocols • divide channel into smaller “pieces” (time slots, frequency) • 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 DataLink Layer

  25. 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 DataLink Layer

  26. 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! DataLink Layer

  27. 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 DataLink Layer

  28. 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 DataLink Layer

  29. 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 DataLink Layer

  30. 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 DataLink Layer

  31. 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! DataLink Layer

  32. 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] DataLink Layer

  33. 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. DataLink Layer

  34. 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! DataLink Layer

  35. 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 DataLink Layer

  36. 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 DataLink Layer

  37. “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! DataLink Layer

  38. “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) DataLink Layer

  39. 802.4 - Token Bus Physical line or tree, but logical ring. Stations know “left” and “right” stations. One token “passed” from station to station. Only station with token can transmit. DataLink Layer

  40. Token Bus • Physical order of stations does not matter • line is broadcast medium • “Send” token by addressing neighbor • Provisions for adding, deleting stations • Physical layer is not at all compatible with 802.3 • A very complicated standard DataLink Layer

  41. Token Bus Sub-Layer Protocol • Send for some time, then pass token • If no data, then pass token right away • Traffic classes: 0, 2, 4 and 6 (highest) • internal substations for each station • Set timer for how long to transmit • ex: 50 stations and 10 Mbps • want priority 6 to have 1/3 bandwidth • then 67 Kbps each, enough for voice + control DataLink Layer

  42. Token Bus Frame Format • No length field • Data can be much larger (timers prevent hogs) • Frame control • ack required? • Data vs. Control frame - how is ring managed? DataLink Layer

  43. Token Bus Control Frame Summary DataLink Layer

  44. Token Bus Frame Format • No length field • Data can be much larger (timers prevent hogs) • Frame control • ack required? • Data vs. Control frame - how is ring managed? DataLink Layer

  45. Token Bus Control Frame Summary DataLink Layer

  46. 802.5 - Token Ring • Around for years • Physical point-to-point connections • Bounded delay DataLink Layer

  47. 802.5 - Token Ring • Around for years • Physical point-to-point connections • Bounded delay DataLink Layer

  48. “Token” Part of Token Ring • Token circles around the ring • note, token needs to “fit” on the ring • if too big, then stations have to buffer, always • When station wants to transmit, “seizes” token • looks like a data frame but for 1 bit • Puts its data bits onto ring • no physical frame limit • Once bits go around, removed by sender • Regenerates token • Acknowledgement by adding bit DataLink Layer

  49. Brief Note on Performance • Light load • token circles • station grabs, transmits, regenerates token • Heavy load • each station sends, regenerates • next station grabs token • round-robin • nearly 100% efficiency DataLink Layer

  50. Token Ring Sublayer Protocol • Delimiters use invalid Manchester codes • End delimiter has bit for error • Access control has token bit • Frame control has Arrive and Check bits • A=0, C=0 destination not present • A=1, C=0 destination up, not accept frame • A=1, C=1 destination up, frame copied DataLink Layer

More Related