Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) 802.11 WiFi, Ethernet Link (Physical)

Similar presentations


Presentation on theme: "1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) 802.11 WiFi, Ethernet Link (Physical)"— Presentation transcript:

1 1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) 802.11 WiFi, Ethernet Link (Physical)

2 TCP Transmission Control Protocol TCP is an alternative transport layer protocol over IP. TCP provides:  Connection-oriented  Reliable  Full-duplex  Byte-Stream 2

3 Connection-Oriented 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. 3

4 Reliable 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. 4

5 Byte Stream 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). 5

6 Full Duplex 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. 6

7 Motivation SourceDestination Packet 1 Ack 2 Packet 2 Ack 3 Packet 3 7 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.

8 Connection Establishment TCP 3 steps handshake 8

9 Connection Termination 9

10 Window size 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. 10

11 Example: window size of 3 Source Destination Packet 1 Packet 2 Packet 3 Packet 4 Packet 5 Packet 6 ack2 ack3 ack4 ack5 ack6 ack7 11

12 Buffering 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. 12

13 TCP Buffers 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). 13

14 Send Buffers 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. 14

15 Lost packets SourceDestination Packet 1 Packet 2 Packet 3 Packet Lost SourceDestination Fin / Sync Packet Lost 15

16 Packets Retransmissions 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. 16

17 Packets Retransmissions Source Destination Packet 1 Packet 2 Packet 3 Packet Lost Source Destination Fin / Sync Packet Lost Fin / Sync Packet 1 Timeout Consequences of a bad choice of timeout? 17

18 Adaptive Retransmissions Keep a running average of RTT and compute TimeOut as a function of this RTT. Send packet and keep timestamp ts. When ACK arrives, record timestamp ta. SampleRTT = ta - ts 18

19 Adaptive Retransmissions Compute a weighted average: EstimatedRTT = α x estimatedRTT + (1- α) x sampleRTT Original TCP spec: α in range (0.8,0.9)  TimeOut = 2 x EstimatedRTT 19

20 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

21 Fast Retransmit 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. 21

22 Fast Retransmit Packet 1 Packet 2 Packet 3 Packet 4 Packet 5 Packet 6 Retransmit packet 3 ACK 2 ACK 3 ACK 7 ACK 3 SenderReceiver 22 Packet 7 ACK 8

23 Network Congestion 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. 23

24 Slow Start TCP Congestion Control 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). 24

25 TCP Slow start Source Destination Timeout It also explains the TCP adaptive windows size discussed previously 25 Packet Lost

26 Fast Recovery 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 26

27 TCP Frame TCP segments have a 20 byte header with >= 0 bytes of data. 27

28 TCP header fields Port Number:  A port number identifies the endpoint of a connection.  A pair identifies one endpoint of a connection.  Two pairs and identify a TCP connection. 28

29 TCP header fields Sequence Number (SeqNo):  Sequence number is 32 bits long.  So the range of SeqNo is 0 <= SeqNo <= 2 32 -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 29

30 TCP header fields Acknowledgement Number (AckNo):  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 AckNo field to send acknowledgements. (If a host sends an AckNo in a segment it sets the “ACK flag”)  The AckNo contains the next SeqNo that a hosts wants to receive Example: The acknowledgement for a segment with sequence numbers 0-1500 is AckNo=1501 30

31 TCP header fields 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 AckNo=1 31

32 TCP header fields Header Length ( 4bits):  Length of header in 32-bit words  Note that TCP header has variable length (with minimum 20 bytes) 32

33 TCP header fields Flag bits:  URG: Urgent pointer is valid If the bit is set, the following bytes contain an urgent message in the range: SeqNo <= urgent message <= SeqNo+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 33

34 TCP header fields 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 34

35 TCP header fields 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 2 16 -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 35

36 Transport Layer Summary 36 PropertyUDPTCP Corrupted packetsno Reliablenoyes Connection typeConnectionlessConnection oriented Congestion controlNoYes LatencyLowHigh ApplicationsVOIP, Most games, NFS, DNS HTTP, HTTPs, FTP, SMTP, Telnet, SSH


Download ppt "1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) 802.11 WiFi, Ethernet Link (Physical)"

Similar presentations


Ads by Google