510 likes | 849 Views
Chapter 8. The Wonderful World of Routing. Router. Central connection device Routing the packet: Examining the destination IP address in a packet (layer 3 device) Sending the packet to the proper port. Router. Each port in a router is connected to a network
E N D
Chapter 8 The Wonderful World of Routing
Router • Central connection device • Routing the packet: • Examining the destination IP address in a packet (layer 3 device) • Sending the packet to the proper port
Router • Each port in a router is connected to a network • A router’s port can be labeled by using the network address of the network to which the port is connected
Routing Table • Electronic database • In a router (and a computer) • Containing information used by the router to route packets
Routing Table • Each row: a route • Columns: • Destination: the network address of the network connected to a router’s port • Netmask: the subnet mask of the network ID in the network destination • Gateway: the address of the NEXT HOP (i.e., another router that is connected to the router)
How does a Router Route a Frame? • How does a router route a frame? • A router receives a frame • The router decapsulates the frame to get the “DESTINATION IP ADDRESS” • The router applies each routing table’s “netmask” (but the “last resort” 0.0.0.0) to the destination IP address until there is a match with the routing table’s “destination” • After finding the match, the router will encapsulate the frame and send it to the matching port • If no match is found, the router will encapsulate the frame and send it to the “gateway”
How does a Router Route a Frame? • Animation: • http://www.learningocean.com/view.php?cid=967&protocol=IP%20Address&title=3.%20Network%20address&ctype=1
How does a Router Route a Frame? • The next three problems are based on this assumption: Given the following routing table of a router: Destination Subnet Mask Gateway 0.0.0.0 0.0.0.0 202.202.100.1 202.202.1.0 255.255.255.0 0.0.0.0 202.202.2.0 255.255.255.0 0.0.0.0 202.202.3.0 255.255.255.0 0.0.0.0 202.202.4.0 255.255.255.0 0.0.0.0 • If the router receives a frame with destination IP address: 100.100.100.1, where will the router forward the frame? • Port connected to 202.202.1.0 • Port connected to 202.202.2.0 • Port connected to 202.202.3.0 • Port connected to the gateway whose IP address is 202.202.100.1 • If the router receives a frame with destination IP address: 202.202.3.144, where will the router forward the frame? • Port connected to 202.202.1.0 • Port connected to 202.202.2.0 • Port connected to 202.202.3.0 • Port connected to the gateway whose IP address is 202.202.100.1 • If the router receives a frame with destination IP address: 202.202.8.1, where will the router forward the frame? • Port connected to 202.202.1.0 • Port connected to 202.202.2.0 • Port connected to 202.202.3.0 • Port connected to the gateway whose IP address is 202.202.100.1
Routing Table • Every router has a routing table • Every computer that runs TCP/IP also has routing table • To see the routing table Open Command Prompt and type “netstat –r” • A routing table also has a METRIC column • Containing a relative value • Defining the “COST” of using a certain route • The higher the value, the less preferable • Used to decide which route to use if there is more than one route to get to the same place • Determined and entered manually by the network administrator, or • Computed by dynamic routing protocol based on a number of factors (e.g., hop count, network delay, bandwidth)
Routing Table • What will a computer/router do if it finds more than one route to get to the same place? • It will choose the route with more specific netmask (netmask with more 255s) • See the routing table on page 175. Where does the packet with destination IP address: 10.12.14.201 go? • If both routes have the same netmask, it will choose the route with lower metric, • If both routes have the same metric, it will arbitrarily choose one
Communication among Local Computers and to Remote Computers • When a computer receives an IP address (destination IP address) to send information, it will find out if that IP address belongs to local or remote computers. How? • If the IP address belongs to localcomputer, it will use the ARP cache to find the MAC address corresponding to that IP address • If the IP address belongs to remotecomputer, it will use the ARP cache to find the MAC address corresponding to the IP address of the default gateway available in the TCP/IP
How does ARP work? • Computer A (or router A) is sending a frame to computer B (or router B) (destination IP address in the frame: 216.30.120.2) • The frame will go to computer A’s NIC (or router A’s port) • Computer A’s NIC (or router A’s port) will open its ARP cache to get the MAC address that matches the destination IP address in the frame • ARP cache is database containing a list of IP addresses and their corresponding MAC addresses of all LOCAL computers/router
How does ARP work? • Computer A (or router A) is sending a frame to computer B (or router B) (destination IP address in the frame: 216.30.120.2) • The frame will go to computer A’s NIC (or router A’s port) • Computer A’s NIC (or router A’s port) will open its ARP cache to get the MAC address that matches the destination IP address in the frame • ARP cache is database containing a list of IP addresses and their corresponding MAC addresses of all LOCAL computers/router
How does ARP work? • (Continued) • If the ARP cache contains the destination IP address, the corresponding MAC address will be inserted directly to the frame. • If the ARP cache does not contain the destination IP address, the ARP program will send special frame that is addressed to BROADCAST MAC ADDRESS (FFFFFFFFFFFF) so that this frame will be opened and processed by all LOCAL computers • Whenever a BRIDGE/SWITCH receives this frame, it will forward the frame to all other network segments • Whenever a GATEWAY (ROUTER) receives this frame, it will block the frame (This is the reason the ARP cache only contains the addresses of LOCAL computers/router) • This special frame contains message asking if the recipient has the destination IP address • The computer/router having the destination IP address will reply by sending its MAC address • After the ARP program in the sending computer receives the reply, it will add the IP address and its corresponding MAC address to the ARP cache, and insert it to the frame
How does ARP work? • How does a computer acquire the MAC address of a particular IP address • Animation: • http://www.youtube.com/watch?v=RucGbZvwZ5s&feature=related
ARP Cache: IP Address 1 MAC Address 1 IP Address 2 MAC Address 2 … Frame goes to the sender’s NIC MAC Address is Inserted ffffffffffff ffffffffffff ffffffffffff MAC Address ffffffffffff How does ARP work?
How Does ARP Cache Gather MAC Addresses from Local Computers?
Connecting a Private Network to the Internet • Subscribe a set of public IP addresses (every computer and router in the private network has a public IP address) • Disadvantages: Expensive, running out of public IP addresses, security • Subscribe a single or a few public IP addresses and use NAT (Network Address Translation) • Every computer in the private network can use private IP address
NAT • NAT program/software running on a computer or a routertranslating PRIVATE IP address into PUBLIC IP address • All computers in the private network can use any IP addresses (private IP addresses) • NAT program/software translates every private IP address into the public IP address before the packet is sent to the Internet
NAT • Advantages • Cheaper • Saving public IP addresses • Better security • Why? Because NO computer behind the NAT can be accessed directly from the Internet. An external computer can only reply a message sent by a computer behind the NAT (It cannot initiate a communication session. The computer behind the NAT must initiate the contact) • Disadvantage • A Web server cannot be connected to the Internet by using NAT. • Why? Because NO computer behind the NAT can be accessed directly from the Internet (The computer behind the NAT must initiate the contact)
Different types of NAT • Static NAT • One private IP address is mapped to a particular public IP address, and vice versa • Example: 10.1.1.1 is always translated into 130.1.1.1, and 130.1.1.1 is always translated back to 10.1.1.1 • Advantage: Allowing a Web server to be connected to the Internet by using NAT • Disadvantages: expensive, not saving public IP addresses, no better security
Different types of NAT • Static NAT • 125.35.48.166 can be permanently mapped to 10.0.25.11 (The IP address of the first computer) 125.35.48.166 10.0.25.11
Different types of NAT • Dynamic NAT (Pooled NAT, IP masquerading) • A number of computers are dynamically mapped to a pool of public IP addresses • Example: 100 computers are dynamically mapped to 20 public IP addresses • Overloaded NAT • A number of computers are dynamically mapped to a single public IP address • 100 computers are dynamically mapped to 1 public IP addresses • Advantages: Cheaper, saving public IP addresses, better security • Disadvantage: The fewer the number of public IP addresses available, the slower the Internet connection (e.g., 100 computers must queue to use 20 public IP addresses), cannot be used to connect a server
Different types of NAT • Dynamic NAT (Overloaded NAT) • Example: • 10.1.1.1 is mapped to 130.1.1.1, sending a frame to 180.1.1.1 • 10.1.1.2 is mapped to 130.1.1.1, sending a frame to 100.2.2.2 • 10.1.1.3 is mapped to 130.1.1.1, sending a frame to 80.1.1.1 • This frame is requesting information • The frame contains port number • Sender’s port number (ephemeral port) • Destination’s port number (according to the session type) 130.1.1.1 Ephemeral port: 10137 (generated randomly by the sender) Destination’s port number: HTTP session uses port number 80
Different types of NAT 130.1.1.1 • The frames: • Sender IP: 10.1.1.1/ 130.1.1.1 e-port: 1176, d-port: 80, destination IP: 180.1.1.1 • Sender IP: 10.1.1.2/ 130.1.1.1 e-port: 1177, d-port: 80, destination IP: 100.2.2.2 • Sender IP: 10.1.1.3/ 130.1.1.1 e-port: 1178, d-port: 80, destination IP: 80.1.1.1 • Replies: • 180.1.1.1 replies to 130.1.1.1 s-port: 80, d-port: 1176. NAT forwards it to 10.1.1.1 since this computer is the one sending e-port: 1176 • 100.2.2.2 replies to 130.1.1.1 s-port: 80, d-port: 1177 NAT forwards it to 10.1.1.2 since this computer is the one sending e-port: 1177 • 80.1.1.1 replies to 130.1.1.1 s-port: 80, d-port: 1178 NAT forwards it to 10.1.1.3 since this computer is the one sending e-port: 1178
Different types of NAT • Dynamic NAT (Overloaded NAT) • Disadvantage: Cannot connect a Web server behind this NAT • Solution: • Port forwarding: • Setting the NAT • To forward any incoming packet with a certain port number • To a certain computer • Any incoming packet requesting information from a Web server always has d-port: 80 • Hence, by setting the NAT: • “Forward packet with d-port: 80 to IP address 10.1.1.1” • Every packet requesting information from a Web server will always be forwarded to 10.1.1.1 (Assume this is the address of the server)
Different types of NAT • “Forward packet with d-port: 80 to IP address 10.1.1.1” • Port Forwarding • Example: • 10.1.1.1 is mapped to 130.1.1.1, • 10.1.1.2 is mapped to 130.1.1.1, • 10.1.1.3 is mapped to 130.1.1.1, • Assume that 10.1.1.1 is a Web server. • Port forwarding: • “Forward packet with d-port: 80 to IP address 10.1.1.1” • When the NAT receives a frame from a Web client, the frame will have d-port: 80. • Hence, the NAT will forward the frame to 10.1.1.1 NAT 130.1.1.1 d-IP: 130.1.1.1 e-port: 1200 d-port: 80
Static versus Dynamic Routing • Static routing • Routing table manually entered by the network administrator • The packet CANNOT be re-routed (the routing table is STATIC) if the network changes • Dynamic routing • Routing table automatically created by Network layer protocol (e.g., RIP, BGP, OSPF, IS-IS, EIGRP) • The packet can be automatically re-routed (the routing table is DYNAMIC) if the network changes
Dynamic Routing • Basic capabilities of dynamic routing • Discover all possible paths between two networks • Determine and choose the best path (using routingmetric)
Routing Metric • Routing Metric • A relative value representing the cost of a route • Routing metrics are computed by using route attributes such as bandwidth, network delay, hop count (the number of routers in the path) • The higher the metric value, the less preferable the route
Dynamic Routing • Distance Vector • Routers share their entire routing tables to calculate the total costs of different routes to get to a particular network, mainly, by the number of hops • Convergence: • The state where the updating of the routing tables for all the routers has completed • RIPv1 (Max hop count: 15, Update interval: 30 seconds, no CIDR support) • RIPv2 (Max hop count: 15, Update interval: random, CIDR support) • BGP (Used by the Internet)
Dynamic Routing • To avoid routing table “explosion” (i.e., as the number of router increases, the size of the routing table also increases, the convergence time also increases), a large network is divided into: • Autonomous System (AS) (i.e., a group of routers that are controlled by a single administrator, e.g., ISP, and that use a single routing protocol)
Dynamic Routing • Routers WITHIN an Autonomous System communicate by using Interior Gateway Protocol (IGP) (e.g., RIP, iBGP, OSPF) • Routers BETWEEN Autonomous Systems (edge routers) communicate by using Exterior Gateway Protocol (EGP) (e.g., eBGP) • Edge routers: routers connecting two Autonomous Systems
Dynamic Routing Edge Routers
Dynamic Routing Edge Routers
Dynamic Routing • Problems with Distance Vector • Sharing the entire routing tables • Every certain period (whether the topology has changed or not) • Slow to converge • Consuming the network bandwidth • Link State • Sharing the route change/update only • When there is a route change/update • Fast to converge • Saving the network bandwidth
Dynamic Routing • Link State • OSPF (Used as IGP in the Internet, complex → only in expensive, high-end router) • IS-IS
Dynamic Routing • EIGRP • Hybrid of Distance Vector and Link State • Gone
Working with Routers • Rollover/Yost cable • A cable to connect a computer to a router • To configure the router • PuTTYand HyperTerminal • Programs to connect a computer to a router • To configure the router
Working with Routers • Network management software (NMS) • Program displaying an overall view of a network (e.g., routers, switches, nodes) • To monitor and configure elements in the network • Traceroute • Application software • Sending a single packet to a host • As it progresses, it returns information about every router between them