The net directory
The net directory in the Linux file hierarchy is
the repository for the socket abstraction and the network protocols;
these features account for a lot of code, since Linux supports several
different network protocols. Each protocol (IP, IPX, and so on) lives
in its own subdirectory; the directory for IP is called
ipv4 because it represents version 4 of the
protocol. The new standard (not yet in wide use as we write this) is
called ipv6 and is implemented in Linux as well.
Unix-domain sockets are treated as just another network protocol;
their implementation can be found in the unix
subdirectory.
The network implementation in Linux is based on the same file
operations that act on device files. This is natural, because network
connections (sockets) are described by normal file descriptors. The
file socket.c is the locus of the socket file
operations. It dispatches the system calls to one of the network
protocols via a struct proto_ops structure. This
structure is defined by each network protocol to map system calls to
its specific, low-level data handling operations.
Not every subdirectory of net is used to define a
protocol family. There are a few notable exceptions:
core, bridge,
ethernet, sunrpc, and
khttpd.
Files in core implement generic network features
such as device handling, firewalls, multicasting, and aliases; this
includes the handling of socket buffers
(core/skbuff.c) and socket operations that remain independent of the underlying protocol ...