* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Link Layer
Survey
Document related concepts
Airborne Networking wikipedia , lookup
Zero-configuration networking wikipedia , lookup
Network tap wikipedia , lookup
Cracking of wireless networks wikipedia , lookup
Computer network wikipedia , lookup
Deep packet inspection wikipedia , lookup
IEEE 802.1aq wikipedia , lookup
Point-to-Point Protocol over Ethernet wikipedia , lookup
Wake-on-LAN wikipedia , lookup
Multiprotocol Label Switching wikipedia , lookup
Asynchronous Transfer Mode wikipedia , lookup
Internet protocol suite wikipedia , lookup
Recursive InterNetwork Architecture (RINA) wikipedia , lookup
Transcript
Chapter 5 Link Layer and LANs A note on the use of these ppt slides: 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 (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following: If you use these slides (e.g., in a class) in substantially unaltered form, that you mention their source (after all, we’d like people to use our book!) 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 note our copyright of this material. Computer Networking: A Top Down Approach Featuring the Internet, 3rd edition. Jim Kurose, Keith Ross Addison-Wesley, July 2004. Thanks and enjoy! JFK/KWR All material copyright 1996-2004 J.F Kurose and K.W. Ross, All Rights Reserved 5: DataLink Layer 5-1 Chapter 5: The Data Link Layer Our goals: r understand principles behind data link layer services: m m m m error detection, correction sharing a broadcast channel: multiple access link layer addressing reliable data transfer, flow control: done! r instantiation and implementation of various link layer technologies 5: DataLink Layer 5-2 Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization: ATM and MPLS 5: DataLink Layer 5-3 Link Layer: Introduction Some terminology: r r hosts and routers are nodes communication channels that connect adjacent nodes along communication path are links m m m r “link” wired links wireless links LANs layer-2 packet is a frame, encapsulates datagram data-link layer has responsibility of transferring datagram from one node to adjacent node over a link 5: DataLink Layer 5-4 Link layer: context r Datagram transferred by different link protocols over different links: m e.g., Ethernet on first link, frame relay on intermediate links, 802.11 on last link r Each link protocol provides different services m e.g., may or may not provide rdt over link transportation analogy r trip from Princeton to Lausanne m limo: Princeton to JFK m plane: JFK to Geneva m train: Geneva to Lausanne r tourist = datagram r transport segment = communication link r transportation mode = link layer protocol r travel agent = routing algorithm 5: DataLink Layer 5-5 Link Layer Services r Framing, link access: m m m 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! r Reliable delivery between adjacent nodes m we learned how to do this already (chapter 3)! m seldom used on low bit error link (fiber, some twisted pair) m wireless links: high error rates • Q: why both link-level and end-end reliability? 5: DataLink Layer 5-6 Link Layer Services (more) r Flow Control: m pacing between adjacent sending and receiving nodes r Error Detection: m m errors caused by signal attenuation, noise. receiver detects presence of errors: • signals sender for retransmission or drops frame r Error Correction: m receiver identifies and corrects bit error(s) without resorting to retransmission r Half-duplex and full-duplex m with half duplex, nodes at both ends of link can transmit, but not at same time 5: DataLink Layer 5-7 Adaptors Communicating datagram sending node frame adapter rcving node link layer protocol frame adapter r link layer implemented in r receiving side “adaptor” (aka NIC) m looks for errors, rdt, flow control, etc m Ethernet card, PCMCI m extracts datagram, passes card, 802.11 card to rcving node r sending side: r adapter is semim encapsulates datagram in autonomous a frame m adds error checking bits, r link & physical layers rdt, flow control, etc. 5: DataLink Layer 5-8 Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization: ATM 5: DataLink Layer 5-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 5-10 Parity Checking Single Bit Parity: Detect single bit errors Two Dimensional Bit Parity: Detect and correct single bit errors 0 0 5: DataLink Layer 5-11 Internet checksum Goal: detect “errors” (e.g., flipped bits) in transmitted segment (note: used at transport layer only) Sender: r r r treat segment contents as sequence of 16-bit integers checksum: addition (1’s complement sum) of segment contents sender puts checksum value into UDP checksum field Receiver: r r compute checksum of received segment check if computed checksum equals checksum field value: m NO - error detected m YES - no error detected. But maybe errors nonetheless? More later …. 5: DataLink Layer 5-12 Checksumming: Cyclic Redundancy Check r r r view data bits, D, as a binary number choose r+1 bit pattern (generator), G goal: choose r CRC bits, R, such that m m m r <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 widely used in practice (ATM, HDCL) 5: DataLink Layer 5-13 CRC Example Want: D.2r XOR R = nG equivalently: D.2r = nG XOR R equivalently: if we divide D.2r by G, want remainder R R = remainder[ D.2r G ] 5: DataLink Layer 5-14 Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization: ATM 5: DataLink Layer 5-15 Multiple Access Links and Protocols Two types of “links”: r point-to-point m PPP for dial-up access m point-to-point link between Ethernet switch and host r broadcast (shared wire or medium) m traditional Ethernet m upstream HFC m 802.11 wireless LAN 5: DataLink Layer 5-16 Multiple Access protocols r single shared broadcast channel r two or more simultaneous transmissions by nodes: interference m collision if node receives two or more signals at the same time multiple access protocol r distributed algorithm that determines how nodes share channel, i.e., determine when node can transmit r communication about channel sharing must use channel itself! m no out-of-band channel for coordination 5: DataLink Layer 5-17 Ideal Mulitple Access Protocol Broadcast channel of rate R bps 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: m m no special node to coordinate transmissions no synchronization of clocks, slots 4. Simple 5: DataLink Layer 5-18 MAC Protocols: a taxonomy Three broad classes: r Channel Partitioning m m divide channel into smaller “pieces” (time slots, frequency, code) allocate piece to node for exclusive use r Random Access m channel not divided, allow collisions m “recover” from collisions r “Taking turns” m Nodes take turns, but nodes with more to send can take longer turns 5: DataLink Layer 5-19 Channel Partitioning MAC protocols: TDMA TDMA: time division multiple access r access to channel in "rounds" r each station gets fixed length slot (length = pkt trans time) in each round r unused slots go idle r example: 6-station LAN, 1,3,4 have pkt, slots 2,5,6 idle 5: DataLink Layer 5-20 Channel Partitioning MAC protocols: FDMA FDMA: frequency division multiple access r channel spectrum divided into frequency bands r each station assigned fixed frequency band r unused transmission time in frequency bands go idle r example: 6-station LAN, 1,3,4 have pkt, frequency frequency bands bands 2,5,6 idle 5: DataLink Layer 5-21 Random Access Protocols r When node has packet to send m transmit at full channel data rate R. m no a priori coordination among nodes r two or more transmitting nodes ➜ “collision”, r random access MAC protocol specifies: m how to detect collisions m how to recover from collisions (e.g., via delayed retransmissions) r Examples of random access MAC protocols: m slotted ALOHA m ALOHA m CSMA, CSMA/CD, CSMA/CA 5: DataLink Layer 5-22 Slotted ALOHA Assumptions r all frames same size r time is divided into equal size slots, time to transmit 1 frame r nodes start to transmit frames only at beginning of slots r nodes are synchronized r if 2 or more nodes transmit in slot, all nodes detect collision Operation r when node obtains fresh frame, it transmits in next slot r no collision, node can send new frame in next slot r if collision, node retransmits frame in each subsequent slot with prob. p until success 5: DataLink Layer 5-23 Slotted ALOHA Pros r single active node can continuously transmit at full rate of channel r highly decentralized: only slots in nodes need to be in sync r simple Cons r collisions, wasting slots r idle slots r nodes may be able to detect collision in less than time to transmit packet r clock synchronization 5: DataLink Layer 5-24 Slotted Aloha efficiency Efficiency is the long-run fraction of successful slots when there are many nodes, each with many frames to send r Suppose N nodes with many frames to send, each transmits in slot with probability p r prob that node 1 has success in a slot = p(1-p)N-1 r prob that any node has a success = Np(1-p)N-1 r For max efficiency with N nodes, find p* that maximizes Np(1-p)N-1 r For many nodes, take limit of Np*(1-p*)N-1 as N goes to infinity, gives 1/e = .37 At best: channel used for useful transmissions 37% of time! 5: DataLink Layer 5-25 Pure (unslotted) ALOHA r unslotted Aloha: simpler, no synchronization r when frame first arrives m transmit immediately r collision probability increases: m frame sent at t0 collides with other frames sent in [t0-1,t0+1] 5: DataLink Layer 5-26 Pure Aloha efficiency P(success by given node) = P(node transmits) . P(no other node transmits in [p0-1,p0] . P(no other node transmits in [p0-1,p0] = p . (1-p)N-1 . (1-p)N-1 = p . (1-p)2(N-1) … choosing optimum p and then letting n -> infty ... Even worse ! = 1/(2e) = .18 5: DataLink Layer 5-27 Aloha efficiency (Slotted Vs Pure) 5: DataLink Layer 5-28 CSMA (Carrier Sense Multiple Access) CSMA: listen before transmit: If channel sensed idle: transmit entire frame r If channel sensed busy, defer transmission r Human analogy: don’t interrupt others! 5: DataLink Layer 5-29 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 distance & propagation delay in determining collision probability 5: DataLink Layer 5-30 CSMA/CD (Collision Detection) CSMA/CD: carrier sensing, deferral as in CSMA m m collisions detected within short time colliding transmissions aborted, reducing channel wastage r collision detection: m easy in wired LANs: measure signal strengths, compare transmitted, received signals m difficult in wireless LANs: receiver shut off while transmitting r human analogy: the polite conversationalist 5: DataLink Layer 5-31 3 States of CSMA/CD (Contention, Idle, Transmission) 5: DataLink Layer 5-32 CSMA/CD collision detection 5: DataLink Layer 5-33 “Taking Turns” MAC protocols channel partitioning MAC protocols: m share channel efficiently and fairly at high load m inefficient at low load: delay in channel access, 1/N bandwidth allocated even if only 1 active node! Random access MAC protocols m efficient at low load: single node can fully utilize channel m high load: collision overhead “taking turns” protocols look for best of both worlds! 5: DataLink Layer 5-34 “Taking Turns” MAC protocols Token passing: Polling: r control token passed from r master node one node to next “invites” slave nodes sequentially. to transmit in turn r token message r concerns: r concerns: m polling overhead m m latency single point of failure (master) m m m token overhead latency single point of failure (token) 5: DataLink Layer 5-35 Summary of MAC protocols r What do you do with a shared media? m Channel Partitioning, by time, frequency or code • Time Division, Frequency Division m Random partitioning (dynamic), • ALOHA, S-ALOHA, CSMA, CSMA/CD • carrier sensing: easy in some technologies (wire), hard in others (wireless) • CSMA/CD used in Ethernet • CSMA/CA used in 802.11 m Taking Turns • polling from a central site, token passing 5: DataLink Layer 5-36 LAN technologies Data link layer so far: m services, error detection/correction, multiple access Next: LAN technologies m m m m addressing Ethernet hubs, switches PPP 5: DataLink Layer 5-37 Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization: ATM 5: DataLink Layer 5-38 MAC Addresses and ARP r 32-bit IP address: m m network-layer address used to get datagram to destination IP subnet r MAC (or LAN or physical or Ethernet) address: m m used to get datagram from one interface to another physically-connected interface (same network) 48 bit MAC address (for most LANs) burned in the adapter ROM 5: DataLink Layer 5-39 LAN Addresses and ARP Each adapter on LAN has unique LAN address 1A-2F-BB-76-09-AD 71-65-F7-2B-08-53 LAN (wired or wireless) Broadcast address = FF-FF-FF-FF-FF-FF = adapter 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 5: DataLink Layer 5-40 LAN Address (more) r MAC address allocation administered by IEEE r manufacturer buys portion of MAC address space (to assure uniqueness) r Analogy: (a) MAC address: like Social Security Number (b) IP address: like postal address r MAC flat address ➜ portability m can move LAN card from one LAN to another r IP hierarchical address NOT portable m depends on IP subnet to which node is attached 5: DataLink Layer 5-41 ARP: Address Resolution Protocol Question: how to determine MAC address of B knowing B’s IP address? 237.196.7.78 1A-2F-BB-76-09-AD 237.196.7.23 r Each IP node (Host, Router) on LAN has ARP table r ARP Table: IP/MAC address mappings for some LAN nodes 237.196.7.14 m LAN 71-65-F7-2B-08-53 237.196.7.88 < IP address; MAC address; TTL> 58-23-D7-FA-20-B0 TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min) 0C-C4-11-6F-E3-98 5: DataLink Layer 5-42 ARP protocol: Same LAN (network) r r r A wants to send datagram to B, and B’s MAC address not in A’s ARP table. A broadcasts ARP query packet, containing B's IP address m Dest MAC address = FF-FF-FF-FF-FF-FF m all machines on LAN receive ARP query B receives ARP packet, replies to A with its (B's) MAC address m frame sent to A’s MAC address (unicast) r A caches (saves) IP-toMAC address pair in its ARP table until information becomes old (times out) m soft state: information that times out (goes away) unless refreshed r ARP is “plug-and-play”: m nodes create their ARP tables without intervention from net administrator 5: DataLink Layer 5-43 Routing to another LAN walkthrough: send datagram from A to B via R assume A know’s B IP address A R B r Two ARP tables in router R, one for each IP network (LAN) 5: DataLink Layer 5-44 r r r r r r r r 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 adapter sends frame R’s adapter receives frame R removes IP datagram from Ethernet frame, sees its 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 5-45 Unicast to server DHCP relay Other netw orks DHCP server Broadcast Host 5: DataLink Layer 5-46 Operation HType HLen Hops Xid Secs Flags ciaddr yiaddr siaddr giaddr chaddr (16 bytes) sname (64 bytes) file (128 bytes) options 5: DataLink Layer 5-47 Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization: ATM 5: DataLink Layer 5-48 Ethernet “dominant” wired LAN technology: r cheap $20 for 100Mbs! r first widely used LAN technology r Simpler, cheaper than token LANs and ATM r Kept up with speed race: 10 Mbps – 10 Gbps Metcalfe’s Ethernet sketch 5: DataLink Layer 5-49 IEEE 802.2 Logical Link Control (LLC) r a)Position of LLC r b) Protocol Format 5: DataLink Layer 5-50 Encoding Bits 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 NRZ Clock Manchester NRZI 5: DataLink Layer 5-51 Manchester encoding r Used in 10BaseT r Each bit has a transition r Allows clocks in sending and receiving nodes to synchronize to each other m no need for a centralized, global clock among nodes! r Hey, this is physical-layer stuff! 5: DataLink Layer 5-52 Encoding (more) 5: DataLink Layer 5-53 Encodings (cont) • 4B/5B -- every 4 bits of data encoded in a 5bit code -- 5bit codes selected to have no more than one leading 0 and no more than two trailing 0s -- thus, never get more than three consecutive 0s -- resulting 5bit codes are transmitted using NRZI -- achieves 80% efficiency 5: DataLink Layer 5-54 Ethernet Cabling 5: DataLink Layer 5-55 Coaxial Cable 5: DataLink Layer 5-56 Coaxial Cable 5: DataLink Layer 5-57 (UTP )Unshielded Twisted Pair Cat5 Cable 5: DataLink Layer 5-58 Cat5 Crimping tool 5: DataLink Layer 5-59 Cat 5 Crimp RJ45 5: DataLink Layer 5-60 Cat5 Tools 5: DataLink Layer 5-61 How to make a Cable r Cutting the wire (Straightly) 5: DataLink Layer 5-62 Crimping 5: DataLink Layer 5-63 Different Connections Crossover Cable Straight Through Cable RJ-45 PIN RJ-45 PIN RJ-45 PIN RJ-45 PIN 1 Rx+ 3 Tx+ 1 Tx+ 1 Rc+ 2 Rc- 6 Tx- 2 Tx- 2 Rc- 3 Tx+ 1 Rc+ 3 Rc+ 3 Tx+ 6 Tx- 2 Rc- 6 Rc- 6 Tx- Note: The standard connector view shown is color-coded for a straight thru cable 5: DataLink Layer 5-64 X-Connect 5: DataLink Layer 5-65 X-connect (PC to PC) or (Hub to Hub) 5: DataLink Layer 5-66 X-connect (PC to PC) or (Hub to Hub) 5: DataLink Layer 5-67 Ethernet Cabling 5: DataLink Layer 5-68 Network Interface Card (NIC) (Adaptor) 5: DataLink Layer 5-69 Hub 5: DataLink Layer 5-70 Original Fast Ethernet Cabling 5: DataLink Layer 5-71 Gigabit Ethernet Cabling 5: DataLink Layer 5-72 Cable Topologies r a)Linear r b)Spine r c) Tree r d) Segmented 5: DataLink Layer 5-73 Bus Topology Transceiver Ethernet cable Adaptor Host 5: DataLink Layer 5-74 Bus Topology 5: DataLink Layer 5-75 Star topology r Bus topology popular through mid 90s r Now star topology prevails r Connection choices: hub or switch (more later) hub or switch 5: DataLink Layer 5-76 Ethernet Overview • History -- developed by Xerox PARC in mid1970s -- roots in Aloha packetradio network -- standardized by Xerox, DEC, and Intel in 1978 -- similar to IEEE 802.3 standard • CSMA/CD -- carrier sense -- multiple access -- collision detection • Frame Format 64 48 48 16 Preamble Dest addr Src addr Type 32 Body CRC 5: DataLink Layer 5-77 Ethernet (cont) • Addresses -- unique, 48bit unicast address assigned to each adapter -- example: 8:0:e4:b1:2 -- broadcast: all 1 s -- multicast: first bit is 1 • Bandwidth: 10Mbps, 100Mbps, 1Gbps • Length: 2500m (500m segments with 4 repeaters) • Problem: Distributed algorithm to provide fair access 5: DataLink Layer 5-78 Transmit Algorithm • If line is idle... -- send immediately -- upper bound message size of 1500 bytes -- must wait 9.6us between backtoback frames • If line is busy... -- wait until idle and transmit immediately -- called 1persistent (special case of ppersistent) 5: DataLink Layer 5-79 Transmit (cont) • If collision... -- jam for 32 bits, then stop transmitting frame -- minimum frame is 64 bytes (header + 46 bytes of data) -- delay and try again • 1st time: 0 or 51.2us • 2nd time: 0, 51.2, or 102.4us • 3rd time51.2, 102.4, or 153.6us • nth time: k x 51.2us, for randomly selected k = 0..2 n 1 • give up after several tries (usually 16) • exponential backoff 5: DataLink Layer 5-80 Ethernet Frame Structure Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame Preamble: r 7 bytes with pattern 10101010 followed by one byte with pattern 10101011 r used to synchronize receiver, sender clock rates 5: DataLink Layer 5-81 Ethernet Frame Structure (more) r Addresses: 6 bytes m if adapter receives frame with matching destination address, or with broadcast address (eg ARP packet), it passes data in frame to net-layer protocol m otherwise, adapter discards frame r Type: indicates the higher layer protocol (mostly IP but others may be supported such as Novell IPX and AppleTalk) r CRC: checked at receiver, if error is detected, the frame is simply dropped 5: DataLink Layer 5-82 Unreliable, connectionless service r Connectionless: No handshaking between sending and receiving adapter. r Unreliable: receiving adapter doesn’t send acks or nacks to sending adapter m m m 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 5-83 Ethernet uses CSMA/CD r No slots r adapter doesn’t transmit if it senses that some other adapter is transmitting, that is, carrier sense r transmitting adapter aborts when it senses that another adapter is transmitting, that is, collision detection r Before attempting a retransmission, adapter waits a random time, that is, random access 5: DataLink Layer 5-84 Ethernet CSMA/CD algorithm 1. Adaptor receives 4. If adapter detects datagram from net layer & another transmission while creates frame transmitting, aborts and sends jam signal 2. If adapter senses channel idle, it starts to transmit 5. After aborting, adapter frame. If it senses enters exponential channel busy, waits until backoff: after the mth channel idle and then collision, adapter chooses transmits a K at random from {0,1,2,…,2m-1}. Adapter 3. If adapter transmits waits K·512 bit times and entire frame without returns to Step 2 detecting another transmission, the adapter is done with frame ! 5: DataLink Layer 5-85 Ethernet’s CSMA/CD (more) Jam Signal: make sure all other transmitters are aware of collision; 48 bits Bit time: .1 microsec for 10 Mbps Ethernet ; for K=1023, wait time is about 50 msec See/interact with Java applet on AWL Web site: highly recommended ! Exponential Backoff: r Goal: adapt retransmission attempts to estimated current load m r r r heavy load: random wait will be longer first collision: choose K from {0,1}; delay is K· 512 bit transmission times after second collision: choose K from {0,1,2,3}… after ten collisions, choose K from {0,1,2,3,4,…,1023} 5: DataLink Layer 5-86 Collision Detection (2tprop) 5: DataLink Layer 5-87 Collision Detection (2tprop) A B A B A B A B (a) (b) (c) (d) 5: DataLink Layer 5-88 CSMA/CD efficiency r Tprop = max prop between 2 nodes in LAN r ttrans = time to transmit max-size frame efficiency 1 1 5t prop / ttrans r Efficiency goes to 1 as tprop goes to 0 r Goes to 1 as ttrans goes to infinity r Much better than ALOHA, but still decentralized, simple, and cheap 5: DataLink Layer 5-89 Performance 5: DataLink Layer 5-90 10BaseT and 100BaseT r 10/100 Mbps rate; latter called “fast ethernet” r T stands for Twisted Pair r Nodes connect to a hub: “star topology”; 100 m max distance between nodes and hub twisted pair hub 5: DataLink Layer 5-91 Repeaters and Multiport Repeaters (Hubs) Hubs are essentially physical-layer repeaters: m bits coming from one link go out all other links m at the same rate m no frame buffering m no CSMA/CD at hub: adapters detect collisions m provides net management functionality twisted pair hub 5: DataLink Layer 5-92 Gbit Ethernet r uses standard Ethernet frame format r allows for point-to-point links and shared r r r r broadcast channels in shared mode, CSMA/CD is used; short distances between nodes required for efficiency uses hubs, called here “Buffered Distributors” Full-Duplex at 1 Gbps for point-to-point links 10 Gbps now ! 5: DataLink Layer 5-93 Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Interconnections: Hubs and switches r 5.7 PPP r 5.8 Link Virtualization: ATM 5: DataLink Layer 5-94 Extending LANs (Interconnecting LANs) 5: DataLink Layer 5-95 Interconnecting with hubs Hub Hub Interconnecting with hubs r Backbone hub interconnects LAN segments r Extends max distance between nodes r But individual segment collision domains become one large collision domain r Can’t interconnect 10BaseT & 100BaseT hub hub hub hub 5: DataLink Layer 5-97 Bridges and Multiport Bridges (Switches) r Link layer device stores and forwards Ethernet frames m examines frame header and selectively forwards frame based on MAC dest address m when frame is to be forwarded on segment, uses CSMA/CD to access segment r transparent m hosts are unaware of presence of switches r plug-and-play, self-learning m switches do not need to be configured m 5: DataLink Layer 5-98 Interconnecting with hubs and Switch 5: DataLink Layer 5-99 Interconnecting with Switches (Forwarding) switch 1 2 hub 3 hub hub • How do determine onto which LAN segment to forward frame? • Looks like a routing problem... 5: DataLink Layer 5-100 Bridge (Switch) Self learning . LANs have physical limitations (e.g., 2500m) . Connect two or more LANs with a bridge -- accept and forward strategy -- level 2 connection (does not add packet header) A B C Port 1 Bridge Port 2 X Y Z . Ethernet Switch = Bridge on Steroids 5: DataLink Layer 5-101 Bridge (Switch) Self learning r A switch has a switch table r entry in switch table: (MAC Address, Interface, Time Stamp) m stale entries in table dropped (TTL can be 60 min) r switch learns which hosts can be reached through which interfaces m when frame received, switch “learns” location of sender: incoming LAN segment m records sender/location pair in switch table m 5: DataLink Layer 5-102 Bridge (Switch) Filtering/Forwarding When switch receives a frame: index switch table using MAC dest address if entry found for destination then{ if dest on segment from which frame arrived then drop the frame else forward the frame on interface indicated } else flood forward on all but the interface on which the frame arrived 5: DataLink Layer 5-103 Bridges and Extended LANs (Example1) . Do not forward when unnecessary . Maintain forwarding table A B C Host Port A 1 Port 1 B 1 Port 2 C 1 X 2 Y 2 Z 2 Bridge X Y Z . Learn table entries based on source address . Table is an optimization; need not be complete . Always forward broadcast frames 5: DataLink Layer 5-104 Switch example2 Suppose C sends frame to D 1 B C A B E G 3 2 hub hub hub A address interface switch 1 1 2 3 I D E F G H r Switch receives frame from from C m notes in bridge table that C is on interface 1 m because D is not in table, switch forwards frame into interfaces 2 and 3 r frame received by D 5: DataLink Layer 5-105 Switch example2 (cntd) Suppose D replies back with frame to C. address interface switch B C hub hub hub A I D E F G A B E G C 1 1 2 3 1 H r Switch receives frame from from D m notes in bridge table that D is on interface 2 m because C is in table, switch forwards frame only to interface 1 r frame received by C 5: DataLink Layer 5-106 Switch: traffic isolation r switch installation breaks subnet into LAN segments r switch filters packets: m same-LAN-segment frames not usually forwarded onto other LAN segments m segments become separate collision domains switch collision domain hub collision domain hub collision domain hub 5: DataLink Layer 5-107 Switches: dedicated access r Switch with many interfaces r Hosts have direct connection to switch r No collisions; full duplex Switching: A-to-A’ and B-to-B’ simultaneously, no collisions A C’ B switch C B’ A’ 5: DataLink Layer 5-108 More on Switches r cut-through switching: frame forwarded from input to output port without first collecting entire frame m slight reduction in latency r combinations of shared/dedicated, 10/100/1000 Mbps interfaces 5: DataLink Layer 5-109 Institutional network to external network mail server web server router switch IP subnet hub hub hub 5: DataLink Layer 5-110 Institutional network 5: DataLink Layer 5-111 Switches vs. Routers r both store-and-forward devices m routers: network layer devices (examine network layer headers) m switches are link layer devices r routers maintain routing tables, implement routing algorithms r switches maintain switch tables, implement filtering, learning algorithms 5: DataLink Layer 5-112 Summary comparison hubs routers switches traffic isolation no yes yes plug & play yes no yes optimal routing cut through no yes no yes no yes 5: DataLink Layer 5-113 More on Bridge-Spanning Tree (SPT) Algorithm • Problem: loops • Bridges run a distributed spanning tree algorithm -- select which bridges actively forward -- developed by Radia Perlman -- now IEEE 802.1 specification (a) (b) 5: DataLink Layer 5-114 SPT Algorithm Overview •Each bridge has unique id (e.g., B1, B2, B3) •Select bridge with smallest id as root •Select bridge on each LAN closest to root as •designated bridge (use id to break ties) •Each bridge forwards frames over each LAN for which it is the designated bridge A B B3 C B5 D B2 B7 E K F B1 G H B6 B4 I J 5: DataLink Layer 5-115 SPT Algorithm Details • Bridges exchange configuration messages -- id for bridge sending the message -- id for what the sending bridge believes to be root bridge -- distance (hops) from sending bridge to root bridge • Each bridge records current best configuration •message for each port • Initially, each bridge believes it is the root 5: DataLink Layer 5-116 SPT Algorithm Detail (cont) . When learn not root, stop generating config messages -- in steady state, only root generates configuration messages . When learn not designated bridge, stop forwarding config messages -- in steady state, only designated bridges forward config messages . Root continues to periodically send config messages . If any bridge does not receive config message after a period of time, it starts generating config messages claiming to be the root 5: DataLink Layer 5-117 More on Bridge- Broadcast and Multicast • Forward all broadcast/multicastframes -- current practice • Learn when no group members downstream • Accomplished by having each member of group G send a frame to bridge multicast address with G in source field 5: DataLink Layer 5-118 More on Bridge- Limitations of Bridges • Do not scale -- spanning tree algorithm does not scale -- broadcast does not scale • Do not accommodate heterogeneity • Caution: beware of transparency 5: DataLink Layer 5-119 More on Bridge- Virtual LAN (VLAN) W X VLAN 100 VLAN 100 B1 B2 VLAN 200 VLAN 200 Y Z 5: DataLink Layer 5-120 Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Hubs and switches r 5.7 Point to Point Links r 5.8 Link Virtualization: ATM 5: DataLink Layer 5-121 Point to Point Links - Outline Encoding (Done) Framing Error Detection (Done) Sliding Window Algorithm(Done) Internet PointtoPoint Links 5: DataLink Layer 5-122 Point to Point Data Link Control r one sender, one receiver, one link: easier than broadcast link: m no Media Access Control m no need for explicit MAC addressing m e.g., dialup link, ISDN line r popular point-to-point DLC protocols: m PPP (point-to-point protocol) m HDLC: High level data link control (Data link used to be considered “high layer” in protocol stack! 5: DataLink Layer 5-123 Framing • Break sequence of bits into a frame • Typically implemented by network adaptor Bits Node A Adaptor Adaptor Node B Frames 5: DataLink Layer 5-124 Approaches • Sentinelbased -- delineate frame with special pattern: 01111110 -- e.g., HDLC, SDLC, PPP 8 16 Beginning sequence Header Body 16 8 CRC Ending sequence -- problem: special pattern appears in the payload -- solution: Byte Stuffing (CharacterOriented) and Bit stuffing 5: DataLink Layer 5-125 Character-Oriented Framing Byte Stuffing Data to be sent A DLE B ETX DLE STX E After stuffing and framing DLE r STX A r DLE B ETX DLE DLE STX E DLE Frames consist of integer number of bytes ETX m Asynchronous transmission systems using ASCII to transmit printable characters Octets with HEX value <20 are nonprintable m STX (start of text) = 0x02; ETX (end of text) = 0x03; m r DLE Special 8-bit patterns used as control characters Byte used to carry non-printable characters in frame m m m m DLE (data link escape) = 0x10 DLE STX (DLE ETX) used to indicate beginning (end) of frame Insert extra DLE in front of occurrence of DLE STX (DLE ETX) in frame All DLEs occur in pairs except at frame boundaries Byte Stuffing (Examples) 5: DataLink Layer 5-127 Bit Oriented (Bit Stuffing) HDLC frame Flag Address Control Information FCS Flag any number of bits r Frame delineated by flag character r HDLC uses bit stuffing to prevent occurrence of flag 01111110 inside the frame r Transmitter inserts extra 0 after each consecutive five 1s inside the frame r Receiver checks for five consecutive 1s m m m if next bit = 0, it is removed if next two bits are 10, then flag is detected If next two bits are 11, then frame has errors Example: Bit stuffing & de-stuffing (a) Data to be sent 0110111111111100 After stuffing and framing 0111111001101111101111100001111110 (b) Data received 01111110000111011111011111011001111110 After destuffing and deframing *000111011111-11111-110* Approaches (cont)- Counterbased • Counterbased -- include payload length in header -- e.g., DDCMP 8 8 8 14 42 Count Header 16 Body CRC -- problem: count field corrupted -- solution: catch when CRC fails 5: DataLink Layer 5-130 Counter-based 5: DataLink Layer 5-131 Approaches (cont)- Clockbased • Clockbased -- each frame is 125us long -- e.g., SONET: Synchronous Optical Network -- STSn (STS1 = 51.84 Mbps) Overhead Payload STS-1 STS-1 STS-1 9 row s Hdr STS-3c 90 columns 5: DataLink Layer 5-132 Internet PointtoPoint Links PPP Design Requirements [RFC 1557] r packet framing: encapsulation of network-layer r r r r datagram in data link frame m carry network layer data of any network layer protocol (not just IP) at same time m ability to demultiplex upwards bit transparency: must carry any bit pattern in the data field error detection (no correction) connection liveness: detect, signal link failure to network layer network layer address negotiation: endpoint can learn/configure each other’s network address 5: DataLink Layer 5-133 PPP non-requirements r no error correction/recovery r no flow control r out of order delivery OK r no need to support multipoint links (e.g., polling) Error recovery, flow control, data re-ordering all relegated to higher layers! 5: DataLink Layer 5-134 PPP Data Frame r Flag: delimiter (framing) r Address: does nothing (only one option) r Control: does nothing; in the future possible multiple control fields r Protocol: upper layer protocol to which frame delivered (eg, PPP-LCP, IP, IPCP, etc) 5: DataLink Layer 5-135 PPP Data Frame r info: upper layer data being carried r check: cyclic redundancy check for error detection 5: DataLink Layer 5-136 PPP Frame Flag 01111110 Address 1111111 Control 00000011 Protocol Information CRC Flag 01111110 integer # of bytes All stations are to accept the frame r Unnumbered frame Specifies what kind of packet is contained in the payload, e.g., LCP, NCP, IP, OSI CLNP, IPX PPP uses similar frame structure as HDLC, except m m Protocol type field Payload contains an integer number of bytes PPP uses the same flag, but uses byte stuffing r Problems with PPP byte stuffing r m m Size of frame varies unpredictably due to byte insertion Malicious users can inflate bandwidth by inserting 7D & 7E Byte-Stuffing in PPP PPP is character-oriented version of HDLC r Flag is 0x7E (01111110) r Control escape 0x7D (01111101) r Any occurrence of flag or control escape inside of frame is replaced with 0x7D followed by original octet XORed with 0x20 (00100000) r Data to be sent 7E 41 41 7D 42 7E 50 70 46 7D 5D 42 7D 5E 50 70 After stuffing and framing 46 7E PPP Data Control Protocol Before exchanging networklayer data, data link peers must r configure PPP link (max. frame length, authentication) r learn/configure network layer information m for IP: carry IP Control Protocol (IPCP) msgs (protocol field: 8021) to configure/learn IP address 5: DataLink Layer 5-139 PPP Phases Dead 7. Carrier dropped Terminate 6. Done 5. Open Failed Failed 4. NCP configuration Network Home PC to Internet Service Provider 1. PC calls router via modem 2. PC and router exchange LCP packets to negotiate PPP parameters Establish 3. Check on identities 4. NCP packets exchanged to 2. Options configure the network layer, e.g. negotiated TCP/IP ( requires IP address assignment) Authenticate 5. Data transport, e.g. send/receive IP packets 6. NCP used to tear down the 3. Authentication network layer connection (free up IP address); LCP used to shut completed down data link layer connection 1. Carrier detected 7. Modem hangs up PPP Authentication r Password Authentication Protocol m Initiator must send ID & password m Authenticator replies with authentication success/fail m After several attempts, LCP closes link m Transmitted unencrypted, susceptible to eavesdropping r Challenge-Handshake Authentication Protocol (CHAP) m m m m m Initiator & authenticator share a secret key Authenticator sends a challenge (random # & ID) Initiator computes cryptographic checksum of random # & ID using the shared secret key Authenticator also calculates cryptocgraphic checksum & compares to response Authenticator can reissue challenge during session Link Layer r 5.1 Introduction and r r r r services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 Link-Layer Addressing 5.5 Ethernet r 5.6 Hubs and switches r 5.7 PPP r 5.8 Link Virtualization: ATM and MPLS 5: DataLink Layer 5-142 Virtualization of networks Virtualization of resources: a powerful abstraction in systems engineering: r computing examples: virtual memory, virtual devices m Virtual machines: e.g., java m IBM VM os from 1960’s/70’s r layering of abstractions: don’t sweat the details of the lower layer, only deal with lower layers abstractly 5: DataLink Layer 5-143 The Internet: virtualizing networks 1974: multiple unconnected nets ARPAnet m data-over-cable networks m packet satellite network (Aloha) m packet radio network m ARPAnet "A Protocol for Packet Network Intercommunication", V. Cerf, R. Kahn, IEEE Transactions on Communications, May, 1974, pp. 637-648. … differing in: addressing conventions m packet formats m error recovery m routing m satellite net 5: DataLink Layer 5-144 The Internet: virtualizing networks Internetwork layer (IP): r addressing: internetwork appears as a single, uniform entity, despite underlying local network heterogeneity r network of networks Gateway: r “embed internetwork packets in local packet format or extract them” r route (at internetwork level) to next gateway gateway ARPAnet satellite net 5: DataLink Layer 5-145 Cerf & Kahn’s Internetwork Architecture What is virtualized? r two layers of addressing: internetwork and local network r new layer (IP) makes everything homogeneous at internetwork layer r underlying local network technology m cable m satellite m 56K telephone modem m today: ATM, MPLS … “invisible” at internetwork layer. Looks like a link layer technology to IP! 5: DataLink Layer 5-146 ATM and MPLS r ATM, MPLS separate networks in their own right m different service models, addressing, routing from Internet r viewed by Internet as logical link connecting IP routers m just like dialup link is really part of separate network (telephone network) r ATM, MPSL: of technical interest in their own right 5: DataLink Layer 5-147 Asynchronous Transfer Mode: ATM r 1990’s/00 standard for high-speed (155Mbps to 622 Mbps and higher) Broadband Integrated Service Digital Network architecture r Goal: integrated, end-end transport of carry voice, video, data m meeting timing/QoS requirements of voice, video (versus Internet best-effort model) m “next generation” telephony: technical roots in telephone world m packet-switching (fixed length packets, called “cells”) using virtual circuits 5: DataLink Layer 5-148 ATM architecture r adaptation layer: only at edge of ATM network data segmentation/reassembly m roughly analagous to Internet transport layer r ATM layer: “network” layer m cell switching, routing r physical layer m 5: DataLink Layer 5-149 ATM: network or link layer? Vision: end-to-end transport: “ATM from desktop to desktop” m ATM is a network technology Reality: used to connect IP backbone routers m “IP over ATM” m ATM as switched link layer, connecting IP routers IP network ATM network 5: DataLink Layer 5-150 ATM Adaptation Layer (AAL) r ATM Adaptation Layer (AAL): “adapts” upper layers (IP or native ATM applications) to ATM layer below r AAL present only in end systems, not in switches r AAL layer segment (header/trailer fields, data) fragmented across multiple ATM cells m analogy: TCP segment in many IP packets 5: DataLink Layer 5-151 ATM Adaptation Layer (AAL) [more] Different versions of AAL layers, depending on ATM service class: r r r AAL1: for CBR (Constant Bit Rate) services, e.g. circuit emulation AAL2: for VBR (Variable Bit Rate) services, e.g., MPEG video AAL5: for data (eg, IP datagrams) User data AAL PDU ATM cell 5: DataLink Layer 5-152 ATM Layer Service: transport cells across ATM network r analogous to IP network layer r very different services than IP network layer Network Architecture Internet Service Model Guarantees ? Congestion Bandwidth Loss Order Timing feedback best effort none ATM CBR ATM VBR ATM ABR ATM UBR constant rate guaranteed rate guaranteed minimum none no no no yes yes yes yes yes yes no yes no no (inferred via loss) no congestion no congestion yes no yes no no 5: DataLink Layer 5-153 ATM Layer: Virtual Circuits r VC transport: cells carried on VC from source to dest m call setup, teardown for each call before data can flow m each packet carries VC identifier (not destination ID) m every switch on source-dest path maintain “state” for each passing connection m link,switch resources (bandwidth, buffers) may be allocated to VC: to get circuit-like perf. r Permanent VCs (PVCs) long lasting connections m typically: “permanent” route between to IP routers r Switched VCs (SVC): m dynamically set up on per-call basis m 5: DataLink Layer 5-154 ATM VCs r Advantages of ATM VC approach: QoS performance guarantee for connection mapped to VC (bandwidth, delay, delay jitter) r Drawbacks of ATM VC approach: m Inefficient support of datagram traffic m one PVC between each source/dest pair) does not scale (N*2 connections needed) m SVC introduces call setup latency, processing overhead for short lived connections m 5: DataLink Layer 5-155 ATM Layer: ATM cell r 5-byte ATM cell header r 48-byte payload m m Why?: small payload -> short cell-creation delay for digitized voice halfway between 32 and 64 (compromise!) Cell header Cell format 5: DataLink Layer 5-156 ATM cell header r VCI: virtual channel ID will change from link to link thru net r PT: Payload type (e.g. RM cell versus data cell) r CLP: Cell Loss Priority bit m CLP = 1 implies low priority cell, can be discarded if congestion r HEC: Header Error Checksum m cyclic redundancy check m 5: DataLink Layer 5-157 ATM Physical Layer (more) Two pieces (sublayers) of physical layer: r Transmission Convergence Sublayer (TCS): adapts ATM layer above to PMD sublayer below r Physical Medium Dependent: depends on physical medium being used TCS Functions: m Header checksum generation: 8 bits CRC m Cell delineation m With “unstructured” PMD sublayer, transmission of idle cells when no data cells to send 5: DataLink Layer 5-158 ATM Physical Layer Physical Medium Dependent (PMD) sublayer r SONET/SDH: transmission frame structure (like a container carrying bits); m bit synchronization; m bandwidth partitions (TDM); m several speeds: OC3 = 155.52 Mbps; OC12 = 622.08 Mbps; OC48 = 2.45 Gbps, OC192 = 9.6 Gbps r TI/T3: transmission frame structure (old telephone hierarchy): 1.5 Mbps/ 45 Mbps r unstructured: just cells (busy/idle) 5: DataLink Layer 5-159 IP-Over-ATM Classic IP only r 3 “networks” (e.g., LAN segments) r MAC (802.3) and IP addresses IP over ATM r replace “network” (e.g., LAN segment) with ATM network r ATM addresses, IP addresses ATM network Ethernet LANs Ethernet LANs 5: DataLink Layer 5-160 IP-Over-ATM app transport IP Eth phy IP AAL Eth ATM phy phy ATM phy ATM phy app transport IP AAL ATM phy 5: DataLink Layer 5-161 Datagram Journey in IP-over-ATM Network r at Source Host: m IP layer maps between IP, ATM dest address (using ARP) m passes datagram to AAL5 m AAL5 encapsulates data, segments cells, passes to ATM layer r ATM network: moves cell along VC to destination r at Destination Host: m m AAL5 reassembles cells into original datagram if CRC OK, datagram is passed to IP 5: DataLink Layer 5-162 IP-Over-ATM Issues: r IP datagrams into ATM AAL5 PDUs r from IP addresses to ATM addresses m just like IP addresses to 802.3 MAC addresses! ATM network Ethernet LANs 5: DataLink Layer 5-163 Multiprotocol label switching (MPLS) r initial goal: speed up IP forwarding by using fixed length label (instead of IP address) to do forwarding m m borrowing ideas from Virtual Circuit (VC) approach but IP datagram still keeps IP address! PPP or Ethernet header MPLS header label 20 IP header remainder of link-layer frame Exp S TTL 3 1 5 5: DataLink Layer 5-164 MPLS capable routers r a.k.a. label-switched router r forwards packets to outgoing interface based only on label value (don’t inspect IP address) m MPLS forwarding table distinct from IP forwarding tables r signaling protocol needed to set up forwarding m RSVP-TE m forwarding possible along paths that IP alone would not allow (e.g., source-specific routing) !! m use MPLS for traffic engineering r must co-exist with IP-only routers 5: DataLink Layer 5-165 MPLS forwarding tables in label out label dest 10 12 8 out interface A D A 0 0 1 in label out label dest out interface 10 6 A 1 12 9 D 0 R6 0 0 D 1 1 R3 R4 R5 0 0 R2 in label 8 out label dest 6 A out interface in label 6 outR1 label dest - A A out interface 0 0 5: DataLink Layer 5-166 10.1.1/24 R3 1 0 R1 0 R2 Prefix Interface Prefix Interface 10.1.1 0 10.1.1 1 10.3.3 0 10.3.3 0 ■■■ 10.3.3/24 R4 ■■■ 5: DataLink Layer 5-167 10.1.1/24 Label = 15, Prefix = 10.1.1 R3 1 0 R1 Prefix 0 R2 Interface 10.3.3/24 Label Prefix 10.1.1 0 15 10.1.1 1 10.3.3 0 16 10.3.3 0 ■■■ R4 Interface ■■■ (a) 10.1.1/24 R3 1 R1 Prefix 10.1.1 10.3.3 R2 0 Remote Interface Label 0 15 0 16 0 10.3.3/24 R4 Label Prefix 15 10.1.1 Interface 1 16 10.3.3 0 ■■■ ■■■ (b) 5: DataLink Layer 5-168 Label = 24, Prefix = 10.1.1 10.1.1/24 R3 1 0 R1 0 R2 10.3.3/24 R4 Prefix 10. 1. 1 Interface 0 Remote Label 15 10. 3. 3 0 16 ■■■ Label Prefix 15 10.1.1 16 10.3.3 Interface 1 Remote Label 24 0 ■■■ 5: DataLink Layer 5-169 (a) ATM cell header GFC VPI VCI PTI CLP HEC DATA Label (b) “ Shim “ header (for PPP, Ethernet, etc.) PPP header Label header Layer 3 header 5: DataLink Layer 5-170 R6 R1 R5 R2 R3 R4 (a) R6 R1 LSR1 LSR3 R5 R2 LSR2 R4 R3 (b) 5: DataLink Layer 5-171 R1 R6 R7 R3 R2 R4 R5 5: DataLink Layer 5-172 ATM cells arrive ATM cells sent Tail Head R2 Cells sent into tunnel at head R3 Tunneled data arrives at tail 5: DataLink Layer 5-173 1. ATM cells arrive 101 6. ATM cells sent 202 Tail Head R2 2. Demux label added DL 101 3. Tunnel label added TL DL 101 R3 DL 101 TL DL 101 5. Demux label examined 4. Packet is forw arded to tail 5: DataLink Layer 5-174 VPN A / Site 2 VPN B / Site 2 VPN B / Site 1 Provider netw ork VPN A / Site 3 VPN A / Site 1 VPN B / Site 3 5: DataLink Layer 5-175 Chapter 5: Summary r principles behind data link layer services: m m m error detection, correction sharing a broadcast channel: multiple access link layer addressing r instantiation and implementation of various link layer technologies m Ethernet m switched LANS m PPP m virtualized networks as a link layer: ATM, MPLS 5: DataLink Layer 5-176