Multiplexing of information flows, gear of slots (sockets)
For connection establishment between two processes on different computers of a network it is necessary to know not only Internet addresses of computers, but also number of TCP port which process uses on this computer. Set B with a computer Internet address the TCP port forms the slot. Couple of slots it is unique identifies each joint or a data stream on the Internet, and the port provides independence of each TCP port on this computer.
The typical application-oriented process using the TCP protocol is the appendix FTP (File Transfer Protocol, the File transfer protocol). The stack of protocols in this case will look as follows: FTP/TCP/I P/ETH ERNET. When using the UDP protocol (User Datagram Protocol, the Protocol of datagrams of the user) data are passed between application-oriented process and the module of the UDP protocol. For example, the SNMP protocol (Simple Network Management Protocol, the Simple network management protocol) uses transport services of the UDP protocol. Ero a stack of protocols looks so: SNMP/UDP/IP/ETHERNET.
One slot on the computer can be involved in joints with several slots on remote computers. Besides, through the same slot the data stream can be passed in both directions, thus, the gear of slots is unique identifies each data stream and allows to work on one computer as several at the same time
Transport protocols of the Internet
to appendices. This function is called multiplexing of joints of the transport layer.
Modules of the TCP and UDP protocols and also, the driver of Ethernet are n X 1 multiplexers. Functioning as multiplexers, they switch several inputs to one output. These modules perform also functions of demultiplexers 1 X n. Working, as demultiplexers, they switch an input flow to one of outputs in compliance the CO value placed in the block header of data of the upper layer protocol. When the Ethernet-frame is processed by the driver of the network Ethernet interface, it can be sent or to the ARP protocol module, or to the IP protocol module. B this case specifies the value placed in the field of frame header Type/Code where exactly the data unit transferred these by an Ethernet-frame shall be directed.
When the IP packet is received by the IP protocol module, the data which are contained in it can be passed or to the module of the TCP protocol, or — UDP that is defined by field value of Protocol of title of this packet. When the segment of TCP is received by the TCP module, the choice of the application program between which the data unit shall be passed is performed on the basis of field value of Destination Port of title of a segment.
Multiplexing of data is in the opposite direction performed quite simply as from each module there is only one path down. The module of each protocol adds to a protocol data unit of the top level the title based on which the node which received this data unit can execute demultiplexing.
Assignment of ports to appendices on each node of a network happens independent. The TCP protocol can self-contained select port with which appendix will work, or appendix itself will specify with what port on this computer it will work. However, as a rule, appendices services use the same port numbers which are more narrow than steel well-known, for example, such as HTTP, FTP, SMTP, etc. in order that on the computer it was possible to join this process, specifying only the machine address. For example, the Internet browser if not to specify to it follow-up, looks for the appendix working with port 80 to the specified address is the most widespread portdlya the WWW servers.
Besides, the machine can be supplied with several network interfaces, then it shall perform multiplexing like n x m, i. e. between several application programs and network interfaces.
Connection establishment and data transfer
Joint of the TCP protocol is established by function invocation of OPEN with arguments in the form of number of local port and the slot (An IP address + port)
remote process. The OPEN function is called in that case when process intends to pass information (active OPEN), or in that case when process expects information arrival (passive OPEN). Function returns value of the identifier of joint to which the user process can refer by the subsequent challenges. The identifier of joint specifies a data structure in which variables and information of this TCP joint are stored. This data structure is called TCB (Transmission Control Block, the Control package joint).
B to structure of TCB are stored such parameters of joint as the addresses of local and remote slots, pointers on the obtained and sent user data, pointers on queue of units for resending, number of the current segment etc, that is all information used by this joint is stored.
As more narrow it was marked above, joint can be open in the active or passive mode. The passive mode designates that the process, bound to this joint, expects arrival of a special signal of opening of joint and will not try to open the port self-contained. In other words, the port opened by one side in the passive mode expects the initiating signal from the partner. This mode is used by processes which provide the service through known number of the port (for example, HTTP, SMTP etc).
Process can call function of passive opening of the port, wait for receipt of a signal of active opening of the port from other process, and only after its receiving joint will be established. Joint is also established if two processes actively open the port towards each other. This flexibility in the organization of joint is especially important on the distributed networks when computers work asynchronously.
Support of the guaranteed delivery of data
The TCP protocol provides information exchange in situations when the packets passed on a network are hurt, lost, duplicated or enter on the receiver with violation of an initial sequence. Such opportunity is reached by assignment of sequence number to each passed data unit and uses of the gear of delivery confirmation of the passed data units.
When the TCP protocol passes the next segment, its copy is located in queue of repetition of drive and then the confirmation waiting time clock is launched. When the system receives confirmation in the form of the TCP segment containing the managing flag of ASK meaning that this segment is received, it deletes its copy from queue. The segment of confirmation contains number of the received segment based on which there is a monitoring
Transport protocols of the Internet
deliveries of data to the addressee. If confirmation did not enter before the time clock expiration, the segment is resent. The notification message of the TCP protocol on receiving a segment does not mean yet that he was brought to the ultimate user. It only means that the TCP protocol performed the functions laid to it.
When using the TCP protocol the sequence number therefore in what poryatsk segments would not reach the assignment points placed in them bytes of the initial message always will be assembled in initially given sequence is assigned to each byte of data. The sequence number of the first byte of data in the passed segment is called sequence number of a segment. Numbering is carried out “from the head of composition”, i. e. from a packet header. The TCP segment contains a confirmation number (acknowledgment number) which represents number of the last received segment. In other words, number designates: “still I received everything”.
Ha of fig. 5.3 is introduced the diagram of the organization of drive and data reception with handshake.
Fig. 5.3. The diagram of the organization of drive and data reception with handshake
Here It is necessary to tell several words about the gear of preventing of appearance on a network of packets with identical numbers. They can appear, for example, in case of establishment and fast reset of joint or in case of reset of joint and its fast restoration i. e. when number of the spoiled packet can be used by a new data packet directly. The gear of preventing of similar situations is based on generation of an accidental bib number of byte of the message.
So, in case of establishment of new joint the 32-bit number of ISN (Initial Sequence Number) is generated. The generator uses 32 low orders of the engine time clock which values change each 4 microseconds (a complete stroke — 4.55 hours). Besides, each datagram on a network has limited lifetime of TTL which certainly is less than the repetition period
counter. Thus, on a network the impossibility of appearance of segments of packets with identical sequential numbers is guaranteed.
The damaged packets are eliminated the gear of check of checksum of data which is placed in each passed packet.
The procedure of connection establishment uses a special flag of synchronization — SYN and consists of three stages of message exchange — so-called “three-stage handshake”. Use of three acknowledging messages is always enough single-digit to synchronize data streams.
Initialization of joint begins with exchange of packets which go when opening the port by the user, for example, the OPEN command, and contain a flag of SYN and starting sequence number.
Joint is considered established when in both directions the sequences of numbering of the passed data units are synchronized, i. e. both sides “know” what data unit and with what number will enter since the opposite end of joint. The diagram of the organization of handshake in the TCP protocol during creation and a rupture of joint is provided on fig. 5.4.
Fig. 5.4. The diagram of the organization of handshake during creation and a rupture of joint in the TCP protocol
Joint is closed when the sides exchange the packets containing the FiN command (end). At the same time all resources of a system occupied with this joint shall be released.