Chapter 4 – Fundamentals of IPv4 Addressing and Routing

  • At TCP/IP, two options exist for network layer protocol are: IPv4 and IPv6 
  • Both define the same kinds of network layer functions, but with different details 
  • IP focuses on delivering data, in the form of IP packets, from the source host to the destination host. 
  • IP is relying on lower layers to deliver the data. 
  • IP is not concerned with physical data transmission but on logical data transmission. 
  • Routing protocols provide brain to routers, and make them learn information they need for routing packets successfully 
  • Routers and hosts work together to perform IP routing 
  • Every host’s operating system has TCP/IP software that implements the network layer and makes everything flow 
  • Hosts use that software to choose where to send data 
  • Then, routers decide where to send those packets next 
  • Together, hosts and routers work together to deliver data to correct destination 

Host forwarding logic: SEND PACKETS TO NEARBY ROUTER! 

  • The host begins to analyze IP address 
  • It realizes IP address is not on the same LAN 
  • Host’s logic tells him to send that packet on the gateway, or nearby router on the same LAN. 
  • To send that packet to a nearby router, the host makes data-link frame across the medium. 
  • Frame contains header, trailer, and data in between. That data holds network layer info together with IP address. 


  • Each router has IP routing table 
  • The table has IP address groupings (IP networks and IP subnets) 
  • The router looks at the routing table, realizes IP is not on the same IP address grouping, and forwards the packet to the next router. 
  • Same process continues until the router finds its IP grouping 
  • To easily understand this, think of a freeway with interchanges. You look for signs which tell you where your town is. When you see your sign, then you make a turn. 


  • Router uses almost the same logic as R1 and R2 

How network layer routing uses LANs and WANs

  • Network layer logic in a host or router, must pass the packet to data-link layer protocols, which ask physical layer to send the data. 
  • Data link layer adds header and trailer to the packet, creating frame, before sending the frames over physical network 
  • Routing process forwards network layer packet from end to end through the network, while data link frame only takes a smaller part of the trip. 
  • Routers build new data link headers and trailers 
  • New headers contain data-link addresses 
  • Router decides which data-link address (MAC) to use, is by looking in the Address Resolution Protocol, ARP table 
  • In example above, R3 will look in ARP table to find MAC address of PC3. 

How addressing helps routing

  • IP defines an IP address that identifies any host or router interface on a TCP/IP network. 
  • TCP/IP groups IP addresses together so that all addresses on the same network, are part of the TCP/IP network 
  • We call those groups IP subnets 
  • The concept of subnets is similar to postal codes in a country, or groups. 
  • Network layer protocols group addresses by their location and by the actual address 

IPv4 header

  • Header has 32-bit source IP address, and 32-bit destination IP address.  

Routing protocols

  • Both routers and hosts need to know routing logic to send/receive packets 
  • Hosts need to know IP address of their default gateway router to send packets to remote destinations 
  • Routers need to know routes so that they can forward packets to other IP networks or IP subnets 

Figure 4-4: 

  • Example of how routers learn new routes (advertising). 
  • R3 will send routing protocol message to R2 
  • R2 learns a route for network 
  • R2 sends routing protocol message to R1 
  • R1 learns a route for that same IP network ( 

IPv4 addressing

  • The most important topic on CCENT and CCNA 
  • If a device wants to communicate with TCP/IP, it needs an IP address.  
  • When a device has IP address, TCP/IP related software and hardware that will push data, that device can send/receive IP packets 
  • IP consists of a 32-bit number 
  • Written in dotted decimal notation 
  • Each byte (8bits) is equal to one number out of four numbers in an IP address 
  • Each DDN has four decimal octets 
  • Each octet is separated with periods 
  • Word octet is the term for byte. 
  • The range between each octet is 0-255 
  • Each network interface uses a unique IP address. 

Rules for grouping IP addresses

  • Network ID is the network IP address 

All IP addresses in the same network must not be separated from each other by a router 

IP addresses separated from each other by a router, must be in different networks. 

Class A, B, and C IP networks

  • 32 to the power of two, is equal to more than 4 billion combinations, from,,, … 
  • Class A gets half of the IPv4 address space (1-126) 
  • Class B gets fourth of the IPv4 address space (128-191) 
  • Class C gets eight of the IPv4 address space (192-223) 
  • Classes A, B, and C define unicast IP address, meaning that the address identifies a single host interface. 
  • Class D defines multicast addresses used to send one packet to multiple hosts 
  • Class E defines experimental IP addresses, which are nowadays reserved for future use. 

Network ID

  • Identifies a network.  
  • It is an IP network that starts like so we know the first octet is network part, and zeros are host part of the IP address. 
  • Network ID is just one reserved IP address per network that identifies the IP network. 
  • The network ID cannot be used by a host as an IP address. 
  • Network ID, network number and network address are all the same words 
  • 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

  • One of the most important topics for CCENT and CCNA 
  • Subnetting defines methods of subdividing IPv4 address space into groups that are smaller than a single IP network 
  • Subnetting means further subdividing Class A, B, or C network space 
  • The subnet is a shorthand for subdivided network 
  • Where we use entire Class A, B, C network, we can use smaller subnets, saving fewer IP addresses 
  • In the example above, we have 5 networks (,,,, and (no subnetting) 
  • 3 LANs use Class B network, two serials use Class B network too. 
  • Those 5 groups, waste a lot of IP addresses 
  • The more common way is to subnet Class B address 
  • For example,,, … and so on 
  • This subnetted network will provide 5 groups of IP addresses, that support 254 host addresses. – one group of the 254 addresses that begins with – one group of the 254 addresses that begins with – one group of the 254 addresses that begins with – one group of the 254 addresses that begins with – one group of the 254 addresses that begins with 
  • Now, each subnet has 254 hosts to fill in one particular LAN network and more than enough for the WAN links. 
  • Each host and a router interface will have its own IP address. 
  • The IP addresses will not be randomly chosen, but instead, a network engineers will group them together to help the routing process. 
  • The groups of addresses can be an entire Class A, B, or C, or it can be a subnet. 

IPv4 routing

Host routing

  1. If the destination IP address is in the same IP subnet as I am, send the packet directly to that destination host 
  2. Otherwise, send the packet to my default gateway (default router). This router has an interface that is on the same subnet as the host!!! 
  1. PC1 wants to send IP packet to PC11. 
  2. PC1 does some calculations on subnetting, and has the conclusion that PC11 is on the same subnet 
  3. PC1 sends the packet to the PC11, ignoring the gateway router 


  1. PC1 wants to send an IP packet to PC2 
  2. PC1 does some calculations on subnetting and has the conclusion that PC2 is NOT on the same subnet 
  3. PC1 sends the packet to the nearby gateway, who has the responsibility to forward that packet along the way to the PC2 

Summary of router forwarding logic: 

  • When a router receives a data-link frame addressed to that router’s data-link address, he needs to think about processing that frame. 
  • When such a frame arrives, the router uses the following logic to forward the data-link frame: 
    • Use FCS and check if the frame had any errors during the transport. if it did happen, discard the frame 
    • Remove the old data-link header and trailer and see the IP packet
    • See the IP destination address and compare it to the routing table. Next, find the route that best matches the destination address. 
    • Encapsulate the IP packet inside NEW data-link header and trailer, appropriate for outgoing interface 
    • Forward that new frame to the outgoing interface 

Detailed routing example: IMPORTANT

In this example: 

  • All routers use OSPF routing protocol. 
  • All routers know routes for all subnets. 
  • PC2: subnet (this subnet consists of all IP addresses that begin with 150.150.4.X) 
  • PC1 sends IP packet to (PC2’s IP address) 

Step 1)  PC1 sends the packet to its default router.  

  • PC1 builds IP packet with a destination address of PC2’s IP address ( 
  • Because the destination address is on different subnet, PC1 sends the packet to the gateway 
  • PC1 encapsulates network layer IP packet, and puts it inside Ethernet frame 
  • that frame will have destination MAC address of gateway R1 
  • PC1 sends the frame through the Ethernet medium 

Step 2) R1 processes the incoming frame and forwards the packet to R2 

  • R1 checks the frame’s FCS, and no errors occurred. 
  • R1 removes an Ethernet header and trailer. 
  • R1 compares the packet’s destination address ( with the routing table and finds the entry for this subnet (this subnet includes IPs from 
  • Because R1 knows where to forward the packet, it sends it to the right interface 
  • R1 begins encapsulating the packet in an HDLC frame. 
  • R1 forwards the packet to the Serial0 interface, to next R2 (  

Step 3) R2 processes the incoming frame and forwards the packet to R3 

  • R2 repeats the same process as R1 when he receives HDLC frame. 
  • R2 checks the frame’s FCS, and no errors occurred
  • R2 removes HDLC header and trailer 
  • R2 finds its route for subnet ( 
  • when looking routing table, R2 realizes that IP’s destination address ( matches that route. He knows where to send the packet 
  • R2 encapsulates the packet in an Ethernet header and trailer. 
  • R2 sends the packet our interface Fast Ethernet 0/0 to next router  

Step 2) R1 processes the incoming frame and forwards the packet to R2 

  • R3 checks the frame’s FCS, and no errors occurred
  • R3 removes Ethernet header and trailer 
  • R3 matches its own route for subnet 
  • R3 routing table for shows that outgoing interface is R3’s Ethernet interface and there are no next hops 
  • R3 encapsulates the packet inside new Ethernet header and trailer with destination MAC address of PC2 
  • Forwards the frame to PC2 

IPv4 routing protocols

Routing protocol goals: 

  • To dynamically learn and update routing table with a route to each subnet in internetwork 
  • If more than one route to a subnet is available, chose the best route in the routing table 
  • To notice when some routers in the table are no longer valid, and remove them from routing table 
  • If a route is removed from the routing table and at the same time another route through some other router is available, add that route to the routing table 
  • Work quickly to find new routes and replace lost routes (time lost when a router needs to find another route and its replacement is called convergence time) 
  • To prevent routing loops 

How routers learn routing information from each other

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

The following example will show how three routers learned about subnet  

Follow items A-F to see how each router learns its route to 

  1. Subnet exists as a subnet at the bottom of the figure, connected to R3 
  2. R3 adds connected route to its IP routing table (Step-1) (happens without routing protocol) 
  3. R3 sends a routing protocol message (routing update) to R2, forcing R2 to learn about subnet (Step-2) 
  4. R2 adds route for subnet to its routing table (Step-3) 
  5. R2 sends a routing protocol message (routing update) to R1, forcing R1 to learn about subnet (Step-2) 
  6. R1 adds route for subnet to its routing table (Step-3).  
  •     new route is set to R1’s own Serial0 as outgoing interface 
  •     new route is set to R2 as the next-hop router IP address ( 

How network layer forwards packets from source to destination in an internetwork

Domain Name System DNS: 

  • TCP/IP has a way to use hostnames to identify other computers. 
  • When you open a web browser and type, your computer does not send an IP packet with destination IP 
  • In contrary, it sends an IP packet to an IP address used by the webserver for Google i.e 
  • Routers treat DNS packets just like any other TCP/IP packet, routing them based on their destination address. 
  • No single DNS knows all the names and matching IP addresses, but the information is distributed across many DNS servers. 
  • 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. 

Address Resolution Protocol ARP


  • Router, in the process above, know everything from where to route the packet, to the IP address, but does not know its MAC address 
  • ARP is a method where each device on a LAN can dynamically learn the MAC address of another IP host or router. 
  • ARP has a protocol that has ARP Request, message that asks simple request is this your IP address, please reply. 
  • ARP also defines ARP Reply which lists both IP and MAC address 
  • ARP Request is a broadcast 
  • Hosts remember ARP results keeping them in ARP cache or ARP table. 
  • The host or router uses ARP occasionally to build the table the first time. 
  • Each time host or router wants to send a packet, it first checks the correct match of IP and MAC and then sends it. 
  • Host or router will time out ARP cache to clean the table, so ARP Requests can be seen from time to time 

ICMP Echo and the ping command

  • Testing IP connectivity without relying on applications 
  • For that, we use ping 
  • Ping (Packet Internet Groper) uses ICMP Internet Control Message Protocol 
  • ICMP sends ICMP echo request to another IP address 
  • The computer with that IP address should respond with ICMP echo reply 
  • Ping tests layer 1, 2 and 3 of OSI model 

2 thoughts on “Chapter 4 – Fundamentals of IPv4 Addressing and Routing

Leave a Reply