Transmissin Cntrl Prtcl Intrductin TCP is ne f the mst imprtant prtcls f Internet Prtcls suite. It is mst widely used prtcl fr data transmissin in cmmunicatin netwrk such as Internet. Features TCP is reliable prtcl, that is, the receiver sends an acknwledgement back t the sender, f each packet it receives. Sender is nw cnfirmed that packet has been received and can prcess further packets in its queue. TCP ensures that data has been received in the rder it was sent. TCP is cnnectin riented. TCP requires that cnnectin between tw remte pints be established befre sending actual data. TCP prvides errr-checking and recvery mechanism. TCP prvides end-t-end cmmunicatin. TCP prvides flw cntrl and quality f service. TCP perates in Client/Server pint-t-pint mde. TCP prvides full duplex server, i.e. it can act like receiver and sender. Header TCP header at minimum is 20 bytes lng and maximum 60 bytes. [Image: TCP Header] Surce Prt (16-bits): Identifies surce prt f the applicatin prcess n the sending device. Destinatin Prt (16-bits): Identifies destinatin prt f the applicatin prcess n the receiving device. Sequence Number (32-bits): Sequence number f data bytes f a segment in a sessin. Acknwledgement Number (32-bits): When ACK flag is set, this number cntains the next sequence number f the data byte expect and wrks as acknwledgement f the previus data received. Data Offset (4-bits): This field cntains tw meaning. First, it tells the size f TCP header (32-bit wrds) Secndly, it indicates the ffset f data in current packet in the whle TCP segment.
Reserved (3-bits): Reserved fr future use and all are set zer by default. Flags (1-bit each): NS: Nnce Sum bit is used by Explicit Cngestin Ntificatin signaling prcess. CWR: When a hst receives packet with ECE bit set, it sets Cngestin Windws Reduced t acknwledge that ECE received. ECE: has tw meaning: If SYN bit is clear t 0, then ECE means that the IP packet has its CE (cngestin experience) bit set. If SYN bit is set t 1, ECE means that the device is ECT capable URG: indicates that Urgent Pinter field has significant data and shuld be prcessed. ACK: indicates that Acknwledgement field has significance. If ACK is cleared t 0, it indicates that packet des nt cntain any acknwledgement. PSH: when set, it is a request t the receiving statin t PUSH data (as sn as it cmes) t the receiving applicatin withut buffering it. RST: Reset flag has many features: It is used t refuse an incming cnnectin. It is used t reject a segment. It is used t restart a cnnectin. SYN: this flag is used t set up a cnnectin between hsts. FIN: this flag is used t release a cnnectin and n mre data is exchanged thereafter. Because packets with SYN and FIN flags have sequence numbers, they are prcessed in crrect rder. Windws Size: This field is used fr flw cntrl between tw statins and indicates the amunt f buffer (in bytes) the receiver has allcated fr a segment, i.e. hw much data is the receiver expecting. Checksum: this field cntains the checksum f Header, Data and Pseud Headers. Urgent Pinter: Pints t the urgent data byte if URG flag is set t 1. Optins: Facilitates additinal ptins which are nt cvered by the regular header. Optin field is always described in 32-bit wrds. If this field cntains data less than 32-bit, padding is used t cver the remaining bits t reach 32-bit bundary. Addressing: TCP cmmunicatin between tw remte hsts is dne by means f prt numbers (Transprt Service Access Pints). Prts numbers can range frm 0 65535 which are knwn as: System Prts (0 1023) User Prts ( 1024 49151) Private/Dynamic Prts (49152 65535) Cnnectin Management: TCP cmmunicatin wrks in Server/Client mdel. The client initiates the cnnectin and the server either accept r rejects it. Three-way handshaking is used fr cnnectin management.
Three-way handshake] [Image: ESTABLISHMENT: Client initiates the cnnectin and sends the segment with a Sequence number. Server acknwledges it back with its wn Sequence number and ACK f client s segment (client s Sequence number+1). Client after receiving ACK f its segment sends an acknwledgement f Server s respnse. RELEASE: Either f server and client can send TCP segment with FIN flag set t 1. When the receiving end respnds it back by ACKnwledging FIN, that directin f TCP cmmunicatin is clsed and cnnectin is released. Bandwidth Management: TCP uses the cncept f windw size t accmmdate the need f Bandwidth management. Windw size tells the sender (the remte end), hw much data byte segment the receiver (this end) can receive. TCP uses slw start phase by using windw size 1 increases the windw size expnentially after each successful cmmunicatin. Fr example: Client uses windws size 2 and sends 2 bytes f data. When the acknwledgement f this segment received the windws size is dubled t 4 and next segment will be sent f 4 data bytes. When the acknwledgement f 4-byte data segment is received client sets windws size t 8 and s n. If an acknwledgement is missed, i.e. data lst in transit netwrk r it receives NACK the windw size is reduced t half and slw start phase starts again. Errr Cntrl & Flw Cntrl: TCP uses prt numbers t knw what applicatin prcess it needs t handver the data segment. Alng with that it uses sequence numbers t synchrnize itself with the remte hst. All data segments are sent and received with sequence numbers. The Sender knws which last data segment was received by the Receiver when it gets ACK. The Receiver knws what last segment was sent by the Sender lking at the sequence number f recently received packet. If the sequence number f a segment recently received des nt match with the sequence number the receiver was expecting it is discarded and NACK is sent back. If tw segments arrives with same sequence number, the TCP timestamp value is cmpared t make a decisin.
Multiplexing: The technique t cmbine tw r mre data stream in ne sessin is called Multiplexing. When a TCP client initializes a cnnectin with Server, it always refers t a well-defined prt number which indicates the applicatin prcess. The client itself uses a randmly generated prt number frm private prt number pls. Using TCP Multiplexing, a client can cmmunicate with a number f different applicatin prcess in a single sessin. Fr example, a client requests a web page which in turn cntains different type f data (HTTP, SMTP, FTP etc.) the TCP sessin timeut is increased and the sessin is kept pen fr lnger time s that the three-way handshake verhead can be avided. This enables the client system t receive multiple cnnectin ver single virtual cnnectin. These virtual cnnectins are nt gd fr Servers if the timeut is t lng. Cngestin Cntrl: When large amunt f data is fed t system which is nt capable f handling such amunt f data, cngestin ccurs. TCP cntrls cngestin by means f Windw mechanism. TCP sets a windw size telling the ther end hw much data segment t send. TCP may use three algrithms fr cngestin cntrl: Additive increase, Multiplicative Decrease Slw Start Timeut React Timer Management: TCP uses different types f timer t cntrl and management different type f tasks: KEEP-ALIVE TIMER: This timer is used t check the integrity and validity f a cnnectin. When keep-alive time expires, the hst sends a prbe t check if the cnnectin still exists. RETRANSMISSION TIMER: This timer maintains stateful sessin f data sent. If the acknwledgement f sent data des nt receive within the Retransmissin time, the data segment is sent again. PERSIST TIMER: TCP sessin can be paused by either hst by sending Windw Size 0. T resume the sessin a hst needs t send Windw Size with sme larger value. If this segment never reaches the ther end, bth end may wait fr each ther fr infinite time.
When the Persist timer expires, the hst re-send its windw size t let the ther end knw. Persist Timer helps avid deadlcks in cmmunicatin. TIMED-WAIT: After releasing a cnnectin, either hst waits fr a Timed-Wait time t terminate the cnnectin cmpletely. This is in rder t make sure that the ther end has received the acknwledgement f its cnnectin terminatin request. Timed-ut can be a maximum f 240 secnds (4 minutes). Crash Recvery: TCP is very reliable prtcl. It prvides sequence number t each f byte sent in segment. It prvides the feedback mechanism i.e. when a hst receives a packet it is bund t ACK that packet having the next sequence number expected (if it is nt the last segment). When a TCP Server crashes mid-way cmmunicatin and re-starts its prcess it sends TPDU bradcast t all its hsts. The hsts can then send the lasts data segment which was never unacknwledged and carry nwards. Surce: http://www.tutrialspint.cm/data_cmmunicatin_cmputer_netwrk/transmissin_cntrl_prtc l.htm