Transmission Control Protocol Prepared by J Kowsalya Devi
Transmission Control Protocol Prepared by J. Kowsalya Devi Teaching Fellow/CSE University College of Engineering Kanchipuram OER- CN- FDP 201 X 1
TCP(Transmission Control Protocol) • Connection oriented protocol TCP Services • TCP & UDP uses same network layer. • Does not support multicasting & broadcasting. • Provides flow control. TCP Header (TCP Data is Encapsulated in an IP datagram) ------IP Datagram--------------------------- IP Header TCP Data TCP Segment--------------- OER- CN- FDP 201 X 2
TCP (Continued) • TCP functionality • • • Provides connection-oriented, reliable, in-sequence, byte-stream service Provides a logical full-duplex (two way) connection Provides flow-control by advertised window. Provides congestion control by congestion window. Support multiple applications in the same end systems. • TCP establishes connection by setting up variables that are used in two peer TCP entities. Most important variables are initial sequence numbers. • TCP uses Selective Repeat ARQ. • TCP terminates each direction of connection independently, allowing data to continue flowing in one direction after closing the other direction. OER- CN- FDP 201 X 3
TCP Header Format OER- CN- FDP 201 X 4
1. Source Port – Specifies the application sending the segment. 2. Destination port – identifies the receiving application port no. s below 256 called well known ports. Port 23 -TELNET, Port 53 -DNS name server, Port 21 - FTP. 3. Sequence number – Numbered 0 after 232 - 1. 4. ACK number- Seq no. of next data by the sender expects to receive if the ACK bit is set. If this bit is not set, this field has no effect. 5. Header Length- Length of the header in 32 bit words. 6. Reserved – Must be 0. 7. Flags(6 Bits) • URG- Urgent pointer is valid if it set to 1. • ACK-ACK no. is valid if it is set to 1. • PSH- receiver should pass the data to the application as soon as possible. • RST-reset the connection. • SYN-Synchronize seq. no to initiate a connection. • FIN-used to release the connection. 8. Window Size- No. of bytes the sender is willing to accept. 9. Checksum – Error detection. 10. Urgent Pointer- If it is set the TCP entity must deliver it to the higher layers immediately. 11. Options- Optional 12. DATA- field size is variable. OER- CN- FDP 201 X 5
TCP Connection Establishment • Three way handshaking. • Connection request(seq=x) • Connection accepted(seq=y, ack=x+1) • Connection accepted(confirmed) (seq=x+1, ack=y+1) • Reject(ack=x)/(ack=y) OER- CN- FDP 201 X 6
TCP State Descriptors CLOSED - Disconnected TIME_WAIT - Wait for network to discard related packets CLOSING - Connection closed by both sides simultaneously FIN_WAIT_2 - Connection closed locally and ACK’d FIN_WAIT_1 - Connection closed locally LAST_ACK -Connection closed by peer, closed locally, await ACK CLOSE_WAIT - Connection closed by peer ESTABLISHED - Connection ready for data transport SYN_SENT - Connection request sent SYN_RCVD - Connection request received LISTEN - Waiting for incoming connection OER- CN- FDP 201 X 7
TCP connection management modeling OER- CN- FDP 201 X Fig. TCP Connection management finite state machine. 8
TCP Transmission policy Silly window syndrome Ø Sending data in very small segments 1. Syndrome created by the Sender • Sending application program creates data slowly (e. g. 1 byte at a time) • Wait and collect data to send in a larger block • How long should the sending TCP wait? • Solution: Nagle’s algorithm • Nagle’s algorithm takes into account (1) the speed of the application program that creates the data (2) the speed of the network that transports the data OER- CN- FDP 201 X 9
Silly Window Syndrome 2. Syndrome created by the Receiver • Receiving application program consumes data slowly (e. g. 1 byte at a time) • The receiving TCP announces a window size of 1 byte. The sending TCP sends only 1 byte… • Solution 1: Clark’s solution • Sending an ACK but announcing a window size of zero until there is enough space to accommodate a segment of max. size or until half of the buffer is empty OER- CN- FDP 201 X 10
Silly Window Syndrome Ø Delayed Acknowledgement • The receiver waits until there is decent amount of space in its incoming buffer before acknowledging the arrived segments • The delayed acknowledgement prevents the sending TCP from sliding its window. It also reduces traffic. • Disadvantage: it may force the sender to retransmit the unacknowledged segments • To balance: should not be delayed by more than 500 ms OER- CN- FDP 201 X 11
TCP Timer Management 1) 2) 3) 4) Retransmission timer is used when expecting an ACK from the other end. Persistence timer keeps window size information flowing even if the other end closes its receiver window. Keep Alive Timer detects when the other end, Idle connection crashes. 2 Maximum Segment lifetimer measures the time a connection has been in the TIME_WAIT state. OER- CN- FDP 201 X 12
TCP Congestion Control OER- CN- FDP 201 X 13
TCP Sliding Windows • Operates at the octet level • Octets of the data stream are numbered sequentially 1 2 3 4 5 6 Octets 1&2 have been sent and acknowledged 7 8 9 10 Octets 7&8 can be sent Octets 3 -6 sent but not acknowledged OER- CN- FDP 201 X 14
TCP Sliding Windows • Four per (full duplex) connection: • • A sends to B A receives from B B sends to A B receives from A OER- CN- FDP 201 X 15
TCP Sliding Windows Flow Control • Each window can vary in size over time • Each ACK contains a window advisement • Specifies how many additional octets of data the receiver is willing to accept • Sender increases or decreases sending window sized based on the receiver’s advise • Provides end-to-end flow control OER- CN- FDP 201 X 16
TCP Sliding Windows Flow Control Example • Sender transmits 3 octets 1 2 3 4 5 6 7 8 9 10 11 12 13 14 • Receives an ACK 3 with window advisement = 3 1 2 3 4 5 6 7 8 9 OER- CN- FDP 201 X 10 11 17
TCP Sliding Windows Flow Control Example (cont) • Receives an ACK 4 with window advisement = 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 • Sender transmits 4 octets 1 2 3 4 5 6 • Receives an ACK 8 with window advisement = 4 1 2 3 4 5 6 7 8 9 OER- CN- FDP 201 X 10 11 18
- Slides: 18