Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


A 4-tuple notation (192.168.1.20:7777, 192.168.1.10:3506) is used to uniquely identify a connection.
The first element specifies the address and port of the local system, the second the address and port of
the client.

An asterisk (*) is substituted if one of the elements is still undefined. A server process listening on a
passive socket but not yet connected to a client is therefore denoted by192.168.1.20:7777, *.*.

Two socket pairs are registered in the kernel once a server has duplicated itself withforkto handle a
connection.

Listen Established
192.168.1.20:7777, *.* 192.168.1.20:7777, 192.168.1.10:3506

Although the sockets of both server processes have the same IP address/port number combination, they
are differentiated by the 4-tuple.

Consequently, the kernel must note all four connection parameters when distributing incoming and out-
going TCP/IP packets to ensure that assignments are made correctly. This task is known asmultiplexing.

Thenetstattool displays and checks the state of all TCP/IP connections on the system. The following
sample output is produced if two clients are connected to the server:

wolfgang@meitner>netstat -na
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.1.20:7777 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.20:7777 192.168.1.10:3506 ESTABLISHED
tcp 0 0 192.168.1.20:7777 192.168.1.10:3505 ESTABLISHED

12.3.3 Datagram Sockets


UDP is a second, widely used transport protocolthat builds on IP connections. UDP stands forUser
Datagram Protocoland differs from TCP in several basic areas:

❑ UDP is packet-oriented. No explicit connection setup is required before data are sent.
❑ Packets can be lost during transmission. There is no guarantee that data will actually reach their
destination.
❑ Packets are not necessarily received in the same order in which they were sent.

UDP is commonly used for video conferencing, audio streaming, and similar services. Here it doesn’t
matter if a few packets go missing — all that would be noticed would be brief dropouts in multimedia
sequences. However, like IP, UDP guarantees that thecontentsof packets are unchanged when they arrive
at their destinations.

An IP address and port number can be used by a TCP and a UDP processat the same time.Inmultiplexing,
the kernel ensures that only packets of the correct transport protocol are forwarded to the appropriate
process.
Free download pdf