Last time: Transport 1 Transport 2 � transport layer services � connection-oriented transport: TCP � multiplexing/demultiplexing � reliable transfer � connectionless transport: UDP � flow control � principles of reliable data transfer � timer � connection management � sequence number � principles of congestion control � acknowledgement � TCP congestion control � negative acknowledgement � window, pipelining � sliding window protocols � go-back-N � selective repeat 23/9-08 Datakommunikation - Jonny Pettersson, UmU 23/9-08 Datakommunikation - Jonny Pettersson, UmU Transmission Control Vad TCP måste klara Protocol(TCP) � Koppla ihop många olika maskiner � Definierar säker överföring i TCP/IP Internet genom att bland annat definiera � Behov av explicit upp- och nedkoppling � Hantera varierande RTT � Formen på paket och ackar � Behov av adaptiv timeout för omsändning � Funktioner som kan användas för att se till att data anländer korrekt � Hantera långa fördröjningar i nätet � Hur TCP skiljer på flera mottagare inom en � Behov av hantering av sent anländande paket maskin � TTL � Hur kommunikationen initieras och avslutas � Hantera olika kapaciteter hos mottagare � VIKTIGT! � Behov av att kunna anpassa till olika noders resurser � Hantera olika nätverkskapaciteter � TCP är ett protokoll, ej en mjukvara � Behov av att hantera trafikstockningar på nätet 23/9-08 Datakommunikation - Jonny Pettersson, UmU 23/9-08 Datakommunikation - Jonny Pettersson, UmU TCP - Överblick När skickas segment? RFCs: 793, 1122, 1323, 2018, 2581 � Kopplingsorienterat � Full duplex � Tre sätt att trigga en sändning � Byte-stream � Flow control: Så sändaren � MSS (Maximum Segment Size), oftast matchat inte dränker mottagaren � app skriver bytes med MTU (Maximum Transmission Unit) för � TCP sänder segment � Congestion control: Så lokala nätverket sändaren inte dränker � app läser bytes � Push operation från applikationen nätverket � Pipeline � Timeout Application process Application process Write Read … bytes … bytes TCP TCP Send buffer Receive buffer … Segment Segment Segment Transmit segments 23/9-08 23/9-08 Datakommunikation - Jonny Pettersson, UmU Datakommunikation - Jonny Pettersson, UmU 1
Portar och kopplingar Välkända TCP portar � TCP använder portar på ett mer � 7 - Echo komplicerat sätt än UDP � 9 - Discard � Flera kopplingar per port � 21 - FTP � TCP identifierar kopplingar som par av � 25 - SMTP kommunikationspunkter � 79 - Finger � < SrcPort , SrcIPAddr , DesPort , DesIPAddr > 23/9-08 Datakommunikation - Jonny Pettersson, UmU 23/9-08 Datakommunikation - Jonny Pettersson, UmU TCP segment structure TCP seq. #’s and ACKs 32 bits Seq. #’s: URG: urgent data Host A Host B counting source port # dest port # � byte stream (generally not used) by bytes “number” of first User sequence number of data S e q = ACK: ACK # byte in segment’s types 4 2 , A C K = 7 9 acknowledgement number (not segments!) , d a t valid data ‘C’ a = ‘ C ’ host ACKs head not rcvr window size ACKs: U A P R S F PSH: push data now receipt of len used # bytes � seq # of next byte C ’ ‘C’, echoes (generally not used) ‘ checksum ptr urgent data = a t a d rcvr willing 3 , = 4 back ‘C’ expected from K C A 9 , = 7 to accept e q S RST, SYN, FIN: Options (variable length) other side connection estab � cumulative ACK host ACKs (setup, teardown receipt Q: how receiver handles commands) S e q = application of echoed 4 3 out-of-order segments , A C K = 8 0 ‘C’ data � A: TCP spec doesn’t (variable length) say, - up to Internet Checksum implementor time (TCP header + data + simple telnet scenario pseudo header) 23/9-08 23/9-08 Datakommunikation - Jonny Pettersson, UmU TCP sender events: TCP reliable data transfer data rcvd from app: timeout: � Create segment with � retransmit segment � TCP creates rdt � Retransmissions are seq # that caused timeout service on top of IP’s triggered by: � seq # is byte-stream � restart timer unreliable service � timeout events number of first data � duplicate acks Ack rcvd: � Pipelined segments byte in segment � Initially consider � If acknowledges � Cumulative acks � start timer if not simplified TCP sender: previously unacked � TCP uses single already running (think segments � ignore duplicate acks retransmission timer of timer as for oldest � ignore flow control, � update what is known to unacked segment) congestion control be acked � expiration interval: � start timer if there are outstanding segments TimeOutInterval 23/9-08 23/9-08 Datakommunikation - Jonny Pettersson, UmU Datakommunikation - Jonny Pettersson, UmU 2
NextSeqNum = InitialSeqNum SendBase = InitialSeqNum TCP ACK generation [RFC 1122, RFC 2581] TCP loop (forever) { sender switch(event) TCP Receiver action Event at Receiver event: data received from application above (simplified) create TCP segment with sequence number NextSeqNum if (timer currently not running) Arrival of in-order segment with Delayed ACK. Wait up to 500ms start timer expected seq #. All data up to for next segment. If no next segment, pass segment to IP Comment: expected seq # already ACKed send ACK NextSeqNum = NextSeqNum + length(data) • SendBase-1: last cumulatively Arrival of in-order segment with Immediately send single cumulative event: timer timeout ack’ed byte ACK, ACKing both in-order segments retransmit not-yet-acknowledged segment with expected seq #. One other Example: smallest sequence number segment has ACK pending • SendBase-1 = 71; start timer y= 73, so the rcvr Arrival of out-of-order segment Immediately send duplicate ACK, wants 73+ ; event: ACK received, with ACK field value of y higher-than-expect seq. # . indicating seq. # of next expected byte if (y > SendBase) { y > SendBase, so Gap detected SendBase = y that new data is if (there are currently not-yet-acknowledged segments) acked Arrival of segment that Immediately send ACK, provided that start timer } partially or completely fills gap segment starts at lower end of gap } /* end of loop forever */ 23/9-08 Datakommunikation - Jonny Pettersson, UmU TCP: retransmission scenarios TCP retransmission scenarios (more) Host A Host A Host B Host A Host B Host B S e S e q = S e q = 9 2 q = 9 2 , 8 9 2 , 8 b , 8 b y t e b y t e s y t e s d a s d a t a d a t a Seq=92 timeout S t a e q = 1 0 0 , 2 0 b y t e ACK=100 s timeout d a timeout t a ACK=100 S e q = 1 0 0 , 2 0 b y ACK=100 t e s d a t a X ACK=120 X loss loss S e S q = e q = Sendbase 9 2 9 , 8 2 , b y 8 b t e s ACK=120 y t d SendBase e s a t a d a = 100 t a Seq=92 timeout = 120 SendBase = 120 ACK=120 ACK=100 SendBase SendBase time = 100 = 120 Cumulative ACK scenario time time premature timeout lost ACK scenario 23/9-08 Datakommunikation - Jonny Pettersson, UmU Tillförlitlig och ordnad leverans TCP Flow Control flow control receiver: explicitly informs sender of sender won’t overrun Sending application Receiving application (dynamically changing) receiver’s buffers by amount of free buffer transmitting too much, space too fast TCP TCP � RcvWindow field in LastByteWritten LastByteRead TCP segment RcvBuffer = size or TCP Receive Buffer sender: keeps the amount LastByteAcked LastByteSent NextByteExpected LastByteRcvd RcvWindow = amount of spare room in Buffer of transmitted, Sändaren Mottagaren unACKed data less than most recently received LastByteAcked ≤ LastByteSent LastByteRead < NextByteExpected RcvWindow LastByteSent ≤ LastByteWritten NextByteExpected ≤ LastByteRcvd Buffrar mellan LastByteAcked och + 1 Buffrar mellan LastByteRead och LastByteWritten LastByteRcvd receiver buffering 23/9-08 23/9-08 Datakommunikation - Jonny Pettersson, UmU Datakommunikation - Jonny Pettersson, UmU 3
Recommend
More recommend