The Linux operating system implements the standard Berkeley socket API, which has its origins in the BSD Unix developments (4.2/4.3/4.4 BSD) RUSL99.
The Linux Network Subsystem architecture is shown on Figure 2-1[BTSPEC]. The standard components of the Linux network subsystem are Berkeley socket interface and Network Device Driver Interface.
The Berkeley Socket Interface allows user space programs to open communication endpoint to remote devices. Socket is a network abstraction of the channel endpoint. Socket is associated with the protocol. Usually, the PF_INET is used to associate a socket with the TCP/IP protocol.
Network Device Driver Interface enables multiple network devices to be used at the same time. Device driver registers device in the system. And each device has appropriate type to distinguish class of devices like Ethernet, PPP, X.25, etc.
The network driver interface includes packet scheduler interface. Packet scheduler implements queuing discipline for different type of devices.
The protocol component is an actual protocol implementation. Each protocol should registers itself in the socket interface with appropriate protocol family (PF_XXX) and in the network device driver interface with the appropriate protocol type. Each packet received will be delivered to the appropriate protocol layer.
The networking layer is fairly object-oriented in its design, as indeed is much of the Linux kernel. The core structure of the networking code goes back to the initial networking and socket implementations by Ross Biro and Orest Zborowski. The key objects are:
Device or Interface: A network interface is programming code for sending and receiving data packets. Usually an interface is used for a physical device like an Ethernet card; however, some devices are software only, e.g., the loopback device used for sending data to yourself.
Protocol: Each protocol is effectively a different networking language. Some protocols exist purely because vendors chose to use proprietary networking schemes, while others are designed for special purposes. Within the Linux kernel each protocol is a separate module of code providing services to the socket layer.
Socket: A socket is a connection endpoint providing Unix file I/O and exists as a file descriptor to the user program. In the kernel each socket is a pair of structures that represent the high level socket interface and the low level protocol interface.
sk_buff: All the buffers used by the networking layers are sk_buffs. The control for these buffers is provided by core low-level library routines that are available to all of the networking system. sk_buffs provide the general buffering and flow control facilities needed by network protocols.