Lecture 10: Switching & Internetworking
Total Page:16
File Type:pdf, Size:1020Kb
Lecture 10: Switching & Internetworking CSE 123: Computer Networks Alex C. Snoeren HW 2 due WEDNESDAY Lecture 10 Overview ● Bridging & switching ◆ Spanning Tree ● Internet Protocol ◆ Service model ◆ Packet format CSE 123 – Lecture 10: Internetworking 2 Selective Forwarding ● Only rebroadcast a frame to the LAN where its destination resides ◆ If A sends packet to X, then bridge must forward frame ◆ If A sends packet to B, then bridge shouldn’t LAN 1 LAN 2 A W B X bridge C Y D Z CSE 123 – Lecture 9: Bridging & Switching 3 Forwarding Tables ● Need to know “destination” of frame ◆ Destination address in frame header (48bit in Ethernet) ● Need know which destinations are on which LANs ◆ One approach: statically configured by hand » Table, mapping address to output port (i.e. LAN) ◆ But we’d prefer something automatic and dynamic… ● Simple algorithm: Receive frame f on port q Lookup f.dest for output port /* know where to send it? */ If f.dest found then if output port is q then drop /* already delivered */ else forward f on output port; else flood f; /* forward on all ports but the one where frame arrived*/ CSE 123 – Lecture 9: Bridging & Switching 4 Learning Bridges ● Eliminate manual configuration by learning which addresses are on which LANs Host Port A 1 ● Basic approach B 1 ◆ If a frame arrives on a port, then associate its source C 1 address with that port D 1 ◆ As each host transmits, the table becomes accurate W 2 X 2 ● What if a node moves? Table aging Y 3 ◆ Associate a timestamp with each table entry Z 2 ◆ Refresh timestamp for each new packet with same source ◆ If entry gets too stale, remove it CSE 123 – Lecture 9: Bridging & Switching 5 Learning Example Suppose C sends frame to D and D replies back with frame to C ● C sends frame, bridge has no info about D, so floods to both LANs ◆ bridge notes that C is on port 1 ◆ frame ignored on upper LAN ◆ frame received by D CSE 123 – Lecture 9: Bridging & Switching 6 Learning Example ● D generates reply to C, sends ◆ bridge sees frame from D ◆ bridge notes that D is on port 2 ◆ bridge knows C on port 1, so selectively forwards frame via port 1 CSE 123 – Lecture 9: Bridging & Switching 7 Learning bridges recap ● Each bridge keeps a list mapping link-layer destination address to port number (what are the directions to this destination?) ● This list is populated by looking at the source address of each packet it receives on a given port and entering those values in the table (if a packet from A came from port x, then packets to A should be sent on part x) ● If a packet arrives with a destination address not in the table, then send on all ports (except the one it came on) ● Simple, automatic , self healing 8 Network Topology ● Linear organization ◆ Inter-bridge hubs (e.g. CS) are single points of failure ◆ Unnecessary transit (e.g. EE<->SE must traverse CS) ● Backbone/tree ◆ Can survive LAN failure ◆ Manages all inter-LAN communication ◆ Requires more ports CSE 123 – Lecture 9: Bridging & Switching 9 An Issue: Cycles A ● Learning works well in B tree topologies B3 C B5 D B7 ● But trees are fragile B2 ◆ Net admins like E F K redundant/backup paths B1 ● How to handle Cycles? G H ◆ Where should B1 B6 forward packets destined B4 for LAN A? CSE 123 – Lecture 9: Bridging & Switching 10 Spanning Tree A ● Spanning tree uses B subset of bridges so B3 there are no cycles C B5 ◆ Prune some ports D B7 B2 K ◆ Only one tree E F B1 ● Q: How do we find a spanning tree? G H ◆ Automatically! B6 B4 ◆ Elect root, find paths I J CSE 123 – Lecture 9: Bridging & Switching 11 Spanning Tree Algorithm ● Each bridge sends periodic configuration messages ◆ (RootID, Distance to Root, BridgeID) ◆ All nodes think they are root initially ● Each bridge updates route/Root upon receipt ◆ Smaller root address is better ◆ Select port with lowest cost to root as “root port” ◆ To break ties, bridge with smaller address is better ● Rebroadcast new config to ports for which we’re “best” ◆ Don’t bother sending config to LANs with better options ◆ Add 1 to distance, send new configs on ports that haven’t told us about a shorter path to the root ● Only forward packets on ports for which we’re on the shortest path to root (prunes edges to form tree) CSE 123 – Lecture 10: Internetworking 12 Spanning Tree Example ● Sample messages to and from B3: A B B3 1. B3 sends (B3, 0, B3) to B2 and B5 C B5 2. B3 receives (B2, 0, B2) and (B5, 0, B5) and accepts B2 as root D B7 B2 K 3. B3 sends (B2, 1, B3) to B5 E F 4. B3 receives (B1, 1, B2) and (B1, 1, B5) and accepts B1 as root 5. B3 wants to send (B1, 2, B3 ) but B1 doesn’t as its nowhere “best” G H 6. B3 receives (B1, 1, B2) and (B1, 1, B5) again and again… B6 B4 Data forwarding is turned off for LAN A I J CSE 123 – Lecture 10: Internetworking 13 Important Details ● What if root bridge fails? ◆ Age configuration info » If not refreshed for MaxAge seconds then delete root and recalculate spanning tree » If config message is received with a more recent age, then recalculate spanning tree ◆ Applies to all bridges (not just root) ● Temporary loops ◆ When topology changes, takes a bit for new configuration messages to spread through the system ◆ Don’t start forwarding packets immediately -> wait some time for convergence CSE 123 – Lecture 10: Internetworking 14 Switched Ethernet ● Hosts directly connected to a bridge ◆ learning + spanning tree protocol ● Switch supports parallel forwarding ◆ A-to-B and A’-to-B’ simultaneously ◆ Generally full duplex as well ● Switch backplane capacity varies ◆ Ideally, nonblocking ◆ I.e., can run at full line rate on all ports ● No longer any shared bus ◆ Each link is its own collision domain ◆ Collision detection largely irrelevant CSE 123 – Lecture 10: Internetworking 15 Layer-2 Forwarding ● Create spanning tree across LANs ◆ Learn which ports to use to reach which addresses ● Benefits ◆ Higher link bandwidth (point-to-point links) ◆ Higher aggregate throughput (parallel communication) ◆ Improved fault tolerance (redundant paths) ● Limitations ◆ Requires homogeneous link layer (e.g. all Ethernet) ◆ Harder to control forwarding topology ● What if we want to connect different link layers? CSE 123 – Lecture 10: Internetworking 16 Combing Networks ● Main challenge is heterogeneity of link layers: ◆ Addressing » Each network media has a different addressing scheme ◆ Bandwidth » Modems to terabits ◆ Latency » Seconds to nanoseconds ◆ Frame size » Dozens to thousands of bytes ◆ Loss rates » Differ by many orders of magnitude ◆ Service guarantees » “Send and pray” vs reserved bandwidth CSE 123 – Lecture 10: Internetworking 17 internetworking ● Cerf & Kahn74, “A Protocol for Packet Network Intercommunication” ◆ Foundation for the modern Internet ● Routers forward packets from source to destination ◆ May cross many separate networks along the way ● All packets use a common Internet Protocol ◆ Any underlying data link protocol ◆ Any higher layer transport protocol CSE 123 – Lecture 10: Internetworking 18 TCP/IP Protocol Stack host host HTTP Application Layer HTTP TCP Transport Layer TCP router router I I Network Layer I I P P P P Ethernet Ethernet SONET SONET Ethernet Ethernet interface interface interfaceLink Layerinterface interface interface CSE 123 – Lecture 10: Internetworking 19 IP Networking Router Ethernet FDDI data packet data packet Eth IP TCP HTTP FDDI IP TCP HTTP CSE 123 – Lecture 10: Internetworking 20 Routers ● A router is a store-and-forward device ◆ Routers are connected to multiple networks ◆ On each network, looks just like another host ◆ A lot like a switch, but supports multiple datalink layers and makes decisions at the network layer ● Must be explicitly addressed by incoming frames (L2) ◆ Not at all like a switch, which is transparent ◆ Removes link-layer header, parses IP header (L3) ● Looks up next hop, forwards on appropriate network ◆ Each router need only get one step closer to destination CSE 123 – Lecture 10: Internetworking 21 IP Philosophy ● Impose few demands on network ◆ Make few assumptions about what network can do ◆ No QoS, no reliability, no ordering, no large packets ◆ No persistent state about communications; no connections ● Manage heterogeneity at hosts (not in network) ◆ Adapt to underlying network heterogeneity ◆ Re-order packets, detect errors, retransmit lost messages… ◆ Persistent network state only kept in hosts (fate-sharing) ● Service model: best effort, a.k.a. send and pray CSE 123 – Lecture 10: Internetworking 22 IP Packet Header 0 15 16 31 ver HL TOS length R M D identification E F F offset S TTL protocol header checksum 20 bytes source address destination address options (if any) data (if any) CSE 123 – Lecture 10: Internetworking 23 Version field ● Which version of IP is this? ◆ Plan for change ◆ Very important! ● Current versions ◆ 4: most of Internet today ◆ 6: new protocol with larger addresses ◆ What happened to 5? Standards body politics. CSE 123 – Lecture 10: Internetworking 24 Header length ● How big is IP header? ◆ Counted in 32-bit words ◆ Variable length » Options ◆ Engineering consequences of variable length… ● Most IP packet headers are 20 bytes long CSE 123 – Lecture 10: Internetworking 25 Type-of-Service ● How should this packet be treated? ◆ Care/don’t care for delay, throughput, reliability, cost ◆ How to interpret, how to apply on underlying net? ◆ Largely unused until 2000 (hijacked for new purposes, ECN & Diffserv) CSE 123 – Lecture 10: Internetworking 26 Length ● How long is whole packet in bytes? ◆ Includes header ◆ Limits total packet to 64K ◆ Redundant? CSE 123 – Lecture 10: Internetworking 27 TTL (Time-to-Live) ● How many more routers can this packet pass through? ◆ Designed to limit packet from looping forever ● Each router decrements TTL field ● If TTL is 0 then router discards packet CSE 123 – Lecture 10: Internetworking 28 Protocol ● Which transport protocol is the data using? ◆ i.e.