62
1 TCP Notas de la clase 25 Octubre del 2011

1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Embed Size (px)

Citation preview

Page 1: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

1

TCP

Notas de la clase 25 Octubre del 2011

Page 2: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

2

Referencias

• Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions on Communications, Vol. COM-22, No. 5, pp 637-648, May 1974.

• J. Postel, RFC-793 "Transmission Control Protocol" September 1981.

( varios errores e inconsistencias)

• RFC 1122 October 1989 ( se salvan bugs del 793)

• Extensiones de TCP en el RFC 1323

• Peterson and Davie , pp 378-405

• Paxon , Allman , Chu and Sargent RFC 6298 “Computing TCP’s Retransmission Timer” June 2011

Page 3: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

3

Agenda

o Revisión Nivel de Transporteo El Protocolo TCP

Características TCP Connection setup Segmentos TCP Números de Secuencia TCP TCP Sliding Window Control de Flujo Timeouts y Retransmisiones (RTX)

Page 4: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

4

Recordar los modelos de capas….

1 Parte de la clase

Page 5: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

5

Nivel Transporte : “End to End”

Enri Lean

milagros.dc.uba.ar stone.ac.upc.es

Nivel de Red

Nivel de Enlace

Nivel de Aplicación

Nivel de Transporte

O.S. O.S.HeaderData HeaderData

HD

HD

HD

HD HD

HD

Page 6: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

6

Modelo OSI

Session

Network

Link

PhysicalPhysicalPhysical

Application

Presentation

Transport

Network

Link Link

Network

Transport

Session

Presentation

Application

Network

Link

Physical

Peer-layer communication

layer-to-layer communication

Router Router

1

2

3

4

5

6

7

1

2

3

4

5

6

7

Page 7: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

7

TCP : Características TCP es orientado a conexion

Manejo de la conexión : 3-way handshake usado para setup y 2-2 o 4 way handshake para la liberación ( “problema de los dos ejércitos”)

TCP provee un servicio de flujo de bytes (stream-of-bytes ) TCP es confiable ( estableciendo una suerte de “conexión lógica entre los

sockets”) Acknowledgements ACKs Checksums Números de secuencia para detectar datos perdidos o desordenados Datos perdidos o corruptos se RTX después de un timeout. Datos desordenados se podrían reordenar. Control de Flujo evita inundar al receptor .

TCP implementa mecanismos de control de congestión ( se le dedica una clase la semana próxima ).

Page 8: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

8

TCP : orientado a conexión

3-way handshake

(Activo)Cliente

(Pasivo)Server

Syn

Syn + Ack

Ack

4-way handshake

(Activo)Cliente

(Pasivo)Server

Fin

(Data +) Ack

Fin

Ack

Caso ideal , en el RFC 793 Se plantean varios escenarios

Page 9: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

9

TCP soporta un “stream de bytes”

By te 0

By te 1

By te 2

By te 3

By te 0

By te 1

By te 2

By te 3

Host A

Host B

By te 8 0

By te 8 0

Page 10: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

10

…dicho servicio se emula usando segmentos TCP

By te 0

By te 1

By te 2

By te 3

By te 0

By te 1

By te 2

By te 3

Host A

Host B

By te 8 0

TCP Data

TCP Data

By te 8 0

Un segmento se envía cuando:1. Segmento full (MSS bytes),2. No esta “full” , pero sucede

time out, 3. “Pushed” por la aplicación.

Page 11: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

11

Formato del Segmento TCP

IP HdrIP Data

TCP HdrTCP Data

Src port Dst port

Sequence #

Ack Sequence #

HLEN4

RSVD6

UR

GA

CK

PS

HR

ST

SYN

FIN

FlagsWindow Size

Checksum Urg Pointer

(TCP Options)

0 15 31

TCP Data

TCP Header y Data + dirección

IP

Los números de port Src/dst y la direcciones identifican unívocamente un “socket”

Veremos concepto de

pseudo header

Page 12: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

12

Números de SecuenciaHost A

Host B

TCP Data

TCP Data

TCP HDR

TCP HDR

ISN (initial sequence number)

Seq_Num = 1er byte

ACK Seq_Num = Próximo byte

esperado

Page 13: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

13

ISN: Initial Sequence Numbers

Connection Setup3-way handshake

(Active)Client

(Passive)Server

Syn +ISNA

Syn + Ack +ISNB

Ack

Page 14: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 14

TCP Sliding Window How much data can a TCP sender have

outstanding in the network? How much data should TCP retransmit when an

error occurs? Just selectively repeat the missing data?

How does the TCP sender avoid over-running the receiver’s buffers?

Page 15: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

15

“TCP Sliding Window”

Window Size

OutstandingUn-ack’d data

Data OK to send

Data not OK to send yet

Data ACK’d

• Politica de retransmision “Go Back N”.• window size es “advertised” por el receptor ( server) (usualmente 4k – 8k Bytes en connection set-up).

Page 16: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

16

TCP Sliding Window

Host A

Host BACK

Window Size

Round-trip time

(1) RTT > Window size

ACK

Window Size

Round-trip time

(2) RTT = Window sizeACK

Window Size???

Page 17: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

RTO

17

Page 18: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

18

Jacobson ( 1988)

Page 19: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

19

TCP: Retransmisión y Timeouts

Host A

Host B

ACK

Round-trip time (RTT)

ACK

Retransmission TimeOut (RTO)

Estimated RTT

Data1 Data2

Guard

Band

valor adaptativo de timeout de RTX ( lazo cerrado !!!!!, teoria de control) : CongestionChanges in Routing

RTT es muy variable

Page 20: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

20

Concepto :TCP Timer Management

(a) Función densidad de probabilidad para tiempos de llegadas de ACK a nivel 2

(b) Función densidad de probabilidad para tiempos de llegadas de ACK TCPFiguras : Tanembaum 4 edicion

Page 21: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

21

Retransmisión Adaptiva (Algoritmo Original)

• Mide SampleRTT para cada par segmento/ ACK• Calcula el promedio ponderado de RTT

– EstimatedRTT = x EstimatedRTT + x SampleRTT– donde + = 1 <= 0.9 <= 0.2

• Fijar timeout basado en EstimatedRTT– TimeOut = 2 x EstimatedRTT

Page 22: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

22

Algoritmo de Karn/Partridge [KP87]

• No considerar RTT cuando se retransmite• Duplicar timeout luego de cada retransmisión

Sender Receiver

Original transmission

ACK

Sam

pleR

TT

Retransmission

Sender Receiver

Original transmission

ACK

Sam

pleR

TT

Retransmission

[KP87] Karn, P. and C. Partridge, "Improving Round-Trip TimeEstimates in Reliable Transport Protocols", SIGCOMM 87.

Page 23: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

23

Algoritmo de Jacobson/ Karels [JK88]Proponen un nueva forma de calcular Timeout de RTX• Diff = sampleRTT - EstRTT• EstRTT = EstRTT + ( x Diff)• Dev = Dev + ( |Diff| - Dev)

– donde es un factor entre 0 y 1 (Por ejemplo 1/8)

• Considerar varianza cuando fijamos el timeout• TimeOut = x EstRTT + x Dev

– donde = 1 y = 4• Notas

– Los algoritmos son tan buenos/malos como la granularidad del reloj (500ms en Unix)– Un preciso mecanismo de timeout es importante para controlar la congestión ( como

veremos en la próxima clase)– Además de ayudar a controlar la congestión, la idea es no retransmitir cuando no es

necesario.

[JK88] Jacobson, V. and M. Karels, "Congestion Avoidance and Control", ftp://ftp.ee.lbl.gov/papers/congavoid.ps.Z.

Page 24: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

24

Ejemplo de estimación de RTT:

100

150

200

250

300

350

1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106

tiempo (segundos)

RTT

(mili

segu

ndos

)

MuestraRTT EstimadoRTT

Page 25: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

RFC 6298 "Computing TCP's Retransmission Timer", June 2011

• El algoritmo básico del emisor TCP mantiene dos variables de estado Para computar el RTO SRTT (smoothed round-trip time) and RTTVAR (round-trip time variation)

Hasta que el emisor realice la medición para el primer segmento:

– “SHOULD set” RTO <- 1 segundo ( versiones anteriores 3 segundos o mas)

Cuando se realiza la primera medida R ; RTT el host “debe” setear SRTT <- R RTTVAR <- R/2 RTO <- SRTT + max (G, K*RTTVAR) , siendo K=4, G = 1seg

(granularidad)

25

Page 26: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

RFC 6298 "Computing TCP's Retransmission Timer", continuación

• Las subsiguientes mediciones R’ del RTT el host debe setear :

RTTVAR <- (1 - beta) * RTTVAR + beta * |SRTT - R’| (1)

SRTT <- (1 - alpha) * SRTT + alpha * R’ (2)

Con alpha=1/8 y beta=1/4 (sugeridos en [JK88]).

Nota : el valor de SRTT usado para actualizar RTTVAR en (1) es el valor antes de su propia actulizacion en (2). RTTVAR y SRTT debe calcularse en el orden precedente .

• Luego se debe setear el RTO :

RTO <- SRTT + max (G, K*RTTVAR)

26

Page 27: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

RFC 6298 "Computing TCP's Retransmission Timer", continuación

• Si el RTO is calculado es menor a 1 segundo entonces deberia redondear a 1…… siguen las consideraciones para evaluar cual es un valor conservativo y evitar retransmisiones espureas ……

27

Page 28: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

28

TCP

2 parte de la Clase

Page 29: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

29

TCP

Repaso ( basado en el Peterson)

Page 30: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

30

Protocolos End-to-End

• Se apoyan en la capa Red, la cual es de mejor esfuerzo (best-effort)– descarta mensajes– re-ordena mensajes– puede entregar múltiples copias de un mensaje dado– limita los mensajes a algún tamaño finito– entrega mensajes después de un tiempo arbitrariamente largo

• Servicios comunes ofrecidos/deseados end-to-end– garantía de entrega de mensajes– entrega de mensajes en el mismo orden que son enviados– entrega de a lo más una copia de cada mensaje– soporte para mensajes arbitrariamente largos mensajes– soporte de sincronización– permitir al receptor controlar el flujo de datos del transmisor– soportar múltiples procesos de nivel aplicación en cada máquina

Page 31: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

31

TCP Generalidades• Orientado a conexión• flujo de byte

– app escriben bytes– TCP envía segmentos– app lee bytes

Application process

Writebytes

TCPSend buffer

Segment Segment Segment

Transmit segments

Application process

Readbytes

TCPReceive buffer

… …

• Full duplex• Control de flujo: evita que el Tx

rebalse al receptor• Control de congestión: evita que el Tx

sobrecargue la red

Page 32: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

32

Enlace de Datos Versus Transporte• Potencialmente conecta muchas máquinas diferentes

– requiere de establecimiento y término de conexión explícitos

• Potencialmente diferentes RTT– requiere mecanismos adaptivos para timeout

• Potencialmente largos retardos en la red– requiere estar preparado par el arribo de paquetes muy antiguos

• Potencialmente diferente capacidad en destino– requiere acomodar diferentes capacidades de nodos

• Potencialmente diferente capacidad de red– requiere estar preparado para congestión en la red

Page 33: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

33

Version HLen TOS Length

Ident Flags Offset

TTL Protocol Checksum

SourceAddr

DestinationAddr

Options (variable) Pad(variable)

0 4 8 16 19 31

Contexto Formato de Segmento

Options (variable)

Data

Checksum

SrcPort DstPort

HdrLen 0 Flags

UrgPtr

AdvertisedWindow

SequenceNum

Acknowledgment

IP

TCP

Pseudo encabezado

URG|ACK|PSH|RST|SYN|FIN

Page 34: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

34

Formato de Segmento

Options (variable)

Data

Checksum

SrcPort DstPort

HdrLen 0 Flags

UrgPtr

AdvertisedWindow

SequenceNum

Acknowledgment

0 4 10 16 31

Page 35: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

35

Formato de Segmento (cont)• Cada conexión es identificada por la 4-tupla:

– (SrcPort, SrcIPAddr, DsrPort, DstIPAddr)

• Ventana deslizante + control de flujo– acknowledgment, SequenceNum, AdvertisedWindow

• Flags– SYN, FIN, RESET, PUSH, URG, ACK

• Checksum– pseudo header(IP) + TCP header + data

Sender

Data (SequenceNum)

Acknowledgment +AdvertisedWindow

Receiver

Page 36: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

36

Establecimiento y Término de Conexión

Active participant(client)

Passive participant(server)

SYN, SequenceNum = x

SYN + ACK, SequenceNum = y,

ACK, Acknowledgment = y + 1

Acknowledgment = x + 1

Page 37: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

37

Diagrama de Estado de TransmisiónCLOSED

LISTEN

SYN_RCVD SYN_SENT

ESTABLISHED

CLOSE_WAIT

LAST_ACKCLOSING

TIME_WAIT

FIN_WAIT_2

FIN_WAIT_1

Passive open Close

Send/SYNSYN/SYN + ACK

SYN + ACK/ACK

SYN/SYN + ACK

ACK

Close/FIN

FIN/ACKClose/FIN

FIN/ACKACK + FIN/ACK Timeout after two segment lifetimes

FIN/ACK

ACK

ACK

ACK

Close/FIN

Close

CLOSED

Active open/SYN

Page 38: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

38

Revisión de Ventana Deslizante

• Lado TransmisorLastByteAcked < = LastByteSent

LastByteSent < = LastByteWritten

Se tiene en buffer los bytes entre LastByteAcked y LastByteWritten

Sending application

LastByteWritten

TCP

LastByteSentLastByteAcked

Receiving application

LastByteRead

TCP

LastByteRcvdNextByteExpected

• Lado ReceptorLastByteRead < NextByteExpected

NextByteExpected < = LastByteRcvd +1

Se tiene en buffer los bytes entre NextByteRead y LastByteRcvd

LastByteRead+1

Page 39: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

39

Control de Flujo• Tamaño del buffer de envío: MaxSendBuffer• Tamaño del buffer de recepción: MaxRcvBuffer• Lado receptor

– LastByteRcvd - LastByteRead < = MaxRcvBuffer– AdvertisedWindow = MaxRcvBuffer - (LastByteRcvd - NextByteRead)

• Lado Transmisor– LastByteSent - LastByteAcked < = AdvertisedWindow– EffectiveWindow = AdvertisedWindow - (LastByteSent - LastByteAcked)– LastByteWritten - LastByteAcked < = MaxSendBuffer– Bloquear Tx si (LastByteWritten - LastByteAcked) + y > MaxSenderBuffer, y

bytes que se desean escribir. • Siempre enviar ACK en respuesta a la llegada de segmentos de datos• Tx persiste enviando 1 byte cuando AdvertisedWindow = 0

Sending application

LastByteWrittenTCP

LastByteSentLastByteAcked

Receiving application

LastByteReadTCP

LastByteRcvdNextByteExpected

Page 40: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

40

• ¿Qué tan agresivamente el Tx explota la apertura de ventana?

• Soluciones en lado Receptor– Retardar los acuses de recibo

Síndrome de Ventana estúpida (Silly)

Sender Receiver

Page 41: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

41

Silly Window Syndrome

Page 42: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

42

Algoritmo de Nagle• ¿Qué tanto tiempo el Tx retarda la transmisión de datos?

– Demasiado largo: afecta aplicaciones interactivas

– Demasiado corto: Utilización de la red es pobre

– Estrategias: Basadas en timers v/s auto relojes

• Cuando la aplicación genera datos adicionales:– Si se llena un segmento (y la ventana está abierta): enviar

– Sino

• Si hay datos sin ack en Tx: dejar en buffer hasta llegada de ack

• sino: enviar datos

Page 43: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 43

Protección contra reapariciones de igual número de secuencia

• SequenceNum de 32 bits

Bandwidth Tiempo hasta tener problemaT1 (1.5 Mbps) 6.4 hoursEthernet (10 Mbps) 57 minutesT3 (45 Mbps) 13 minutesFDDI (100 Mbps) 6 minutesSTS-3 (155 Mbps) 4 minutesSTS-12 (622 Mbps) 55 secondsSTS-24 (1.2 Gbps) 28 seconds

Page 44: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

44

Mantención del “caño lleno”

• AdvertisedWindow de 16 bits

Bandwidth Delay x Bandwidth ProductT1 (1.5 Mbps) 18KBEthernet (10 Mbps) 122KBT3 (45 Mbps) 549KBFDDI (100 Mbps) 1.2MBSTS-3 (155 Mbps) 1.8MBSTS-12 (622 Mbps) 7.4MBSTS-24 (1.2 Gbps) 14.8MB

Asumiendo RTT de 100 ms

64 KB

Page 45: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

45

Extensiones de TCP

• Son implementadas como opciones del encabezado

• Almacenar marcas de tiempo en segmentos de salida

• Extender espacio de secuencia con marca de tiempo de 32-bit (PAWS)

• Desplazar (escalar) ventana avisada. La idea es medir la ventana en unidades de 2, 4, 8 bytes.

Page 46: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

46

Recordemos MSS

Application Message

TCP dataTCP hdr

MSSTCP Segment

IP dataIP hdrIP Packet

Ethernet dataEthernet

Ethernet Frame

20 bytes

20 bytes

14 bytes 4 bytesMTU 1500 bytes

Page 47: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

47

Checksum !!!!!!!!!

• Se calcula entre el TCP Header , Data y el pseudo header

Page 48: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Tanembaum 4 Edicion 48

Window Management

Page 49: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

49

Initial Sequence Number• Select initial sequence numbers (ISN) to protect against

segments from prior connections (that may circulate in the network and arrive at a much later time)

• Select ISN to avoid overlap with sequence numbers of prior connections

• Use local clock to select ISN sequence number

• Time for clock to go through a full cycle should be greater than the maximum lifetime of a segment (MSL); Typically MSL=120 seconds

Page 50: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 50

TCP Connection Establishment

(a) TCP connection establishment in the normal case.(b) Call collision.

6-31

Initial sequence numbers are not 0. TCP uses a clock tick counter (at 4 usecs rate) to setup the initial sequence numbers. This scheme prevents delayed duplicates.

Page 51: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 51

Connection Establishment (cont)

Active participant(client)

Passive participant(server)

SYN, SequenceNum = x

ACK, Acknowledgment =y+1

Acknowledgment =x+1

SYN+ACK,

SequenceNum=y,

Page 52: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 52

TCP Connection Release • Graceful release:

– Each side of the connection released independently.

• Either side send TCP segment with FIN=1.• When FIN acknowledged, that direction is shut down for data.• Connection released when both sides shut down.

– 4 segments: 1 FIN and 1 ACK for each direction; 1st. ACK+2nd. FIN combined.

– Two-army problem , Timers , 2 MSL

Page 53: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 53

TCP Connection Management Modeling

TCP connection management finite state machine. The heavy solid line is the normal path for a client. The heavy dashed line is the normal path for a server. The light lines are unusual events. Each transition is labeled by the event causing it and the action resulting from it, separated by a slash.

Page 54: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

54

TCP Connection Management ModelingThe states used in the TCP connection management finite

state machine.

Page 55: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 55

Maximum Segment Size

• Maximum Segment Size– largest block of data that TCP sends to other end

• Each end can announce its MSS during connection establishment

• Default is 576 bytes including 20 bytes for IP header and 20 bytes for TCP header

• Ethernet implies MSS of 1460 bytes• IEEE 802.3 implies 1452

Page 56: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 56

Tear-down Packet Exchange

Sender ReceiverFIN

FIN-ACK

FIN

FIN-ACK

Data write

Data ack

Page 57: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 57

Connection Tear-down

Page 58: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 58

Detecting Half-open Connections

Page 59: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Spring 2005 59

TIME-WAIT Assassination

Page 60: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Berkeley Sockets

The socket primitives for TCP.

Page 61: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Socket Programming

Example:Internet File

Server

Client code using sockets.

6-6-1

Page 62: 1 TCP Notas de la clase 25 Octubre del 2011. 2 Referencias Cerf, V., and R. Kahn, "A Protocol for Packet Network Intercommunication", IEEE Transactions

Socket Programming

Example:Internet File Server (2)

Client code using sockets.