Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


been established. The data are then copied to the address space of the userspace process in the kernel and
are used to build a TCP packet. I do not intend to discuss this complicated operation because it involves a
large number of procedures, all of which are targeted at satisfying the complex requirements of the TCP
protocol. Unfortunately, sending a TCP packet is not limited simply to construction of a packet header
and transfer to the IP layer. It is also necessary to comply with the following (by no means exhaustive)
list of demands:


❑ Sufficient space for the data must be available in the wait queue of the receiver.
❑ The ECN mechanism must be implementedto prevent connection congestion.
❑ Possible stalemate situations must be detected as otherwise communication comes to a halt.
❑ The TCPslow-startmechanism requires a gradual increase in packet size at the start of
communication.
❑ Packets sent but not acknowledged must be retransmitted repeatedly after a certain timeout
period until they are finally acknowledged by the receiver.

As the retransmission queue is a key element of reliable data transmission via a TCP connection, let’s
take a look here at how it actually works. After a packet has been assembled, the kernel arrives at
tcp_push_one, which performs the following three tasks:


❑ tcp_snd_testchecks whether the data can be sent at the present time. This may not be possible
because of backlogs caused by an overloaded receiver.
❑ tcp_transmit_skbforwards the data to the IP layer using the address family-specific
af_specific->queue_xmitfunction (ip_queue_xmitis used for IPv4).
❑ update_send_headtakes care of updating some statistics. More important, it initializes the
retransmit timer of the TCP segment sent. This is not necessary for every sent packet, but only
for the first packet that follows after an acknowledged data region.

inet_csk_reset_xmit_timeris responsible for resetting the retransmit timer. The timer is the basis
for resending data packets that have not been acknowledged and acts as a kind of TCP transmission
guarantee certificate. If the receiver does not acknowledge data receipt within a certain period (time-out),
the data are retransmitted. The kernel timer used is described in Chapter 15. Thesockinstance associated
with the particular socket holds a list of retransmit timers for each packet sent. The time-out function used
by the kernel istcp_write_timer, which invokes the functiontcp_retransmit_timerif an ACK is not
received. The following must be noted when retransmitting segments:


❑ The connection may have been closed in the meantime. In this case, the stored packet and the
timer entry are removed from kernel memory.
❑ Retransmission is aborted when more retransmit attempts have been made than specified in the
sysctl_tcp_retries2variable.^32

As mentioned above, the retransmit timer is deleted once an ACK has been received for a packet.


(^32) The default for this variable is 15, but it can be modified using/proc/sys/net/ipv4/tcp_retries2.

Free download pdf