Addressing and Switching in the Link Layer

Similar documents
Address and Switching in the Link Layer

ECE 158A: Lecture 13. Fall 2015

Switching and Forwarding Reading: Chapter 3 1/30/14 1

CS 457 Lecture 11 More IP Networking. Fall 2011

Data Link Layer. Our goals: understand principles behind data link layer services: instantiation and implementation of various link layer technologies

Missing pieces + Putting the pieces together

Lecture 11: Addressing, Framing, and Switching in the Link Layer CS 3035/GZ01: Networked Systems Kyle Jamieson

Principles behind data link layer services

Principles behind data link layer services:

Principles behind data link layer services:

Link layer: introduction

CS 43: Computer Networks Switches and LANs. Kevin Webb Swarthmore College December 5, 2017

Communication Networks

Medium Access Protocols

Ethernet. EE 122: Intro to Communication Networks. Fall 2007 (WF 4-5:30 in Cory 277) Vern Paxson TAs: Lisa Fowler, Daniel Killebrew & Jorge Ortiz

Summary of MAC protocols

Last time. Network layer. Introduction. Virtual circuit vs. datagram details. IP: the Internet Protocol. forwarding vs. routing

The Link Layer and LANs: Ethernet and Swiches

Cisco Cisco Certified Network Associate (CCNA)

Missing pieces + Putting the pieces together

Principles behind data link layer services:

CS 455/555 Intro to Networks and Communications. Link Layer Addressing, Ethernet, and a Day in the Life of a Web Request

LAN Interconnection and Other Link Layer Protocols

CSEN 503 Introduction to Communication Networks. Mervat AbuElkheir Hana Medhat Ayman Dayf. **Slides are attributed to J. F. Kurose

Introduction to Internetworking

CSC 4900 Computer Networks: Link Layer (2)

Communication Networks ( ) / Spring 2011 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner

19: Networking. Networking Hardware. Mark Handley

Switching & ARP Week 3

L2 Addressing and data plane. Benjamin Baron

ECE 4450:427/527 - Computer Networks Spring 2017

Reliable Transport I: Concepts and TCP Protocol

Interface The exit interface a packet will take when destined for a specific network.

Guide to Networking Essentials, 6 th Edition. Chapter 5: Network Protocols

Objectives. Hexadecimal Numbering and Addressing. Ethernet / IEEE LAN Technology. Ethernet

More on Link Layer. Recap of Last Class. Interconnecting Nodes in LAN (Local-Area Network) Interconnecting with Hubs. Computer Networks 9/21/2009

Chapter 3 Part 2 Switching and Bridging. Networking CS 3470, Section 1

Hubs. twisted pair. hub. 5: DataLink Layer 5-1

Administrivia CSC458 Lecture 4 Bridging LANs and IP. Last Time. This Time -- Switching (a.k.a. Bridging)

Communication Networks ( ) / Fall 2013 The Blavatnik School of Computer Science, Tel-Aviv University. Allon Wagner

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

Lecture 6 The Data Link Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Lecture 5 The Data Link Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Lecture 9 The Data Link Layer part II. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

Network Model. Why a Layered Model? All People Seem To Need Data Processing

CCM 4300 Lecture 5 Computer Networks, Wireless and Mobile Communications. Dr Shahedur Rahman. Room: T115

CS 3516: Advanced Computer Networks

Telematics I. Chapter 6 Internetworking. (Acknowledement: These slides have been compiled from H. Karl s set of slides)

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

Professor Yashar Ganjali Department of Computer Science University of Toronto.

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

CIS 551 / TCOM 401 Computer and Network Security. Spring 2007 Lecture 8

Top-Down Network Design, Ch. 7: Selecting Switching and Routing Protocols. Top-Down Network Design. Selecting Switching and Routing Protocols

Lecture 6. Data Link Layer (cont d) Data Link Layer 1-1

EPL606. Internetworking. Part 2a. 1Network Layer

Lecture 9: Bridging & Switching"

Some portions courtesy Srini Seshan or David Wetherall

Subnets. IP datagram format. The Internet Network layer. IP Fragmentation and Reassembly. IP Fragmentation & Reassembly. IP Addressing: introduction

ICS 451: Today's plan

What is Multicasting? Multicasting Fundamentals. Unicast Transmission. Agenda. L70 - Multicasting Fundamentals. L70 - Multicasting Fundamentals

Computer Network Fundamentals Spring Week 3 MAC Layer Andreas Terzis

Full file at

CSE 123: Computer Networks Alex C. Snoeren. HW 2 due Thursday 10/21!

Top-Down Network Design

Chapter 2 - Part 1. The TCP/IP Protocol: The Language of the Internet

Links Reading: Chapter 2. Goals of Todayʼs Lecture. Message, Segment, Packet, and Frame

CSC 401 Data and Computer Communications Networks

CSCD 330 Network Programming Spring 2017

Chapter 5 Link Layer. Computer Networking: A Top Down Approach. 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012

PUCPR. Internet Protocol. Edgard Jamhour E N G L I S H S E M E S T E R

Introduction to Communication Networks Spring Unit 13 Network extensions Bridges.

CS4450. Computer Networks: Architecture and Protocols. Lecture 20 Pu+ng ALL the Pieces Together. Spring 2018 Rachit Agarwal

1: Review Of Semester Provide an overview of encapsulation.

CompSci 356: Computer Network Architectures. Lecture 7: Switching technologies Chapter 3.1. Xiaowei Yang

CSCI Computer Networks

CompSci 356: Computer Network Architectures. Lecture 8: Spanning Tree Algorithm and Basic Internetworking Ch & 3.2. Xiaowei Yang

Internet Architecture and Experimentation

Introduction to computer networking

The trace is here:

The Interconnection Structure of. The Internet. EECC694 - Shaaban

EEC-684/584 Computer Networks

Layer 2 functionality bridging and switching

Review. Error Detection: CRC Multiple access protocols. LAN addresses and ARP Ethernet. Slotted ALOHA CSMA/CD

CSE 123A Computer Networks

Link Layer and LANs. CMPS 4750/6750: Computer Networks

Routing. Information Networks p.1/35

Chapter 4: Network Layer

Computer Networks. Wenzhong Li. Nanjing University

Chapter 6 The Link Layer and LANs

CSCI-1680 Link Layer Wrap-Up Rodrigo Fonseca

Computer Networking Introduction

ECSE 414 Fall 2014 Final Exam Solutions

Growth. Individual departments in a university buy LANs for their own machines and eventually want to interconnect with other campus LANs.

Internetworking/Internetteknik, Examination 2G1305 Date: August 18 th 2004 at 9:00 13:00 SOLUTIONS

THE INTERNET PROTOCOL INTERFACES

Internetworking Part 1

The Internetworking Problem. Internetworking. A Translation-based Solution

The Internet Protocol

Router Architecture Overview

Da t e: August 2 0 th a t 9: :00 SOLUTIONS

Transcription:

Addressing and Switching in the Link Layer Stefano Vissicchio UCL Computer Science COMP00

Recap: We have done a full pass on the stack email WWW phone...! SMTP HTTP RTP...! TCP UDP!! IP! When and how to transmit (e.g., Wifi and Ethernet)! ethernet PPP! CSMA async sonet...! copper fiber radio...!

Recap: We have done a full pass on the stack email WWW phone...! SMTP HTTP RTP...! How to ensure reliability (error detection/correction codes, checksums, reliability protocols) TCP UDP!! IP!! ethernet PPP! CSMA async sonet...! copper fiber radio...!

Recap: We have done a full pass on the stack email WWW phone...! Primitives for Internet communication (e.g., IP, congestion control, DNS) SMTP HTTP RTP...! TCP UDP!! IP!! ethernet PPP! CSMA async sonet...! copper fiber radio...! 4

We now focus on switching and routing How do hosts and network devices know where to send packets? Host bootstrapping (ARP, DHCP) Packet delivery from one hop to the next one (forwarding) Best path selection for each packet (routing) 5

We now focus on switching and routing How do hosts and network devices know where to send packets? Host bootstrapping (ARP, DHCP) This requires us to restart from the link layer Packet delivery from one hop to the next one (forwarding) Best path selection for each packet (routing) 6

Recap: What we ve covered on the link layer IP datagram Link-layer protocol Sending entity frame frame Receiving entity Enables the exchange of messages (frames) on a cable Functionality:. Framing: Determine start and end of bits and frames. Error control: Detect and/or correct errors. Reliable delivery: Deliver frames exactly once 4. Medium access control, for hosts to share the medium 7

Agenda We finish the functionality of the link layer, and tie it in to IP. Addressing. Bootstrapping a host. Extending LANs 8

Comparing addressing schemes Network layer address Identifier with Internet-wide scope -bit IP address, represented as 4 unsigned integers a.b.c.d Hierarchical address space Set by software, depending on the location Link layer address (MAC address) Identifier within a Local Area Network (LAN) Unique 48-bit address Usually a flat address space Burned in NIC ROM, also sometimes software settable 9

MAC addresses 48-bit globally unique addresses, assigned by NIC vendors Represented as 6 hexadecimal numbers xx:yy:zz:uu:mm:ww Top bytes specify the vendor Receiver s link layer passes a frame up (to network layer) if: The frame destination is the NIC address The frame destination is broadcast address (ff:ff:ff:ff:ff:ff) The card is in promiscuous mode (catches all the frames) 0

Agenda We finish the functionality of the link layer, and tie it in to IP. Addressing. Bootstrapping a host Providing addressing information (DHCP) Enabling hosts to send packets (ARP). Extending LANs

New hosts need bootstrapping information What IP address should the host use? How to contact the local DNS server? How to send packets to destinations? Local and remote???...7...56 host host... DNS 5.6.7. host host... DNS...0/ 55.55.54.0...9 router router router 5.6.7.0/4

DHCP and ARP avoid manual configuration Dynamic Host Configuration Protocol (DHCP) End host learns its address and basic information on LAN, namely: IP address, what s local, DNS servers, gateway...48 / host host...56 DNS 5.6.7. host host... DNS...0/ 55.55.54.0 router...9 router router 5.6.7.0/4

DHCP and ARP avoid manual configuration Address Resolution Protocol (ARP) Enables hosts to reach local destinations ARP provide mapping between IP and MAC address...48 / host host......56 DNS A:F:BB:76:09:AD 5.6.7. host host... DNS...0/ 55.55.54.0...9 5.6.7.0/4 router router router 4

Key ideas in both protocols Broadcasting: when in doubt, shout! Send query to all hosts in the LAN Caching: remember the past for a while Store the information you learn to reduce overhead Remember your own address and other host s addresses Soft state: eventually forget the past Associate a time-to-live (TTL) field to information On expiry either refresh or discard information Key for robustness in the face of unpredictable change 5

Bootstrapping problem Host doesn t have an IP address yet So, host doesn t know what source address to use Host doesn t know whom to ask for an IP address So, host doesn t know what destination address to use host host router router 6

DHCP solution: Client discovery message Broadcasting: shout to discover a server that can help Client sends a DHCP discover message The message is sent in broadcast Source IP address 0.0.0.0 Destination MAC address ff:ff:ff:ff:ff:ff Destination IP address 55.55.55.55 host host router router 7

DHCP solution: Server reply Any DHCP server on the LAN replies, with an offer DHCP offer messages contain Configuration parameters: proposed IP address, netmask, gateway, DNS server Lease time: duration of information validity host host DHCP server router router 8

DHCP solution: Relay agent reply Also, any DHCP relay agent replies with a DHCP offer A relay agent is configured with the IP address of a DHCP server on another network Unicasts client requests to the remote DHCP server Receives the server replies (sent in unicast to relay agent) Forwards such replies to the client s network host host DHCP server DHCP relay router router 9

DHCP solution: Client configuration Client accepts one of the received offers Client sends a DHCP request echoing the parameters DHCP server confirms with a DHCP ACK Other servers see they were not chosen They can safely offer the non-accepted parameters to other clients, afterwards...48 / host...56 host DNS host host... DNS...9 router router router 0

DHCP summary Arriving client DHCP discover (broadcast) DHCP offer (broadcast) DHCP ACK (broadcast) DHCP request (broadcast) DHCP server Why all broadcasts?

DHCP summary Arriving client DHCP discover (broadcast) DHCP offer (broadcast) DHCP ACK (broadcast) DHCP request (broadcast) DHCP server Why all broadcasts? Discover broadcast: client doesn t know DHCP server s identity Offer broadcast: client doesn t have an IP address yet Request broadcast: so other servers can see ACK broadcast: client still doesn t have an IP address

Why soft state? Clients can release the IP address, with DHCP release e.g., clean shutdown of the computer... But they might also not release the address at all e.g., the host crashes e.g., buggy client software Performance trade-offs Short lease time: returns inactive addresses quickly Long lease time: avoids overhead of frequent renewals

Now, the host knows things... ü IP address ü IP subnet mask ü IP address of Gateway router ü IP address of DNS server It should be able to send packets to other IP addresses, but How can it use the local network to send packets? 4

... But the host do not know enough (yet) Hosts can send any packet: Directly to the destination, if it is local (same IP subnet) To the configured gateway, if the destination is remote Two questions to answer Is the destination local? Which is the destination MAC address to use?...48/...56 host host host... host DNS DNS...0/ 55.55.54.0...9 router router router 5

Is the destination local? Use the netmask! Compare X = bitwise AND (destination IP address, netmask) Y = bitwise AND (own IP address, netmask) Destination is local if and only if X == Y...48/...56 host host host... host DNS DNS...0/ 55.55.54.0...9 router router router 6

Which is the MAC address to use? Need to know the mapping between IP and MAC addresses For any possible machine in the LAN Including routers, needed to reach remote destinations There is a protocol to build such mappings: ARP...48/...56 A:F:BB:76:09:AD host host host... host DNS DNS...0/ 55.55.54.0...9 router router router 7

Address Resolution Protocol (ARP) Every node maintains an ARP table Containing (IP address, link-layer address) pairs Hosts consult the table when sending a packet Map destination IP address to destination MAC address Encapsulate and transmit the data packet But what if the destination IP address is not in the table? 8

Address Resolution Protocol (ARP) To discover an unknown IP MAC address mapping Sender broadcasts: Who has IP address...56? (including its own link-layer and IP addresses) IP-address owner responds: IP address...56 is at link-layer address A:F:BB:76:09:AD (in unicast, to the source of the broadcast) Sender caches response in its ARP table 9

Example: Putting pieces together Host A wants to send a datagram to host B A already knows B s IP address from the DNS server Every packet is forwarded in two macro-steps:. A sends the packet to R. R forwards the packet to B A host 74:9:9c:e8:ff:55 8.6.74.9 49:bd:d:c7:56:a 8.87.0. B host Network 8.6.64.0/0 e6:e9:00:7:bb:4b 8.6.64. router R a::f9:cd:06:9b 8.87.0. Network 8.87.0.0/0 0

Step : A first sends to R Host A constructs an IP packet to send to B IP source 8.6.74.9, IP destination 8.87.0. Host A knows about the default gateway R To reach destinations outside of 8.6.64.0/0 IP address 8.6.64. of R, learned from DHCP A host 74:9:9c:e8:ff:55 8.6.74.9 49:bd:d:c7:56:a 8.87.0. B host Network 8.6.64.0/0 e6:e9:00:7:bb:4b 8.6.64. router R a::f9:cd:06:9b 8.87.0. Network 8.87.0.0/0

Step : A first sends to R A learns the MAC address of R s interface (if not in A s cache) ARP request: broadcast request for 8.6.64. ARP response: R responds with e6:e9:00:7:bb:4b A encapsulates the built IP packet in a link-layer header A sends this frame to R, MAC address e6:e9:00:7:bb:4b A host 74:9:9c:e8:ff:55 8.6.74.9 49:bd:d:c7:56:a 8.87.0. B host Network 8.6.64.0/0 To: R A à B data e6:e9:00:7:bb:4b 8.6.64. router R a::f9:cd:06:9b 8.87.0. Network 8.87.0.0/0

Step : R forwards the datagram to B Router R s left interface receives the packet R extracts the IP packet from the Ethernet frame R sees the IP packet is destined to 8.87.0. R consults its forwarding table Packet matches 8.87.0.0/0 via the right interface A host 74:9:9c:e8:ff:55 8.6.74.9 49:bd:d:c7:56:a 8.87.0. B host Network 8.6.64.0/0 e6:e9:00:7:bb:4b 8.6.64. A à B router R data a::f9:cd:06:9b 8.87.0. Network 8.87.0.0/0

Step : R forwards the datagram to B R s right interface learns the MAC address of B ARP request: broadcast request for 8.87.0. ARP response: B responds with 49:bd:d:c7:56:a R encapsulates the packet and sends to B A host 74:9:9c:e8:ff:55 8.6.74.9 49:bd:d:c7:56:a 8.87.0. B host Network 8.6.64.0/0 e6:e9:00:7:bb:4b 8.6.64. router R To: B A à B data a::f9:cd:06:9b 8.87.0. Network 8.87.0.0/0 4

ARP (in)security Hazard: Any node can send an ARP reply and say whatever they want This enables several attacks Impersonation: malicious host impersonate the destination Legit receiver never sees a problem: never receives a packet! its NIC doesn t capture later packets, since they do not carry its link-layer address Man-in-the-middle: imposter receives frames from the source and updates them with correct link-layer address Sender and receiver never see a problem but the imposter gets to inspect (and alter?) all frames 5

ARP (in)security Hazard: Any node can send an ARP reply and say whatever they want This enables several attacks Impersonation: malicious host impersonate the destination The attacker might not even need to Legit receiver never sees a problem: never receives a packet! win a race with the legit destination its NIC doesn t capture later packets, since they do not (if the sender blindly believes ARP messages) carry its link-layer address Man-in-the-middle: imposter receives frames from the source and updates them with correct link-layer address Sender and receiver never see a problem but the imposter gets to inspect (and alter?) all frames 6

Agenda We finish the functionality of the link layer, and tie it in to IP. Addressing. Bootstrapping a host. Extending LANs Link-layer devices Self-learning algorithm The Spanning Tree Protocol 7

Is a LAN implemented as a single cable?...48 / host...56 5.6.7. host DNS host host... DNS...0/ 55.55.54.0 router...9 router router 5.6.7.0/4 Physical limits Signal weakens as it travels Performance shortcomings All hosts in the LAN must share the same bandwidth More hosts à more potential collisions 8

There are more devices than just routers HTTP host HTTP message host HTTP TCP TCP segment TCP intermediate system intermediate system IP IP datagram IP IP datagram IP Ethernet interface Ethernet interface SONET interface SONET interface Ethernet interface Ethernet interface Ethernet frame SONET frame Ethernet frame 9

There are more devices than just routers Routers: forward IP datagrams based on network-layer addresses in the IP header H H H H data Network Link Physical Router IP datagram H H data Switches (bridges): forward linklayer frames based on link-layer addresses in the link-layer header H H H H data Repeaters and hubs: re-broadcast all bits in the physical-layer frame Link Physical Switch Link layer frame H H H data Repeater Physical-layer frame H H H H data Physical H H H H data 40

Physical layer: repeaters Analog electronic devices that join cables together Continuously monitor electrical signals on each cable Transmit an amplified copy of the input signals Overcome weakening of signals as they travel Repeater 4

Physical layer: hubs Very similar to repeaters Operates at the physical layer too Join multiple input lines electrically Do not necessarily amplify the signal (but commonly do so) hub hub hub hub 4

Limitations of repeaters and hubs Do not separate collision domains They create one larger place where packets collide, since every bit is sent everywhere Do not circumvent limitations of the shared medium Maximum nodes and distances as in a single LAN for collision detection e.g., cannot go beyond 500 m in commercial Ethernet 4

Limitations of repeaters and hubs (cont d) Force limited aggregate throughput departments each get 0 Mbps independently if connect via hubs/repeaters, they must share 0 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 00 Mbit/s Ethernet and Gigabit Ethernet 44

Link layer: switches Switches connect two or more collision domains Each switch port defines a different collision domain Switches forward frames selectively Extract link-layer destination address from each frame Forward each frame to the appropriate collision domain Switch collision domain hub 45

Switches enable concurrent communication Host A can talk to C, while B talks to D B A switch C 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, ü Change in medium access control, but same framing D 46

Advantages of switches over hubs/repeaters Separates collision domains! Applies CSMA/CD in each LAN (not whole net) Extends the geographic span of the network Joins segments using different technologies Only forwards frames as needed Avoids unnecessary load on connected LANs Improves privacy by limiting scope of frames hosts can only snoop the traffic traversing their LAN 47

Disadvantages of switches wrt. repeaters/hubs Higher costs Switches are more complicated devices Introduce delay in forwarding frames Switches must receive, parse and decide where to forward every crossing frame Hence, introduces store-and-forward delay Ameliorated with cut-through switching Start forwarding after only header received 48

How do switches know where to send frames? Switches maintain a forwarding table Maps destination link-layer address to outgoing switch interface Goal: construct the switch table automatically Without intervention from network administrators Solution: Self-learning algorithm 49

Self learning algorithm: building the table Basic idea: build the forwarding table on the fly as new frames arrive at the switch Let s assume we start from an empty table B Switch forwarding table: Address Port Time-to-live A switch 4 C D 50

Self learning algorithm: building the table For any frame sent on a LAN, the switch will get to know where is located the source link-layer address: Maps the source address to its incoming port Stores the mapping in its forwarding table Switch forwarding table: B Address Port Time-to-live A A à B data A switch 4 C D Switch just learned how to reach A. 5

Self learning algorithm: building the table For any forwarding entry, the switch sets the time-to-live to eventually forget the address-port mapping e.g., if hosts move or disappear Switch forwarding table: B Address Port Time-to-live A minutes A à B data A switch 4 C D This is yet another example of soft state 5

Self learning algorithm: handling misses The switch uses flooding to forward frames for unfamiliar destination (e.g., B) or broadcast messages i.e., forwarding the frame out all ports except for the one on which the frame arrived after the reply, the switch will learn about the destination Switch forwarding table: B Address Port Time-to-live A minutes A à B data A switch 4 C D 5

Self learning algorithm: pseudo-code When switch receives a frame Look for link-layer destination address in the forwarding table if entry found for destination { if dest on segment from which frame arrived then drop frame else forward frame on interface indicated } else flood the frame Forward on all ports except the port on which the frame arrived 54

Self learning algorithm: pseudo-code When switch receives a frame Look for link-layer destination address in the forwarding table if entry found for destination { if dest on segment from which frame arrived then drop frame else forward frame on interface indicated } else flood the frame Forward on all ports except the port on which the frame arrived Is that safe? 55

Flooding can lead to loops Flooding can lead to forwarding loops and severe congestion e.g., if the network contains a cycle of switches Loops can be catastrophic for the extended LAN. Unlike IP, layer cannot stop loops. Loop à (exponential) increase of frames: broadcast storm Frames are broadcast, received and rebroadcast by each switch 56

Flooding can lead to loops Flooding can lead to forwarding loops and severe congestion e.g., if the network contains a cycle of switches Loops can be catastrophic for the extended LAN. Unlike IP, How layer can cannot we revise stop the loops self learning. Loop à algorithm (exponential) to avoid increase broadcast of frames: storms? broadcast storm Frames are broadcast, received and rebroadcast by each switch 57

Spanning Tree Protocol (STP) Early 980s: Digital Equipment Corporation (key Ethernet vendor) wanted to leverage the benefits of topology redundancy while avoiding broadcast storms Radia Perlman s idea: forward data frames over a tree no looping for frames flooded by the self learning algorithm Network, with cycles Forwarding tree, no cycles 58

Spanning Tree Protocol (STP) Requirements Connect every switch and LAN in the network Provide automatic setup and failure repair STP defines how switches build a spanning tree A spanning tree is a sub-graph that touches all vertices but contains no cycles Network, with cycles Spanning tree, no cycles 59

STP: Overview Input: physical network Users connect Ethernet switches and shared-medium Ethernet LANs arbitrarily (potentially, with cycles) STP defines a distributed algorithm, aimed to. Decide the root of the spanning tree. Compute the edges of the spanning tree. Support forwarding between any pair of LANs (over the tree) The STP algorithm relies on exchanging control-plane messages between switches 60

STP: Running Example We run STP over the example network shown here Nodes represent switches Links represents LANs 4 Note that this network has many cycles and possibly many hosts connected to each LAN 6

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 (interpreted as a number) 4 Switches block some ports from sending or receiving frames of Ethernet type IP (or other L data) B 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 Blocked ports B Root switch 6

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 (interpreted as a number) 4 Switches block some ports from sending or receiving Let s begin frames with of a simplified version of the Ethernet type IP (or full other STP L distributed data) algorithm 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 B Blocked ports Root switch B 6

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 64

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 Root id: 4 Root id: 4 Root id: Root id: 65

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 sends (, 0, ); switch sets its root id to, switch ignores Root id: ß (, 0, ) 4 Root id: 4 Root id: Root id: 66

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 sends (, 0, ); switches and set their root ids to Root id: 4 Root id: 4 Root id: ß (, 0, ) Root id: 67

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 sends (, 0, ); switch 4 sets its root id to, others ignore Root id: 4 Root id: Root id: Root id: 68

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 4 sends (4, 0, 4); switch ignores Not yet agreeing on the identity of the root: we need to propagate information multiple hops through the network Root id: Root id: 4 Root id: Root id: 69

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) Recall: (root ID, dist to root, sent from) 70

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 Configuration message rule: Switch X sets its configuration message to (r, d, X). If configuration message changes, sends updated message immediately Root id: Msg: (, 0, ) 4 Root id: 4 Msg: (4, 0, 4) Root id: Msg: (, 0, ) Root id: Msg: (, 0, ) Recall: (root ID, dist to root, sent from) 7

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 Configuration message rule: Switch X sets its configuration message to (r, d, X). If configuration message changes, sends updated message immediately Switch sends (, 0, ), switches and update their root ids and msgs Recall: (root ID, dist to root, sent from) Root id: Msg: (,, ) Root id: Msg: (, 0, ) 4 Root id: Msg: (4, 0, 4) Root id: Msg: (,, ) 7

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 Configuration message rule: Switch X sets its configuration message to (R, d, X). If configuration message changes, sends updated message immediately Switch sends (,, ), switch 4 updates its root id and message Recall: (root ID, dist to root, sent from) Root id: Msg: (,, ) Root id: Msg: (, 0, ) 4 Root id: Msg: (,, 4) Root id: Msg: (,, ) 7

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 Configuration message rule: Switch X sets its configuration message to (r, d, X) 4 Root id: Msg: (,, 4) All switches agree on the root identifier. Root id: Msg: (,, ) Now they must decide which ports to block to form the spanning tree. Root id: Msg: (,, ) Root id: Msg: (, 0, ) Recall: (root ID, dist to root, sent from) 74

STP: Port status All switches connected to a Ethernet LAN (or the two at the ends of a cable) agree on a single designated port 4 Root id: Msg: (,, 4) Designated port: The port on the shortest path from the LAN or cable to the root is the designated port (D) D Root id: Msg: (,, ) D The designated port forwards frames from the LAN to the root Only designated ports send configuration messages D Root id: Msg: (, 0, ) Root id: Msg: (,, ) D Recall: (root ID, dist to root, sent from) 75

STP: Port status Root port: Each non-root switch notes which of its ports is on the shortest path to the root; this port is the root port (R) Recall: (root ID, dist to root, sent from) R D R D Root id: Msg: (,, ) Root id: Msg: (, 0, ) 4 Root id: Msg: (,, 4) Root id: Msg: (,, ) D D R 76

STP: Port status Blocked port: If neither designated nor root, a port is a blocked port (B), R 4 Root id: Msg: (,, 4) Blocked ports don t forwarding data traffic. R D Root id: Msg: (,, ) B D B Root id: Msg: (,, ) R D Root id: Msg: (, 0, ) D Recall: (root ID, dist to root, sent from) 77

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) D: (X, 0, X). For each of 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) 78

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: (R, d, X ) better than (R, d, X ) if R < R or (R = R and d < d ) or (R = R and d = d and X < X ) 79

STP: Complete example All switches begin thinking they are root with all ports in the designated state D: (4,0,4) 4 Root id: 4 Msg: (4,0,4) D: (,0,) D: (,0,) Root id: Msg: (,0,) D: (,0,) D: (,0,) D: (,0,) Root id: Msg: (,0,) D: (,0,) Recall: (root ID, dist to root, sent from) D: (,0,) Root id: Msg: (,0,) D: (,0,) 80

STP: Complete example All switches begin thinking they are root with all ports in the designated state Switch sends (,0,), switches and update their root ids, ports, and msgs Switch breaks tie between the two copies of (,0,) locally by numbering its ports Each switch s port remembers the best configuration message seen so far Recall: (root ID, dist to root, sent from) R: (,0,) ß (, 0, ) D: (,0,) D: (4,0,4) D: (,0,) Root id: Msg: (,,) B: (,0,) Root id: Msg: (,0,) 4 Root id: 4 Msg: (4,0,4) D: (,0,) D: (,0,) Root id: Msg: (,,) R: (,0,) D: (,0,) (, 0, ) à 8

STP: Complete example Switch sends (,,) from its designated ports: Switch 4 updates its root id and message Switch, port remains designated because Switch s message (,,) is better than (,,) R: (,0,) (,,) à R: (,,) D: (,0,) Root id: Msg: (,,) B: (,0,) 4 Root id: Msg: (,,4) D: (,0,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) D: (,0,) Root id: D: (,0,) Msg: (,0,) 8

STP: Complete example Switch sends (,,) from port only Switch blocks its port since (,,) is better than its message (,,), and it prefers port as its root port. R: (,0,) R: (,,) D: (,0,) Root id: Msg: (,,) B: (,0,) 4 Root id: Msg: (,,4) B: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) D: (,0,) Root id: Msg: (,0,) D: (,0,) 8

STP: Dynamics When do switches send configuration messages? If you think you re the root, send periodically with parameter hello time (two seconds recommended in 80.d) Other switches send on all designated ports upon receiving root s message How does the algorithm adapt to topology changes? State table contains age field, which is updated continuously Aging rule: If age reaches a threshold max age (0 sec in 80.d), discard that table entry and recalculate using all rules What happens if max age is too big? Too small? Recalculate when receive better or newer configuration message on port p (resulting in a table entry being overwritten) 84

STP: Handling failures Suppose the Ethernet LAN fails R: (,,) 4 Root id: Msg: (,,4) R: (,0,) D: (,0,) Root id: Msg: (,,) B: (,0,) B: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) D: (,0,) Root id: Msg: (,0,) D: (,0,) 85

STP: Handling failures Suppose the Ethernet LAN fails Switch : Stops hearing the root s messages through port, so it becomes designated Port becomes root Updates its own message D: (,,) R: (,,) D: (,0,) Root id: Msg: (,,) B: (,0,) 4 Root id: Msg: (,,4) R: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) D: (,0,) Root id: Msg: (,0,) D: (,0,) 86

STP: Handling failures Suppose the Ethernet LAN fails Switch 4: Updates message heard on root port Updates its own message Switch : Stops hearing the root s messages through port, so it becomes designated D: (,,) R: (,,) D: (,0,) Root id: Msg: (,,) D: (,,) 4 Root id: Msg: (,,4) R: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) D: (,0,) Root id: Msg: (,0,) D: (,0,) 87

STP: Handling topology change Suppose we fix the LAN. Now we have created (temporary) forwarding loops R: (,,) 4 Root id: Msg: (,,4) This also happens when switches are powered-up D: (,,) D: (,0,) Root id: Msg: (,,) D: (,,) R: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) D: (,0,) Root id: Msg: (,0,) D: (,0,) 88

STP: Pre-forwarding port state Suppose any of the following apply to a port:. Transition from B à D. Any newly-connected port (detect Ethernet carrier). Any port on a freshlypowered switch The port then enters the preforwarding (PF) state, where: It sends configuration messages and transitions to blocked and root states as if designated But it does not forward data frames, so can t create loops PF: (,,) PF: (,0,) R: (,,) D: (,0,) Root id: Msg: (,,) PF: (,,) Root id: Msg: (,0,) 4 Root id: Msg: (,,4) R: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) D: (,0,) 89

STP: Pre-forwarding port state Switches returns to old state R: (,,) 4 Root id: Msg: (,,4) R: (,0,) D: (,0,) Root id: Msg: (,,) PF: (,,) B: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) PF: (,0,) Root id: Msg: (,0,) D: (,0,) 90

STP: Pre-forwarding port state Switch returns to old state Switch returns to old state R: (,,) 4 Root id: Msg: (,,4) R: (,0,) D: (,0,) Root id: Msg: (,,) B: (,0,) B: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) PF: (,0,) Root id: Msg: (,0,) D: (,0,) 9

STP: Pre-forwarding port state Switch returns to old state Switch returns to old state Switch 4 returns to old state R: (,,) 4 Root id: Msg: (,,4) Now switch, port remains in the pre-forwarding state R: (,0,) D: (,0,) Root id: Msg: (,,) B: (,0,) R: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) Recall: (root ID, dist to root, sent from) PF: (,0,) Root id: D: (,0,) Msg: (,0,) 9

STP: Leaving the pre-forwarding state If still in PF state after some number of seconds (forwarding delay parameter) then the port becomes designated (D) How long should forwarding delay be? Long enough for the entire spanning tree to re-form, i.e.: Twice the maximum transit time across the extended LAN 0 seconds in 80.d R: (,0,) R: (,,) D: (,0,) Root id: Msg: (,,) B: (,0,) 4 Root id: Msg: (,,4) B: (,,) D: (,,) Root id: Msg: (,,) R: (,0,) D: (,0,) Root id: D: (,0,) Msg: (,0,) 9

Final thoughts: Ethernet evolution Everything has changed over the years, but the link layer frame format From the coaxial cable shared medium to switches From Mbit/s experimental Ethernet to 00 Gbit/s recent standards From electrical signaling to optical Lesson: The right interface can accommodate many changes Implementation is hidden behind interface 94