1 / 30

TCP : Transmission Control Protocol

TCP : Transmission Control Protocol. Computer Network System Sirak Kaewjamnong. Agenda. Service provide by TCP TCP format How TCP reliable TCP connection TCP state. TCP Encapsulation. With Ethernet frame. Segment. Ethernet header. IP header. TCP header. data. TCP and UDP Services.

ponce
Download Presentation

TCP : Transmission Control Protocol

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong

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

  3. TCP Encapsulation • With Ethernet frame Segment Ethernet header IP header TCP header data

  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. TCP TCP performs typical transport layer function • passed data to relevant application-level services • error recovery • flow control data stream (avoid buffer overflow)

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

  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 Receive Send Application Send Receive

  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. 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. 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. 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. 0 15 16 31 Source Port : 16 Destination Port : 16 Sequence Number : 32 Acknowledgment Number : 32 Data offs :4 Resv:6 Flag:6 Window Size : 16 Checksum : 16 Urgent Pointer : 16 Option and Padding TCP Header

  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. 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. 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. 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. 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 B Host A 1. send SYN (seq = x) 2. Send SYN (seq = y, ack = x+1) 3. send ACK (ack = y+1) Connection is setup

  18. TCP State Diagram : Open

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

  20. Host B Host A TCP Connection Close • Use FIN flag to close connection 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. TCP State Diagram : Close

  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. 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. 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. Sliding Window : Small Window Size Window size = 1 • 1 byte window size utilizes efficiency of channel in haft (haft-duplex transmission) • Why not send many packets and get back cumulative ACK? Send 1 Receive 1 Ack 2 Sender Receiver Send 2 Receive 2 Ack 3

  26. Sliding Window : Larger Window Size Window size = 3 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 • A larger window size allows more data to be transmitted pending acknowledgment • Window size specifies how many bytes the receiver is willing to accept Receiver Sender

  27. Sliding Window Buffer • Sender groups its packet to be transmitted with window indication Offer window SndWnd Sent and not ACK Can Send ASAP Can’t Send now Sent and ACK … 999 1000 …. 1099 1100…1199 1200 ... SndUna SndNxt SndUna + SndWnd

  28. … 999 … 999 … 999 1000 …. 1099 1000 …. 1099 1000 …. 1099 1100…1199 1100…1199 1100…1199 1200 ... 1200 ... 1200 ... TCP in Action Movement of the right and left edges of the window Initial SndUna,SndNxt SndUna + SndWnd Send 100 bytes SndUna SndNxt SndUna + SndWnd More 100 bytes SndUna SndNxt, SndUna + SndWnd ACK 100 bytes … 999 1000 …. 1099 1100…1199 1200 ... 1299 SndUna SndNxt SndUna + SndWnd

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

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

More Related