Link Layer: Introduction daptors ommunicating hosts and routers are nodes links connect nodes wired links wireless links layer-2 packet is a frame, encapsulates datagram datagram controller sending host frame datagram controller receiving host datagram data-link layer transfers datagram from one node to physically adjacent node over a link sender: puts datagram in frame adds error checking, addresses etc. receiver looks for errors, etc. extracts datagram, to upper layer Data Link Layer 5-1 Data Link Layer 5-2 Error Detection Parity hecking ED= Error Detection and orrection bits (redundancy) D = Data protected by error checking, may include header fields Not 100% reliable! protocol may miss some errors, but rarely larger ED field yields better detection and correction Single it Parity: Two Dimensional it Parity: Detect and correct single bit errors otherwise 0 0 Data Link Layer 5-3 Data Link Layer 5-4 hecksumming: yclic Redundancy heck an detect many errors More about this on the exercise next week! Multiple ccess Links and Protocols Two types of links : point-to-point point-to-point link broadcast (shared wire or medium) old-fashioned Ethernet 802.11 wireless LN shared wire (e.g., cabled Ethernet) shared RF (e.g., 802.11 WiFi) shared RF (satellite) humans at a cocktail party (shared air, acoustical) Data Link Layer 5-5 Data Link Layer 5-1
frequency bands Multiple ccess protocols single shared channel collisions possible Multiple access protocol determine when node can transmit communication about channel sharing must use channel itself! M Protocols hannel Partitioning divide channel into smaller pieces (time slots, frequency) allocate piece to node for exclusive use Random ccess channel not divided, allow collisions recover from collisions Taking turns nodes take turns, nodes with more to send can take longer turns Data Link Layer 5-7 Data Link Layer 5-8 hannel Partitioning M protocols: TDM TDM: time division multiple access access to channel in "rounds" each sender gets fixed length slot in each round unused slots go idle hannel Partitioning M protocols: FDM FDM: frequency division multiple access spectrum divided into frequency bands each sender assigned fixed frequency band unused transmission time in frequency bands go idle -slot frame 1 3 4 1 3 4 FDM cable Data Link Layer 5-9 Data Link Layer 5-10 Random ccess Protocols When node has packet to send transmit at full channel data rate no coordination among nodes two or more transmitting nodes collision, random access M protocol specifies: how to detect collisions how to recover from collisions Examples of random access M protocols: slotted LOH LOH SM, SM/D, SM/ Slotted LOH ssumptions: all frames same size time divided into equal size slots (time to transmit 1 frame) nodes start to transmit only slot beginning if 2 or more nodes transmit in slot, all nodes detect collision Operation: when node obtains fresh frame, transmits in next slot if no collision: node can send new frame in next slot if collision: node retransmits frame in each subsequent slot with prob. p until success Data Link Layer 5-11 Data Link Layer 5-12 2
Slotted LOH Pros single active node can continuously transmit decentralized: only slots need to be in sync simple ons collisions, wasting slots idle slots nodes may be able to detect collision in less than time to transmit packet clock synchronization Pure (unslotted) LOH unslotted loha: simpler, no synchronization when frame first arrives transmit immediately collision probability increases: frame sent at t 0 collides with other frames sent in [t 0-1,t 0 +1] Data Link Layer 5-13 Data Link Layer 5-14 SM (arrier Sense Multiple ccess) SM: listen before transmit: hannel idle: transmit hannel busy: wait Human analogy: don t interrupt others! SM collisions collisions can occur: caused by propagation delay collision: entire packet transmission time wasted Data Link Layer 5-15 Data Link Layer 5-1 SM/D (ollision Detection) SM/D collision detection if collision detected stop transmission collision detection: easy in wired LNs: compare transmitted and received signals difficult in wireless LNs: received signal overwhelmed by local transmission strength human analogy: the polite conversationalist Data Link Layer 5-17 Data Link Layer 5-18 3
Taking Turns M protocols Taking Turns M protocols channel partitioning M protocols: share channel efficiently and fairly at high load inefficient at low load: delay in channel access, 1/N bandwidth allocated even if only 1 active node! random access M protocols efficient at low load: single node can fully utilize channel high load: collisions taking turns protocols look for best of both worlds! Polling: master node invites slave nodes to transmit in turn disadvantages: polling overhead latency single point of failure (master) slaves data data poll master Data Link Layer 5-19 Data Link Layer 5-20 Taking Turns M protocols Summary of M protocols Token passing: control token passed from one node to next disadvantages: token overhead latency single point of failure (token) (nothing to send) T T channel partitioning, by time, frequency or code Time Division, Frequency Division random access (dynamic), LOH, S-LOH, SM, SM/D carrier sensing: easy in wired, hard in wireless SM/D used in Ethernet SM/ used in 802.11 (WiFi) taking turns polling from central site, token passing luetooth, IM Token Ring data Data Link Layer 5-21 Data Link Layer 5-22 M ddresses and RP 32-bit IP address: network-layer address used to get datagram to destination IP subnet M (or LN or physical or Ethernet) address: function: get frame from one interface to the next (same network) 48 bit M address (for most LNs) burned in NI ROM, also sometimes software settable LN ddresses and RP Each adapter on LN has unique LN address 71-5-F7-2-08-53 LN (wired or wireless) 1-2F--7-09-D 58-23-D7-F-20-0 0-4-11-F-E3-98 roadcast address = FF-FF-FF-FF-FF-FF = adapter Data Link Layer 5-23 Data Link Layer 5-24 4
LN ddress (more) M address allocation administered by IEEE manufacturer buys portion of M address space analogy: (a) M address: like Social Security Number (b) IP address: like postal address M address does not change IP hierarchical address NOT portable address depends on IP subnet to which node is attached RP: ddress Resolution Protocol Question: how to determine M address of knowing s IP address? 137.19.7.23 71-5-F7-2-08-53 LN 137.19.7.78 1-2F--7-09-D 137.19.7.14 58-23-D7-F-20-0 Each IP node (host, router) on LN has RP table RP table: IP/M address mappings for some LN nodes < IP address; M address; TTL> TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min) 137.19.7.88 0-4-11-F-E3-98 Data Link Layer 5-25 Data Link Layer 5-2 ddressing: routing to another LN send datagram from to via R. assume knows s IP address assume knows IP address of first hop router, R (how?) Ethernet Dominant wired LN technology: cheap first widely used LN technology simpler, cheaper than token rings 111.111.111.111 74-29-9-E8-FF-55 R 222.222.222.220 1-23-F9-D-0-9 222.222.222.222 49-D-D2-7-5-2 Metcalfe s Ethernet sketch 111.111.111.112-49-DE-D0--7D 111.111.111.110 E-E9-00-17--4 222.222.222.221 88-2-2F-54-1-0F Data Link Layer 5-27 Data Link Layer 5-28 Star topology bus topology popular through mid 90s all nodes can collide with each other today: star topology active switch in center Ethernet Frame Structure Sending adapter encapsulates IP datagram in Ethernet frame Preamble: 7 bytes with pattern 10101010 followed by one byte with pattern 10101011 synchronizes receiver and sender clock rates switch bus: coaxial cable star Data Link Layer 5-29 Data Link Layer 5-30 5
Ethernet Frame Structure (more) ddresses: bytes if adapter receives frame with matching destination address, or with broadcast address (e.g. RP packet), it passes data in frame to network layer protocol otherwise, adapter discards frame Type: indicates higher layer protocol (mostly IP) R: checked at receiver, if error is detected, frame is dropped Ethernet: Unreliable, connectionless connectionless: No handshaking between sending and receiving NIs unreliable: receiving NI doesn t send acks or nacks to sending NI stream of datagrams passed to network layer can have gaps gaps will be filled if app is using TP otherwise, app will see gaps Ethernet s M protocol: SM/D Data Link Layer 5-31 Data Link Layer 5-32 Ethernet SM/D algorithm 1. NI receives datagram 4. If NI detects another from network layer, transmission while creates frame transmitting, aborts and 2. If NI senses channel idle, sends jam signal starts frame transmission 5. fter aborting, NI If NI senses channel enters exponential busy, waits until channel backoff: wait random time, idle, then transmits after that return to 2. 3. If NI transmits entire frame without detecting another transmission, NI is done with frame! Ethernet s SM/D (more) Jam Signal: make sure all other transmitters are aware of collision; 48 bits it time:.1 microsec for 10 Mbps Ethernet Exponential ackoff: 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} Data Link Layer 5-33 Data Link Layer 5-34 Switch: allows multiple simultaneous transmissions hosts have dedicated, direct connection to switch switches buffer packets Ethernet protocol used on each incoming link, but no collisions switching: -to- and - to- simultaneously, without collisions 5 1 2 3 4 switch with six interfaces (1,2,3,4,5,) Switch Table Q: how does switch know that reachable via interface 4? : each switch has a switch table looks like a routing table! Q: how are entries created, maintained in switch table? 1 2 3 5 4 switch with six interfaces (1,2,3,4,5,) Data Link Layer 5-37 Data Link Layer 5-38
Switch: self-learning switch learns which hosts can be reached through which interfaces when frame received, switch learns location of sender: incoming LN segment records sender/location pair in switch table M addr interface TTL 1 0 5 1 2 3 4 Source: Dest: Switch table (initially empty) Interconnecting switches switches can be connected together S 1 S 2 D E Sending from to G - how does S 1 know to forward frame destined to F via S 4 and S 3? S 4 F G S 3 H I Data Link Layer 5-39 Data Link Layer 5-40 7