220 likes | 332 Views
Section 5: The Transport Layer. Introduction. In the previous section we looked at the services provided by the network layer and specifically how the Internet uses IP to provide unreliable connectionless packet delivery service.
E N D
Introduction • In the previous section we looked at the services provided by the network layer and specifically how the Internet uses IP to provide unreliable connectionless packet delivery service. • Building on top of this, transport protocols must provide reliable end-to-end communication, independent of the underlying network used. • In order to describe the services provided by the transport layer we will use TCP as an example CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
TCP Services • From an application program’s point of view, the service offered by TCP has seven major features: • Connection Orientation • Point-To-Point Communication • Complete Reliability • Full Duplex Communication • Stream Interface • Reliable Connection Start-up • Graceful Connection Shutdown CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Hence, TCP provides a completely reliable (no data duplication or loss), connection oriented, full-duplex stream transport service that allows two application programs to form a connection, send data in either direction, and then terminate the connection. • Each TCP connection is started reliably and terminated gracefully, with all data being delivered before the termination occurs. CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
TCP and IP • With TCP/IP, irrespective of whether the underlying network is a LAN, WAN, single network, or internetwork, the internet protocol (IP) is always present in the network layer. • Thus, all transport packets (known as segments) are transferred across the underlying network in IP datagrams. • The underlying internet system does not provide hardware support or software support for connections CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Therefore, for TCP to provide an end-to-end protocol, it uses what are known as virtual connections (i.e. connections held in software) • In essence TCP treats IP as a packet communication system that connects hosts at two endpoints of a connection, and IP treats each TCP message as data to be transferred • This idea is shown graphically in the next slide. CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Courtesy of Computer Networks 3rd Ed. by A.S.Tanenbaum, 1994 CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Achieving reliability • Problems: • Unreliable delivery by the underlying communications system, and, system crashes and reboots. • TCP combines a number of different mechanisms to achieve reliability, of which the more prominent are: • Adaptive retransmission • Sliding window for flow control • 3-way handshake for establishing and releasing connections • (We will not cover congestion control) CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Adaptive retransmission • To compensate for packet loss the sender uses a retransmission scheme whereby if a packet is not acknowledged by the receiver in a certain amount of time, the sender assumes it to be lost and retransmits • The delay required for the data to reach a destination and an acknowledgement to return depends on the traffic in the internet and the distance to the destination • In order for the network usage to be optimised TCP adapts to these delays CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
It performs this adaptation policy by building up a sequence of round-trip times for a connection and then performing a statistical analysis of that sequence. • This then allows TCP to accurately estimate the round-trip time (RTT) and set the timeout accordingly. CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Flow Control • To overcome the maximum achievable bandwidth associated with the positive acknowledgement and retransmission, TCP uses a sliding window protocol, which allows several unacknowledged segments to be present in the network. • The next slide show a diagrammatic representation of the technique CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Sliding window 1 2 3 4 5 6 7 8 9 10111213141516171819202122 Back edge of window Bytes already acknowledged Bytes already sent Window size (determined by the recipient) Bytes not yet acknowledged Bytes not sent yet Front edge of window CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Bytes behind the trailing edge of the window have been both transmitted and acknowledged. • Bytes in front of the leading edge of the window have not been sent yet. • To control this sliding window, there are three fields with the TDP header. • The sequence number is placed in the header by the sender and indicates the byte offset within the data stream at which this segment begins CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
The acknowledgement number is used in the acknowledgements returned by the recipient, to indicate which segment is being acknowledged • A third field, called the windowsize field is used in acknowledgement packets to indicate how many more bytes of data (beyond the one that is currently being acknowledged) the recipient is willing to accept before further acknowledgements are sent CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Three-Way Handshake • To guarantee that connection are established or terminated reliable, TCP uses a 3-way handshake in which three message are exchanged (a minimum of 3 message are required to ensure setup or release) • When setting up a connection TCP uses synchronisation segments (SYN segment) • When releasing a segment it uses finish segments (FIN segments) CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Setting up a connection Send SYN Receive SYN Send SYN + ACK Receive SYN + ACK Send ACK CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Accessing TCP Services • Access to the services provided by TCP can only be granted through transport service access points (TSAPs) known as ports. • To use a port a socket must be created and bound to it. • Each socket is addressed by a number made up of the machines IP address and a 16-bit port number local to that host (e.g. 149.157.245.10,23 is the telnet port on csa10) • Port numbers below 1024 are called well-known ports and are reserved for standard services CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Berkeley sockets • One implementation of TCP used in Berkeley UNIX a set of socket primitives described below • SOCKET: Create a new communication end point • BIND: Attach a local address to a socket • LISTEN: Announce willingness to accept connections • CONNECT: Actively attempt to establish a connection • SEND: Send some data over the connection • RECEIVE: Receive some data from the connection • CLOSE: Release the connection CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Building servers • Servers execute the first four primitives in the order given • A successful call to SOCKET return an ordinary file descriptor that may be used in succeeding calls. • BIND assigns an specific address to the newly created socket, at which stage clients who know this address may connect to it • The LISTEN call allows a number of clients to try and connect simultaneously in which case they will be queued for service CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
LISTEN is non-blocking i.e. once called it sets up the queue, tells the TCP to look after it, and returns control to the programs • When the server wishes to accept an incoming connection it executes the ACCEPT call. If a client is waiting a connection is set-up otherwise the call blocks until a client tries to connect. • ACCEPT returns a new file descriptor specifically assigned for communication between the server and the new client CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.
Building clients • When a client wishes to utilise the services of TCP it must also first make a call to SOCKET. In this case however the address of the TSAP does not matter since the client connects to the server (not vice-versa) • Once the socket has been created the CONNECT call asks TCP to make a connection to the server • SEND and RECEIVE may then be used to exchange data • To release a connection a call to CLOSE is made CS 320 - Computer Networks John Mc Donald, Dept. of Computer Science, NUI Maynooth.