Tcp

TCP provides many more functions than UDP. Consequently, its implementation in the kernel is much more difficult and comprehensive, and a whole book could easily be dedicated to the specific problems involved. The connection-oriented communication model used by TCP to support the secure transmission of data streams not only requires greater administrative overhead in the kernel, but also calls for further operations such as explicit connection setup following from negotiations between computers. The handling (and prevention) of specific scenarios as well as optimization to boost transmission performance account for a large part of TCP implementation in the kernel; all their subtleties and oddities are not discussed here.

Let's look at the three major components of the TCP protocol (connection establishment, connection termination, and the orderly transmission of data streams) by first describing the procedure required by the standard before going on to examine the implementation.

A TCP connection is always in a clearly defined state. These include the listen and established states mentioned above. There are also other states and clearly defined rules for the possible transitions between them, as shown in Figure 12-25.

At first glance, the diagram is a little confusing, not to say off-putting. However, the information it contains almost fully describes the behavior of a TCP implementation. Basically, the kernel could distinguish

Passive Open SYN

SYN, ACK Isyn_recv -

closed ^

Close

Close

Close

Active Open

established

Close

SYN, ACK

Sending: Black Receiving: Gray Protocol: Underlined

fin_wait_2

fin_wait_2

1

ACK

closing

ACK

t

-Wclose_wait

Close

FIN

t

last

_ack|

>

r

Figure 12-25: TCP state-transition diagram.

between the individual states and implement the transitions between them (using a tool known as a finite state machine). This is neither particularly efficient nor fast, so the kernel adopts a different approach. Nevertheless, when describing the individual TCP actions, I make repeated reference to this diagram and use it as a basis for our examination.

Continue reading here: TCP Headers

Was this article helpful?

0 0