< The Linux Kernel

Linux kernel network functionality spans from sockets interface through protocols to network cards.


⚲ Shell interfaces:

  • man 8 netstat prints network connections, routing tables, interface statistics and other details
  • man 8 ip shows and configures routing, network devices, interfaces and tunnels
  • man 8 ss - socket statistics utility

Sockets

sys/socket.h — main user mode sockets header

⚲ Basic common and client side interface:

⚲ Additional server side interface:

⚙️ Internals

📚 References

Network storage

🔧 TODO man 2 sendfiledo_sendfile id. See also Zero-copy between file descriptors

Names

⚲ API: man 2 uname, man 2 sethostname, man 2 gethostname, man 2 setdomainname man 2 getdomainname


⚙️ Details


📚 References

Address families

⚲ Address Family aka AF, domain defines address format and address length socklen_t. See man 3 inet_ntop, function man 3 inet_pton derives socklen_t from AF, man 2 getsockname man 2 getpeername.

PF - Protocol Family index (PF_MAX id) actually is the same as Address Family index (AF).


⚙️ Internals

Protocols

Each Protocol Family (PF, same index as Address Family AF) consists of several protocol implementations.

Directory /proc/net contains various files and subdirectories containing information about the networking layer. File /proc/net/protocols lists available and used protocols.

In each PF protocols are classified to different types sock_type id, for example stream, datagram and raw socket. TCP is type of stream, UDP is type of datagram, raw and ping are type of raw.


References

Network device interfaces

👁 Example: drivers/net/loopback.c src - the most famous and simple interface lo

⚙️ function loopback_xmit id receives skb and passes it back with netif_rx id


📚 References

Network drivers

⚙️ Internals

📚 References

💾 Historical

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.