TCP 1 Layer name Protocols Application DNS Transport




































- Slides: 36
TCP 1 Layer name Protocols Application DNS Transport TCP, UDP Internet (Network ) IP Link (Physical) 802. 11 Wi. Fi, Ethernet
TCP Transmission Control Protocol 2 �TCP is an alternative transport layer protocol over IP. �TCP provides: Connection-oriented Reliable Full-duplex Byte-Stream
Connection-Oriented 3 �Connection oriented means that a virtual connection is established before any user data is transferred. �If the connection cannot be established - the user program is notified. �If the connection is ever interrupted - the user program(s) is notified.
Reliable 4 �Reliable means that every transmission of data is acknowledged by the receiver. �If the sender does not receive acknowledgement within a specified amount of time, the sender retransmits the data.
Byte Stream 5 �Stream means that the connection is treated as a stream of bytes. �The user application does not need to package data in individual datagrams (as with UDP).
Full Duplex 6 �TCP provides transfer in both directions. �To the application program these appear as 2 unrelated data streams, although TCP can piggyback control and data communication by providing control information (such as an ACK) along with user data.
Motivation 7 Source Destination Packet 1 Ack 2 The sender: 1. Send a packet. 2. Wait for acknowledgement 3. Go back to 1. The receiver: 1. Wait for a packet 2. Acknowledge the sender 3. Go back to 1. Packet 2 Ack 3 Packet 3
Connection Establishment TCP 3 steps handshake 8
Connection Termination 9
Window size 10 �The window size is the number of packets that are transmitted before ack received. �In the previous example, the windows size was fixed to 1. �The windows size in TCP is adaptive (details later) �Both the source and the destination should have a buffer with equal (or bigger) size than the window size. �Receiver puts each packet in its right place No out of place packets.
Example: window size of 3 11 Source Destination Packet 1 Packet 2 Packet 3 ack 2 ack 3 ack 4 Packet 5 Packet 6 ack 5 ack 6 ack 7
Buffering 12 �Keep in mind that TCP is part of the Operating System. The O. S. takes care of all these details asynchronously. �The TCP layer doesn’t know when the application will ask for any received data. �TCP buffers incoming data so it’s ready when we ask for it.
TCP Buffers 13 �Both the client and server allocate buffers to hold incoming and outgoing data The TCP layer does this. �Both the client and server announce with every ACK how much buffer space remains (the Window field in a TCP segment).
Send Buffers 14 �The application gives the TCP layer some data to send. �The data is put in a send buffer, where it stays until the data is ACK’d. �The TCP layer won’t accept data from the application unless (or until) there is buffer space.
Lost packets 15 Source Destination Fin / Sync Packet Lost Source Packet 1 Packet 2 Packet 3 Destination Packet Lost
Packets Retransmissions 16 �To overcome this, the sender should have a timeout for a retransmission. �RTT: : Round Trip Time between a pair of hosts on the Internet (until ack received). �The timeout value is set as a function of the expected RTT.
Packets Retransmissions 17 Source Destination Source Fin / Sync Timeout Fin / Sync Destination Packet Lost Packet 1 Packet 2 Packet 3 Timeout Packet Lost Packet 1 Consequences of a bad choice of timeout?
Adaptive Retransmissions 18 �Keep a running average of RTT and compute Time. Out as a function of this RTT. �Send packet and keep timestamp ts. �When ACK arrives, record timestamp ta. �Sample. RTT = ta - ts
Adaptive Retransmissions 19 �Compute a weighted average: Estimated. RTT = α x estimated. RTT + (1 - α) x sample. RTT �Original TCP spec: α in range (0. 8, 0. 9) Time. Out = 2 x Estimated. RTT
Adaptive retransmissions with exponential backoff strategy 20 �Consider what happens when TCP sends a segment after a sharp increase in delay �Solution – use exponential backoff. If the timer expires and causes a retransmission, TCP increases the timeout by a factor of 2
Fast Retransmit 21 �The problem – waiting for a timeout takes long time and the throughput drops. �Fast Retransmit was added to the TCP protocol. �Since the receiver responds every time a packet arrives, this implies the sender will see duplicate ACKs. �Fast Retransmit - Upon receipt of three duplicate ACKs, the TCP Sender retransmits the lost packet.
Fast Retransmit 22 Sender Receiver Packet 1 Packet 2 Packet 3 ACK 2 Packet 4 ACK 3 Packet 5 ACK 3 Packet 6 ACK 3 Retransmit packet 3 Packet 7 ACK 8
Network Congestion 23 �Network congestion occurs when a link or node is carrying so much data that its quality of service deteriorates �Typical effects include queuing delay and packet loss �Simple solution - retry to send the packets That creates a positive effect that only lead to more load. �Instead, Congestion Control algorithms are used.
Slow Start TCP Congestion Control 24 �When congestion is detected (packets loss), decrease the window size to one The current window size is called congestion threshold. �On each ack, increase the window size by 1. Note– it has an exponential growth phase. �When the window size equal to the congestion threshold, start to increase the window size linearly (increase by 1 on each window-size # of packets).
TCP Slow start Source Timeout 25 Destination Packet Lost It also explains the TCP adaptive windows size discussed previously
Fast Recovery 26 �Handling congestion is expensive. �This algorithm try to avoid congestion �Algorithm description: If 3 duplicated ACKs detected. � The congestion window size is reduced to the slow-start threshold
TCP Frame 27 TCP segments have a 20 byte header with >= 0 bytes of data.
TCP header fields 28 �Port Number: �A port number identifies the endpoint of a connection. � A pair <IP address, port number> identifies one endpoint of a connection. � Two pairs <client IP address, server port number> and <server IP address, server port number> identify a TCP connection.
TCP header fields 29 �Sequence Number (Seq. No): Sequence number is 32 bits long. So the range of Seq. No is 0 <= Seq. No <= 232 -1 4. 3 Gbyte Each sequence number identifies a byte in the byte stream Initial Sequence Number (ISN) of a connection is set during connection establishment
TCP header fields 30 �Acknowledgement Number (Ack. No): Acknowledgements are piggybacked, I. e a segment from A -> B can contain an acknowledgement for a data sent in the B -> A direction A hosts uses the Ack. No field to send acknowledgements. (If a host sends an Ack. No in a segment it sets the “ACK flag”) The Ack. No contains the next Seq. No that a hosts wants to receive Example: The acknowledgement for a segment with sequence numbers 0 -1500 is Ack. No=1501
TCP header fields 31 �Acknowledgement Number (cont’d) TCP uses the sliding window flow protocol to regulate the flow of traffic from sender to receiver TCP uses a variation of sliding window which uses only cumulative ACKs �Example: Assume: Sender sends two segments with “ 1. . 1500” and “ 1501. . 3000”, but receiver only gets the second segment. In this case, the receiver cannot acknowledge the second packet. It can only send Ack. No=1
TCP header fields 32 �Header Length ( 4 bits): Length of header in 32 -bit words Note that TCP header has variable length (with minimum 20 bytes)
TCP header fields 33 �Flag bits: URG: Urgent pointer is valid If the bit is set, the following bytes contain an urgent message in the range: Seq. No <= urgent message <= Seq. No+urgent pointer ACK: Acknowledgement Number is valid PSH: PUSH Flag Notification from sender to the receiver that the receiver should pass all data that it has to the application. Normally set by sender when the sender’s buffer is empty
TCP header fields 34 �Flag bits: RST: Reset the connection The flag causes the receiver to reset the connection Receiver of a RST terminates the connection and indicates higher layer application about the reset SYN: Synchronize sequence numbers Sent in the first packet when initiating a connection FIN: Sender is finished with sending Used for closing a connection Both sides of a connection must send a FIN
TCP header fields 35 �Window Size: Each side of the connection advertises the window size Window size is the maximum number of bytes that a receiver can accept. Maximum window size is 216 -1= 65535 bytes �TCP Checksum: TCP checksum covers over both TCP header and TCP data (also covers some parts of the IP header) �Urgent Pointer: Only valid if URG flag is set
Transport Layer Summary 36 Property UDP TCP Corrupted packets no no Reliable no yes Connection type Connectionless Connection oriented Congestion control No Yes Latency Low High Applications VOIP, Most games, NFS, DNS HTTP, HTTPs, FTP, SMTP, Telnet, SSH