So, guys, now in this slide, let us try to understand the use case of the netlink sockets.
So let us revisit again the layered architecture of our computer system in this slide.
This time I have shown you only the application layer and the kernel layer.
There is no need to show the hardware layer as it is irrelevant for the discussion.
Now that as we know that to perform any socket based communication, the Linux kernel provides us the
bunch of system calls collectively which are called as socket interface, right?
So there are APIs like socket, accept, bind, send, receive, close or et cetera.
Right?
So if you have ever written any socket program, you must have used these APIs in order to write your
socket based communication.
Now it is the application running in the application layer which make use of this socket interface in
order to set up socket based communication.
Now it doesn't matter what type of communication the application is interested in, it might be possible
that the application wants to communicate with some remote machine present elsewhere on the network.
So for that the application will establish a network socket based communication using the same socket
interface.
Right.
In another example, the application May wants to interact with another application running on the same
system.
For that, the socket interface that is provided for setting up the communication between two applications
running on the same machine are called Unix domain sockets.
So again, the application make use of this socket interface in order to facilitate communication using
Unix domain sockets.
And finally, the application may be entrusted with the communication with any kernel subsystem lying
on the kernel space for that Netlink sockets have been designed for that.
Again, the application make use of the same socket interface that is same bunch of system calls in
order to set up netlink based communication with any kernel subsystems running in the kernel space.
So this is where netlink sockets comes into the picture.
Now what are these kernel subsystems?
Remember, kernel is a very big piece of code and it is logically divided into various subsystems.
These kernel subsystems, for example, could be the entire routing infrastructure which sits in the
kernel space of Linux operating system, including the entire TCP IP stack, which is also present or
which is also a part of Linux kernel.
Then another component of the Linux kernel could be firewall or iptables.
The application can program firewalls or iptables using netlink sockets.
The netlink sockets can also be used to program the ARP table.
Besides, netlink sockets can also be used to retrieve or set various interface properties.
Right.
Here.
Interface means network interface cards, which is used to send or receive the network packets, right.
So you can see that there could be any number of Linux kernel subsystems and the application can interact
with any of those Linux kernel subsystems using unified interface provided as netlink sockets.
Right.