Computer Networks The Network Layer 1 Routing. Forwarding. Main Functions 2
Design Issues Services provided to transport layer. How to design network-layer protocols. 3 Store-and-Forward Packet Switching Subnet fig 5-1. Host sends packet to nearest router.. Packet forwarded to next router.. Until packet reaches destination. 4
Services What kind of services provided to transport layer? Connection-oriented versus connectionless service? 5 Connectionless Service Datagram network. Move all intelligence to the edges. Routers just route. Everything else should be done end-to-end. No ordering, no flow/congestion control, no reliable delivery. Best-effort service model. Packets are routed independently E.g., Internet. 6
Connection-Oriented Service Virtual circuit networks. `A la telephone network. Reliable, ordered service. Virtual connection established from source to destination. E.g., X-25, ATM. 7 Datagram Network Operation How does it work? Data from transport layer is broken into packets, or datagrams. Network layer at host adds network-layer header and forwards packets to directlyconnected router. 8
Datagram Network: Example Routing within a diagram subnet. 9 Virtual Circuit Network Operation Connection-establishment before sending data. All traffic for that connection follows same route. 10
Virtual Circuit Network: Example Routing within a virtual-circuit subnet. 11 Virtual-Circuit versus Datagram Subnets 5-4 12
Routing 13 Routing One of the main functions of network layer. Routing versus forwarding? Datagram versus VC networks? 14
Routing Algorithm Computes routing tables. Properties: Correctness. Robustness. Stability. Optimality. Try to optimize a certain metric. 15 Optimality Principle General statement about optimal routes (topology, routing algorithm independent). If router J is on optimal path between I and K, then the optimal path from J to K also falls along the same route. Proof by contradiction. Corollary: Set of optimal routes from all sources to destination form a tree rooted at destination. Sink tree. 16
Types of Routing Algorithms Non-adaptive versus adaptive. 17 Adaptive and Non-adaptive Routing Non-adaptive routing: Fixed routing, static routing. Do not take current state of the network (e.g., load, topology). Routes are computed in advance, off-line, and downloaded to routers when booted. Adaptive routing: Routes change dynamically as function of current state of network. Algorithms vary on how they get routing information, metrics used, and when they change routes. 18
Static Algorithms (Non-Adaptive) 1.Shortest-path routing. 2.Flooding. 19 Shortest-Path Routing Problem: Given a graph, where nodes represent routers and edges, links, find shortest path between a given pair of nodes. What is shortest in shortest path? Depends on the routing metric in use. Example: number of hops (static), geographic distance (static), delay, bandwidth (raw versus available), combination of a subset of these. Dijkstra s shortest-path algorithm (1959). 20
Dijkstra s Shortest-Path Algorithm Initially, links are assigned costs. As the algorithm executes, nodes are labeled with its distance to source along best known path. Initially, no routes known, so all nodes are labeled with infinity. Labels change as the algorithm proceeds. Labels can be temporary or permanent. Initially all labels are tentative. A label becomes permanent if it represents the shortest path from the source to the node. 21 Shortest Path Routing Find shortest-path from A to D: Start Label each adjacent node with distance to A. B is made permanent. 22
Flooding Every incoming packet forwarded on every outgoing link except the one it arrived on. Problem: duplicates. Constraining the flood: Hop count. Keep track of packets that have been flooded. Robust, shortest delay (picks shortest path as one of the paths). 23 Flooding: Example Stallings Figure 12.4 (hop-count=3) 24
Dynamic Routing Algorithms (Adaptive Routing) Distance vector routing. Link state routing. 25 Distance Vector Routing Aka, Bellman-Ford (1957), Ford-Fulkerson (1962). Original ARPANET routing; also used by Internet s RIP. Each router keeps routing table (or routing vector) with best known distance to each destination and corresponding outgoing interface. Routing tables are updated by exchanging routing information with neighbors. 26
Distance Vector (Cont d) Routing table at each router: One entry per participating router. Each entry contains outgoing interface and distance to corresponding destination. Metric: number of hops, delay, queue length. Each router knows distance to its neighbors. Old ARPANET algorithm: DV where cost metric is outgoing link queue length. 27 Distance Vector Routing (a) A subnet. (b) Input from A, I, H, K, and the new routing table for J. 28
Routing Updates Every T interval, routers exchange routing updates. Routing update from router X consists of a vector with all destinations and the corresponding distance from X to them. When router Y receives an update from X, it can estimate its distance to router Z through X as D yz = D yx + D xz. Router Y receives update from all its neighbors and builds a new RT. 29 1 1 2 4 2 Distance Vector: Example 5 3 3 9 2 1 6 1 1 0-79 5 Node Distance Next 1 0-2 2 2 3 3 4 4 1 4 5 2 4 6 4 4 3 2 T=T 2 Node Distance Next 2 2 2 3 5 3 4 1 4 5 6 3 6 8 3 2 3 4 3 7 5 0 4 2 3 0 2 2 2 0 3 1 1 5 3 3 T=T 0 T=T 1 30
1.Routing loops. 2.Slow convergence. 3.Counting to infinity. Problems 31 Count-to-Infinity Good news propagate faster. A B C D E Initially, A down: A comes up: infinity 1 infinity infinity infinity infinity infinity infinity (after 1 exchange) 1 2 infinity infinity (after 2 exchanges) 1 2 3 infinity (after 3 exchanges) 1 2 3 4 (after 4 exchanges) 32
Count-to-Infinity (Cont d) But, bad news propagate slower! A B C D E Initially, all up: A goes down: 1 2 3 4 3 2 3 4 (after 1 exchange) 3 4 3 4 (after 2 exchanges) 5 4 5 4 (after 3 exchanges) 5 6 5 6 (after 4 exchanges) 7 6 7 6 (after 5 exchanges) 7 8 7 8 (after 6 exchanges). infinity 33 Count-to-Infinity (Cont d) Gradually routers work their way up to infinity. Number of exchanges depends on how large is infinity. To reduce number of exchanges, if metric is number of hops, infinity=maximum path+1. 34
Solution Routing loops: Path vector: record actual path used in the DV. Previous hop tracing: records preceding router. Count-to-infinity: Split horizon: router reports to neighbor cost infinity for destination if route to that destination is through that neighbor. 35 Split Horizon Tries to make bad news spread faster. A node reports infinity as distance to node X on link packets to X are sent. Example, in the first exchange, C tells D its distance to A but tells B its distance to A is infinity. So B discovers its link to A is down and C s distance to A is infinity; so it sets its distance to A to infinity. 36
Link State Routing DV routing used in the ARPANET until 1979, when it was replaced by link state routing. Used by the Internet s OSPF. Based on Dijkstra s all pairs shortest path algorithm. Plus link state updates. 37 Link State Routing (Cont d) Link state routing is based on: Discover your neighbors and measure the communication cost to them. Send updates about your neighbors to all other routers. Compute shortest path to every other router. 38
Finding Neighbors When router is booted, its first task is to find who its neighbors are. Special single-hop hello packets. Cost metric: Number of hops: in this case, always 1. Delay: echo packets and measure RTT/2. Load? 39 Generating Link State Updates Link state packets (LSP). Sender identity. Sequence number. TTL. List of (neighbor, cost). When to send updates? Proactive: periodic updates; how often? Reactive: whenever some significant event is detected, e.g., link goes down. Where to send them? Everywhere: flood. 40
Processing Updates When LSP is received: Check sequence number. If higher than current sequence number, keep it and flood it; otherwise, discard it. Periodically decrement TTL. When TTL=0, purge LSP. 41 Computing Routes Routers have global view of network. They receive updates from all other routers with their cost to their neighbors. Build network graph. Use Dijkstra s shortest-path algorithm to compute shortest paths to all other nodes. 42
Measuring Line Cost A subnet in which the East and West parts are connected by two lines. 43 Building Link State Packets (a) A subnet. (b) The link state packets for this subnet. 44
Distributing the Link State Packets B s LSP buffer: each row corresponds to a recently LSP that hasn t been processed yet. 45 Link State Routing: Problems Scalability: Storage: kn, where n is number of routers and k is number of neighbors. Computation time. LSP propagation via flooding. 46
DV: DV versus LS Node tells its neighbors what it knows about everybody. Based on other s knowledge, node chooses best route. Distributed computation. LS: Node tells everyone what it knows about its neighbors. Every node has global view. Compute their own routes. 47 Hierarchical Routing For scalability: As network grows, so does RT size, routing update generation, processing, and propagation overhead, and route computation time and resources. Divide network into routing regions. Routers within region know how to route packets to all destinations within region. But don t know how to route within other regions. Border routers: route within regions. 48
Hierarchical Routing: Example Flat routing: 1B 1A 1C 3A 3B 2C 4A 2A 2B 2D 5B 5A 5C 4B 4C 5E 5D 1A Dest. Next Hops 1A - - 1B 1B 1 1C 1C 1 2A 1B 2 2B 1B 3 2C 1B 3 2D 1B 4 3A 1C 3 3B 1C 2 4A 1C 3 4B 1C 4 4C 1C 4 5A 1C 4 5B 1C 5 5C 1B 5 5D 1C 6 5E 1C 5 49 Hierarchical Routing: Example Hierarchy: 1B 1A 1C 3A 3B 2A 2B 4A 2C 2D 5B 5A 5C 4B 4C 5E 5D 1A Dest. Next Hops 1A - - 1B 1B 1 1C 1C 1 2 1B 2 3 1C 2 4 1C 3 5 1C 4 50
Hierarchical Routing Optimal paths are not guaranteed. Example: 1A->5C should be via 2 and not 3. How many hierarchical levels? Example: 720 routers. 1 level: each router needs 720 RT entries. 2 levels: 24 regions of 30 routers: each router s RT has 30+23 entries. 3 levels: 8 clusters of 9 regions with 10 routers: each router s RT 10+8+7. 51 Many-to-Many Routing Support many-to-many communication. Example applications: multi-point data distribution, multi-party teleconferencing. 52
Broadcasting Send to ALL destinations. Several possible routing mechanisms to broadcasting. Simplistic approach: send separate packet to each destination. Simple but expensive. Source needs to know about all destinations. Flooding: May generate too many duplicates (depending on node connectivity). 53 Multidestination Routing Packet contains list of destinations. Router checks destinations and determines on which interfaces it will forward packet. Router generates new copy of packet for each output line and includes in packet only the appropriate set of destinations. Eventually, packets will only carry 1 destination. 54
Spanning Tree Routing Use spanning tree (sink tree) rooted at broadcast initiator. No need for destination list. Each on spanning tree forwards packets on all lines on the spanning tree (except the one the packet arrived on). Efficient but needs to generate the spanning tree and routers must have that information. 55 Reverse Path Forwarding Routers don t have to know spanning tree. Router checks whether broadcast packet arrived on interface used to send packets to source of broadcast. If so, it s likely that it followed best route and thus not a duplicate; router forwards packet on all lines. If not, packet discarded as likely duplicate. 56
Broadcast Routing Reverse path forwarding. (a) A subnet. (b) a Sink tree. (c) The tree built by reverse path forwarding. 57 Multicasting Special form of broadcasting: Instead of sending messages to all nodes, send messages to a group of nodes. Multicast group management: Creating, deleting, joining, leaving group. Group management protocols communicate group membership to appropriate routers. 58
Multicast Routing Each router computes spanning tree covering all other participating routers. Tree is pruned by removing that do not contain any group members. 1,2 1 1 1 1,2 1 2 1 2 1 1 2 1 1,2 2 1 1,2 2 2 1 1 2 2 2 2 2 59 Shared Tree Multicasting Source-rooted tree approaches don t scale well! 1 tree per source, per group! Routers must keep state for m*n trees, where m is number of sources in a group and n is number of groups. Core-based trees: single tree per group. Host unicast message to core, where message is multicast along shared tree. Routes may not be optimal for all sources. State/storage savings in routers. 60
Internetworking 61 Internetworking What is it? Connecting networks together forming a single internet. 62
Connecting Networks A collection of interconnected networks. 63 How Networks Differ 5-43 64
How Networks Can Be Connected (a) Two Ethernets connected by a switch. (b) Two Ethernets connected by routers. 65 How to Internet? Connection-oriented versus connectionless internetworking. Connection oriented internetworking: Based on VC concatenation. Connectionless internetworking follows the datagram model. 66
Concatenated Virtual Circuits Gateway. Builds VC crossing the different networks.. Use of gateways to perform necessary conversions. 67 Connectionless Internetworking. Follows datagram model.. Packets from Host X to Host Y may follow different routes.. Gateways make routing decisions and perform translations. 68
Translating versus Gluing Translation: converting between different protocols. Hard! Alternative: gluing. I.e., using the same network layer protocol everywhere. That s what IP does! 69 Tunneling Interconnecting source and destination on separate networks but of the same type. S D 70
Tunneling Analogy 71 More Tunneling 72
Internetworking 73 Internetwork Routing Inherently hierarchical. Routing within each network: interior gateway protocol (IGP). Routing between networks: exterior gateway protocol (EGP). Within each network, different routing algorithms can be used. Each network is autonomously managed and independent of others: autonomous system (AS). 74
Internetwork Routing: Example (a) An internetwork. (b) A graph of the internetwork. 75 Internetwork Routing (Cont d) Typically, packet starts in its LAN. Gateway receives it (broadcast on LAN to unknown destination). Gateway sends packet to gateway on the destination network using its routing table. If it can use the packet s native protocol, sends packet directly. Otherwise, tunnels it. 76
Fragmentation Happens when internetworking. Network-specific maximum packet size. Width of TDM slot. OS buffer limitations. Protocol (number of bits in packet length field). Maximum payloads range from 48 bytes (ATM cells) to 64Kbytes (IP packets). 77 Problem What happens when large packet wants to travel through network with smaller maximum packet size? Fragmentation. Gateways break packets into fragments; each sent as separate packet. Gateway on the other side have to reassemble fragments into original packet. 2 kinds of fragmentation: transparent and nontransparent. 78
Types of Fragmentation (a) Transparent fragmentation. Nontransparent fragmentation. (b) 79 Transparent Fragmentation Small-packet network transparent to other subsequent networks. Fragments of a packet addressed to the same exit gateway, where packet is reassembled. OK for concatenated VC internetworking. Subsequent networks are not aware fragmentation occurred. ATM networks (through special hardware) provide transparent fragmentation. 80
Problems with Transparent Fragmentation Exit gateway must know when it received all the pieces. Fragment counter or end of packet bit. Some performance penalty but requiring all fragments to go through same gateway. May have to repeatedly fragment and reassemble through series of small-packet networks. 81 Non-Transparent Fragmentation Only reassemble at destination host. Each fragment becomes a separate packet. Thus routed independently. Problems: Hosts must reassemble. Every fragment must carry header until it reaches destination host. 82
Keeping Track of Fragments Fragments must be numbered so that original data stream can be reconstructed. Tree-structured numbering scheme: Packet 0 generates fragments 0.0, 0.1, 0.2, If these fragments need to be fragmented later on, then 0.0.0, 0.0.1,, 0.1.0, 0.1.1, But, too much overhead in terms of number of fields needed. Also, if fragments are lost, retransmissions can take alternate routes and get fragmented differently. 83 Keeping Track of Fragments (Cont d) Another way is to define elementary fragment size that can pass through every network. When packet fragmented, all pieces equal to elementary fragment size, except last one (may be smaller). Packet may contain several fragments. 84
Fragmentation: Example Fragmentation when the elementary data size is 1 byte. (a) Original packet, containing 10 data bytes. (b) Fragments after passing through a network with maximum packet size of 8 payload bytes plus header. (c) Fragments after passing through a size 5 gateway. 85 Keeping Track of Fragments Header contains packet number, number of first fragment in the packet, and last-fragment bit. Last-fragment bit 1 byte 27 0 1 A B C D E F G H I J Packet number Number of first fragment (a) Original packet with 10 data bytes. 27 0 0 A B C D E F G H 27 8 1 I J (b) Fragments after passing through network with maximum packet size = 8 bytes. 86
The Internet 87 Design Principles for Internet Keep it simple. Exploit modularity. Expect heterogeneity. Think robustness. Avoid static options and parameters. Think about scalability. Consider performance and cost. 88
Internet as Collection of Subnetworks 89 IP (Internet Protocol) Glues Internet together. Common network-layer protocol spoken by all Internet participating networks. Best effort datagram service: No reliability guarantees. No ordering guarantees. 90
IP Transport layer breaks data streams into datagrams; fragments transmitted over Internet, possibly being fragmented. When all packet fragments arrive at destination, reassembled by network layer and delivered to transport layer at destination host. 91 IPv4: IP version 4. IP Versions Current, predominant version. 32-bit long addresses. IPv6: IP version 6 (aka, IPng). Evolution of IPv4. Longer addresses (16-byte long). 92
IP Datagram Format IP datagram consists of header and data (or payload). Header: 20-byte fixed (mandatory) part. Variable length optional part. 93 The IP v4 Header 94
IP Options 5-54 95 IP address formats. IP Addresses 96
IP Addresses (Cont d) Class A: 128 networks with 16M hosts each. Class B: 16,384 networks with 64K hosts each. Class C: 2M networks with 256 hosts each. More than 500K networks connected to the Internet. Network numbers centrally administered by ICANN. 97 IP Addresses (Cont d) Special IP addresses. 98
Scalability of IP Addresses Problem: a single A, B, or C address refers to a single network. As organizations grow, what happens? 99 Example: A Campus Network 100
Solution Subnetting: divide the organization s address space into multiple subnets. How? Use part of the host number bits as the subnet number. Example: Consider a university with 35 departments. With a class B IP address, use 6-bit subnet number and 10-bit host number. This allows for up to 64 subnets each with 1024 hosts. 101 Subnets A class B network subnetted into 64 subnets. 102
Subnet Mask Indicates the split between network and subnet number + host number. Subnet Mask: 255.255.252.0 or /22 (network + subnet part) 103 Subnetting: Observations Subnets are not visible to the outside world. Thus, subnetting (and how) is a decision made by local network admin. 104
Subnet: Example Subnet 1: 10000010 00110010 000001 00 00000001 130.50.4.1 Subnet 2: 10000010 00110010 000010 00 00000001 130.50.8.1 Subnet 3: 10000010 00110010 000011 00 00000001 130.50.12.1 105 Problem with IPv4 IPv4 is running out of addresses. Problem: class-based addressing scheme. Example: Class B addresses allow 64K hosts. More than half of Class B networks have fewer than 50 hosts! 106
Solution: CIDR CIDR: Classless Inter-Domain Routing. RFC 1519. Allocate remaining addresses in variablesized blocks without considering classes. Example: if an organization needs 2000 addresses, it gets 2048-address block. Forwarding had to be modified. Routing tables need an extra entry, a 32-bit mask, which is ANDed with the destination IP address. If there is a match, the packet is forwarded on that interface. 107 Network Address Translation Another quick fix to the address shortage in IP v4. Specified in RFC 3022. Each organization gets a single (or small number of) IP addresses. This is used for Internet traffic only. For internal traffic, each host gets its own internal IP address. Three IP ranges have been declared as private. 10.0.0.0 10.255.255.255/8 172.16.0.0 172.31.255.255/12 192.168.0.0 192.168.255.255/16 No private IP address can show up on the Internet, i.e., outside the organization s network. 108
NAT Network Address Translation 109 Internet Control Protocols Companion protocols to IP. Control protocols used mainly for signaling and exchange of control information. Examples: ICMP, ARP, RARP, BOOTP, and DHCP. 110
ICMP Internet Control Message Protocol. A way to debug the Internet and find out what is happening at routers. Defines a dozen different messages that are generated typically by routers upon some unexpected event. 111 ICMP Message Types 5-61 112
Address Resolution Protocol ARP. RFC 826. Protocol for machines to map IP addresses to Ethernet addresses. This is needed when packet needs to be delivered to a local host on a LAN (Ethernet). 113 ARP: Example. Host 1 wants to send packet to host 2.. Assume that host 1 knows host 2 s IP address.. Host 1 builds packet with host 2 s IP address.. IP knows it s a local destination but now needs host 2 s Ethernet address. 114
ARP Operation Host 1 broadcasts an ARP request on the Ethernet asking who owns host 2 s IP address. Host 2 replies with its Ethernet address. Some optimizations: ARP caches. Piggybacking host s own Ethernet address on ARP requests. Proxy ARP: services ARP requests for hosts on separate LANs. 115 Beyond ARP ARP solves the problem of mapping IP address to Ethernet address. How do we solve the inverse problem? I.e., how to map an Ethernet address to an IP address? Older protocols: RARP (RFC 903) and BOOTP (RFC 951). RARP broadcasts not forwarded by routers. BOOTP uses UDP but requires manual configuration of IP-Ethernet mappings. 116
DHCP Dynamic Host Configuration Protocol. RFCs 2131 and 2132. Assigns IP addresses to hosts dynamically. DHCP server may not be on the same LAN as requesting host. DHCP relay agent. 117 DHCP Operation Newly booted host broadcasts a DHCP DISCOVER message. DHCP relay agent intercepts DHCP DISCOVERs on its LAN and unicasts them to DHCP server. 118
DHCP Operation 119 DHCP: Address Reuse How long should an IP address be allocated? Issue: hosts come and go. IP addresses may be assigned on a Lease basis. Hosts must renew their leases. 120