Title: Escenarios en conexiones TCP
1Escenarios en conexiones TCP
- Contenidos
- Algunos recorridos del diagrama de estado TCP
2Establecimiento y Término de Conexión
Active participant
Passive participant
(client)
(server)
SYN, SequenceNum
x
,
y
1
SYN ACK, SequenceNum
x
Acknowledgment
ACK, Acknowledgment
y
1
3Diagrama de Estado de Transmisión
4Escenario 1 Establecimiento de una conexión
Cliente
Servidor
CLOSED
Active open/SYN
Passive open
Close
Close
LISTEN
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
Close/FIN
ESTABLISHED
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
Close/FIN
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
ACK
ACK
FIN/ACK
TIME_WAIT
CLOSED
Time after two segment lifetimes
5Escenario 1 El servidor debe prepararse parra
recibir conexionesLa aplicación solicita abrir
un socket (o punto de conexión en un puerto)
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Servidor
Cliente
6Escenario 1 Un cliente pide abrir un socket y
envÃa un SYN pidiendo establecimiento de conexión
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
SYN
Time after two segment lifetimes
open
Cliente
Servidor
7Escenario 1 Un servidor recibe un SYN y responde
con un ACK y SYN
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
SYN
Time after two segment lifetimes
open
Cliente
Servidor
SYN ACK
8Escenario 1 El cliente recibe el SYN ACK y
para él queda establecida la conexión
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
SYN
Time after two segment lifetimes
open
Cliente
Servidor
SYN ACK
ACK
9Escenario 1 El servidor recibe su ACK y queda
establecida la conexión para él.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
SYN
Time after two segment lifetimes
open
Cliente
Servidor
SYN ACK
ACK
Intercambio de mensajes
10Escenario 2 Cierre de la conexión por el
servidor.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Servidor
11Escenario 2 La aplicación en el servidor
solicita un close del socket.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Close
Servidor
FIN
12Escenario 2 El cliente recibe el FIN y envÃa
acuse de recibo.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Close
Servidor
FIN
ACK
13Escenario 2 El servidor recibe el acuse y queda
a la espera del cierre por parte del cliente.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Close
Servidor
FIN
ACK
14Escenario 2 El cliente decide cerrar conexión,
envÃa su FIN.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Close
Servidor
FIN
ACK
Close
FIN
15Escenario 2 El servidor recibe el FIN y acusa su
recibo.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Close
Servidor
FIN
ACK
Close
FIN
ACK
16Escenario 2 El cliente recibe el ACK de su FIN y
cierra la conexión.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Close
Servidor
FIN
ACK
Close
FIN
ACK
La conexión es cerrada
17Escenario 2 El cliente recibe el ACK de su FIN y
cierra la conexión.
CLOSED
Active open/SYN
CLOSED
Active open/SYN
Passive open
Close
Passive open
Close
Close
Close
LISTEN
LISTEN
Send/SYN
SYN/SYN ACK
Send/SYN
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN_RCVD
SYN_SENT
SYN/SYN ACK
SYN ACK/ACK
ACK
SYN ACK/ACK
ACK
Close/FIN
Close/FIN
ESTABLISHED
ESTABLISHED
FIN/ACK
Close/FIN
FIN/ACK
Close/FIN
CLOSE_WAIT
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_1
FIN/ACK
FIN/ACK
Close/FIN
Close/FIN
ACK
ACK
LAST_ACK
CLOSING
ACK FIN/ACK
LAST_ACK
CLOSING
ACK FIN/ACK
FIN_WAIT_2
FIN_WAIT_2
ACK
ACK
ACK
ACK
FIN/ACK
FIN/ACK
TIME_WAIT
CLOSED
TIME_WAIT
CLOSED
Time after two segment lifetimes
Time after two segment lifetimes
Intercambio de mensajes
Cliente
Close
Servidor
FIN
ACK
Close
FIN
ACK
La conexión es cerrada
Luego de un tiempo el servidor cierra su socket
también
18Iniciador de Cierre
Diagrama recorrido por quien inicia el cierre
19Receptor del cierre (Me colgó el muy _at_
!!!)
Secuencia seguida por quien recibe el cierre de
su par no habiendo iniciado él el cierre
20Diagrama de Estado de Transmisión
Los distintos caminos dependen de si hay cierre
en ambos lados o no y si los FIN se cruzan en el
camino.
Intercambio de mensajes
Close
FIN
FIN
Close
ACK
ACK
Intercambio de mensajes
Close
FIN
Close
FIN ACK
ACK
21Algoritmo ventana deslizante
- NS Network simulator es un simulador de redes
bastante evolucionado y de libre
disposición.Ref http//www.isi.edu/nsnam/ns/ - Invito a los interesados a verlo. Ojo no es un
programa trivial, por lo cual se escapa al
alcance de este curso. - A través de este simulador se puede estudiar los
fenómenos de ventana deslizante y otros.