Network protocols and
Algorithms
Routing Tables in Routers
Routers
• A Router is a networking device is usually
connected to two or more different networks
and used to forward data packets between
computer networks.
• When a data packet comes to a router port,
the router reads address information
(destination IP address) in packet to
determine out which port the packet will be
sent.
Routing Tables
• In computer networking, a routing table,
or routing information base (RIB), is a data
table stored in a router or a network host that
lists the routes to particular network
destinations, and in some
cases, metrics (distances) associated with
those routes.
• The routing table contains information about
the topology of the network immediately
around it.
Routing Tables
• Routers use Routing Tables to determine out
which interface the packet will be sent.
• Each router’s routing table is unique and
stored in the RAM of the device.
• The main purpose of a routing table is to help
routers make effective routing decisions.
• All IP-enabled devices, including routers and
switches, use routing tables.
Routing Tables
• Each routing table might contain different
entries and information, such
as IPv4 or IPv6 address classes. But the
primary fields of all routing tables stay the
same.
Routing Tables
Route Determination Process (finding
Subnet ID using Routing Table)
• Consider the routing table maintained by the
internal router:
Routing Tables
• To find its right subnet (subnet ID), router
performs the bitwise ANDing of destination IP
Address mentioned on the data packet and all
the subnet masks one by one.
– If there occurs only one match, router forwards
the data packet on the corresponding interface.
– If there occurs more than one match, router
forwards the data packet on the interface
corresponding to the longest subnet mask.
– If there occurs no match, router forwards the data
packet on the interface corresponding to the
default entry.
Example
The routing table of a router is shown below:
Destination Mask Interface
[Link] [Link] Eth0
[Link] [Link] Eth1
[Link] [Link] Eth2
[Link] [Link] Eth3
On which interfaces will the router forward
packets addressed to destinations
[Link]?
Solution
• To find the interface, we follow the following
steps:
1. Bitwise AND between IP address [Link] and
subnet masks.
2. Match the output network address with the destination
address given corresponding to the network mask.
Solution
Result of Bitwise
Destination Address Mask
AND operation
[Link] [Link] [Link] [Link]
[Link] [Link] [Link] [Link]
[Link] [Link] [Link] [Link]
[Link] [Link] [Link] [Link]
• The packet with the IP address [Link] will be
forwarded to the interface eth2.