Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


Comparing TCP and UDP is like comparing the postal service with the telephone network. TCP corre-
sponds to a telephone call. The calling party must set up a connection (which must be accepted by the
person called) before information can be passed. During the call, all information sent is received in the
same order in which it was sent.

UDP can be likened to the postal service. Packets (or letters in this analogy) can be sent to recipients
without contacting them in advance for permission to do so. There is no guarantee that letters will be
delivered (although both the postal service and the network will do their best). Similarly, there is no
guarantee that letters will be sent or received in a particular sequence.

Those interested in further examples of the use ofUDP sockets are referred to the many textbooks on
network and system programming.

12.4 The Layer Model of Network


Implementation


The kernel implements the network layer very similarly to the TCP/IP reference model introduced at the
beginning of this chapter.

The C code is split into levels with clearly defined tasks, and each level is able to communicate only with
the level immediately above and below via clearly defined interfaces. This has the advantage that various
devices, transmission mechanisms, and protocols can be combined. For example, normal Ethernet cards
can be used not only to set up Internet (IP) connections but also to transmit other protocols such as
Appletalk or IPX without the need for any kind of modification to the device driver of the card.

The Layer Model of Network Implementation


Application
C Standard library

Protocol
specific

Hardware Specific

Physical
Transmission

Host to Host Layer

Network Layer

Transport Layer

Application Layer
Kernel

Userspace

struct socket
struct sock
struct proto

dev.c

driver.c

struct net_device

struct
packet_
type

Figure 12-3: Implementation of the layer model in the kernel.

The network subsystem is one of the most comprehensive and demanding parts of the kernel. Why is
this so? The answer is that it deals with a very large number of protocol-specific details and subtleties,
and the code path through the layer is riddled with excessive function pointers in place of direct function
Free download pdf