Fundamentals of IPv4 Addressing and Routing – Detailed Discussion – Internold Networks

Fundamentals of IPv4 Addressing and Routing

The TCP/IP network layer (Layer 3) defines how to deliver IP packets over the entire trip, from the original device that creates the packet to the device that needs to receive the packet.

That process requires cooperation among several different jobs and concepts on a number of devices.

  • IP routing: The process of hosts and routers forwarding IP packets (Layer 3 protocol data units [PDU]), while relying on the underlying LANs and WANs to forward the bits.
  • IP addressing: Addresses used to identify a packet’s source and destination host computer. Addressing rules also organize addresses into groups, which greatly assists the routing process.
  • IP routing protocol: A protocol that aids routers by dynamically learning about the IP address groups so that a router knows where to route IP packets so that they go to the right destination host.
  • Other utilities: The network layer also relies on other utilities. For TCP/IP, these utilities include Domain Name System (DNS), Address Resolution Protocol (ARP), and ping.

Note that all these functions have variations both for the well-established IP version 4 (IPv4) and for the emerging newer IP version 6 (IPv6). 

Overview of Network Layer Functions

Many protocol models have existed over the years, but today the TCP/IP model dominates.

And at the network layer of TCP/IP, two options exist for the main protocol around which all other network layer functions revolve: IP version 4 (IPv4) and IP version 6 (IPv6).

Both IPv4 and IPv6 define the same kinds of network layer functions, but with different details.

IP focuses on the job of routing data, in the form of IP packets, from the source host to the destination host.

IP does not concern itself with the physical transmission of data, instead relying on the lower TCP/IP layers to do the physical transmission of the data.

Instead, IP concerns itself with the logical details, rather than physical details, of delivering data.

In particular, the network layer specifies how packets travel end to end over a TCP/IP network, even when the packet crosses many different types of LAN and WAN links.

Network Layer Routing (Forwarding) Logic

Routers and end-user computers (called hosts in a TCP/IP network) work together to perform IP routing.

The host operating system (OS) has TCP/IP software, including the software that implements the network layer.

Hosts use that software to choose where to send IP packets, often to a nearby router. Those routers make choices of where to send the IP packet next.

Together, the hosts and routers deliver the IP packet to the correct destination, as shown in the example in the diagram below.

The IP packet, created by PC1, goes from the top of the figure all the way to PC2 at the bottom of the figure.

NOTE: The term path selection is sometimes used to refer to the routing process shown in previous diagram. At other times, it refers to routing protocols, specifically how routing protocols select the best route among the competing routes to the same destination.

Host Forwarding Logic: Send the Packet to the Default Router

In prior diagram, PC1 does some basic analysis, and then chooses to send the IP packet to the router so that the router will forward the packet.

PC1 analyzes the destination address and realizes that PC2’s address (168.1.1.1) is not on the same LAN as PC1.

So PC1’s logic tells it to send the packet to a device whose job it is to know where to route data: a nearby router, on the same LAN, called PC1’s default router.

To send the IP packet to the default router, the sender sends a data-link frame across the medium to the nearby router; this frame includes the packet in the data portion of the frame.

That frame uses data link layer (Layer 2) addressing in the data-link header to ensure that the nearby router receives the frame.

NOTE: The default router is also referred to as the default gateway.

R1 and R2’s Logic: Routing Data Across the Network

All routers use the same general process to route the packet.

Each router keeps an IP routing table. This table lists IP address groupings, called IP networks and IP subnets.

When a router receives a packet, it compares the packet’s destination IP address to the entries in the routing table and makes a match. This matching entry also lists directions that tell the router where to forward the packet next.

In the above diagram, R1 would have matched the destination address (168.1.1.1) to a routing table entry, which in turn told R1 to send the packet to R2 next.

Similarly, R2 would have matched a routing table entry that told R2 to send the packet, over an Ethernet over MPLS (EoMPLS) link, to R3 next.

The routing concept works a little like driving down the freeway when approaching a big interchange. You look up and see signs for nearby towns, telling you which exits to take to go to each town.

Similarly, the router looks at the IP routing table (the equivalent of the road signs) and directs each packet over the correct next LAN or WAN link (the equivalent of a road).

R3’s Logic: Delivering Data to the End Destination

The final router in the path, R3, uses almost the same logic as R1 and R2, but with one minor difference. R3 needs to forward the packet directly to PC2, not to some other router. 

How Network Layer Routing Uses LANs and WANs

While the network layer routing logic ignores the physical transmission details, the bits still have to be transmitted.

To do that work, the network layer logic in a host or router must hand off the packet to the data link layer protocols, which, in turn, ask the physical layer to actually send the data.

The data link layer adds the appropriate header and trailer to the packet, creating a frame, before sending the frames over each physical network.

The routing process forwards the network layer packet from end to end through the network, while each data-link frame only takes a smaller part of the trip.

Each successive data link layer frame moves the packet to the next device that thinks about network layer logic.

In short, the network layer thinks about the bigger view of the goal, like “Send this packet to the specified next device…,” while the data link layer thinks about the specifics, like “Encapsulate the packet in a data-link frame and transmit it.”

The diagram below points out the key encapsulation logic on each device.

Because the routers build new data-link headers and trailers, and because the new headers contain data-link addresses, the PCs and routers must have some way to decide what data-link addresses to use.

An example of how the router determines which data-link address to use is the IP Address Resolution Protocol (ARP). ARP dynamically learns the data-link address of an IP host connected to a LAN.

For example, at the last step, at the bottom of above diagram, Router R3 would use ARP once to learn PC2’s MAC address before sending any packets to PC2.

Routing as covered so far has two main concepts:

  • The process of routing forwards Layer 3 packets, also called Layer 3 protocol data units (L3 PDU), based on the destination Layer 3 address in the packet.
  • The routing process uses the data link layer to encapsulate the Layer 3 packets into Layer 2 frames for transmission across each successive data link.

IP Addressing and How Addressing Helps IP Routing

IP defines network layer addresses that identify any host or router interface that connects to a TCP/IP network.

The idea basically works like a postal address: Any interface that expects to receive IP packets needs an IP address, just like you need a postal address before receiving mail from the postal service.

TCP/IP groups IP addresses together so that IP addresses used on the same physical network are part of the same group.

IP calls these address groups an IP network or an IP subnet.

Using that same postal service analogy, each IP network and IP subnet works like a postal code (or ZIP code). All nearby postal addresses are in the same postal code (ZIP code), while all nearby IP addresses must be in the same IP network or IP subnet.

IP defines specific rules about which IP address should be in the same IP network or IP subnet.

Numerically, the addresses in the same group have the same value in the first part of the addresses.

For example, the previous diagrams could have used the following conventions:

  • Hosts on the top Ethernet: Addresses start with 10
  • Hosts on the R1-R2 serial link: Addresses start with 168.10
  • Hosts on the R2-R3 EoMPLS link: Addresses start with 168.11
  • Hosts on the bottom Ethernet: Addresses start with 168.1

To make routing more efficient, network layer protocols group addresses, both by their location and by the actual address values. A router can list one routing table entry for each IP network or subnet, instead of one entry for every single IP address.

The routing process also makes use of a 20-byteIPv4 header, as shown in below diagram. 

The header lists a 32-bit source IP address, as well as a 32-bit destination IP address. 

Routing Protocols

For routing logic to work on both hosts and routers, each needs to know something about the TCP/IP internetwork.

Hosts need to know the IP address of their default router so that hosts can send packets to remote destinations.

Routers, however, need to know routes so that routers know how to forward packets to each and every IP network and IP subnet.

Although a network engineer could configure (type) all the required routes, on every router, most network engineers instead simply enable a routing protocol on all routers.

If you enable the same routing protocol on all the routers in a TCP/IP internetwork, with the correct settings, the routers will send routing protocol messages to each other.

As a result, all the routers will learn routes for all the IP networks and subnets in the TCP/IP internetwork.

Diagram below shows an example.

In this case, IP network 168.1.0.0, which consists of all addresses that begin with 168.1, sits on the Ethernet at the bottom of the diagram. 

R3, knowing this fact, sends a routing protocol message to R2 (Step 1).

R2 learns a route for network 168.1.0.0 as a result, as shown on the left.

At Step 2, R2 turns around and sends a routing protocol message to R1 so that R1 now has a route for that same IP network (168.1.0.0).

IPv4 Addressing

One of the most important concept in your CCNA study is the understanding of IP addresses, their formats, the grouping concepts, how to subdivide groups into subnets, how to interpret the documentation for existing networks’ IP addressing, and so on.

Simply put, you had better know addressing and subnetting!

Rules for IP Addresses

If a device wants to communicate using TCP/IP, it needs an IP address.

When the device has an IP address and the appropriate software and hardware, it can send and receive IP packets.

Any device that has at least one interface with an IP address can send and receive IP packets and is called an IP host.

IP addresses consist of a 32-bit number, usually written in dotted-decimal notation (DDN).

The “decimal” part of the term comes from the fact that each byte (8 bits) of the 32-bit IP address is shown as its decimal equivalent.

The four resulting decimal numbers are written in sequence, with “dots,” or decimal points, separating the numbers—hence the name dotted-decimal.

For example, 168.1.1.1 is an IP address written in dotted-decimal form; the actual binary version is 10101000 00000001 00000001 00000001.

Each DDN has four decimal octets, separated by periods. The term octet is just a vendor-neutral term for byte.

Because each octet represents an 8-bit binary number, the range of decimal numbers in each octet is between 0 and 255, inclusive.

For example, the IP address of 168.1.1.1 has a first octet of 168, the second octet of 1, and so on.

Finally, note that each network interface uses a unique IP address. Most people tend to think that their computer has an IP address, but actually their computer’s network card has an IP address.

For example, if your laptop has both an Ethernet network interface card (NIC) and a wireless NIC, with both working at the same time, both will have an IP address.

Similarly, routers, which typically have many network interfaces that forward IP packets, have an IP address for each interface.

Rules for Grouping IP Addresses

The original specifications for TCP/IP grouped IP addresses into sets of consecutive addresses called IP networks.

The addresses in a single IP network have the same numeric value in the first part of all addresses in the network.

The diagram below shows a simple internetwork that has three separate IP networks.

The diagram lists a network identifier (network ID) for each network, as well as a text description of the DDN values in each network. 

For example, the hosts in the Ethernet LAN on the far left use IP addresses that begin with a first octet of 8; the network ID happens to be 8.0.0.0.

As another example, the serial link between R1 and R2 consists of only two interfaces—a serial interface on each router—and uses an IP address that begins with the three octets 199.1.1.

The above diagram also provides a good figure with which to discuss two important facts about how IPv4 groups IP addresses:

  • All IP addresses in the same group must not be separated from each other by a router.
  • IP addresses separated from each other by a router must be in different groups.

Take the first of the two rules, and look at hosts A and B on the left.

Hosts A and B are in the same IP network and have IP addresses that begin with 8.

Per the first rule, hosts A and B cannot be separated from each other by a router (and they are indeed not separated from each other by a router).

Next, take the second of the two rules and add host C to the discussion. Host C is separated from host A by at least one router, so host C cannot be in the same IP network as host A. Host C’s address cannot begin with 8.

Likewise, IP routing relies on all addresses in one IP network or IP subnet being in the same location, specifically on a single instance of a LAN or WAN data link. Otherwise, the routers might deliver IP packets to the wrong locations.

For any TCP/IP internetwork, each LAN and WAN link will use either an IP network or an IP subnet. 

Class A, B, and C IP Networks

The IPv4 address space includes all possible combinations of numbers for a 32-bit IPv4 address.

Literally 232 different values exist with a 32-bit number, for more than 4 billion different numbers.

With DDN values, these numbers include all combinations of the values 0 through 255 in all four octets: 0.0.0.0, 0.0.0.1, 0.0.0.2, and all the way up to 255.255.255.255.

IP standards first subdivide the entire address space into classes, as identified by the value of the first octet.

  • Class A gets roughly half of the IPv4 address space, with all DDN numbers that begin with 1–126.. 
  • Class B gets one-fourth of the address space, with all DDN numbers that begin with 128–191 inclusive.
  • Class C gets one-eighth of the address space, with all numbers that begin with 192–223.

See diagram below for details.

The diagram also notes the purpose for the five address classes.

  • Classes A, B, and C define unicast IP addresses, meaning that the address identifies a single host interface. 
  • Class D defines multicast addresses, used to send one packet to multiple hosts.
  • Class E originally defined experimental addresses but are now reserved for future use.

IPv4 standards also subdivide the Class A, B, and C unicast classes into predefined IP networks.

Each IP network makes up a subset of the DDN values inside the class.

IPv4 uses three classes of unicast addresses so that the IP networks in each class can be different sizes, and therefore meet different needs.

Class A networks each support a very large number of IP addresses (more than 16 million host addresses per IP network).

However, because each Class A network is so large, Class A holds only 126 Class A networks.

Class B defines IP networks that have 65,534 addresses per network, but with space for more than 16,000 such networks.

Class C defines much smaller IP networks, with 254 addresses each.

See the diagram below for details.

The diagram shows a visual perspective, as well as the literal numbers, for all the Class A, B, and C IPv4 networks in the entire world. It shows clouds for IP networks.

It, of course, does not show one cloud for every possible network, but shows the general idea, with a small number of large clouds for Class A and a large number of small clouds for Class C.

The Actual Class A, B, and C IP Networks

The previous diagram shows the number of Class A, B, and C IP networks in the entire world.

Eventually, you need to actually pick and use some of these IP networks to build a working TCP/IP internetwork, so you need to be able to answer the question: What are the specific IP networks?

First, you must be able to identify each network briefly using a network identifier (network ID).

The network ID is just one reserved DDN value per network that identifies the IP network. (The network ID cannot be used by a host as an IP address.)

For example, the table shows the network IDs that match the given diagram.

Network IDs Used

NOTE: Many people use the term network ID, but others use the terms network number and network address. Be ready to use all three terms.

So, what are the actual Class A, B, and C IP networks, and what are their network IDs?

First, consider the Class A networks. As learned, only 126 Class A networks exist. 

As it turns out, they consist of all addresses that begin with 1, all addresses that begin with 2, all addresses that begin with 3, and so on, up through the 126th such network of “all addresses that begin with 126.”

The table below lists a few of these networks.

Sampling of IPv4 Class A Networks

Class B networks have a first octet value between 128 and 191, inclusive, but in a single Class B network, the addresses have the same value in the first two octets.

For example, our previous diagram uses Class B network 130.4.0.0. The DDN value 130.4.0.0 must be in Class B, because the first octet is between 128 and 191, inclusive.

However, the first two octets define the addresses in a single Class B network.

Table below lists some sample IPv4 Class B networks.

Sampling of IPv4 Class B Networks

Class C networks can also be easily identified, with a first octet value between 192 and 223, inclusive.

With Class C networks and addresses, the first three octets define the group, with addresses in one Class C network having the same value in the first three octets.

Table below shows some samples.

Listing all the Class A, B, and C networks would of course take too much space.

Table below summarizes the first octet values that identify the class and summarizes the range of Class A, B, and C network numbers available in the entire IPv4 address space.

All Possible Valid Network Numbers

NOTE: The term classful IP network refers to any Class A, B, or C network, because it is defined by Class A, B, and C rules.

IP Subnetting

Like IP addressing, IP subnetting is also one of the most important topics that a Network Engineer needs to master.

Subnetting defines methods of further subdividing the IPv4 address space into groups that are smaller than a single IP network.

IP subnetting defines a flexible way for anyone to take a single Class A, B, or C IP network and further subdivide it into even smaller groups of consecutive IP addresses.

In fact, the name subnet is just shorthand for subdivided network. Then, in each location where you used to use an entire Class A, B, or C network, you can use a smaller subnet, wasting fewer IP addresses.

To make it clear how an internetwork can use both classful IPv4 networks as well as subnets of classful IPv4 networks, the next two diagrams show the same internetwork, one with classful networks only and one with subnets only. The first diagram uses five Class B networks with no subnetting.

The design in 1st diagram below requires five groups of IP addresses, each of which is a Class B network in this example.

Specifically, the three LANs each use a single Class B network, and the two serial links each use a Class B network.

It wastes many IP addresses, because each Class B network has 216 – 2 host addresses—far more than you will ever need for each LAN and WAN link.

For example, the Ethernet on the left uses an entire Class B network, which supports 65,534 IP addresses that begin with 150.1.

However, a single LAN seldom grows past a few hundred devices, so many of the IP addresses in Class B network 150.1.0.0 would be wasted. Even more waste occurs on the point-to-point serial links, which need only two IP addresses.

The 2nd diagram illustrates a more common design today, one that uses basic subnetting. As in the previous diagram, it needs five groups of addresses.

However, in this case, the figure uses five subnets of Class B network 150.9.0.0.

Using Subnets for the Same Design as the Previous Figure

Subnetting allows the network engineer for the TCP/IP internetwork to choose to use a longer part of the addresses that must have the same value.

Subnetting allows quite a bit of flexibility, but 2nd diagram above shows one of the simplest forms of subnetting.

In this case, each subnet includes the addresses that begin with the same value in the first three octets, as follows:

  • One group of the 254 addresses that begin with 150.9.1
  • One group of the 254 addresses that begin with 150.9.2
  • One group of the 254 addresses that begin with 150.9.3
  • One group of the 254 addresses that begin with 150.9.4
  • One group of the 254 addresses that begin with 150.9.5

As a result of using subnetting, the network engineer has saved many IP addresses.

First, only a small part of Class B network 150.9.0.0 has been used so far. Each subnet has 254 addresses, which should be plenty of addresses for each LAN, and more than enough for the WAN links.

In summary, you now know some of the details of IP addressing, with a focus on how it relates to routing. Each host and router interface will have an IP address.

However, the IP addresses will not be randomly chosen but will instead be grouped together to aid the routing process.

The groups of addresses can be an entire Class A, B, or C network number or it can be a subnet.

IPv4 Routing

IPv4 Host Routing

Hosts actually use some simple routing logic when choosing where to send a packet. If you assume that the design uses subnets (which is typical), this two-step logic is as follows:

  • Step 1. If the destination IP address is in the same IP subnet as I am, send the packet directly to that destination host.
  • Step 2. Otherwise, send the packet to my default gateway, also known as a default router. (This router has an interface on the same subnet as the host.)

For example, consider the diagram below and focus on the Ethernet LAN on the left.

When PC1 sends an IP packet to PC11 (150.9.1.11), PC1 first considers some match related to subnetting.

PC1 concludes that PC11’s IP address is in the same subnet as PC1, so PC1 ignores its default router (Core, 150.9.1.1), sending the packet directly to PC11, as shown in Step 1 of the diagram.

Alternatively, when PC1 sends a packet to PC2 (150.9.4.10), PC1 does the same kind of subnetting math, and realizes that PC2 is not on the same subnet as PC1.

So, PC1 forwards the packet (Step 2) to its default gateway, 150.9.1.1, which then routes the packet to PC2.

Router Forwarding Decisions and the IP Routing Table

A Summary of Router Forwarding Logic

First, when a router receives a data-link frame addressed to that router’s data-link address, the router needs to think about processing the contents of the frame.

When such a frame arrives, the router uses the following logic on the data-link frame:

  • Step 1. Use the data-link Frame Check Sequence (FCS) field to ensure that the frame had no errors; if errors occurred, discard the frame.
  • Step 2. Assuming that the frame was not discarded at Step 1, discard the old data-link header and trailer, leaving the IP packet.
  • Step 3. Compare the IP packet’s destination IP address to the routing table, and find the route that best matches the destination address. This route identifies the outgoing interface of the router, and possibly the next-hop router IP address.
  • Step 4. Encapsulate the IP packet inside a new data-link header and trailer, appropriate for the outgoing interface, and forward the frame.

With these steps, each router forwards the packet to the next location, inside a data-link frame.

With each router repeating this process, the packet reaches its final destination.

While the router does all the steps in the list, Step 3 is the main routing or forwarding step.

The packet has a destination IP address in the header, whereas the routing table lists slightly different numbers, typically a list of networks and subnets.

To match a routing table entry, the router thinks like this:

  • Network numbers and subnet numbers represent a group of addresses that begin with the same prefix.
  • Think about those numbers as groups of addresses. 
  • In which of the groups does this packet’s destination address reside?

The next example shows specific examples of matching the routing table.

A Detailed Routing Example

The routing example uses the diagram below.

In this example, all routers happen to use the Open Shortest Path First (OSPF) routing protocol, and all routers know routes for all subnets.

In particular, PC2, at the bottom, sits in subnet 150.150.4.0, which consists of all addresses that begin with 150.150.4.

In the example, PC1 sends an IP packet to 150.150.4.10, PC2’s IP address.

NOTE: Note that the routers all know in this case that “subnet 150.150.4.0” means “all addresses that begin with 150.150.4.”

The following list explains the forwarding logic at each step in the diagram above.

(Note that the text refers to Steps 1, 2, 3, and 4 of the routing logic shown in the previous section — A Summary of Router Forwarding Logic)

  • Step A 
    • PC1 sends the packet to its default router.
    • PC1 first builds the IP packet, with a destination address of PC2’s IP address (150.150.4.10).
    • PC1 needs to send the packet to R1 (PC1’s default router) because the destination address is on a different subnet.
    • PC1 places the IP packet into an Ethernet frame, with a destination Ethernet address of R1’s Ethernet address.
    • PC1 sends the frame on to the Ethernet. (Note that the figure omits the data-link trailers.)
  • Step B
    • R1 processes the incoming frame and forwards the packet to R2.
    • Because the incoming Ethernet frame has a destination MAC of R1’s Ethernet MAC, R1 copies the frame off the Ethernet for processing.
    • R1 checks the frame’s FCS, and no errors have occurred (Step 1).
    • R1 then discards the Ethernet header and trailer (Step 2).
    • Next, R1 compares the packet’s destination address (150.150.4.10) to the routing table and finds the entry for subnet 150.150.4.0—which includes addresses 150.150.4.0 through 150.150.4.255 (Step 3).
    • Because the destination address is in this group, R1 forwards the packet out interface Serial0 to next-hop Router R2 (150.150.2.7) after encapsulating the packet in a High-Level Data Link Control (HDLC) frame (Step 4).
  • Step C
    • R2 processes the incoming frame and forwards the packet to R3.
    • R2 repeats the same general process as R1 when R2 receives the HDLC frame.
    • R2 checks the FCS field and finds that no errors occurred (Step 1).
    • R2 then discards the HDLC header and trailer (Step 2).
    • Next, R2 finds its route for subnet 150.150.4.0—which includes the address range 150.150.4.0–150.150.4.255—and realizes that the packet’s destination address 150.150.4.10 matches that route (Step 3).
    • Finally, R2 sends the packet out interface Fast Ethernet 0/0 to next-hop router 150.150.3.1 (R3) after encapsulating the packet in an Ethernet header (Step 4).
  • Step D
    • R3 processes the incoming frame and forwards the packet to PC2.
    • Like R1 and R2, R3 checks the FCS, discards the old data-link header and trailer, and matches its own route for subnet 150.150.4.0.
    • R3’s routing table entry for 150.150.4.0 shows that the outgoing interface is R3’s Ethernet interface, but there is no next-hop router because R3 is connected directly to subnet 150.150.4.0.
    • All R3 has to do is encapsulate the packet inside a new Ethernet header and trailer, with a destination Ethernet address of PC2’s MAC address, and forward the frame.

IPv4 Routing Protocols

The routing (forwarding) process depends heavily on having an accurate and up-to-date IP routing table on each router.

Goals of a routing protocol, regardless of how the routing protocol works

  • To dynamically learn and fill the routing table with a route to each subnet in the internetwork.
  • If more than one route to a subnet is available, to place the best route in the routing table.
  • To notice when routes in the table are no longer valid, and to remove them from the routing table.
  • If a route is removed from the routing table and another route through another neighboring router is available, to add the route to the routing table. (Many people view this goal and the preceding one as a single goal.)
  • To work quickly when adding new routes or replacing lost routes. (The time between losing the route and finding a working replacement route is called convergence time.)
  • To prevent routing loops.

Routing protocols all use some similar ideas to allow routers to learn routing information from each other.

Of course, each routing protocol works differently; otherwise, you would not need more than one routing protocol.

However, many routing protocols use the same general steps for learning routes:

  • Step 1. Each router, independent of the routing protocol, adds a route to its routing table for each subnet directly connected to the router.
  • Step 2. Each router’s routing protocol tells its neighbors about the routes in its routing table, including the directly connected routes and routes learned from other routers.
  • Step 3. After learning a new route from a neighbor, the router’s routing protocol adds a route to its IP routing table, with the next-hop router of that route typically being the neighbor from which the route was learned.

For example, consider below diagram which is similar to previous one, but now with a focus on how the three routers each learned about subnet 150.150.4.0.

Note that routing protocols do more work than is implied in the figure; this figure just focuses on how the routers learn about subnet 150.150.4.0.

Follow items A through F shown in the diagram to see how each router learns its route to 150.150.4.0.

​(Note that the text refers to Steps 1, 2, 3, and 4 of the routing logic shown in the previous section — A Summary of Router Forwarding Logic)

  • Step A
    • Subnet 150.150.4.0 exists as a subnet at the bottom of the diagram, connected to Router R3.
  • Step B
    • R3 adds a connected route for 150.150.4.0 to its IP routing table (Step 1); this happens without help from the routing protocol.
  • Step C
    • R3 sends a routing protocol message, called a routing update, to R2, causing R2 to learn about subnet 150.150.4.0 (Step 2).
  • Step D
    • R2 adds a route for subnet 150.150.4.0 to its routing table (Step 3).
  • Step E
    • R2 sends a similar routing update to R1, causing R1 to learn about subnet 150.150.4.0 (Step 2).
  • Step F
    • R1 adds a route for subnet 150.150.4.0 to its routing table (Step 3).
    • The route lists R1’s own Serial0 as the outgoing interface and R2 as the next-hop router IP address (150.150.2.7).

Other Network Layer Features

The TCP/IP network layer defines many functions beyond the function defined by the IPv4 protocol.

Sure, IPv4 plays a huge role in networking today, defining IP addressing and IP routing.

However, other protocols and standards, defined in other Requests For Comments (RFC), play an important role for network layer functions as well.

For example, routing protocols like Open Shortest Path First (OSPF) exist as separate protocols, defined in separate RFCs.

This section introduces three other network layer features that should be helpful and give some perspective and make sense on future discussions. 

The three topics are:

  • Domain Name System (DNS)
  • Address Resolution Protocol (ARP)
  • Ping

Using Names and the Domain Name System

Can you imagine a world in which every time you used an application, you had to think about the other computer and refer to it by IP address?

Instead of using easy names like google.com or facebook.com, you would have to remember and type IP addresses, like 74.125.225.5.

Certainly, that would not be user friendly and could drive some people away from using computers at all.

Thankfully, TCP/IP defines a way to use hostnames to identify other computers.

The user either never thinks about the other computer or refers to the other computer by name. Then, protocols dynamically discover all the necessary information to allow communications based on that name.

For example, when you open a web browser and type in the hostname www.google.com, your computer does not send an IP packet with destination IP address www.google.com; it sends an IP packet to an IP address used by the web server for Google.

TCP/IP needs a way to let a computer find the IP address used by the listed hostname, and that method uses the Domain Name System (DNS).

Enterprises use the DNS process to resolve names into the matching IP address, as shown in the example in diagram below. 

In this case, PC11, on the left, needs to connect to a server named Server1.

At some point, the user either types in the name Server1 or some application on PC11 refers to that server by name.

At Step 1, PC11 sends a DNS message—a DNS query—to the DNS server.

At Step 2, the DNS server sends back a DNS reply that lists Server1’s IP address.

At Step 3, PC11 can now send an IP packet to destination address 10.1.2.3, the address used by Server1.

Note that the example in above diagram shows a cloud for the TCP/IP network because the details of the network, including routers, do not matter to the name resolution process.

Routers treat the DNS messages just like any other IP packet, routing them based on the destination IP address.

For example, at Step 1 in the figure, the DNS query will list the DNS server’s IP address as the destination address, which any routers will use to forward the packet.

Finally, DNS defines much more than just a few messages. DNS defines protocols, as well as standards for the text names used throughout the world, and a worldwide set of distributed DNS servers.

The domain names that people use every day when web browsing, which look like www.example.com, follow the DNS naming standards.

Also, no single DNS server knows all the names and matching IP addresses, but the information is distributed across many DNS servers.

So, the DNS servers of the world work together, forwarding queries to each other, until the server that knows the answer supplies the desired IP address information.

The Address Resolution Protocol

IP routing logic requires that hosts and routers encapsulate IP packets inside data link layer frames.

In previous diagrams and examples, it shows how every router de-encapsulates each IP packet and encapsulates the IP packet inside a new data-link frame.

On Ethernet LANs, whenever a host or router needs to encapsulate an IP packet in a new Ethernet frame, the host or router knows all the important facts to build that header—except for the destination MAC address.

The host knows the IP address of the next device, either another host IP address or the default router IP address.

A router knows the IP route used for forwarding the IP packet, which lists the next router’s IP address.

However, the hosts and routers do not know those neighboring devices’ MAC addresses beforehand.

TCP/IP defines the Address Resolution Protocol (ARP) as the method by which any host or router on a LAN can dynamically learn the MAC address of another IP host or router on the same LAN.

ARP defines a protocol that includes the ARP Request, which is a message that asks the simple request “if this is your IP address, please reply with your MAC address.”

ARP also defines the ARP Reply message, which indeed lists both the original IP address and the matching MAC address.

The diagram below shows the ARP Request on the left as a LAN broadcast, so all hosts receive the frame.

On the right, at Step 2, host PC2 sends back an ARP Reply, identifying PC2’s MAC address.

The text beside each message shows the contents inside the ARP message itself, which lets PC2 learn R3’s IP address and matching MAC address, and R3 learn PC2’s IP address and matching MAC address.

Note that hosts remember the ARP results, keeping the information in their ARP cache or ARP table.

A host or router only needs to use ARP occasionally, to build the ARP cache the first time.

Each time a host or router needs to send a packet encapsulated in an Ethernet frame, it first checks its ARP cache for the correct IP address and matching MAC address.

Hosts and routers will let ARP cache entries time out to clean up the table, so occasional ARP Requests can be seen.

NOTE: You can see the contents of the ARP cache on most PC operating systems by using the arp -a command from a command prompt.

ICMP Echo and the ping Command

After you have implemented a TCP/IP internetwork, you need a way to test basic IP connectivity without relying on any applications to be working.

The primary tool for testing basic network connectivity is the ping command.

Ping (Packet Internet Groper) uses the Internet Control Message Protocol (ICMP), sending a message called an ICMP echo request to another IP address.

The computer with that IP address should reply with an ICMP echo reply. If that works, you successfully have tested the IP network.

In other words, you know that the network can deliver a packet from one host to the other and back.

ICMP does not rely on any application, so it really just tests basic IP connectivity—Layers 1, 2, and 3 of the OSI model.

Diagram below outlines the basic process.

Note that while the ping command uses ICMP, ICMP does much more. 

ICMP defines many messages that devices can use to help manage and control the IP network. More of ICMP in future discussions.