Program for IP Forwarding Table Lookup

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

There exists a routing table in the Unix operating system consisting of several tuples that contain the I.P. (Internet Protocol) address of the network, the subnet mask, the IP address of the gateway, and the name of the interface.

This information is required for forwarding packets to the exterior of the network for connecting to the internet. In this article, we shall have a look at how a computer system takes a sequence of decisions when packets need to be forwarded.

Introduction

There exist the following two different methods of delivering IP datagrams:

Sharpen Your Fundamentals with Free Learning

Routing

Involves finding and setting up routing tables.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Forwarding

Involves passing a packet from an input interface to an output interface.

The process of forwarding must be executed as quickly as possible. On routers, forwarding is done often with hardware support. On personal computer systems, it is performed in the kernel of the machine’s operating system.

Example of IP Forwarding Lookup Table

Let us have a look at a sample IP forwarding lookup table for a clearer understanding. Assume there exists a packet having source IP address “20.129.0.1”. Its routing table may look something like the following:

Network IP addressSubnet maskGateway IP addressInterface name
200.200.16.0255.255.248.0192.13.2.55eth4
20.128.0.0255.128.0.012.1.1.1eth1
200.200.200.0255.255.248.0192.13.2.55eth4
0.0.0.00.0.0.012.23.44.1eth9

We shall refer to this system as well as the table above in the article later.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Working of IP Forwarding Lookup Table

When a packet is sent to the kernel of the operating system in order to find the interface and gateway, the first thing that is done is a bitwise AND operation individually with each subnet mask entry in the table for finding the longest prefix match. After obtaining the desired bitwise AND operation result, it’s then compared with the IP addresses of the network.

The result now produced is the IP address corresponding to the gateway, as well as the name of the interface via which the packet may now go out. “00010100.10000001.00000000.00000001” is the binary representation of “20.129.0.1”. A bitwise AND operation is performed upon this value with the subnet mask of each entry in our table.

The subnet mask from entry 2 (20.128.0.0, 255.128.0.0, 12.1.1.1, eth1) yields the longest matching prefix for our packet. Therefore, our packet goes out from the interface eth1 and selects the gateway 12.1.1.1 for forwarding.

Implementation of IP Forwarding Lookup Table

Following is a C program that implements an IP forwarding lookup table

Conclusion

  • There exists a routing table In the Unix operating system consisting of several tuples that contain the I.P. (Internet Protocol) address of the network, the subnet mask, the IP address of the gateway, and the name of the interface.
  • There exist two different methods of delivering IP datagrams: Routing and Forwarding.
  • When a packet is sent to the kernel of the operating system in order to find the interface and gateway, the first thing that is done is a bitwise AND operation individually with each subnet mask entry in the table for finding the longest prefix match.