* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download ch5_DATALINK_0708
Airborne Networking wikipedia , lookup
Network tap wikipedia , lookup
Power over Ethernet wikipedia , lookup
Computer network wikipedia , lookup
Deep packet inspection wikipedia , lookup
Multiprotocol Label Switching wikipedia , lookup
Zero-configuration networking wikipedia , lookup
Asynchronous Transfer Mode wikipedia , lookup
Cracking of wireless networks wikipedia , lookup
Point-to-Point Protocol over Ethernet wikipedia , lookup
Wake-on-LAN wikipedia , lookup
IEEE 802.11 wikipedia , lookup
IEEE 802.1aq wikipedia , lookup
Internet protocol suite wikipedia , lookup
Recursive InterNetwork Architecture (RINA) wikipedia , lookup
Communication Networks P. Demeester Chapter 5 Data Link Layer Computer networking A top-down approach featuring the internet 4th Edition, 2008 Addison Wesley James F. Kurose, Keith W. Ross ISBN 0-321-49770-8 DataLink Layer Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved 5-1 Chapter 5: The Data Link Layer Our goals: understand principles behind data link layer services (using Ethernet and PPP examples): [error detection, correction] sharing a broadcast channel: multiple access link layer addressing reliable data transfer, flow control: done DataLink Layer 5-2 Chapter 5 outline 5.1 Introduction and 5.6 Hubs, bridges, and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay DataLink Layer 5-3 Link Layer: Introduction “link” Some terminology: hosts and routers are “nodes” communication channels that connect adjacent nodes along communication path are links IP forwarding wired links wireless links LANs Layer 2-PDU is a frame, encapsulates datagram data-link layer has responsibility of transferring datagram from one node to adjacent node over a link DataLink Layer 5-4 Link layer: context 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 (rdt) over link transportation analogy trip from Princeton to Lausanne limo: Princeton to JFK plane: JFK to Geneva train: Geneva to Lausanne tourist = datagram transport segment = communication link transportation mode = link layer protocol travel agent = routing algorithm DataLink Layer 5-5 Link Layer Services Framing, link access: encapsulate datagram into frame, adding header, trailer channel access if shared medium ‘physical addresses’ used in frame headers to identify source, destination • different from IP address! Reliable delivery between adjacent nodes we learned how to do this already (chapter 3)! seldom used on low bit error link (fiber, some twisted pair) wireless links: high error rates DataLink Layer 5-6 Link Layer Services (more) Flow Control: pacing between adjacent sending and receiving nodes Error Detection: errors caused by signal attenuation, noise. 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 5-7 Adaptors Communicating datagram sending node frame adapter rcving node link layer protocol frame adapter link layer implemented in receiving side “adaptor” (aka NIC) looks for errors, rdt, flow control, etc Ethernet card, PCMCIA extracts datagram, passes card, 802.11 card to receiving node sending side: adapter is semi encapsulates datagram in autonomous a frame adds error checking bits, link & physical layers rdt, flow control, etc. DataLink Layer 5-8 Chapter 5 outline 5.1 Introduction and 5.6 Hubs, bridges, and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay DataLink Layer 5-9 Ethernet “dominant” LAN technology: cheap $20 for 100Mbs! first widely used LAN technology Simpler, cheaper than token LANs and ATM Kept up with speed race: 10, 100, 1000 Mbps Metcalfe’s Ethernet Sketch (1976) DataLink Layer 5-10 Ethernet A C ? D B Use of address How to send a frame from A to B ? • How to know that the frame is for B ? Carrier Sense • When are you allowed to send a frame ? • What happens if 2 frames are put on the bus at the same time ? Collision detection and back-off DataLink Layer 5-11 Ethernet Frame Structure Bitrate : 10 Mbit/s preamble 7 frame destination source type delimiter address address 1 6 6 2 data pad checksum 0-1500 0-46 4 Preamble : for synchronization of the receiver (7 bytes : 10101010) ==> 10 MHz square, 5.6 msec (Manchester coding) Frame delimiter (10101011) : indicates the frame start (=data will follow) Destination address : worldwide unique hardware address of receiver (6 bytes) (3 bytes “fixed” per manufacturer, 3 bytes “configured”) Source address : worldwide unique hardware address of sender (6 bytes) Type : the type of data that are transported by the Ethernet frame Data : the information to be transferred (variable length) Pad : padding bytes to be added Checksum : a 4 byte CRC code (in order to obtain a minimum frame length of 64 bytes) Address example : 00.20.8A.05.D4.40 DataLink Layer 5-12 Note : Between the frames there is a minimum IPG (Inter Packet Gap)of 12 bytes Manchester encoding Used in 10BaseT, 10Base2 Each bit has a transition (double clockrate required : 20 MHz) Allows clocks in sending and receiving nodes to synchronize to each other no need for a centralized, global clock among nodes! [ this is physical-layer] DataLink Layer 5-13 Unreliable connectionless service Addressing if adapter receives frame with matching destination address, or with broadcast address, it passes data in frame to network-layer protocol otherwise, adapter discards frame Connectionless: No handshaking between sending and receiving adapter. Unreliable: receiving adapter doesn’t send acks or nacks 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 DataLink Layer 5-14 Carrier Sense Multiple Access C A B A has a frame to send : if bus idle ==> start sending B has a frame to send : bus busy ==> wait sending A finished sending : bus becomes idle ==> B starts sending DataLink Layer 5-15 Carrier Sense Multiple Access A C 100 m, 0.5 msec A starts sending B 0.5 msec 10 bit 1 msec B wants to send but has to wait (bus is busy) time A finished sending 1 msec B starts sending because bus is idle (wait 96 bits) B finished sending DataLink Layer 5-16 Carrier Sense Multiple Access / Collision Detection A B C B wants to send but has to wait (bus is busy) time B starts sending because bus is idle A wants to send but has to wait (bus is busy) C wants to send but has to wait (bus is busy) A stops sending (collision detection) C stops sending (collision detection) ==> start exponential back-off DataLink Layer 5-17 Successful Collision Detection ? A B C C starts sending because bus is idle C stops sending frame and adds 48 bits jamming (collision detection) C did not receive frame from A correctly but A doesn’t know ! A finished sending !!! DID NOT DETECT COLLISION !!! Frame duration > 2 times propagation time : correct collision detection ==> minimum frame length = 64 bytes or 512 bits ==> at 10 Mbit/s this gives a maximum of 51.2 msec roundtrip delay (5 msec delay per km cable ==> max 5 km cable) see notes DataLink Layer 5-18 Binary Exponential Backoff COLLISION DETECTION ==> Minimum frame length = 51.2 msec time slot (512 bit times) two frames collide two stations wait 0 or 1 time slot two stations wait 0,1,2 or 3 time slots two station wait 0 … 23-1 time slots maximum of 1023 time slots OK DataLink Layer 5-19 CSMA/CD efficiency Tprop = max propagation time between 2 nodes in LAN ttrans = time to transmit max-size frame efficiency 1 1 5t prop / ttrans Efficiency goes to 1 as tprop goes to 0 Goes to 1 as ttrans goes to infinity DataLink Layer 5-20 Ethernet Technologies: 10Base2 10: 10Mbps; 2: under “200” meters max cable length (actually : 185 m) thin coaxial cable in a bus topology : segment (max. 30 nodes) repeater : repeats bits it hears on one interface to its other interfaces: physical layer device only! repeaters used to connect different segments (max of 4 repeaters or 5 segments) has become a legacy technology (IEEE 802.3 standard) DataLink Layer 5-21 10BaseT and 100BaseT 10/100 Mbps rate; latter called “fast ethernet” T stands for Twisted Pair (actually : 2 twisted pairs : one for transmitting and one for receiving) Nodes connect to a hub: “star topology” (100 m max distance between nodes and hub) nodes hub Hubs are essentially physical-layer repeaters: bits coming in one link go out all other links no frame buffering no CSMA/CD at hub: adapters detect collisions provides network management functionality (fast ethernet : IEEE 802.3u standard, 1995) DataLink Layer 5-22 Fast Ethernet Name Cable 100Base-T4 Twisted Pair 100 m (4 TP’s) Use cat. 3 UTP (telephone cable) 100Base-TX Twisted Pair 100 m (2 TP’s) Full duplex at 100 Mb/s (cat.5 UTP) 100Base-FX Full duplex at 100 Mb/s Fiber (2 fibers) Max. Segment 2 km Advantages 100Base-T4 : existing telephony cables, 4 TP’s required, low clock rate (25 MHz using special tricks) 100Base-TX : 4B/5B coding (clock rate 125 MHz) : 4 bits (or 16 combinations) are coded in 5 bits (16 combinations may be used for other purposes, e.g. marking frame boundaries) [100Base-T = T4 and TX] Note : Fast Ethernet not on standard coax plant DataLink Layer 5-23 Ethernet Hub Ethernet-NIC HUB DataLink Layer 5-24 Ethernet Hub Collision domain HUB RX TX RX TX RX TX 4 pins used : one TP to transmit (TX) one TP to receive (RX) ! Crossed and straight cables ! DataLink Layer 5-25 Gbit Ethernet standard since mid 1998 use standard Ethernet frame format allows for point-to-point links (switch) and shared broadcast channels (hub) in shared mode, CSMA/CD is used; short distances between nodes (<25 m, unless use of carrier extension or frame bursting to min. 512 bytes) not very useful mode (not efficient) Full-Duplex at 1 Gbps for point-to-point links (switch) 10 Gbps now (IEEE 802.ae, 2002) ! (fast ethernet : IEEE 802.3z standard, 1998) DataLink Layer 5-26 Gbit Ethernet Name Cable Max. Segment Advantages 1000Base-SX Fiber 550 m Multimode fiber 1000Base-LX Fiber 5 km Single or Multimode Fiber 1000Base-CX Twisted Pair 25 m (2 STP’s) Shielded Twisted Pair 1000Base-T Twisted Pair 100 m (4 UTP’s) Standard cat. 5 UTP On fiber : 8B/10B (1 byte or 8 bits coded in 10 bits, 1.25 GHz clock) On cat. 5 UTP : 5 level encoding (for 2 bit combinations : 00,01,10,11) and 4 twisted pairs (2 TX en 2 RX) clock : 125 MHz (allowing 1 Gb/s operation) Support of flow control on the data link level Note : Fast Ethernet not on standard coax plant DataLink Layer 5-27 Other Issues • Standardization CSMA/CD MAC : IEEE 802.3 note : Ethernet is an implementation of 802.3 • Protocol Stack : more complex network layer LLC sublayer data link layer MAC sublayer physical layer IEEE 802.2 : LLC (Logical Link Control Sublayer, HDLC like) IEEE 802.3 : CSMA/CD IEEE 802.4 : Token Bus IEEE 802.5 : Token Ring • LLC: extra features not in MAC, uniform interface towards L3 e.g.: reliability (seq and ack numbers), source/destination access point, … L3 IP packet L2 LLC IP packet L1 MAC LLC IP packet MAC DataLink Layer Chapter 5 outline 5.1 Introduction and 5.6 Hubs, bridges, and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay DataLink Layer 5-29 LAN Addresses and ARP 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 interface to another physically- connected interface (same network) 48 bit MAC address (for most LANs) burned in the adapter ROM IP : 157.193.122.1 Eth : 00:12:27:BE:12:C1 IP : 157.193.122.11 Eth : 00:60:97:A4:3D:CD IP : 157.193.122.10 Eth : 00:50:97:A3:3E:10 IP : 157.193.122.12 Eth : 00:60:97:A4:3D:CE IP : 157.193.122.15 Eth : 00:60:97:A4:3D:CF DataLink Layer 5-30 LAN Address (more) MAC address allocation administered by IEEE manufacturer buys portion of MAC address space (to assure uniqueness) MAC flat address => portability can move LAN card from one LAN to another IP hierarchical address NOT portable depends on IP network to which node is attached DataLink Layer 5-31 Forwarding to an external subnetwork ? Problem : 157.193.102.3 (A) wants to send IP packet to 157.193.103.12 (B) Routing table in A : go to router (157.193.102.254) Packet leaving A has destination address 157.193.103.12 (and not 157.193.102.254) How does the packet know that it has to go to the router ? Use of the layer 2 Ethernet address of the router ! How does A know the Ethernet address of the router ? Use of ARP (Address Resolution Protocol) B 157.193.103.12 Subnetwork 157.193.103.0 S-IP : 157.193.102.3 D-IP : 157.193.103.1 157.193.103.254 router 157.193.102.254 Subnetwork 157.193.102.0 157.193.102.51 Routing table A : 157.193.103.0/24 to 157.193.102.254 A 157.193.102.3 DataLink Layer Forwarding to an external subnetwork ? B Subnetwork 157.193.103.0 157.193.103.12 00.90.96.15.15.15 Ethernet + IP S-IP : 157.193.102.3 S-MAC : 00.90.96.14.14.14 D-IP : 157.193.103.12 D-MAC : 00.90.96.15.15.15 … Ethernet + IP S-IP : 157.193.102.3 S-MAC : 00.90.96.12.12.12 D-IP : 157.193.103.12 D-MAC : 00.90.96.13.13.13 … 157.193.103.254 00.90.96.14.14.14 router 157.193.102.254 00.90.96.13.13.13 A Subnetwork 157.193.102.0 157.193.102.3 DataLink Layer 00.90.96.12.12.12 Address Resolution Protocol : ARP ARP cache: 157.193.122.11 00:60:97:A3:3D:CD (TTL = 20 min) IP : 157.193.122.10 Eth : 00:50:97:A3:3E:10 IP : 157.193.122.1 Eth : 00:12:27:BE:12:C1 2: ARP reply : Eth address for IP: 157.193.122.11 00:60:97:A4:3D:CD IP : 157.193.122.11 Eth : 00:60:97:A4:3D:CD 1: ARP request : Eth address for IP: 157.193.122.11 ? IP : 157.193.122.12 Eth : 00:60:97:A4:3D:CE IP : 157.193.122.15 Eth : 00:60:97:A4:3D:CF DataLink Layer ARP protocol A wants to send datagram to B, and A knows B’s IP address. Suppose B’s MAC address is not in A’s ARP table. A broadcasts ARP query packet, containing B's IP address all machines on LAN receive ARP query B receives ARP packet, replies to A with its (B's) MAC address frame sent to A’s MAC address (unicast) A caches (saves) IP-to- MAC address pair in its ARP table until information becomes old (times out) soft state: information that times out (goes away) unless refreshed ARP is “plug-and-play”: nodes create their ARP tables without intervention from net administrator DataLink Layer 5-35 Chapter 5 outline 5.1 Introduction and 5.6 Hubs, bridges, and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay DataLink Layer 5-36 Interconnecting LAN segments Hubs Bridges Switches Remark: switches are essentially multi-port bridges. What we say about bridges also holds for switches! DataLink Layer 5-37 Interconnecting with hubs Backbone hub interconnects LAN segments Extends max distance between nodes But individual segment collision domains become one large collision domain if a node in CS and a node EE transmit at same time: collision Can’t interconnect 10BaseT & 100BaseT at same time collision domain hub CS EE SE DataLink Layer 5-38 Bridges Link layer device stores and forwards Ethernet frames examines frame header and selectively forwards frame based on MAC dest address when frame is to be forwarded on segment, uses CSMA/CD to access segment transparent hosts are unaware of presence of bridges plug-and-play, self-learning bridges do not need to be configured DataLink Layer 5-39 Bridges: traffic isolation Bridge installation breaks LAN into LAN segments bridges filter packets: same-LAN-segment frames not usually forwarded onto other LAN segments segments become separate collision domains collision domains bridge CS EE SE DataLink Layer 5-40 Forwarding : Self learning How do determine to which LAN segment to forward frame? A bridge has a bridge table entry in bridge table: <Node LAN Address, Bridge Interface, Time Stamp> stale entries in table dropped (TTL can be 60 min) bridges learn which hosts can be reached through which interfaces when frame received, bridge “learns” location of sender: incoming LAN segment records sender/location pair in bridge table DataLink Layer 5-41 Filtering/Forwarding When bridge receives a frame: index bridge 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 DataLink Layer 5-42 Bridge example Send frame from X to Y Send frame back from Y to X Fill in bridge table X 1 D 1 A 1 2 2 4 3 B Y 4 3 4 1 2 4 C 3 X X 1 Y 3 1 2 3 Y X 4 X 4 Y 1 DataLink Layer 5-43 Interconnection without backbone bridge hub bridge CS SE EE Not recommended for two reasons: - single point of failure at Computer Science hub - all traffic between EE and SE must path over CS segment Recommended DataLink Layer 5-44 Bridges Spanning Tree for increased reliability, desirable to have redundant, alternative paths from source to dest (example : fully redundant versus single link/node failures) with multiple paths, cycles result - bridges may multiply and forward frame forever solution: organize bridges in a spanning tree by disabling subset of interfaces DataLink Layer 5-45 Example UGent DataLink Layer 5-46 Some bridge features Isolates collision domains resulting in higher total max throughput limitless number of nodes and geographical coverage Can connect different Ethernet types (e.g. 10/100, fibre/TP) Transparent (“plug-and-play”): no configuration necessary DataLink Layer 5-47 Bridges vs. Routers both store-and-forward devices routers: network layer devices (examine network layer headers) bridges are link layer devices routers maintain routing tables, implement routing algorithms bridges maintain bridge tables, implement filtering, learning and spanning tree algorithms DataLink Layer 5-48 Routers vs. Bridges Bridges + and + Bridge operation is simpler requiring less packet processing + Bridge tables are self learning - All traffic confined to spanning tree, even when alternative bandwidth is available - Bridges do not offer protection from broadcast storms Routers + and - + arbitrary topologies can be supported, cycling is limited by TTL counters (and good routing protocols) + provide protection against broadcast storms - require IP address configuration (not plug and play) - require higher packet processing bridges do well in small (few hundred hosts) while routers used DataLink Layer 5-49 in large networks (thousands of hosts) Ethernet Switches Essentially a multi-interface bridge layer 2 (frame) forwarding, filtering using LAN addresses Switching: A-to-A’ and B-to-B’ simultaneously, no collisions large number of interfaces often: individual hosts, star-connected into switch Ethernet, but no collisions! DataLink Layer 5-50 Ethernet Switches cut-through switching: frame forwarded from input to output port without awaiting for assembly of entire frame slight reduction in latency combinations of shared/dedicated, 10/100/1000 Mbps interfaces DataLink Layer 5-51 Not an atypical LAN (IP network) Dedicated Shared DataLink Layer 5-52 Summary comparison hubs bridges routers switches traffic isolation no yes yes yes plug & play yes yes no yes optimal routing cut through no no yes no yes no no yes DataLink Layer 5-53 Chapter 5 outline 5.1 Introduction and 5.6 Hubs, bridges, and services 5.2 Error detection and correction 5.3Multiple access protocols 5.4 LAN addresses and ARP 5.5 Ethernet switches 5.7 Wireless links and LANs 5.8 PPP 5.9 ATM 5.10 Frame Relay DataLink Layer 5-54 Point to Point Data Link Control one sender, one receiver, one link: easier than broadcast link: no Media Access Control no need for explicit MAC addressing e.g., dialup link, ISDN line popular point-to-point DLC protocols: PPP (point-to-point protocol) HDLC: High level Data Link Control (Data link used to be considered “high layer” in protocol stack! DataLink Layer 5-55 PPP Design Requirements [RFC 1557] packet framing: encapsulation of network-layer datagram in data link frame carry network layer data of any network layer protocol (not just IP) at same time 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 DataLink Layer 5-56 PPP non-requirements no error correction/recovery no flow control out of order delivery OK no need to support multipoint links (e.g., polling) Error recovery, flow control, data re-ordering all relegated to higher layers! DataLink Layer 5-57 PPP Frame flag 01111110 1 Start of frame address control protocol payload Checksum 11111111 00000011 1 1 1 or 2 variable 2 or 4 flag 01111110 1 End of frame Flag : delineate the frame Address : no specific address used Control : unnumbered frame (no reliable transmission) (no sequence numbers, no ACK, …) Protocol : which kind of packet LCP, NCP, IP, IPX, AppleTalk, ... Payload : the information to be transferred (typ. 1500 bytes) Checksum : a CRC code DataLink Layer 5-58 Byte Stuffing “data transparency” requirement: data field must be allowed to include flag pattern <01111110> Is received <01111110> data or flag? Sender: adds (“stuffs”) control escape byte <01111101> byte before each < 01111110> data byte Receiver: <01111101><01111110>: discard first byte, continue data reception DataLink Layer 5-59 Byte Stuffing flag byte pattern in data to send flag byte pattern plus stuffed byte in transmitted data DataLink Layer 5-60 PPP Data Control Protocol Before exchanging network-layer data, data link peers must : LCP (Link Control Protocol) : configure PPP link (max. frame length, authentication, compressed frame header, …) NCP (Network Control Protocol) : learn/configure network layer information Different for different network layers (DECnet, Apple Talk, IP, …) for IP: carry IP Control Protocol (IPCP) msgs (protocol field: 8021) to configure/ learn IP address, IP compression, … dead LCP terminate LCP establish authenticate NCP negotiate open DataLink Layer 5-61 Table of contents 5.1 Introduction and services 5.4 LAN addresses and ARP 5.5 Ethernet 5.6 Hubs, bridges, and switches 5.8 PPP Table of contents 3 29 9 36 54 62 DataLink Layer 5-62