Chapter 5 Chapter 5: The Data Link Layer Link Layer and LANs Our goals: understand principles behind data link layer services: error detection, correction sharing a broadcast channel: multiple access A note on the use of these ppt slides: link layer addressing We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you can add, modify, and delete slides reliable data transfer, flow control: done! (including this one) and slide content to suit your needs. They obviously Computer Networking: represent a lot of work on our part. In return for use, we only ask the A Top Down Approach instantiation and implementation of various link following: 5th edition. If you use these slides (e.g., in a class) in substantially unaltered form, layer technologies that you mention their source (after all, we’d like people to use our book!) Jim Kurose, Keith Ross If you post any slides in substantially unaltered form on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and Addison-Wesley, April note our copyright of this material. 2009.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2009 J.F Kurose and K.W. Ross, All Rights Reserved 5: DataLink Layer 5-1 5: DataLink Layer 5-2
Link Layer Link Layer: Introduction Some terminology: 5.1 Introduction and 5.5 Ethernet hosts and routers are nodes services 5.6 Link-layer switches communication channels that connect adjacent nodes 5.2 Error detection 5.7 PPP along communication path are links and correction 5.8 Link virtualization: wired links 5.3Multiple access MPLS wireless links protocols LANs 5.4 Link-layer layer-2 packet is a frame, encapsulates datagram Addressingv
data-link layer has responsibility of transferring datagram from one node to adjacent node over a link
5: DataLink Layer 5-3 5: DataLink Layer 5-5
1 Link Layer: Link layer: context Introduction 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 rdt over link
5: DataLink Layer 5-6 5: DataLink Layer 5-8
Link Layer Services Link Layer Services (more)
framing, link access: flow control: encapsulate datagram into frame, adding header, trailer pacing between adjacent sending and receiving nodes channel access if shared medium error detection: “MAC” addresses used in frame headers to identify errors caused by signal attenuation, noise. source, dest receiver detects presence of errors: • different from IP address! • signals sender for retransmission or drops frame reliable delivery between adjacent nodes error correction: we learned how to do this already (chapter 3)! receiver identifies and corrects bit error(s) without seldom used on low bit-error link (fiber, some twisted resorting to retransmission pair) wireless links: high error rates half-duplex and full-duplex with half duplex, nodes at both ends of link can transmit, but not at same time
5: DataLink Layer 5-10 5: DataLink Layer 5-11
2 Where is the link layer implemented? Where is the link layer implemented?
in each and every host link layer implemented in “adaptor” (aka network interface card NIC) Ethernet card, PCMCI card, 802.11 card implements link, physical layer attaches into host’s system buses combination of hardware, software, firmware
5: DataLink Layer 5-13 5: DataLink Layer 5-14
Adaptors Communicating Adaptors Communicating
frame frame datagram datagram sending host receiving host sending host receiving host
sending side: receiving side encapsulates datagram in looks for errors, rdt, flow frame control, etc adds error checking bits, extracts datagram, passes rdt, flow control, etc. to upper layer at receiving side 5: DataLink Layer 5-16 5: DataLink Layer 5-17
3 Link Layer Error Detection
5.1 Introduction and 5.5 Ethernet EDC= Error Detection and Correction bits services 5.6 Link-layer switches (redundancy) 5.2 Error detection 5.7 PPP D = Data protected by error checking, may and correction 5.8 Link virtualization: include header fields 5.3Multiple access MPLS protocols • Error detection not 100% reliable! 5.4 Link-layer • protocol may miss some errors, but rarely Addressing • larger EDC field yields better detection and correction
5: DataLink Layer 5-18 5: DataLink Layer 5-20
Error Detection Parity Checking
Single Bit Parity: Detect single bit errors or one-dimensional bit parity
Bit Parity:
5: DataLink Layer 5-21 5: DataLink Layer 5-22
4 Parity Checking (Cont) Internet checksum (review)
Two Dimensional Bit Parity: Goal: detect “errors” (e.g., flipped bits) in transmitted Detect and correct double bit errors or two-dimensional bit parity packet (note: used at transport layer only)
Sender: Receiver: compute checksum of treat segment contents received segment as sequence of 16-bit integers check if computed checksum equals checksum field value: checksum: addition (1’s complement sum) of NO - error detected segment contents YES - no error detected. sender puts checksum But maybe errors value into UDP checksum nonetheless? field
5: DataLink Layer 5-23 5: DataLink Layer 5-24
Checksumming: Cyclic Redundancy Check CRC Example
view data bits, D, as a binary number Want: choose r+1 bit pattern (generator), G goal: choose r CRC bits, R, such that equivalently:
5: DataLink Layer 5-25 5: DataLink Layer 5-26
5 Link Layer Multiple Access Links and Protocols Two types of “links”: 5.1 Introduction and 5.5 Ethernet point-to-point services 5.6 Link-layer switches PPP for dial-up access point-to-point link between 5.2 Error detection 5.7 PPP Ethernet switch and host and correction 5.8 Link virtualization: broadcast (shared wire or 5.3Multiple access MPLS medium) protocols old-fashioned Ethernet 5.4 Link-layer upstream HFC Addressing 802.11 wireless LAN
5: DataLink Layer 5-27 5: DataLink Layer 5-28
Multiple Access protocols MAC Protocols: a taxonomy
single shared broadcast channel Three broad classes: two or more simultaneous transmissions by nodes: Channel Partitioning interference divide channel into smaller “pieces” (time slots, frequency, code) collision if node receives two or more signals at the same time allocate piece to node for exclusive use Random Access Multiple Access Protocol channel not divided, allow collisions distributed algorithm that determines how nodes “recover” from collisions share channel, i.e., determine when node can transmit “Taking turns” communication about channel sharing must use channel nodes take turns, but nodes with more to send can take itself! longer turns
5: DataLink Layer 5-29 5: DataLink Layer 5-30
6 Channel Partitioning MAC protocols: TDMA Channel Partitioning MAC protocols: FDMA
TDMA: time division multiple access FDMA: frequency division multiple access access to channel in "rounds" channel spectrum divided into frequency bands each station gets fixed length slot (length = pkt each station assigned fixed frequency band trans time) in each round unused transmission time in frequency bands go idle unused slots go idle example: 6-station LAN, 1,3,4 have pkt, frequency example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 bands 2,5,6 idle idle
6-slot frame 1 3 4 1 3 4
FDM cable frequency bands frequency
5: DataLink Layer 5-31 5: DataLink Layer 5-32
Random Access Protocols CSMA (Carrier Sense Multiple Access)
When node has packet to send transmit at full channel data rate R. CSMA: listen before transmit: no a priori coordination among nodes If channel sensed idle: transmit entire frame ➜ two or more transmitting nodes “collision”, If channel sensed busy, defer transmission random access MAC protocol specifies: how to detect collisions how to recover from collisions (e.g., via delayed human analogy: don’t interrupt others! retransmissions) Examples of random access MAC protocols: slotted ALOHA ALOHA CSMA, CSMA/CD, CSMA/CA
5: DataLink Layer 5-33 5: DataLink Layer 5-34
7 CSMA collisions spatial layout of nodes CSMA/CD (Collision Detection) collisions can still occur: CSMA/CD: carrier sensing, deferral as in CSMA propagation delay means collisions detected within short time two nodes may not hear each other’s transmission colliding transmissions aborted, reducing channel wastage collision: entire packet transmission collision detection: time wasted easy in wired LANs: measure signal strengths, note: compare transmitted, received signals role of distance & propagation difficult in wireless LANs: received signal strength delay in determining collision overwhelmed by local transmission strength probability human analogy: the polite conversationalist
5: DataLink Layer 5-35 5: DataLink Layer 5-36
CSMA/CD collision detection “Taking Turns” MAC protocols
Polling: master node “invites” slave nodes data to transmit in turn poll typically used with master “dumb” slave devices data concerns: polling overhead latency slaves single point of failure (master)
5: DataLink Layer 5-37 5: DataLink Layer 5-38
8 “Taking Turns” MAC protocols Link Layer
Token passing: T 5.1 Introduction and 5.5 Ethernet control token passed services from one node to next 5.6 Link-layer switches sequentially. 5.2 Error detection 5.7 PPP and correction token message (nothing 5.8 Link virtualization: 5.3Multiple access concerns: to send) MPLS T protocols token overhead 5.4 Link-Layer latency Addressing single point of failure (token)
data
5: DataLink Layer 5-39 5: DataLink Layer 5-40
MAC Addresses and ARP LAN Addresses and ARP
Each adapter on LAN has unique LAN address 32-bit IP address: network-layer address 1A-2F-BB-76-09-AD Broadcast address = used to get datagram to destination IP subnet FF-FF-FF-FF-FF-FF MAC (or LAN or physical or Ethernet) address: LAN (wired or = adapter function: get frame from one interface to another wireless) 71-65-F7-2B-08-53 physically-connected interface (same network) 58-23-D7-FA-20-B0 48 bit MAC address (for most LANs)
0C-C4-11-6F-E3-98
5: DataLink Layer 5-41 5: DataLink Layer 5-42
9 LAN Address (more) ARP: Address Resolution Protocol
Each IP node (host, MAC address allocation administered by Question: how to determine MAC address of B router) on LAN has IEEE knowing B’s IP address? ARP table Manufacturer buys portion of MAC ARP table: IP/MAC address space (to assure uniqueness) 137.196.7.78 address mappings for 1A-2F-BB-76-09-AD Analogy: some LAN nodes 137.196.7.23 137.196.7.14 < IP address; MAC address; TTL> (a) MAC address: like Social Security Number TTL (Time To Live): time (b) IP address: like postal address LAN after which address 71-65-F7-2B-08-53 mapping will be forgotten 58-23-D7-FA-20-B0 (typically 20 min)
0C-C4-11-6F-E3-98 137.196.7.88
5: DataLink Layer 5-43 5: DataLink Layer 5-44
Link Layer Ethernet Ethernet is a link layer protocol in the TCP/IP 5.1 Introduction and 5.5 Ethernet stack, describing how networked devices can services 5.6 Link-layer switches format data for transmission to other network devices on the same network segment, and how to 5.2 Error detection 5.7 PPP and correction put that data out on the network connection. 5.8 Link virtualization: 5.3Multiple access MPLS protocols 5.4 Link-Layer Addressing
Metcalfe’s Ethernet sketch
5: DataLink Layer 5-45 Sumber: searchnetworking.techtarget.com/definition/Ethernet 5: DataLink Layer 5-46
10 Star topology Ethernet CSMA/CD algorithm
bus topology popular through mid 90s all nodes in same collision domain (can collide with each 1. NIC receives datagram 4. If NIC detects another other) from network layer, transmission while today: star topology prevails creates frame transmitting, aborts and active switch in center 2. If NIC senses channel idle, sends jam signal each “spoke” runs a (separate) Ethernet protocol (nodes starts frame transmission 5. After aborting, NIC do not collide with each other) If NIC senses channel enters exponential busy, waits until channel backoff: after mth idle, then transmits collision, NIC chooses K at 3. If NIC transmits entire random from frame without detecting {0,1,2,…,2m-1}. NIC waits another transmission, NIC K·512 bit times, returns to switch is done with frame ! Step 2 bus: coaxial cable star 5: DataLink Layer 5-47 5: DataLink Layer 5-48
Ethernet’s CSMA/CD (more) CSMA/CD efficiency
Jam Signal: make sure all Exponential Backoff: other transmitters are Goal: adapt retransmission Tprop = max prop delay between 2 nodes in LAN aware of collision; 48 bits attempts to estimated ttrans = time to transmit max-size frame Bit time: .1 microsec for 10 current load Mbps Ethernet ; heavy load: random wait 1 for K=1023, wait time is will be longer efficiency about 50 msec first collision: choose K from 1 5t prop/ttrans {0,1}; delay is K· 512 bit transmission times efficiency goes to 1 after second collision: choose See/interact with Java as tprop goes to 0 K from {0,1,2,3}… applet on AWL Web site: as ttrans goes to infinity highly recommended ! after ten collisions, choose K from {0,1,2,3,4,…,1023} better performance than ALOHA: and simple, cheap, decentralized!
5: DataLink Layer 5-49 5: DataLink Layer 5-50
11 802.3 Ethernet Standards: Link & Physical Layers Link Layer many different Ethernet standards common MAC protocol and frame format 5.1 Introduction and 5.5 Ethernet services different speeds: 2 Mbps, 10 Mbps, 100 Mbps, 5.6 Link-layer switches, 1Gbps, 10G bps 5.2 Error detection LANs, VLANs different physical layer media: fiber, cable and correction 5.7 PPP 5.3 Multiple access 5.8 Link virtualization: protocols MPLS MAC protocol application 5.4 Link-layer and frame format transport Addressing network 100BASE-TX 100BASE-T2 100BASE-FX
link 100BASE-T4 100BASE-SX 100BASE-BX physical
copper (twister fiber physical layer
pair) physical layer 5: DataLink Layer 5-51 5: DataLink Layer 5-52
Hubs Switch … physical-layer (“dumb”) repeaters: link-layer device: smarter than hubs, take bits coming in one link active role go out all other links store, forward Ethernet frames at same rate twisted pair examine incoming frame’s MAC address, all nodes connected to selectively forward frame to one-or-more hub can collide with outgoing links when frame is to be forwarded on one another hub segment, uses CSMA/CD to access segment no frame buffering transparent no CSMA/CD at hub: hosts are unaware of presence of switches host NICs detect collisions plug-and-play, self-learning switches do not need to be configured
5: DataLink Layer 5-53 5: DataLink Layer 5-54
12 Switch: allows multiple simultaneous Switch Table transmissions A A Q: how does switch know that hosts have dedicated, C’ B A’ reachable via interface 4, C’ B direct connection to switch B’ reachable via interface 5? switches buffer packets 1 2 1 2 3 A: each switch has a switch 3 Ethernet protocol used on 6 6 each incoming link, but no 5 4 table, each entry: 5 4 collisions; full duplex (MAC address of host, interface C to reach host, time stamp) C each link is its own collision domain looks like a routing table! B’ A’ B’ A’ switching: A-to-A’ and B- Q: how are entries created, to-B’ simultaneously, switch with six interfaces maintained in switch table? switch with six interfaces without collisions (1,2,3,4,5,6) (1,2,3,4,5,6) something like a routing not possible with dumb hub protocol?
5: DataLink Layer 5-55 5: DataLink Layer 5-56
Source: A Source: A Switch: self-learning Dest: A’ Self-learning, Dest: A’ A A A’ forwarding: A A A’ switch learns which hosts example can be reached through C’ B C’ B which interfaces 1 frame destination 1 when frame received, 2 2 6 3 unknown: flood A6 A’ 3 switch “learns” location of 4 4 sender: incoming LAN 5 destination A 5 segment C location known: C records sender/location selective send A’ A pair in switch table B’ A’ B’ A’
MAC addr interface TTL MAC addr interface TTL A 1 60 Switch table A 1 60 Switch table (initially empty) A’ 4 60 (initially empty)
5: DataLink Layer 5-57 5: DataLink Layer 5-58
13 Interconnecting switches Self-learning multi-switch example
Suppose C sends frame to I, I responds to C switches can be connected together
S4 1 S4
S1 S1 2 S3 S3 A S2 A S2 F F I I B C D B C D H H E G E G
Q: sending from A to G - how does S1 know to Q: show switch tables and packet forwarding in S1, forward frame destined to F via S4 and S3? S2, S3, S4 A: self learning! (works exactly the same as in single-switch case!)
5: DataLink Layer 5-59 5: DataLink Layer 5-60
Switches vs. Routers VLANs: motivation both store-and-forward devices routers: network layer devices (examine network layer headers) What’s wrong with this picture? What happens if: switches are link layer devices CS user moves office to EE, but wants connect to CS routers maintain routing tables, implement routing switch? algorithms single broadcast domain: switches maintain switch tables, implement all layer-2 broadcast traffic (ARP, DHCP) filtering, learning algorithms crosses entire LAN Computer Computer (security/privacy, Science Electrical efficiency issues) Engineering Engineering each lowest level switch has only few ports in use
5: DataLink Layer 5-61 5: DataLink Layer 5-62
14 Port-based VLAN: switch ports grouped VLANs (by switch management software) so Link Layer that single physical switch ……
1 7 9 15 5.1 Introduction and 5.5 Ethernet Virtual Local 2 8 10 16 services Area Network 5.6 Link-layer switches … … 5.2 Error detection 5.7 PPP Switch(es) supporting and correction VLAN capabilities can Electrical Engineering Computer Science 5.8 Link virtualization: (VLAN ports 1-8) (VLAN ports 9-15) be configured to 5.3Multiple access MPLS define multiple virtual … operates as multiple virtual switches protocols LANS over single 5.4 Link-Layer physical LAN 1 7 9 15 Addressing infrastructure. 2 8 10 16
… …
Electrical Engineering Computer Science (VLAN ports 1-8) (VLAN ports 9-16)
5: DataLink Layer 5-63 5: DataLink Layer 5-64
Point to Point Data Link Control PPP Design Requirements [RFC 1557]
one sender, one receiver, one link: easier than packet framing: encapsulation of network-layer broadcast link: datagram in data link frame no Media Access Control carry network layer data of any network layer protocol (not just IP) at same time no need for explicit MAC addressing ability to demultiplex upwards e.g., dialup link, ISDN line bit transparency: must carry any bit pattern in the popular point-to-point DLC protocols: data field PPP (point-to-point protocol) error detection (no correction) HDLC: High level data link control (Data link used to be considered “high layer” in protocol connection liveness: detect, signal link failure to stack! network layer network layer address negotiation: endpoint can learn/configure each other’s network address
5: DataLink Layer 5-65 5: DataLink Layer 5-66
15 PPP non-requirements Link Layer
no error correction/recovery 5.1 Introduction and 5.5 Ethernet no flow control services 5.6 Link-layer switches out of order delivery OK 5.2 Error detection 5.7 PPP and correction no need to support multipoint links (e.g., polling) 5.8 Link virtualization: 5.3Multiple access MPLS protocols 5.4 Link-Layer Error recovery, flow control, data re-ordering Addressing all relegated to higher layers!
5: DataLink Layer 5-67 5: DataLink Layer 5-68
Multiprotocol label switching (MPLS) MPLS capable routers
initial goal: speed up IP forwarding by using fixed a.k.a. label-switched router length label (instead of IP address) to do forwards packets to outgoing interface based forwarding only on label value (don’t inspect IP address) borrowing ideas from Virtual Circuit (VC) approach MPLS forwarding table distinct from IP forwarding but IP datagram still keeps IP address! tables signaling protocol needed to set up forwarding PPP or Ethernet MPLS header IP header remainder of link-layer frame RSVP-TE header forwarding possible along paths that IP alone would not allow (e.g., source-specific routing) !! use MPLS for traffic engineering label Exp S TTL must co-exist with IP-only routers 20 3 1 5 5: DataLink Layer 5-69 5: DataLink Layer 5-70
16 MPLS forwarding tables
in out out label label dest interface
10 A 0 in out out 12 D 0 label label dest interface 8 A 1 10 6 A 1 12 9 D 0
R6 0 0 D 1 1 R4 R3 R5 0 0 A R2 R1 in out out label label dest interface in out out label label dest interface 8 6 A 0 6 - A 0 5: DataLink Layer 5-71
17