Packet Routing

What is IPv4 Packet Routing?

IPv4 Packet Routing is the process of forwarding IP packets from a source to a destination across one or more networks using routers. It relies on the destination IP address and routing tables to determine the best path.

Why is IPv4 Packet Routing useful?

It enables communication between devices on different networks by determining the optimal path for data to travel. Without routing, IPv4 packets could only be delivered within the same local network.

How does IPv4 Packet Routing work?

Routers examine the destination IP address in each packet, consult their routing table, and forward the packet to the next hop along the path to the destination. The TTL field in the IPv4 header ensures the packet doesn’t loop indefinitely.

Where is IPv4 Packet Routing used?

IPv4 routing is used throughout the internet and in all IP-based networks — from home Wi-Fi to enterprise networks to global ISPs — anytime a packet crosses from one network segment to another.

Which OSI layer does IPv4 Packet Routing belong to?

IPv4 routing takes place at the Network Layer (Layer 3) of the OSI model. It is responsible for logical addressing, path determination, and packet forwarding across networks.

Is IPv4 Packet Routing Windows specific?

No, IPv4 routing is not platform-specific. Both Windows and other operating systems support IPv4 routing either by default or with configuration (e.g., enabling routing on a host or using routing software).

Is IPv4 Packet Routing Linux specific?

No, but Linux is commonly used for routing due to its flexibility and robust networking tools like ip, iptables, nftables, and support for routing daemons like Quagga, FRRouting, or Bird.

Which Transport Protocol is used by IPv4 Packet Routing?

IPv4 routing is transport protocol-independent. It routes packets regardless of whether they carry TCP, UDP, ICMP, or other protocols — routing is based on the IP header, not the transport layer.

Which Port is used by IPv4 Packet Routing?

IPv4 routing does not use ports. Port numbers exist at the transport layer (e.g., TCP/UDP). Routing decisions are made using IP addresses and routing tables, not port numbers.

Is IPv4 Packet Routing using client-server model?

IPv4 routing is not tied to any one communication model. It supports client-server, peer-to-peer, broadcast, and multicast communications by enabling packets to reach their intended destination IPs.

What is the purpose of IPv4 Packet Routing?

IPv4 packet routing is the process of forwarding data packets across networks using IP addresses. It ensures that data can travel from a source device to a destination device, even if they are on different networks.

What does an IPv4 router do?

An IPv4 router examines the destination IP address in a packet and determines the best path for forwarding the packet toward its destination, based on the information in its routing table.

How does IPv4 packet routing differ from switching?

IPv4 routing involves forwarding packets across different networks based on IP addresses, whereas switching involves forwarding data frames within the same network using MAC addresses.

What is a packet routing table in IPv4 routing?

A routing table is a list of rules stored in routers that helps determine the best path for packet delivery based on the destination IP address.

How does a router determine the best path for IPv4 packet routing?

Routers use routing tables, which are updated through routing protocols (e.g., OSPF, RIP, BGP), to determine the optimal path for forwarding a packet.

What is a hop in IPv4 packet routing?

A hop refers to a single step in the journey of a packet between routers. Each router the packet passes through is considered a hop.

What is the role of TTL (Time to Live) in IPv4 packet routing?

TTL is a field in the IPv4 header that limits the lifespan of a packet. Each time the packet is forwarded by a router, TTL is decremented. When TTL reaches zero, the packet is discarded, preventing it from circulating indefinitely.

What is IPv4 packet fragmentation in packet routing?

Fragmentation occurs when a router needs to break a large packet into smaller pieces because the next network segment cannot handle the packet’s size (due to MTU limitations). The fragments are reassembled by the destination.

What is the maximum transmission unit (MTU) in IPv4?

The MTU is the largest packet size that can be transmitted over a network link. Routers use this information to determine whether packet fragmentation is necessary.

What is a default route in IPv4 packet routing?

The default route is used by routers to forward packets for which no specific route is found in the routing table. It usually directs packets to the internet gateway or another exit point.

What is the purpose of route aggregation in IPv4 packet routing?

Route aggregation reduces the size of the routing table by summarizing multiple network addresses into a single, broader address range, improving routing efficiency.

How do routers use IP addresses in IPv4 packet routing?

Routers use the destination IP address in an IPv4 packet to determine the best next hop by consulting their routing tables, allowing them to forward packets towards their final destination.

What is the significance of subnetting in IPv4 packet routing?

Subnetting divides a large network into smaller subnets, which helps routers make faster, more efficient routing decisions by limiting the scope of the routing tables.

What is the role of NAT (Network Address Translation) in IPv4 packet routing?

NAT allows private IP addresses used in local networks to be translated to a public IP address for communication across the internet, enabling multiple devices to share a single public IP.

What is route redistribution in IPv4 packet routing?

Route redistribution allows a router to share routing information learned from one routing protocol (e.g., OSPF) with another routing protocol (e.g., RIP), allowing for interoperability between different routing protocols.

What is a packet routing loop in IPv4?

A routing loop occurs when a packet is endlessly forwarded between routers, due to incorrect or outdated routing information, often leading to packet loss.

What is IPv4 packet routing efficiency?

IPv4 routing efficiency refers to how quickly and accurately a router can determine and forward the best path for a packet. Factors affecting efficiency include the size of the routing table and the method of routing protocol used.

What is load balancing in IPv4 packet routing?

Load balancing involves distributing network traffic across multiple routes to ensure that no single route becomes overburdened, improving overall network performance and redundancy.

What is route poisoning in IPv4 packet routing?

Route poisoning is a technique used to prevent routing loops by marking a failed route with an unreachable metric (usually infinity) in the routing protocol, signaling to other routers that the route should no longer be used.

How do the client ping the server on a different subnet successfully?

  • The router VM should configur with IP forwarding and have interfaces in both subnets.

  • Both the client and server should set with the router as their default gateway, enabling cross-subnet communication.

  • In this section, you are going to learn

  • Terminology

  • Version Info

Objective

Confirm that a router can correctly forward packets between different subnets.

Test Setup

The test uses three virtual machines (VMs): a server, a router, and a client. The server and client are on different subnets, with the router connecting them.

  • Laptop 1 (Server)

    • Assign IP 192.168.1.10/24 to the enp0s8 interface.

    • Set the default gateway to the router’s IP on its subnet (192.168.1.1).

    test:~$ sudo ip addr add 192.168.1.10/24 dev enp0s8
    test:~$ sudo ip link set enp0s8 up
    test:~$ sudo ip route add default via 192.168.1.1
    
  • Router VM

    • Assign IP addresses to both interfaces to connect to the server and client subnets.

    • Enable IP forwarding to allow the VM to route packets.

    test:~$ sudo ip addr add 192.168.1.1/24 dev enp0s3
    test:~$ sudo ip addr add 192.168.2.1/24 dev enp0s8
    test:~$ sudo ip link set enp0s3 up
    test:~$ sudo ip link set enp0s8 up
    test:~$ sudo sysctl -w net.ipv4.ip_forward=1
    

    Note

    To make IP forwarding permanent, edit /etc/sysctl.conf and uncomment the line: net.ipv4.ip_forward=1

  • Laptop 2 (Client)

    • Assign IP 192.168.2.10/24 to the enp0s8 interface.

    • Set the default gateway to the router’s IP on its subnet (192.168.2.1).

    test:~$ sudo ip addr add 192.168.2.10/24 dev enp0s8
    test:~$ sudo ip link set enp0s8 up
    test:~$ sudo ip route add default via 192.168.2.1
    

Procedure and Analysis

  • Ping Laptop 1

    • From Laptop 2, ping Laptop 1’s IP address (192.168.1.10).

    test:~$ ping 192.168.1.10
    PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.
    64 bytes from 192.168.1.10: icmp_seq=1 ttl=63 time=4.69 ms
    64 bytes from 192.168.1.10: icmp_seq=2 ttl=63 time=1.48 ms
    64 bytes from 192.168.1.10: icmp_seq=3 ttl=63 time=1.84 ms
    64 bytes from 192.168.1.10: icmp_seq=4 ttl=63 time=1.75 ms
    64 bytes from 192.168.1.10: icmp_seq=5 ttl=63 time=1.93 ms
    64 bytes from 192.168.1.10: icmp_seq=6 ttl=63 time=1.63 ms
    64 bytes from 192.168.1.10: icmp_seq=7 ttl=63 time=2.35 ms
    64 bytes from 192.168.1.10: icmp_seq=8 ttl=63 time=2.24 ms
    64 bytes from 192.168.1.10: icmp_seq=9 ttl=63 time=2.37 ms
    ^C
    --- 192.168.1.10 ping statistics ---
    9 packets transmitted, 9 received, 0% packet loss, time 8015ms
    rtt min/avg/max/mdev = 1.476/2.251/4.688/0.911 ms
    
  • Trace the Packet Path

    • Use traceroute from Laptop 2 to confirm the packet’s path to Laptop 1.

    test:~$ traceroute 192.168.1.10
    traceroute to 192.168.1.10 (192.168.1.10), 30 hops max, 60 byte packets
     1  _gateway (192.168.2.1)  1.504 ms  1.428 ms  1.521 ms
     2  192.168.1.10 (192.168.1.10)  2.752 ms  2.726 ms  2.703 ms
    

Note

  • Hop 1: Router interface on Laptop 2’s subnet (192.168.2.1) forwards the packet.

  • Hop 2: Destination Laptop 1 (192.168.1.10).

  • Confirms the router correctly forwards packets between different subnets.

Wireshark Capture

Download wireshark capture

Note

  • The capture can be used to verify ICMP packets traverse the router correctly.

  • TTL values decrement by 1 at each hop, reflecting router forwarding.

  • Ensures proper network connectivity and routing between subnets.

Packet Routing - Testcases

Packet Routing - Test Cases

#

Test Case

Description

Expected Result

1

Route to Directly Connected Network

Destination in local subnet

Packet delivered directly

2

Route to Remote Network

Destination outside local subnet

Packet forwarded to next hop

3

No Route to Host

Destination not in routing table

ICMP Destination Unreachable sent

4

Default Route Present

No specific route, default exists

Packet forwarded via default gateway

5

Default Route Missing

No specific or default route

Packet dropped

6

Static Route Configured

Manual route entry

Packet follows static route

7

Dynamic Route Learned

Route via OSPF/RIP

Packet follows dynamic route

8

Multiple Routes to Destination

Equal-cost paths

Load balancing or ECMP used

9

Route with Lower Metric

Multiple routes, different metrics

Packet follows lowest metric route

10

Route with Administrative Distance

Conflicting routes

Route with lowest AD used

11

TTL = 1

TTL expires at router

ICMP Time Exceeded sent

12

TTL > 1

TTL decremented, packet forwarded

Packet continues routing

13

TTL = 0

Packet arrives with TTL 0

Packet dropped

14

Packet Fragmented

Size > MTU, DF not set

Packet fragmented and forwarded

15

Packet with DF Set and Size > MTU

DF = 1, size too large

ICMP Fragmentation Needed sent

16

Packet with Valid Checksum

Header checksum correct

Packet forwarded

17

Packet with Invalid Checksum

Header checksum incorrect

Packet dropped

18

Packet with Loopback Address

Destination = 127.0.0.1

Packet not routed

19

Packet with Broadcast Address

Destination = 255.255.255.255

Packet broadcasted locally

20

Packet with Multicast Address

Destination = 224.0.0.1

Routed to multicast group members

21

Packet with Private Address

Destination = 192.168.x.x

Routed within private network

22

Packet with Public Address

Destination = 8.8.8.8

Routed to internet

23

Packet with NAT Translation

Source/destination translated

Packet routed post-translation

24

Packet with PAT Translation

Port-based NAT applied

Routed with port mapping

25

Packet with Policy-Based Routing

Route based on policy

Packet follows policy route

26

Packet with ACL Deny

ACL blocks destination

Packet dropped

27

Packet with ACL Permit

ACL allows destination

Packet forwarded

28

Packet with QoS Tag

DSCP/ToS set

Packet prioritized in routing

29

Packet with Routing Loop

TTL expires in loop

ICMP Time Exceeded sent

30

Packet with ICMP Redirect

Better route exists

Host updates route

31

Packet with Source Routing Option

Strict/loose source route

Packet follows specified path

32

Packet with Invalid Source IP

Source = 0.0.0.0

Packet dropped

33

Packet with Invalid Destination IP

Destination = 0.0.0.0

Packet dropped

34

Packet with Unreachable Next Hop

Next hop not reachable

ICMP Destination Unreachable sent

35

Packet with ARP Resolution

MAC resolved for next hop

Packet forwarded

36

Packet with ARP Failure

No MAC for next hop

Packet queued or dropped

37

Packet with VRRP Gateway

Virtual gateway used

Packet routed via active router

38

Packet with HSRP Gateway

Hot standby router used

Packet routed via active router

39

Packet with BGP Route

Route learned via BGP

Packet routed to external network

40

Packet with OSPF Route

Route learned via OSPF

Packet routed internally

41

Packet with RIP Route

Route learned via RIP

Packet routed with hop count

42

Packet with Static and Dynamic Route

Both exist

Static route preferred

43

Packet with Route Flap

Route changes frequently

Packet may be dropped or delayed

44

Packet with Converged Route

Routing table stable

Packet routed normally

45

Packet with Blackhole Route

Route to null interface

Packet dropped silently

46

Packet with Loop Prevention

TTL or split horizon used

Loop avoided

47

Packet with Route Redistribution

Between protocols

Packet routed across domains

48

Packet with Route Summarization

Aggregated route used

Packet routed efficiently

49

Packet with Route Filtering

Route denied by filter

Packet dropped

50

Packet with Route Preference Change

Admin distance updated

Packet follows new preferred route

  • Reference links