|
||||||||||||||
| ISBN: 3423050012 ISBN: 3423050012 ISBN: 3423050012 ISBN: 3423050012 | ||||||||||||||
|
Wir empfehlen: | |||||||||||||
5.3. State Behavior This section discusses in detail the behavior of each state in response to the arrival of a packet. In what follows a packet is not considered to have arrived until it has passed a number of tests (see the chapter entitled: Packet Reception). The method chosen to describe state behavior is tabular. Each state is listed opposite a sequence of named procedures to execute whenever a packet has arrived. STATE BEHAVIOR
The particular actions associated with each procedure are now described. This procedure details the behavior of the LISTEN state. First check the packet for the RST flag. If it is set then packet is discarded and ignored, return and continue the processing associated with this state. We assume now that the RST flag was not set. Check the packet for the ACK flag. If it is set we have an illegal condition since no connection has yet been opened. Send a RST packet with the correct response SN value: <SN=received AN><CTL=RST> Return to the current state without any further processing. We assume now that neither the RST nor the ACK flags were set. Check the packet for a SYN flag. If it is set then an attempt is being made to open a connection. Create a TCB for this connection. The sender has placed its MDL in the LENGTH field, also specified is the sender's initial SN value. Retrieve and place them into the TCB. Note that the presence of the SO flag is ignored since it has no meaning when either of the SYN, RST, or FIN flags are set. Send a SYN packet which acknowledges the SYN received. Choose the initial SN value and the MDL for this end of the connection: <SN=0><AN=received SN+1 modulo 2><CTL=SYN, ACK><LENGTH=MDL> and go to the SYN-RECEIVED state without any further processing. Any packet not satisfying the above tests is discarded and ignored. Return to the current state without any further processing. This procedure represents the behavior of the SYN-SENT state and is entered when this end of the connection decides to execute an active OPEN. First, check the packet for the ACK flag. If the ACK flag is set then check to see if the AN value was as expected. If it was continue below. Otherwise the AN value was unexpected. If the RST flag was set then discard the packet and return to the current state without any further processing, else send a reset: <SN=received AN><CTL=RST> Discard the packet and return to the current state without any further processing. At this point either the ACK flag was set and the AN value was as expected or ACK was not set. Second, check the RST flag. If the RST flag is set there are two cases: 1. If the ACK flag is set then discard the packet, flush the retransmission queue, inform the user "Error: Connection refused", delete the TCB, and go to the CLOSED state without any further processing. 2. If the ACK flag was not set then discard the packet and return to this state without any further processing. At this point we assume the packet contained an ACK which was Ok, or there was no ACK, and there was no RST. Now check the packet for the SYN flag. If the ACK flag was set then our SYN has been acknowledged. Store MDL received in the TCB. At this point we are technically in the ESTABLISHED state. Send an acknowledgment packet and any initial data which is queued to send: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK><DATA> Go to the ESTABLISHED state without any further processing. If the SYN flag was set but the ACK was not set then the other end of the connection has executed an active open also. Acknowledge the SYN, choose your MDL, and send: <SN=0><AN=received SN+1 modulo 2><CTL=SYN, ACK><LENGTH=MDL> Go to the SYN-RECEIVED state without any further processing. Any packet not satisfying the above tests is discarded and ignored. Return to the current state without any further processing. C1 -------------------------------------------------------- Examine the received SN field value. If the SN value was expected then return and continue the processing associated with this state. We now assume the SN value was not what was expected. If either RST or FIN were set discard the packet and return to the current state without any further processing. If neither RST nor FIN flags were set it is assumed that this packet is a duplicate of one already received. Send an ACK back: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> Discard the duplicate packet and return to the current state without any further processing. C2 -------------------------------------------------------- Examine the received SN field value. If the SN value was expected then return and continue the processing associated with this state. We now assume the SN value was not what was expected. If either RST or FIN were set discard the packet and return to the current state without any further processing. If SYN was set we assume that the other end crashed and has attempted to open a new connection. We respond by sending a legal reset: <SN=received AN><AN=received SN+1 modulo 2><CTL=RST, ACK> This will cause the other end, currently in the SYN-SENT state, to close. Flush the retransmission queue, inform the user "Error: Connection reset", discard the packet, delete the TCB, and go to the CLOSED state without any further processing. If neither RST, FIN, nor SYN flags were set it is assumed that this packet is a duplicate of one already received. Send an ACK back: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> Discard the duplicate packet and return to the current state without any further processing. D1 -------------------------------------------------------- The packet is examined for a RST flag. If RST is not set then return and continue the processing associated with this state. RST is now assumed to have been set. If the connection was originally initiated from the LISTEN state (it was passively opened) then flush the retransmission queue, discard the packet, and go to the LISTEN state without any further processing. If instead the connection was initiated actively (came from the SYN-SENT state) then flush the retransmission queue, inform the user "Error: Connection refused", discard the packet, delete the TCB, and go to the CLOSED state without any further processing. D2 -------------------------------------------------------- The packet is examined for a RST flag. If RST is not set then return and continue the processing associated with this state. RST is now assumed to have been set. Any data remaining to be sent is flushed. The retransmission queue is flushed, the user is informed "Error: Connection reset.", discard the packet, delete the TCB, and go to the CLOSED state without any further processing. D3 -------------------------------------------------------- The packet is examined for a RST flag. If RST is not set then return and continue the processing associated with this state. RST is now assumed to have been set. Discard the packet, delete the TCB, and go to the CLOSED state without any further processing. E -------------------------------------------------------- Check the presence of the SYN flag. If the SYN flag is not set then return and continue the processing associated with this state. We now assume that the SYN flag was set. The presence of a SYN here is an error. Flush the retransmission queue, send a legal RST packet. If the ACK flag was set then send: <SN=received AN><CTL=RST> If the ACK flag was not set then send: <SN=0><CTL=RST> The user should receive the message "Error: Connection reset.", then delete the TCB and go to the CLOSED state without any further processing. F1 -------------------------------------------------------- Check the presence of the ACK flag. If ACK is not set then discard the packet and return without any further processing. We now assume that the ACK flag was set. If the AN field value was as expected then return and continue the processing associated with this state. We now assume that the ACK flag was set and that the AN field value was unexpected. If the connection was originally initiated from the LISTEN state (it was passively opened) then flush the retransmission queue, discard the packet, and send a legal RST packet: <SN=received AN><CTL=RST> Then delete the TCB and go to the LISTEN state without any further processing. Otherwise the connection was initiated actively (came from the SYN-SENT state) then inform the user "Error: Connection refused", flush the retransmission queue, discard the packet, and send a legal RST packet: <SN=received AN><CTL=RST> Then delete the TCB and go to the CLOSED state without any further processing. F2 -------------------------------------------------------- Check the presence of the ACK flag. If ACK is not set then discard the packet and return without any further processing. We now assume that the ACK flag was set. If the AN field value was as expected then flush the retransmission queue and inform the user with an "Ok" if a buffer has been entirely acknowledged. Another packet containing data may now be sent. Return and continue the processing associated with this state. We now assume that the ACK flag was set and that the AN field value was unexpected. This is assumed to indicate a duplicate acknowledgment. It is ignored, return and continue the processing associated with this state. F3 -------------------------------------------------------- Check the presence of the ACK flag. If ACK is not set then discard the packet and return without any further processing. We now assume that the ACK flag was set. If the AN field value was as expected then continue the processing associated with this state. We now assume that the ACK flag was set and that the AN field value was unexpected. This is ignored, return and continue with the processing associated with this state. G -------------------------------------------------------- This procedure represents the behavior of the CLOSED state of a connection. All incoming packets are discarded. If the packet had the RST flag set take no action. Otherwise it is necessary to build a RST packet. Since this end is closed the other end of the connection has incorrect data about the state of the connection and should be so informed. If the ACK flag was set then send: <SN=received AN><CTL=RST> If the ACK flag was not set then send: <SN=0><AN=received SN+1 modulo 2><CTL=RST, ACK> After sending the reset packet return to the current state without any further processing. H1 -------------------------------------------------------- Our SYN has been acknowledged. At this point we are technically in the ESTABLISHED state. Send any initial data which is queued to send: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK><DATA> Go to the ESTABLISHED state and execute procedure I1 to process any data which might be in this packet. Any packet not satisfying the above tests is discarded and ignored. Return to the current state without any further processing. H2 -------------------------------------------------------- Check the presence of the FIN flag. If FIN is not set then continue the processing associated with this state. We now assume that the FIN flag was set. This means the other end has decided to close the connection. Flush the retransmission queue. If any data remains to be sent then inform the user "Warning: Data left unsent." The user must also be informed "Connection closing." An acknowledgment for the FIN must be sent which also indicates this end is closing: <SN=received AN><AN=received SN + 1 modulo 2><CTL=FIN, ACK> Go to the LAST-ACK state without any further processing. H3 -------------------------------------------------------- This state represents the final behavior of the FIN-WAIT state. If the packet did not contain a FIN we assume this packet is a duplicate and that the other end of the connection has not seen the FIN packet we sent earlier. Rely upon retransmission of our earlier FIN packet to inform the other end of our desire to close. Discard the packet and return without any further processing. At this point we have a packet which should contain a FIN. By the rules of this protocol an ACK of a FIN requires a FIN, ACK in response and no data. If the packet contains data we have detected an illegal condition. Send a reset: <SN=received AN><AN=received SN+1 modulo 2><CTL=RST, ACK> Discard the packet, flush the retransmission queue, inform the user "Error: Connection reset.", delete the TCB, and go to the CLOSED state without any further processing. We now assume that the FIN flag was set and no data was contained in the packet. If the AN field value was expected then this packet acknowledges a previously sent FIN packet. The other end of the connection is then also assumed to be closing and expects an acknowledgment. Send an acknowledgment of the FIN: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> Start the 2*SRTT timer associated with the TIME-WAIT state, discard the packet, and go to the TIME-WAIT state without any further processing. Otherwise the AN field value was unexpected. This indicates a simultaneous closing by both sides of the connection. Send an acknowledgment of the FIN: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> Discard the packet, and go to the CLOSING state without any further processing. H4 -------------------------------------------------------- This state represents the final behavior of the LAST-ACK state. If the AN field value is expected then this ACK is in response to the FIN, ACK packet recently sent. This is the final acknowledging message indicating both side's agreement to close the connection. Discard the packet, flush all queues, delete the TCB, and go to the CLOSED state without any further processing. Otherwise the AN field value was unexpected. Discard the packet and remain in the current state without any further processing. H5 -------------------------------------------------------- This state represents the final behavior of the CLOSING state. If the AN field value was expected then this packet acknowledges the FIN packet recently sent. This is the final acknowledging message indicating both side's agreement to close the connection. Start the 2*SRTT timer associated with the TIME-WAIT state, discard the packet, and go to the TIME-WAIT state without any further processing. Otherwise the AN field value was unexpected. Discard the packet and remain in the current state without any further processing. H6 -------------------------------------------------------- This state represents the behavior of the TIME-WAIT state. Check the presence of the ACK flag. If ACK is not set then discard the packet and return without any further processing. Check the presence of the FIN flag. If FIN is not set then discard the packet and return without any further processing. We now assume that the FIN flag was set. This situation indicates that the last acknowledgment of the FIN packet sent by the other end of the connection did not arrive. Resend the acknowledgment: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> Restart the 2*SRTT timer, discard the packet, and remain in the current state without any further processing. I1 -------------------------------------------------------- This represents that stage of processing in the ESTABLISHED state in which all the flag bits have been processed and only data may remain. The packet is examined to see if it contains data. If not the packet is now discarded, return to the current state without any further processing. We assume the packet contained data, that either the SO flag was set or LENGTH is positive. That data is placed into the user's receive buffers. As these become full the user should be informed "Receive buffer full." An acknowledgment is sent: <SN=received AN><AN=received SN+1 modulo 2><CTL=ACK> If data is queued to send then it is most efficient to 'piggyback' this acknowledgment on that data packet. The packet is now discarded, return to the ESTABLISHED state without any further processing. |
||||||||||||||
| |<< Anfang < Zurück Index Weiter > Ende >>| | ||||||||||||||
|
Zurück zur Themenseite: ScientificPublication.com/Startseite/Informatik/Spezifikationen Das Setzen von Verweisen (Links) auf diese Seite ist gestattet und bedarf keine vorherige Absprache. Artikelliste: Realible Asynchronous Transfer Protocol | ||||||||||||||
| Startseite | english | Bookmark setzen | Webseite weiterempfehlen | Impressum | ||||||||||||||