1 / 85

Lecture 11: Addressing, Framing, and Switching in the Link Layer

Lecture 11: Addressing, Framing, and Switching in the Link Layer. CS 3035/GZ01: Networked Systems Kyle Jamieson Department of Computer Science University College London. The link layer: Functionality. E nables the exchange of messages ( frames ) between end hosts Functionality:

sorcha
Download Presentation

Lecture 11: Addressing, Framing, and Switching in the Link Layer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 11: Addressing, Framing, and Switching in the Link Layer CS 3035/GZ01: Networked Systems Kyle Jamieson Department of Computer Science University College London

  2. The linklayer: Functionality • Enables the exchange of messages (frames) between end hosts • Functionality: • Framing: Determine start and end of bits and frames • Error control: Detect and/or correct errors • Reliable delivery: Deliver frames exactly once • Medium access control: Control hosts’ access to a shared medium, if applicable (medium access control) IP datagram Link-layer protocol frame Receiving host frame Sendinghost

  3. Today • We finish the functionality of the link layer, and tie it in to IP • Framing and addressing • Repeaters, hubs, and switches • Bootstrapping a host

  4. Framing frames • We have seen how to frame bits on a link • Ethernet’s Manchester encoding • Result: An infinite stream of bits on a link • But, two hosts connected on the same physical medium need to be able to exchange frames • Service provided by the link layer • Implemented by the network adaptor • Problem:how does the link layer determine where each frame begins and ends? (…how hard can that be?)

  5. Simple approach to framing: count bytes • Sender includes number of bytes in header • Receiver extracts this number of bytes of body • But what if the Count field is corrupted? • L2 will frame the wrong bytes • This is called a framing error • With high probability, CRC will detect the framing error and discard that frame, but: 53 Body 80 Body 53 bytes of data 21 bytes of data Bogus count field ??? 61 Body 80 Body 61 bytes of data misdelivered ??? bytes of data misdelivered • This state of persistent framing errors is called desynchronization

  6. Desynchronization • Once framing on a link is desynchronized, it can stay that way • Need a method to resynchronize • But once we have that method, why use counting?

  7. SYN SYN DLE, SYN, DLE, DLE, DLE, ETX Frame contents ETX ETX Framing with sentinel bytes • Delineate beginning of frame with special byte (SYN) • Delineate end of frame with another special byte (ETX) • What if sentinel occurs in data? • Byte stuffing: insert another special “escape” byte DLEbefore sentinel • What if any of the above escape characters occur in data? • Byte stuffing again: Stuff DLE before DLE occurring in data • Example: • Can we be more efficient?

  8. 01111110 Frame contents 01111111 Framing with sentinel bits • Delineate frame with special bitpattern • e.g., 01111110  start, 01111111  end • Problem: what if sentinel occurs within frame? • Solution: bit stuffing • Senderalways inserts a 0 after five 1s in the frame contents • Receiveralways removes a 0 appearing after five 1s

  9. 01111110 Frame content 01111111 When receiver sees five 1s… • If next bit 0, remove it, and begin counting again • Because this must be a stuffed bit; we can’t be at beginning/end of frame (those had six or seven 1s) • If next bit 1 (i.e., we’ve seen six 1s) then: • If following bit is 0, this is start of frame • Because the receiver has seen 01111110 • If following bit is 1, this is end of frame • Because the receiver has seen 01111111

  10. Example: sentinel bits • Original data, including start/end of frame: 01111110011111101111101111100101111111 • Sender rule: five 1s  insert a 0 • After bit stuffing at the sender: 01111110011111010111110011111000101111111 • Receiver rule: five 1s and next bit 0  remove 0 01111110011111101111101111100101111111

  11. Comparing addressing schemes • Network layer address (IP address) • Function: move datagram to destination network • 32-bit address, dotted quad notation a.b.c.d where each component is an eight-bit unsigned integer • Hierarchical address space • Link layer address (MAC address, Ethernet address): • Function: move frame from one point to another point on the same network • Unique 48-bit address (in most LANs) • Burned in NIC ROM, also sometimes software settable • Usually a flat address space

  12. Ethernet addresses • 48-bit source and destination addresses • Receiver’s link layer passes frame up to network-level protocol: • If destination address matches the adaptor’s • Or the destination address is the broadcast address (ff:ff:ff:ff:ff:ff) • Or the card is in a mode of operation that receives all frames (promiscuous mode) • Addresses are globally unique • Assigned by NIC vendors (top three bytesspecify vendor)

  13. Today • We finish the functionality of the link layer, and tie it in to IP • Framing and addressing • Repeaters, hubs, and switches • Comparison • Self-learning switches • The Spanning Tree Protocol • Bootstrapping a host

  14. HTTPmessage TCP segment IP datagram IP datagram IPdatagram IP IP IP Ethernet interface Ethernetframe SONET frame Ethernet frame Message, segment, datagram, and frame host host HTTP HTTP TCP TCP router router IP Ethernet interface SONET interface Ethernet interface Ethernet interface SONET interface

  15. Different devices switch on different information • Routers: forward IP datagramsbased on network-layer addresses in the IP header • Switches (Bridges): forward link-layer frames based on link-layer addresses in the link-layer header • Repeaters/Hubs: rebroadcast all bits in the physical-layer frame Router IP datagram H H data Network Physical-layer frame Link H H H H data Physical H H H H H H H H H H H H data data data Switch Link layer frame H H H Link data Physical Hub Physical

  16. Repeater Physical Layer: Repeaters • Distance limitation in local-area networks • Electrical signal becomes weaker as it travels • Imposes a limit on the length of a LAN • In addition to limit imposed by collision detection • Repeaters join LANs together • Analog electronic device • Continuously monitors electrical signals on each LAN • Transmits an amplified copy

  17. Physical Layer: Hubs • Joins multiple input lines electrically • Do not necessarily amplify the signal • Very similar to repeaters • Also operate at the physical layer hub hub hub hub

  18. Limitations of repeaters and hubs • One large place where packets collide (collision domain), since every bit is sent everywhere • So, aggregate throughput is limited • e.g., three departments each get 10 Mbps independently • … and then if connect via a hub must share 10 Mbps • Cannot support multiple LAN technologies • Repeaters/hubs do not buffer or interpret frames • So, can’t interconnect between different rates or formats • e.g., no mixing 100 Mbit/s Ethernet and Gigabit Ethernet • Limitations on maximum nodes and distances • Does not circumvent limitations of the shared medium • e.g., still cannot go beyond 2500 m in commercial Ethernet

  19. Link Layer: Switches • Switchesalso connect two or more LANs at the link layer • Extracts destination address from the frame • Looks up the destination in a table • Forwards the frame to the appropriate LAN segment • Or point-to-point link, for higher-speed Ethernet • Each port is its own collision domain (if not just a link) Switch collision domain collision domain hub Extended LAN

  20. Switches and concurrent communication • Host A can talk to C, while B talks to D B switch A C D • If host has (dedicated) point-to-point link to switch: • Full duplex: each connection can send in both directions • Completely avoids collisions • No need for carrier sense, collision detection, and so on • Change in medium access control, but same framing

  21. Switches: Advantages over hubs and repeaters • Only forwards frames as needed • Filters frames to avoid unnecessary load on segments • Sends frames only to segments that need to see them • Extends the geographic span of the network • Separate collision domains allow longer distances • Improves privacy by limiting scope of frames • Hosts can “snoop” the traffic traversing their segment • … but not all the rest of the traffic • Applies CSMA/CD in segment (not whole net) • Smaller collision domain • Joins segments using different technologies

  22. Disadvantages over hubs andrepeaters • Higher cost • More complicated devices that cost more money • Delay in forwarding frames • Bridge/switch must receive and parse the frame • … and perform a look-up to decide where to forward • Introduces store-and-forward delay • Can ameliorate using cut-through switching • Start forwarding after only header received • Need to learn where to forward frames • Bridge/switch needs to construct a forwarding table • Ideally, without intervention from network administrators • Solution: Self-learning algorithm

  23. Motivation for self learning • Benefit if switchforwards frame only on segment(s) that need it • Allows concurrent use of other links • Switch forwarding table • Maps destination link-layer address to outgoing interface • Goal: construct the switch table automatically B switch A C D

  24. Self learning algorithm: Building the table • When a frame (e.g., from A to B) arrives at the switch: • Inspect the sourcelink-layer address • Associate that address with the incomingswitch port • Store the mapping in the switch table • Use time-to-live field to eventually forget the mapping an amount of time later equal to its value • This is an example of soft state A  B data Switch forwarding table: B 2 1 3 switch 4 A C D Switch just learned how to reach A.

  25. Self learning algorithm: Handling misses • When frame arrives with unfamiliar destination (e.g., B) • Forward the frame out allportsexcept for the one on which the frame arrived • This is called flooding • Hopefully, this case won’t happen very often • When e.g. B replies, switch will learn that node, too A  B data Switch forwarding table: B 2 1 3 switch 4 A C D

  26. Self-learning algorithm When switch receives a frame: index into the forwarding table using link-layer destination address ifentry found for destination { ifdest on segment from which frame arrivedthendropframe elseforwardframe on interface indicated }elseflood the frame Forward on all ports except the porton which the frame arrived Problems?

  27. Flooding can lead to loops • Switches sometimes need to flood frames: • Upon receiving a frame with an unfamiliar destination • Upon receiving a frame sent to the broadcast address • Flooding can lead to forwarding loops • e.g., if the network contains a cycle of switches • Either accidentally, or by design for higher reliability • This is catastrophic, for two reasons: • Unlike IP, layer 2 has no way of preventing frame looping • Ethernet duplicates frames, leading to an exponential increase, quickly crashing the extended LAN (this is called a broadcast storm) How can we revise the bridge learning algorithm to avoid broadcast storms?

  28. The spanning tree protocol (STP) • Once the spanning tree is formed: • Switches use the switch learning algorithm to forward data frames over the tree links only • Early 1980s: Digital Equipment Corporation, a key Ethernet vendor, wanted to leverage the benefits of loops while avoiding broadcast storms • Radia Perlman’s idea: Switches agree on a loop-free and connectedspanning tree • Spanning tree: a sub-graph that touches all vertices but contains no cycles Graph with cycles Spanning tree has no cycles

  29. Spanning Tree Protocol (STP): Overview • Users connect Ethernet switches and shared-medium Ethernet LANs together • Arbitrarily, possibly creating forwarding loops • Need a distributed algorithm so that: • Switches cooperate to build the spanning tree • Switches adapt automatically when failures occur 1 2 3 4

  30. STP: Key ingredients of the algorithm • Switches elect one root switch from which to build the tree • Switch identifier = link-layer address on one port • Switches blocksome ports from sending or receiving frames of Ethernet type IP (or other L3 data) • To form tree, switches exchange configuration messages (R, d, X): • From switch X • Proposing switch R (which is d hops away) as the root • Configuration messages are never blocked Let’s begin with a simplified version of the full STP distributed algorithm Blocked ports 1 2 3 4 B B Root switch

  31. Simplified STP: State at each switch • Each switch X keeps the following state: • Its view of who the root is • Initially, itself: X X Root id: X

  32. Simplified STP: Startup and calculating the root • Note: Initially, each switch X periodically sends (X, 0, X) from all its ports Root ID rule: Root ID r at switch X is the minimum of X and root IDs received at all ports 1 Root id: 1 2 Root id: 2 3 Root id: 3 4 Root id: 4

  33. Simplified STP: Startup and calculating the root • Note: Initially, each switch X periodically sends (X, 0, X) from all its ports Root ID rule: Root ID r at switch X is the minimum of X and root IDs received at all ports  (2, 0, 2) • Switch 2 sends (2, 0, 2); switch 3 sets its root id to 1, switch 1 ignores  (2, 0, 2) 1 Root id: 1 2 Root id: 2 3 Root id: 2 4 Root id: 4  (2, 0, 2)

  34. Simplified STP: Startup and calculating the root • Note: Initially, each switch X periodically sends (X, 0, X) from all its ports Root ID rule: Root ID r at switch X is the minimum of X and root IDs received at all ports • Switch 1 sends (1, 0, 1); switches 2 and 3 set their root ids to 1  (1, 0, 1) 1 Root id: 1 2 Root id: 1 3 Root id: 1 4 Root id: 4 (1, 0, 1) 

  35. Simplified STP: Startup and calculating the root • Note: Initially, each switch X periodically sends (X, 0, X) from all its ports  (3, 0, 3) Root ID rule: Root ID r at switch X is the minimum of X and root IDs received at all ports (3, 0, 3)  • Switch 3 sends (3, 0, 3); switch 4 sets its root id to 3, others ignore  (3, 0, 3) 1 Root id: 1 2 Root id: 1 3 Root id: 1 4 Root id: 3

  36. STP: Startup and calculating the root • Note: Initially, each switch X periodically sends (X, 0, X) from all its ports (4, 0, 4)  Root ID rule: Root ID r at switch X is the minimum of X and root IDs received at all ports • Switch 4 sends (4, 0, 4); switch 3 ignores Not yet agreeing on the identity of the root: let’s now see how switches propagate information through the network 1 Root id: 1 2 Root id: 1 3 Root id: 1 4 Root id: 3

  37. Simplified STP: State at each switch • Each switch X keeps the following state: • Its view of who the root is • Initially, itself: X • Its configuration message to send • Initially, announcing itself as root with zero distance to root: (X, 0, X) X Root id: X Msg: (X, 0, X)

  38. Simplified STP: Calculating the message • Switch X finds its distance from the root (d): • If X thinksit is the root, d 0 • Otherwise, d the minimum distance from messages received matching X’s root id (call it r), plus one Configuration message rule: Switch X sets its configuration message to (r, d, X). If configuration message changes, sends updated message immediately 1 Root id: 1 Msg: (1, 0, 1) 2 Root id: 2 Msg: (2, 0, 2) 3 Root id: 3 Msg: (3, 0, 3) 4 Root id: 4 Msg: (4, 0, 4)

  39. Simplified STP: Calculating the message • Switch X finds its distance from the root (d): • If X thinksit is the root, d 0 • Otherwise, d the minimum distance from messages received matching X’s root id (call it r), plus one Configuration message rule: Switch X sets its configuration message to (r, d, X). If configuration message changes, sends updated message immediately • Switch 1 sends (1, 0, 1), switches 2 and 3 update their root ids and msgs  (1, 0, 1) 1 Root id: 1 Msg: (1, 0, 1) 2 Root id: 1 Msg: (1, 1, 2) 3 Root id: 1 Msg: (1, 1, 3) 4 Root id: 3 Msg: (4, 0, 4) (1, 0, 1) 

  40. Simplified STP: Calculating the message • Switch X finds its distance from the root (d): • If X thinksit is the root, d 0 • Otherwise, d the minimum distance from messages received matching X’s root id (call it r), plus one  (1, 1, 3) Configuration message rule: Switch X sets its configuration message to (r, d, X). If configuration message changes, sends updated message immediately • Switch 3 sends (1, 1, 3), switch 4 updates its root id and message 1 Root id: 1 Msg: (1, 0, 1) 2 Root id: 1 Msg: (1, 1, 2) 3 Root id: 1 Msg: (1, 1, 3) 4 Root id: 1 Msg: (1, 2, 4)

  41. Simplified STP: Calculating the message • Switch X finds its distance from the root (d): • If X thinks it is the root, d 0 • Otherwise, d the minimum distance from messages received matching X’s root id (call it r), plus one Now all switches agree on the root identifier. But how do they decide which ports to block to form the spanning tree? Configuration message rule: Switch X sets its configuration message to (r, d, X) 1 Root id: 1 Msg: (1, 0, 1) 2 Root id: 1 Msg: (1, 1, 2) 3 Root id: 1 Msg: (1, 1, 3) 4 Root id: 1 Msg: (1, 2, 4)

  42. STP: Port status • Allswitches connected to a Ethernet LAN (or the two at the ends of a cable) agree on a single“designated” port Designated port:The port on the shortest path from the LAN or cable to the root is the designated port(D) • The designated port forwards frames from the LAN to the root • Only designated ports send configuration messages D D 1 Root id: 1 Msg: (1, 0, 1) 2 Root id: 1 Msg: (1, 1, 2) 3 Root id: 1 Msg: (1, 1, 3) 4 Root id: 1 Msg: (1, 2, 4) D D

  43. STP: Port status Root port: Each non-root switchnotes which of its port is on the shortest path to the root; this port is the root port(R) D D 1 Root id: 1 Msg: (1, 0, 1) 2 Root id: 1 Msg: (1, 1, 2) 3 Root id: 1 Msg: (1, 1, 3) 4 Root id: 1 Msg: (1, 2, 4) D R D R R

  44. STP: Port status Blocked port:If neither designated nor root, a port is a blocked port(B), not forwarding data traffic. D D 1 Root id: 1 Msg: (1, 0, 1) 2 Root id: 1 Msg: (1, 1, 2) 3 Root id: 1 Msg: (1, 1, 3) 4 Root id: 1 Msg: (1, 2, 4) D B R D B R R

  45. STP: State at each switch • Each switch X keeps the following state: • Its view of who the root is • Initially, itself: X • Its configuration message to send • Initially, announcing itself as root with zero distance to root: (X, 0, X) • For eachof X’s ports: • Whether designated (D), root (R), or blocking (B)data traffic • Initially, designated (D) • “Best” configuration message heard on that port • Initially, its own configuration message (X, 0, X) X Root id: X Msg: (X, 0, X) D: (X, 0, X)

  46. STP: Designated port rule • At a switch, for each port p: • Consider all configuration messages received on port p and the configuration message the switch would send • If switch receives a “better” configuration message on a port p, don’t send configuration messages on port p • Else, p is designated:send configuration message on p • Rule for comparing configuration messages: (R1, d1, X1) better than(R2, d2, X2)if R1 < R2or (R1 = R2and d1 < d2) or (R1 = R2and d1 = d2and X1 < X2)

  47. STP: Complete example • All switches begin thinking they are root with all ports in the designated state D: (2,0,2) D: (3,0,3) 1 Root id: 1 Msg: (1,0,1) 2 Root id: 2 Msg: (2,0,2) 3 Root id: 3 Msg: (3,0,3) 4 Root id: 4 Msg: (4,0,4) D: (2,0,2) D: (3,0,3) D: (1,0,1) D: (3,0,3) D: (1,0,1) D: (4,0,4) D: (2,0,2)

  48. STP: Complete example • All switches begin thinking they are root with all ports in the designated state • Switch 1 sends (1,0,1), switches 2 and 3 update their root ids, ports, and msgs • Switch 2 breaks “tie” between the two copies of (1,0,1) locallyby numbering its ports • Each switch’s port remembers the bestconfiguration message seen so far 3 2 1  (1, 0, 1) D: (2,0,2) D: (3,0,3) 4 Root id: 4 Msg: (4,0,4) 1 Root id: 1 Msg: (1,0,1) 3 Root id: 1 Msg: (1,1,3) 2 Root id: 1 Msg: (1,1,2) (1, 0, 1)  B: (1,0,1) R: (1,0,1) D: (1,0,1) D: (3,0,3) D: (1,0,1) D: (4,0,4) R: (1,0,1)

  49. STP: Complete example • Switch 3 sends (1,1,3) from its designated ports , switch 4 updates its root id and message • Switch 2, port 3 remains designated because Switch 2’s message (1,1,2) is better than (1,1,3) • Switch 1, port 1 remains designated because Switch 1’s message (1,0,1) is better than (1,1,3) (1,1,3)  (1,1,3)  3 2 1 D: (1,1,3) D: (3,0,3) 4 Root id: 1 Msg: (1,2,4) 3 Root id: 1 Msg: (1,1,3) 2 Root id: 1 Msg: (1,1,2) 1 Root id: 1 Msg: (1,0,1) B: (1,0,1) R: (1,0,1) D: (1,0,1) D: (3,0,3) D: (1,0,1) R: (1,1,3) 1 2 R: (1,0,1)

  50. STP: Complete example • Switch 2 sends (1,1,2) from port 3 only • Switch 3 blocks its port 3 since (1,1,2) is better than its message (1,1,3) 2 1 3  (1,1,2) 3 2 1 D: (1,1,3) D: (3,0,3) 2 Root id: 1 Msg: (1,1,2) 1 Root id: 1 Msg: (1,0,1) 4 Root id: 1 Msg: (1,2,4) 3 Root id: 1 Msg: (1,1,3) B: (1,0,1) R: (1,0,1) D: (1,0,1) B: (1,1,2) D: (1,0,1) R: (1,1,3) R: (1,0,1)

More Related