Presentation is loading. Please wait.

Presentation is loading. Please wait.

TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.

Similar presentations


Presentation on theme: "TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong."— Presentation transcript:

1 TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong

2 2 Agenda Service provide by TCP TCP format How TCP reliable TCP connection TCP state

3 3 TCP Encapsulation With Ethernet frame Ethernet headerIP headerTCP headerdata Segment

4 4 TCP and UDP Services TCP : Transmission Control Protocol RFC 793 connection-oriented service full duplex reliable service by adding more overhead to manage acknowledgement, flow control and timer

5 5 TCP TCP performs typical transport layer function passed data to relevant application- level services error recovery flow control data stream (avoid buffer overflow)

6 6 TCP Properties Byte stream with full duplex transferring adaptive to LAN/WAN congestion avoidance and control

7 7 TCP Data Stream TCP provides a full duplex that simultaneous manages two streams of data Stream of octets passed between sender and receiver Application Send Receive Application Receive Send

8 8 Ports Port : A 16 bits address allocated for the most common application level service UDP and TCP use port addressing to deliver information to applications Service are known by port number –FTP 20, TELNET 23, SMTP 25, HTTP 80

9 9 Ports Port numbers are generally allocated by 0 not used 1- 255 Reserves port to well known service 256 - 1023 Other reserve port 1024 - 65535 user defined server ports UNIX store general used ports in /etc/service

10 10 Transmission Control Protocol TCP passed block of data to IP, consisting of the TCP header and application layer data, called SEGMENT Adding reliability in TCP achieved by Error detection and correction (due to segment corrupted) Flow control (prevent a transmitter overrunning a receiver owing a resource limitations) Resequencing (IP and deliver datagrams in any order) Removing duplicate segments (due to error recovery mechanism used by TCP)

11 11 How TCP handles Reliability Using sequence number to identify data positive acknowledgments of data received in the correct sequence retransmission of segments which have not been acknowledgment within a variable time limit Let ’ s see these mechanisms in TCP header

12 12 TCP Header 0 15 16 31 Source Port : 16Destination Port : 16 Acknowledgment Number : 32 Window Size : 16 Urgent Pointer : 16Checksum : 16 Option and Padding Sequence Number : 32 Data offs :4Resv:6Flag:6

13 13 TCP Header Details (I) Source, destination port: 16, 16 - identify application at ends of the connection sequence : 32 - indicates 1st data octet in this segment acknowledgment : 32 - next expected sequence number, valid only when the ACK bit (reside in flag) is set data offset : 4 - 32 bit words offset tells the receiver where user data begins

14 14 TCP Header Details (II) Reserve : 6 - not used Flag : 6 URG : validity of urgent pointer field ACK : validity of acknowledgment field PSH : push request (pass segment to application layer immediately) RST : reset the connection SYN : initial synchronization FIN : send at end of byte stream

15 15 TCP Header Details (III) Window: 16 - advertise amount of buffer space this node has allocated checksum : 16 - 16 bits one ’ s complement of pseudo header, TCP header and data urgent pointer : 16 - byte position of data that should be processed first options : - variable length option e.g. max segment size tells destination node

16 16 TCP in Action Before data could be transferred, a connection must be opened Server do passive open (listen) Client do active open (connect) When it finished, the connection is closed TCP has general 3 phases Connection setup phase Data phase Connection close phase

17 17 TCP Connection Establishment TCP uses 3-ways handshake to establish a connection Exchange the sequence number Ensures that both ends are ready and sync sequence number Host A Host B 1. send SYN (seq = x) 2. Send SYN (seq = y, ack = x+1) 3. send ACK (ack = y+1) Connection is setup

18 18 TCP State Diagram : Open

19 19 TCP Transfer Phase Simple example with terminal connection such as telnet. Host echoes back each received character Host A Host B 1. SEQ = 92, ACK =109 Data = “ W ” 2. SEQ = 109, ACK = 93, Data = “ W ” 3. SEQ = 93, ACK =110 Data = “ A ” Host echoes back “ W ”

20 20 TCP Connection Close Use FIN flag to close connection Host A Host B 1. FIN_WAIT_1 Seq = x, 2. CLOASE_WAIT, Ack = x +1 3.FIN_WAIT_2 4. LAST_ACK, Seq = y 5.TIME_WAIT Ack = y+1 Connection is close

21 21 TCP State Diagram : Close

22 22 Open/Close Mechanisms Haft open: one end has closed, aborted without the knowledge of the other end Host may be crashed, power off No detection if no data transfer Reset segment (RST bit)is sent when detected Half close: one end of connection terminated its output, but still receiving data from the other end Simultaneous open: both end perform an active open to each other Simultaneous close: both end perform an active close to each other

23 23 Sliding Window Principle Send and wait for acknowledgment no ACK within a certain time, retransmit the packet use for flow control: prevent sender from overloading receiver with data, e.g. fast server to slow PC congestion inside network, e.g. router performance, slow link speed How to provide flow control set the appropriate size of sliding window size

24 24 Sliding Window Flow Control Receiver advertises it ’ s window size in acknowledgments Sender will adjusts its allowed to send pointer as receiver ’ s advertisement

25 25 Sliding Window : Small Window Size 1 byte window size utilizes efficiency of channel in haft (haft-duplex transmission) Why not send many packets and get back cumulative ACK? SenderReceiver Window size = 1 Send 1 Send 2 Receive 1 Ack 2 Receive 2 Ack 3

26 26 Sliding Window : Larger Window Size A larger window size allows more data to be transmitted pending acknowledgment Window size specifies how many bytes the receiver is willing to accept Window size = 3 Sender Receiver Send 1 Send 2 Send 3 Receive ACK 4 Send 4 Send 5 Send 6 Receive 1 Receive 2 Receive 3 Send ACK 4 Receive 4 Receive 5 Receive 6

27 27 Sliding Window Buffer Sender groups its packet to be transmitted with window indication … 9991200...1000 …. 10991100 … 1199 Sent and ACK Sent and not ACK Can Send ASAP Can ’ t Send now SndWnd Offer window SndUnaSndNxtSndUna + SndWnd

28 28 TCP in Action Movement of the right and left edges of the window … 9991200...1000 …. 10991100 … 1199 … 9991200...1000 …. 10991100 … 1199 … 9991200...1000 …. 10991100 … 1199 … 9991200... 12991000 …. 10991100 … 1199 Initial Send 100 bytes More 100 bytes ACK 100 bytes SndUna,SndNxtSndUna + SndWnd SndNxt, SndUna + SndWnd SndUnaSndNxt SndUna SndNxtSndUna + SndWnd

29 29 Error Recovery (I) Receiver had to send ACK with sequence number Sender reset timer when receives ACK Host A Host B Segment #i, Start timer ACK i+1 Reset timer

30 30 Error Recovery (II) On time out, sender will retransmit the segment This mechanism is used for error recovery Host A Host B Segment #i, Start timer ACK i+ 1 Reset timer Timer expires, resend #i


Download ppt "TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong."

Similar presentations


Ads by Google