Home > Articles > Networking > Routing & Switching

This chapter is from the book

3.2 Router Operation Overview

As you know, every IP host in a network is normally configured with not only its own IP address and mask but also the IP address of the default gateway (see Figure 3-1). If the host needs to send an IP packet to a destination address that does not belong to a subnet the host is directly attached to, the host passes the packet to the default gateway (router).

Figure 3-1. Use of default gateway

A common misunderstanding is how the address of the default gateway is used. People tend to incorrectly think that when a packet is sent to the default router, the host sets the destination address in the IP packet to the configured default router address. However, the router would then consider the packet addressed to itself and would not forward it any further. Why configure the default gateway's IP address, then? The answer is that the host uses the Address Resolution Protocol (ARP) to find the Media Access Control (MAC) address of the specified router. Having acquired the router's MAC address, the host sends the packets directly to it as data link unicast submissions.

What happens when a router receives a packet on one of its interfaces? The first thing to remember is that normally, routers do not check the source IP address of the packet when it is received. It seems obvious. However, people are sometimes very surprised when they see, for example, packets coming from an interface attached to subnet 195.100.10.0 with the source address set to, say, 130.10.86.15.

NOTE

As we will see in Chapter 5, however, Cisco routers can be explicitly configured to perform so-called unicast Reverse-Path Forwarding (RPF) check, whereby the router does verify the source address in the packets to prevent denial-of-service attacks.

Routers never change the source and the destination addresses in IP packets, except for Network Address Translation (NAT), which is not considered in this book. Routers send packets to each other by setting correct data link layer addresses—for example, MAC addresses for Ethernet or Data Link Connection Identifier (DLCI) for Frame Relay—in the data link frames or just pushing them through point-to-point links, using associated encapsulation mechanisms. If they changed the source and destination IP addresses, routers would lose information about where the packets were coming from and going to. In our example, a packet with a source address of 130.10.86.15 could be originated by a host outside the network and forwarded by another router on subnet 195.100.10.0. The intermediate routers won't change the packet's IP addresses but instead just pass the packet to the next closest neighbor toward the destination address.

When a packet is received, the router checks its validity and determines whether the packet must be delivered locally—it is addressed to the router itself—or forwarded further. If the packet must be forwarded, the router makes the routing decision and determines the outbound interface and the IP address of the router that should be the next hop in the path, if the destination network is not directly attached.

Consider a simple example. Suppose that a router is connected to two networks—10.0.0.0 and 20.0.0.0—as illustrated in Figure 3-2. Host A on the first segment sends an IP packet to host B on the second segment. Host A passes the packet to the router by specifying the router's MAC address as the destination address in the Ethernet frame. (The destination IP address is the IP address of B.)

Figure 3-2. Two segments connected by a router

When it receives the frame, R1 examines the IP packet and uses its routing table to decide where to forward the packet. The table contains information in the form "to reach hosts on network N, use interface X and next hop Y." Such a combination of routing parameters is called a route. How does the router know where the networks are, though?

Part of every router's configuration task is assignment of IP addresses to the router's interfaces. A router therefore functions like a normal IP host on each network to which it is connected. Even if it never originated IP packets itself, a router would still need this information to answer the ARP requests sent by end nodes while trying to find the MAC address of the default router or by neighboring routers looking for the MAC address of the next hop.

Because a router's interfaces are configured with IP addresses and corresponding address masks, the router can derive information about the networks connected to its interfaces by applying address masks to the associated addresses. That is the way routers obtain their startup information about directly connected networks and put this information into the routing tables. In our example, the routing table of R1 would look like the following:

Network 10.0.0.0 is directly connected to interface Ethernet 0
Network 20.0.0.0 is directly connected to interface Ethernet 1

This table contains enough information to route the packet from host A to host B. The router just takes the destination address from the IP packet header and looks through the table. Having found the information about network 20.0.0.0, the router understands that the packet destined for a host on this network should be delivered on interface Ethernet 1. The decision is made. Now the router has to encapsulate the IP packet into an Ethernet frame and send it to host B. If this is the first time the router is sending a packet to this host, the router sends an ARP request, asking for B's MAC address. Otherwise, the router uses its ARP cache. This example is quite simple, as both networks are directly connected.

Now look at a network constructed of several routers (Figure 3-3). Every router in the network has information only about directly attached networks:

Figure 3-3. More complex routed network

  • R1:

    Network 10.0.0.0 is directly connected to the interface Ethernet 0
    Network 20.0.0.0 is directly connected to the interface Ethernet 1
  • R2:

    Network 20.0.0.0 is directly connected to the interface Ethernet 0
    Network 30.0.0.0 is directly connected to the interface Ethernet
    1
  • R3:

    Network 20.0.0.0 is directly connected to the interface Ethernet 0
    Network 40.0.0.0 is directly connected to the interface Ethernet 1

Now host A from network 10.0.0.0 sends an IP packet to host C on network 30.0.0.0. When it receives the packet, R1 cannot make the forwarding decision, because it has no information about destination network 30.0.0.0. R1 will drop the packet and send an ICMP "Destination Unreachable" message to host A. What information would R1 need in its routing table to successfully route the packet to host C? There should obviously be a line saying that network 30.0.0.0 is reachable via router R2. The routing table of R1 would have to look like the following.

Network 10.0.0.0 is directly connected to the interface Ethernet 0
Network 20.0.0.0 is directly connected to the interface Ethernet 1
Network 30.0.0.0 is accessible via 20.0.0.2

With this information, the router would make its forwarding decision as follows.

  1. The packet is destined to host 30.0.0.2 (host C).

  2. Look through the routing table for information about address 30.0.0.2.

  3. Address 30.0.0.2 belongs to network 30.0.0.0 that is accessible via host 20.0.0.2.

  4. Look through the routing table for information about address 20.0.0.2.

  5. Network 20.0.0.2 belongs to network 20.0.0.0 that is directly connected to interface Ethernet 1.

  6. Send the packet through the Ethernet 1 interface, using R2's MAC address as the destination MAC address.

As you see, the router performs recursive table lookup, trying to find a route to the next-hop address, specified in the last route in the table. If there were another router, R4, on network 30.0.0.0 and connected to network 50.0.0.0, router R1 would have the following routing table:

Network 10.0.0.0 is directly connected to the interface Ethernet 0
Network 20.0.0.0 is directly connected to the interface Ethernet 1
Network 30.0.0.0 is accessible via 20.0.0.2
Network 50.0.0.0 is accessible via 30.0.0.5         (router R4's IP address)

The steps taken by the router in this case would be the same: "Find information about the destination network; if it goes through another network, find information about that one, too." The router would continue looking through the table recursively until it found a reference to a router's address that belonged to a directly connected network or it realized that there was no route for the address.

Following are some rules of thumb about routing in datagram networks. (IP networks belong to the datagram network group.) Knowing these basic principles is required for network maintenance and troubleshooting.

  • Every router makes its decision alone, based on the information it has in its own routing table. When making the routing decision, a router can use only information in its own routing table. There is no way for a router to check whether its neighbors are going to make a consistent decision. Routers route packets according to the information they have in the routing tables at a particular instance. When it forwards a packet to the next router, a router assumes that the next router will do the same: make its decision according to the information in its own routing table. Only consistent routing information can guarantee a consistent forwarding decision throughout the network.

  • The fact that one router has certain information in its routing table does not mean that other routers have the same information. Even if the first-hop router—the router nearest to the source—has required information about a remote network, other routers on the way to the destination may have no information about it. Therefore, even if the first-hop router forwards a packet successfully, the next router may drop the packet if it doesn't have enough routing information to forward it.

  • Routing information about a path from one network to another does not provide routing information about the reverse, or return, path. Even though all routers along the way to a destination have information about the destination network, the remote routers may have no information about how to route packets coming back. In the example, if host C on network 30.0.0.0 sent a reply to host A on network 10.0.0.0, router R2 would need additional information about how to reach network 10.0.0.0. If it had no information about this network, R2 would have to drop the packet.

According to these rules, the administrator needs to make sure that all routers in a network have adequate and consistent information about every network that might be involved in the communication process.

Lack of routing information about a destination network is not the only reason for a router to drop a packet. A router can also drop packets because of output queue overflow or because of a lack of CPU time needed for the router to take packets out of the input queues. A packet is also dropped when the value of its Time-to-Live (TTL) field reaches 0; each router decrements it by1. This is a protective measure introduced to make sure that even in the presence of temporary or permanent routing loops, the network does not accumulate—forward endlessly—packets destined for the networks for which the loops are experienced. Another reason for a packet drop is inability to fragment an IP packet while trying to send it through one of the router's interfaces.

Normally, every router's interface is assigned a value that specifies the maximum size of a data block that can be sent over it. This value is called maximum transmission unit (MTU) and is usually specific for a given media type. For example, the default MTU for Ethernet and serial interfaces in Cisco routers is 1,500 bytes; for the 16Mbps Token Ring, it is 8,136 bytes. When it is about to send an IP packet over an interface, a router checks whether the packet fits into the interface MTU. If the packet is bigger than the MTU, the router breaks the packet into pieces that fit into it and sends them as separate IP packets. This process is called IP packet fragmentation. Routers can fragment an IP packet if necessary unless it has the do not fragment (DF) bit set in the header. When this bit is set and a router sees that the packet must be fragmented, the router drops the packet and sends an ICMP "Destination Unreachable" message with the code field set to "Fragmentation needed and DF set" to the originator.

NOTE

The difference between an IP packet and an IP datagram is that hosts always send datagrams, which can be fragmented into several IP packets. Therefore, any IP packet can be either a whole IP datagram or a fragment of it. IP packets can be further fragmented if they need to be sent over a link with even smaller MTUs.

If a datagram is fragmented while going through the network, the receiving host performs IP datagram reassembly. Routers do not reassemble IP datagrams from IP packets not destined for themselves, for several reasons. First, it would add extra delays in routing: A router would have to wait until all fragments of a given datagram came to it. Second, the router would need to store all fragments of all datagrams before reassembly. (Imagine an Internet core router doing this.) Third, and maybe most important, because routers perform load sharing—send packets to the same destination along parallel paths—and because IP packets are sometimes dropped on their way through the network, a router may never receive all fragments of a datagram.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020