Passa al contenuto principale

Funzionamento del protocollo: elaborazione degli eventi e richieste dell'utente

3.7 Elaborazione degli eventi​

Questa sezione descrive una possibile sequenza per l'elaborazione degli eventi. Non intende suggerire una particolare implementazione, ma qualsiasi implementazione reale dovrebbe discostarsi da questa descrizione solo nei dettagli e non in modo significativo nella sostanza. Questi sono i tipi di eventi che possono verificarsi:

USER REQUESTS

Open
Send
Receive
Close
Status

ARRIVING SEGMENT

Segment Arrives

TIMEOUTS

Retransmission Timeout
Close-Wait Timeout

L'elaborazione delle richieste dell'utente termina sempre con un ritorno al chiamante, con una possibile indicazione di errore. Le risposte di errore sono fornite come stringa di caratteri. In alcune situazioni è possibile anche una risposta ritardata, che viene restituita all'utente tramite qualsiasi meccanismo di eventi o di pseudo-interrupt disponibile. Il termine "signal" (segnale) è usato per indicare le risposte ritardate.

L'elaborazione dei segmenti in arrivo segue di solito questa sequenza generale: il numero di sequenza viene controllato per verificarne la validità e, se valido, il segmento viene accodato ed elaborato in ordine di numero di sequenza. Per tutti gli eventi, a meno che non sia specificato un cambiamento di stato, RDP resta nello stesso stato.

3.7.1 Eventi delle richieste dell'utente​

Gli scenari seguenti mostrano l'elaborazione degli eventi causati dall'emissione di richieste dell'utente:

Richiesta Open

  CLOSED STATE

Create a connection record
If none available
Return "Error - insufficient resources"
Endif

If passive Open
If local port not specified
Return "Error - local port not specified"
Endif
Generate SND.ISS
Set SND.NXT = SND.ISS + 1
SND.UNA = SND.ISS
Fill in SND.MAX, RMAX.BUF from Open parameters
Set State = LISTEN
Return
Endif

If active Open
If remote port not specified
Return "Error - remote port not specified"
Endif
Generate SND.ISS
Set SND.NXT = SND.ISS + 1
SND.UNA = SND.ISS
Fill in SND.MAX, RMAX.BUF from Open parameters
If local port not specified
Allocate a local port
Endif
Send <SEQ=SND.ISS><MAX=SND.MAX><MAXBUF=RMAX.BUF><SYN>
Set State = SYN-SENT
Return (local port, connection identifier)
Endif

LISTEN STATE
SYN-SENT STATE
SYN-RCVD STATE
OPEN STATE
CLOSE-WAIT STATE

Return "Error - connection already open"

Richiesta Close

  OPEN STATE

Send <SEQ=SND.NXT><RST>
Set State = CLOSE-WAIT
Start TIMWAIT Timer
Return

LISTEN STATE

Set State = CLOSED
Deallocate connection record
Return

SYN-RCVD STATE
SYN-SENT STATE

Send <SEQ=SND.NXT><RST>
Set State = CLOSED
Return

CLOSE-WAIT STATE

Return "Error - connection closing"

CLOSE STATE

Return "Error - connection not open"

Richiesta Receive

  OPEN STATE

If Data is pending
Return with data
else
Return with "no data" indication
Endif

LISTEN STATE
SYN-RCVD STATE
SYN-SENT STATE

Return with "no data" indication

CLOSE STATE
CLOSE-WAIT STATE

Return "Error - connection not open"

Richiesta Send

  OPEN STATE

If SND.NXT < SND.UNA + SND.MAX
Send <SEQ=SND.NXT><ACK=RCV.CUR><ACK><Data>
Set SND.NXT = SND.NXT + 1
Return
else
Return "Error - insufficient resources to send data"
Endif

LISTEN STATE
SYN-RCVD STATE
SYN-SENT STATE
CLOSE STATE
CLOSE-WAIT STATE

Return "Error - connection not open"

Richiesta Status

  Return with:

State of connection (OPEN, LISTEN, etc.)
Number of segments unacknowledged
Number of segments received not given to user
Maximum segment size for the send side of the connection
Maximum segment size for the receive side of the connection