Presentation on theme: "Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF."— Presentation transcript:
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF
Transport Layer Transport Layer is an end-to-end layer and supports communication between the end application processes (e.g. client and server processes). A transport protocol is expected to: Guarantee message delivery. Deliver at most one copy of each message. Allow receiver to apply flow control to the sender. Support multiple application processes on each host. Support synchronization between sender and receiver. Support arbitrarily large messages. The Network Layer in the Internet provides a “best effort” service with packets possibly getting lost and being delivered out of sequence. The Transport Layer provides reliable service to the underlying Network Layer. Physical Link Network Transport Application
Transmission Control Protocol (TCP) TCP offers a connection-oriented, reliable, byte-stream oriented service. A TCP entity accepts user data streams from local processes, breaks them up into pieces (called segments) not exceeding 64KB (1500 bytes in practice due to the limit imposed by Ethernet) and sends each segment as a separate IP datagram. IP gives no guarantee that datagrams will be delivered properly, so it is up to TCP to time out and retransmit them as needed. Datagrams may arrive out of sequence and it is up to TCP to reassemble them into messages in the proper sequence.
Transmission Control Protocol (TCP) TCP sends segments in packets (in frames).
TCP Service Model TCP service is obtained by having both sender and receiver create end points of communication, called sockets. Each socket has a socket address consisting of the IP address of the host and a 16-bit port # (local to the host). To obtain TCP service, a connection must be established between a socket on the sending machine and a socket on the receiving machine. Communications are identified by socket identifiers at both ends (e.g. socket1, socket2). Since TCP service is byte-stream oriented, message boundaries are not preserved end-to-end.
TCP Service Model Common socket primitives in UNIX:
TCP When an application passes data to TCP, TCP may send it immediately or buffer it (in order to collect a larger amount to send at once) at its discretion. Pieces of data exchanged between TCP peers are called segments. TCP has three mechanisms by which to trigger the transmission of a segment: As soon it has collected Maximum Segment Size (MSS) bytes from the sending process. (Note: MSS = MTU – TCP Header – IP header = MTU – 20 – 20 = MTU – 40 (default case)). TCP supports a “push” operation, and the sending process invokes this operation to flush the TCP buffer of unsent bytes. A timer is periodically triggered and the resulting segment contains as many bytes as are currently buffered for transmission.
TCP Segment A segment consists of a fixed 20-byte header (plus an optional part) followed by zero or more data bytes. Every byte in a TCP segment has its own 32-bit sequence # (SEQ field in the TCP segment header contains the sequence # of the first byte of data in that segment) Basic protocol used by TCP entities is the Sliding Window Protocol. When a sender transmits a segment, it starts a timer. When the segment arrives at the destination, the receiving TCP entity sends back a segment (with data if any exists, otherwise without data) bearing an ACK # equal to the next sequence # it expects to receive. The segment also advertises a window to the sender indicating the number of bytes the sender is allowed to send (sliding window flow control). If sender’s timer goes off before the ACK is received, sender retransmits the segment again.
Source and Destination Ports (16-bits each): identify the local end points of the connection. SEQ# and ACK# (32-bits each): Sequence # of the first data byte in the segment. ACK # specifies the next byte expected (ACK # = SEQ # + 1). TCP Header Length (4-bits): size of the TCP header in number of 32-bit words. 1-Bit flags (there are 8 of these flags): CWR and ECE: The Explicit Congestion Echo (ECE) and Congestion Window Reduced (CWR) bits are part of the Explicit Congestion Notification (ECN) mechanism. When a router experiences congestion, instead of simply dropping the packet, it tags the 2 LSBs of the Differentiated Services field (sets these bits to 11) in the IP header, which implies that congestion was experienced. The receiving host echoes/sends a TCP segment to the sending host with ECE = 1. The sending host then cuts its congestion window (part of the Jacobson’s algorithm) as though a timeout had occurred and sends TCP segments with CWR = 1. Then sender stops responding to further segments with ECE = 1.
TCP Segment Header 1-Bit flags (continued): URG: When set, it implies that this segment contains urgent data. The Urgent Pointer field indicates where the non-urgent data contained in this segment begins (e.g. Ctrl-C to kill a process in TELNET/SSH). ACK: Set to 1 indicates that the ACK # field is valid. PSH: Indicates pushed data (e.g. in TELNET/SSH). This indicates to the receiving TCP entity to deliver data to the application process upon arrival and not to buffer it for reasons of efficiency as it generally might) RST: To abort a connection because a receiver has become confused (e.g. it received a segment it did not expect to receive). SYN: Used to establish connections. The Connection Request segment has SYN=1, ACK=0. The Connection Accepted segment has SYN=1, ACK=1. FIN: To release a connection. Specifies that a sender has no more data to send.
TCP Segment Header Window Size (16-bits): indicates how many bytes may be sent starting at the byte acknowledged. This is sent by the receiver to the sender and represents a variable sized sliding window. Checksum (16-bits): Provided for extreme reliability. It checksums the header, data, and the pseudo-header shown below. Including the pseudo- header in the TCP checksum computation helps detect misdelivered packets. Options: Allows each host to specify the maximum TCP payload it is willing to accept (all Internet hosts are required to accept TCP segments of 536 + 20 = 556 bytes).