ECE 428 Internet Protocols (Network Layer: Layer 3) 1
Done so far MAC protocols (with PHYsical layer) Transport bits from one node to another. Key element: Determine WHEN to transmit DLC protocol (running on top of MAC) Establish a reliable link between two nodes Flow control (determined by the receiver) Error control (retransmission) Fragmentation/reassembly Summary: DLC/MAC support 1-hop comm. 2
Links: OC-192 (10 Gbps) The Canadian Network 3
ORION (Ontario Research and Innovation Optical Network) ORION Office 34 King Street East, Suite 800, 8th Floor Toronto, Ontario, M5C 2X8 4
COGENT Network 5
Network Connection to UW 6
UW Network 7
The Internet at a glance Border/edge router AS AS 8
The Internet Cloud Routers + DHCP & DNS servers 9
Multi-hop communication Host1 R R R R R R R Host2 Computer A Computer B Application + Others Router Application + Others Transport Transport Network (IP) Network (IP) Network (IP) DLC1 DLC1 DLC2 DLC2 MAC1/PHY1 MAC1/PHY1 MAC2/PHY2 MAC2/PHY2 Medium 1 Medium2 10
Key question in multi-hop comm. Packet forwarding through a set of routers? How hosts and routers discover each other? How packets are routed to their destinations? 11
Routing protocols What is routing? Routers exchange information about the networks and hosts to which they are connected. Allow routers to build routing tables (RT). An incoming packet to a router is put on an outgoing link based on RT information. Hop-by-hop routing Each router makes an individual, one-hop forwarding decision. 12
What is Routing? OSPF RIP UDP BGP TCP ICMP Network layer Routing Table IP DLC1 DLC2 DLC3 DLC4 MAC1 MAC2 MAC3 MAC4 2 1 3 4 OSPF: Open Shortest Path First BGP: Border Gateway Protocol RIP: Routing Information Protocol TCP: Transmission Control Protocol UDP: User Datagram Protocol ICMP: Internet Control Message Protocol 13
IP Packet Format: Header + Payload 4 bits 8 bits 8 bits 3 bits 13 bits 16 bits 16 bits Bit 0 V=4 IHL SERVICE TYPE TOTAL LENGTH 31 H IDENTIFICATION F FRAGMENT OFFSET e TIME TO LIVE PROTOCOL HEADER CHECKSUM a d SOURCE ADDRESS e DESTINATION ADDRESS r IP OPTIONS IP PAYLOAD V = Version, IHL = Internet Header Length, F = Flags 14
IP Address Length: 32 bits in IPv4 (128 bits in IPv6) <= Unique How many addresses for a node Host: one (common) Router: Many (1 for each link connected to the router) Notation Dotted decimal notation Each of the four bytes is respectively written as a decimal integer separated by periods. Ex.: (81 61 5C 2B) Hex => 129.97.92.43 15
IP Address IP address: 2 logical components of variable length Network prefix (leftmost p = 32 h bits Identical for all hosts connected to the same link Host ID (rightmost h bits) Unique for hosts connected to the same link p = 32-h bits h bits Network-prefix Host 16
IP Address Notation for IP address and prefix length Address/prefix-length (129.97.92.43/24) Usefulness of network prefix Packet forwarding is done using network prefix Routing tables keep an entry for each network prefix -- and not for each host computer Smaller RT size 17
Other header fields Version: 4 for IPV4 IHL (Internet Header Length) Gives IP header length in units of 4-bytes Without the options field (IHL = 5) Service type How the packet is to be handled by the routers Lowest delay, highest reliability, Largely ignored by router manufacturers Total length Length of the entire IP packet including the header in bytes 18
Other header fields Flags, Fragment Offset, ID Used to chop up large IP packets into small chunks If the network can t handle large IP packets. ID A unique value chosen by the sender to allow a recipient to reassemble a packet that had to be chopped up All fragments from the same IP packet have the same ID Offset Position of the fragment in the IP packet Flag: 3 bits <Don t fragment, More fragment to follow, Not used> 19
Other header fields Time To Live (TTL): in # of hops Each time a packet is forwarded: TTL = TTL 1 Idea: Drop a packet if it goes into a routing loop. Protocol: Receiving protocol ID 1: ICMP 6: TCP Header Checksum: To protect Tx error in header IP Options Route Record can be gathered 20
How does IP routing work? A router forwards packets based on Fields within the IP header Entries in its routing table (RT) Classification of packets Packets for which the node is the ultimate destination Give the packet to the upper layer entity identified by Protocol field. Packets for which ANOTHER node is the ultimate destination Forward the packet to another router 21
Structure of a Routing Table Target/Prefixlength Next Hop Interface 129.97.92.43/32 Router 1 x 120.97.92.0/24 Router 2 y Host-specific route Network-prefix route 125.86.55.70/32 directly z 0.0.0.0/0 Router 3 w Default route 22
How does IP routing work? When a node receives an IP packet to forward, Search the RT for an entry whose Target Address/Prefix Length fields MATCH the IP Destination Address in the packet. If a matching entry is found, forward the packet to the node identified by the Next Hop field via the specified Interface. Address matching Given: an IP address and a Target Address/Prefix length Matching occurs if the leftmost Prefix-length bits of Target Address are equal to those same bits in the packet s IP address. If more than one matching is found Select the route with the largest Prefix-length. 23
How does IP routing work? The Next Hop fields in an RT For a Target that is NOT connected to one of the node s directly attached links, the NH field contains the IP. address of a router that can be used to reach that Target. Otherwise, the NH field contains a special value ( directly ) indicating that the Target is connected to one of the node s directly attached links. 24
How does IP routing work? Three categories of RT entries Host-specific route: Denoted by Prefix-length of 32 Provides matching for exactly one IP address. Network-prefix route: Denoted by Prefix-length of 1 31 Default route: Prefix-length = 0 Provides matching for all IP addresses. Used when the first alternatives are absent. 25
How does IP routing work? Summary of matching If a host-specific route is available, use it. If no host-specific route is available, but there is a network-prefix route, use the network-prefix route. If neither a host-specific nor a network-prefix route is available, choose a default router, if one exists Finally, if a packet can not be forwarded, send an ICMP Unreachable message to the source of the packet. 26
Three ways Statically Creating Routing Tables Network-prefix routes to all hosts connected to an attached link. Default route for the rest of the destinations Routers can still update their tables using the following approaches. Dynamically By running routing protocols (OSPF, RIP, BGP) Dynamically When ICMP Redirect messages are received 27
Creating Routing Tables ICMP Redirect Message Two nodes are neighbors if they are on the same link. If a router finds that a neighboring host is using a non-optimal Next Hop to reach a certain destination. The router can inform the host by sending an ICMP Redirect message The Redirect message contains the IP address of the desired router. All the three entities must be on the same link. 28
Autonomous System (AS) Transit AS Multi-homed AS Border/edge router AS Stub AS AS 29
Autonomous System Each AS has a 16-bit unique ID: Max #65,000 By 2004: 10,000 AS AS Number used in Inter-AS routing (BGP) Get an ASN from ARIN (American Registry for Internet Numbers) in NA RIPE (Reseaux IP Europeens ) in Europe APNIC (Asia Pacific Network Info. Center) in Asia 30
Protocols for Constructing RT Intra-Domain (within an AS) RIP (Routing Information Protocol) OSPF (Open Shortest Path First) Inter-Domain (Among AS) BGP (Border Gateway Protocol) 31
RIP Uses the distance-vector (DV) algorithm Metric for computation of shortest path Hop Count Max# of hops is limited to 15 (scope of RIP is an AS) 32
A router RIP Update message Sends an Update msg to each neighbor/30sec. Does not receive an Update for 180sec link down Contains 25 entries of the form <Destination, Cost>. Destination: Network Address (IP/Prefix-length) Behavior: Let X receive entry <Z, C1> from Y Meaning: Y can reach network Z with a cost C1 Let X has an entry in its RT: <Z, NH, C2> If C2 <= C1 + 1: No action is taken (X s RT has the best path.) If C2 > C1 + 1: Replace <Z, NH, C2> with <Z, Y s IP, C1+1> If X has no entry <Z, NH, C2>, create one: <Z, Y s IP, C1+1> 33
RIP: Description A B C 34
RIP Steady state: Shortest paths established. Routers learns from neighbors only local knowledge Local knowledge => routing loop A A B B C C 35
Disadvantages RIP Routing loop Long convergence time Bad news (link failure) propagates slowly. Advantages Routers know this in an indirect manner. Simple Low message overhead 36
OSPF (Link-State Protocol) Types of Link Point-to-Point: two routers directly connected Type 1 (Router link) Transient: Two routers connected to a LAN. Type 2 (Network link) Stub: a router connected to a LAN Type 3 (Summary link to network) Link State: <Type, Cost> Cost: Delay, hop count,. (define your metric..) A router knows the states of all its links: measure cost All routers exchange their knowledge All know the entire topology central idea in OSPF 37
OSPF (Link-State Protocol) Creation of states of the links by each router In the form of Link State Packets (LSP) Dissemination of LSPs to every other router (flood) In an efficient and reliable manner Formation of a shortest path tree for each node Use Dijkstra s Algorithm Calculation of a RT based on shortest paths 38
OSPF (Link-State Protocol) Creation of Link State Packets LSP: <Sender s ID, List of links(link, Cost), Seq#, Age> First two: for topology creation Third: Facilitates flooding, distinguishes new LSPs from old. Fourth: Prevents LSPs from remaining for a long time. LSPs are generated in two ways: When there is a change in the topology of the domain. On a periodic basis: 1-2 hours. 39
OSPF (Link-State Protocol) Flooding of LSPs: 1-to-all The creating node sends a copy of LSP to all neighbors. A node that receives an LSP If the LSP is an old one (check seq #) => drop it. If the LSP is a new one Replace the old one with the new one Send a copy to all neighbors except one from which it was received» Better: wait; send it to those who did not give you a copy. 40
OSPF (Link-State Protocol) Formation of shortest paths (Dijkstra s Alg.) Input: A weighted graph and a source node S Output: All shortest paths from S to all other nodes Process Labeling each node X with <cost, Y, status> Cost: Sum of all edge-weights from S to X Y: Node immediately preceding X on shortest path from S to X Status: T (tentative) or P (permanent) Idea Uses the idea of a working node. Nodes are marked P as computation progresses. Stop: When all are marked P. 41
OSPF (Link-State Protocol) Process (contd.) (S1) Initially: Node S: <0, --, T>; Others: <, --, T> (S2) If all nodes have been marked as P, go to S4 Else{Select a node with smallest cost in its <cost,?, T> Mark the selected node as P; call it working node(w) Go to S3.} (S3) For each T labeled neighbor Z of W, do fol. and go to S2. Let the label of W be <Wc, Wp, P> and of Z be <Zc, Zp, T> Let the cost of W Z link be C If (Wc + C < Zc), replace <Zc, Zp, T> with <Wc+C, W, T> (S4) For each node V in the graph, let <Vc, Vp, P> be its label. Vc: Cost of going from S to V on a shortest path Vp: The node immediately preceding V on the shortest path from S to V. 42
OSPF: Dijkstra s Algorithm B 2 2 7 C 3 3 A E 2 F D 6 1 2 2 G 4 H 43
Border Gateway Protocol 44
Main ideas BGP Allow two ASs to exchange routing information so that IP packets can flow across AS border. Enforce policies, rather than go for shortest paths. All BGP routers on an AS have identical routing info. Supported by all-to-all persistent TCP connections 45
Example Routing AS7 AS4 AS6 AS5 AS2 BGP router TCP connection AS3 AS1 N1, N2 46
Autonomous System (AS) Transit AS R2 R1 Multi-homed AS R4 R3 R5 R6 Stub AS Border/edge router AS4 AS3 N1 47
Example BGP R4 in AS3 knows that it can reach N1. R4 informs R3 in AS2 that it can reach N1. R2 knows whatever R3 knows. => R2 knows that it can reach N1 via R3. Now R2 informs R1 by sending a message as follows. The sequence of AS {AS2, AS3} to reach N1 The next hop router address (of R3) A list of metrics indicating the degree of preferences for the route 48
BGP Routing A BGP router advertises a route to a destination only if it is actively using the route. BGP routers exchange reachability information containing a path vector (AS path) a seq. of AS Path vector information is used to prevent loops When a router receives a path vector, it ensures that its AS number does not appear in the path vector. A path is discarded if its AS number appears on the received path. 49
Policy BGP Policy The attribute (AS path) info. allows policies to be enforced. Example Never use AS X Never use AS X to get to destination Y» Ex.: Never route IP packets originating and terminating at US hosts via Canada Never use AS X and AS Y on the same path. 50
Import policy BGP Routing: Enforce Policy Influence the selection of paths to destinations. Apply import policy to accept, deny or set preferences on the route advertisement received from neighbors. An ISP may reject a path if it includes an untrustworthy AS. Export policy Control the distribution of routing information. Apply export policy to determine which routes should be advertised. An ISP may have agreements to carry transit traffic from certain ISPs and not from all. 51
BGP Protocol at a Glance Initially, BGP peers exchange the entire BGP RT. Subsequently, only incremental updates are sent. An update contains an NLRI (Net. Layer Routing Info) field An AS path A list of IP/PL that can be reached by the above AS path The NH: Sender s IP corresponding to the end-point The receiving router of an update message puts its AS number at the beginning of the received AS path before forwarding the message. (The NH is different for each msg ) Each router constructs an AS-path graph. A BGP router routes packets using its own policies and connectivity information, such as cost. BGP peers exchange keepalive messages every 30s. 52