1.22k likes | 1.36k Views
CEN 4500 Data Communications. Chapter 6: The Transport Layer. Instructor: S. Masoud Sadjadi http://www.cs.fiu.edu/~sadjadi/Teaching/ sadjadi At cs Dot fiu Dot edu. Recap: Transport Layer. Transport layer is not just another layer. It is the heart of the whole protocol hierarchy.
E N D
CEN 4500 Data Communications Chapter 6: The Transport Layer Instructor: S. Masoud Sadjadi http://www.cs.fiu.edu/~sadjadi/Teaching/ sadjadi At cs Dot fiu Dot edu
Recap: Transport Layer • Transport layer is not just another layer. It is the heart of the whole protocol hierarchy. • Its task is to provide reliable, cost-effective data transport from source machine to the destination machine (hence, end-to-end), independently of the physical network or networks currently in use. • Accepts data from above, split it up into smaller units if need be, pass these to the network layer, and ensures that the pieces all arrive correctly at the other end. CEN 4500, S. Masoud Sadjadi
Agenda • The Transport Service • Elements of Transport Protocol • A Simple Transport Protocol • The Internet Transport Protocol: UDP • The Internet Transport Protocol: TCP • Performance Issues • Summary CEN 4500, S. Masoud Sadjadi
The Transport Service • Services Provided to the Upper Layers • Transport Service Primitives • Berkeley Sockets • An Example of Socket Programming: • An Internet File Server CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers • Goal • To provide efficient, reliable, and cost-effective service to its users, normally processes in the application layer. • To achieve this, transport layer makes use of the services provided by the network layer. • The hardware/software within the transport layer that does the work is called the transport entity. • Can be located in the operating system kernel, in a separate user process, in a library package bound into network applications, or on the network interface card. CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers The network, transport, and application layers. CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers • Similar to the type of services in the network layer, there are two types of transport services: • Connection-Oriented Service • Connection establishment, data transfer, and release. • Addressing, flow control, etc. • Connectionless Service • Also very similar to NL. • Then why two layers? What is the difference? • The transport code runs entirely on the users’ machines, but the network layer mostly runs on the routers, which are typically operated by one or more carriers. CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers Relation between hosts on LANs and the subnet. A stream of packets from sender to receiver. CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers The OSI reference model. CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers • So, what happens if the network layer provide inadequate service? For example, what if the subnet loses packets frequently. • The users have no real control over the network layer, so they cannot solve the problem of poor service by using better routers or putting more error handling in the data link layer! • The only possibility is to put on top of the network layer another layer that improves the quality of the service according to the users’ preference. CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers • Why do we need transport layer? (cont.) • The network service calls may vary considerably from network to network. • Transport layer provides a network independent layer by hiding the network service behind a set of transport service primitives. • This way, changing the network service merely requires replacing one set of library procedures by another one • that basically does the same thing, but with a different underlying service. • Therefore, application programmers can write code according to a standard set of primitives and portable on variety of networks. CEN 4500, S. Masoud Sadjadi
Services Provided to the Upper Layers • Revisiting the hybrid reference model • The bottom four layers are transport service provider, whereas the upper layer(s) are the transport service user. • Therefore, the transport layer forms the major boundary between the provider and user of the reliable data transmission service. transport service user transport service provider CEN 4500, S. Masoud Sadjadi
The Transport Service • Services Provided to the Upper Layers • Transport Service Primitives • Berkeley Sockets • An Example of Socket Programming: • An Internet File Server CEN 4500, S. Masoud Sadjadi
Transport Service Primitives • To allow users to access the transport service, the transport layer must provide some operations to application programs • That is, a transport service interface. • Types of services • Connection-oriented service • Connectionless service CEN 4500, S. Masoud Sadjadi
Transport Service Primitives The primitives for a simple transport service. • Example: A Connection-Oriented Client-Server App. • Connection Establishment • The server executes a LISTEN primitive • Typically by calling a library procedure that make a system call to block the server until a client turns up. • When a client wants to talk to the server, it executes a CONNECT primitive. • The transport entity blocks the caller and sends a packet to the server. • A CONNECTION REQUEST TPDU is sent to the server. CEN 4500, S. Masoud Sadjadi
Transport Service Primitives The nesting of transport protocol data units (TPDUs), packets, and frames. CEN 4500, S. Masoud Sadjadi
Transport Service Primitives • Example: A Client-Server Application (cont.) • Connection Establishment (cont. • When the CONNECTION REQUEST TPDU arrives at the server transport entity, it checks to see if the server is blocked on a LISTEN. • It then unblocks the server and sends a CONNECTION ACCEPTED TPDU back to the client. • When the client transport entity receives this TPDU, it unblocks the client and the connection is now established. • Data Exchange • Data can now be exchanged using the SEND and RECEIVE primitives. • Either party can do a (blocking) RECEIVE to wait for the other party to do a SEND • When the TPDU arrives, the receiver is unblocked and … • This works as long as the two sides can keep track of the turns. • Connection Termination • When a connection is no longer needed, it must be released to free table space within the two transport entities. CEN 4500, S. Masoud Sadjadi
Transport Service Primitives • Connection Termination Types • Asymmetric • Either of the two transport user can issue a DISCONNECT primitive. • This results in a DISCONNECT TPDU being sent • Upon its arrival, the connection is released • Symmetric • Each direction is closed separately (independently). • When one side is disconnected, it does not mean that the other side has no more data to transmit. • So, a connection is released when both side disconnect. CEN 4500, S. Masoud Sadjadi
Transport Service Primitives A state diagram for a simple connection management scheme. Transitions are caused either by primitive execution ( ) or by packet arrivals (labeled in italics, ). The solid lines show the client's state sequence. The dashed lines show the server's state sequence. CEN 4500, S. Masoud Sadjadi
The Transport Service • Services Provided to the Upper Layers • Transport Service Primitives • Berkeley Sockets • An Example of Socket Programming: • An Internet File Server CEN 4500, S. Masoud Sadjadi
Berkeley Sockets The socket primitives used in Berkeley UNIX for TCP. CEN 4500, S. Masoud Sadjadi
Berkeley Sockets • Sever Side • The first four primitives in the list are executed in that order by servers. • The SOCKET primitive • creates a new end point and allocates table space for it within the transport entity. • The parameters of the call specify the addressing format to be used, the type of service desired, and the protocol. • A successful SOCKET call returns an ordinary file descriptor for use in succeeding calls • The BIND primitive • assigns a newly-created socket to a network address • The reason for doing the address binding through as separate call is that some servers want to used a predefined (fixed) address and some do not really care. • The LISTEN primitive • would allocate space to queue incoming calls for the case that several clients try to connect at the same time. • It is not a blocking call. CEN 4500, S. Masoud Sadjadi
Berkeley Sockets • Sever Side (cont.) • The ACCEPT primitive • Blocks the server for an incoming connection • When a TPDU asking for a connection arrives, the transport entity creates a new socket with the same properties as the original one and returns a file descriptor for it. • The server can then fork off a process or thread to handle the connection on the new socket and go back to waiting for the next connection on the original socket. • ACCEPT returns a normal file descriptor, which can be used for reading and writing in the standard way, the same as for files. • Client Side • First the SOCKET and then CONNECT (BIND not necessary). • Server and Client • Use SEND/RECV to transmit/receive data (full-duplex conn.) • Or use WRITE/READ, if none of the special options are required. • Use CLOSE for releasing the connection (symmetric). CEN 4500, S. Masoud Sadjadi
The Transport Service • Services Provided to the Upper Layers • Transport Service Primitives • Berkeley Sockets • An Example of Socket Programming: • An Internet File Server CEN 4500, S. Masoud Sadjadi
Socket Programming Example:Internet File Server Client code using sockets. Command line: > cc –o client client.c –lsocket > client goliath.cs.fiu.edu \ /usr/sadjadi/passworkFile.txt > HeHeHe CEN 4500, S. Masoud Sadjadi
Socket Programming Example:Internet File Server (2) Server code using sockets. Command line: > cc –o server server.c –lsocket –lnsl > Server CEN 4500, S. Masoud Sadjadi
Agenda • The Transport Service • Elements of Transport Protocol • A Simple Transport Protocol • The Internet Transport Protocol: UDP • The Internet Transport Protocol: TCP • Performance Issues • Summary CEN 4500, S. Masoud Sadjadi
Elements of Transport Protocols • The transport service is implemented by a transport protocol used between the two transport entities. • It resembles the data link protocols • Both have to deal with error control, sequencing, and flow control, among other issues. • What is the difference with the data link? • At the data link layer, two routers communicate directly via a physical channel. • At the transport layer, the physical channel is replaced by the entire subnet. CEN 4500, S. Masoud Sadjadi
Transport Protocol (a) Environment of the data link layer. (b) Environment of the transport layer. CEN 4500, S. Masoud Sadjadi
Elements of Transport Protocols • What is the difference with the data link? • Addressing • Data link layer: it is not necessary for a router to specify which router it wants to talk to—each outgoing line uniquely specifies a particular router. • Transport layer: explicit addressing of destinations is required. • Connection Establishment • Data link layer: The process is simple as the other end is either always there or it is crashed! • Transport layer: Initial connection establishment is much more complicated. • Storage in the Subnet • Data link layer: When a router sends a packet, it may arrive or be lost, but it cannot bounce around for a while. • Transport layer: If the subnet uses datagrams and adaptive routing inside, there is a non-negligible probability that a packet may be stored for a number of seconds and then delivered later. • Flow Control and Buffering • Data link layer: required in both layers. • Transport layer: Presence of a large and dynamically varying number of connections. CEN 4500, S. Masoud Sadjadi
Elements of Transport Protocols • Addressing • Connection Establishment • Connection Release • Flow Control and Buffering • Multiplexing CEN 4500, S. Masoud Sadjadi
Addressing • When an application process wishes to set up a connection to a remote application process, it must specify which one to connect to. • The problem exists for a connectionless transport as it needs to know which process the messages should be delivered to. • The method normally used is to define transport addresses to which processes can listen for connection requests. • In the Internet, these end points are called ports. • The generic term is Transport Service Access Point (TSAP) for transport layer addresses and NSAP for network addresses. • This way, two or more processes using the same NSAP can be distinguished through TSAP. CEN 4500, S. Masoud Sadjadi
Addressing TSAPs, NSAPs and transport connections. CEN 4500, S. Masoud Sadjadi
Addressing • Initial Connection Protocol • Problem: Assume that there are many server processes and most of which are rarely used; therefore, it is wasteful of resources to have each of them active and listening to a stable TSAP address all the time. • Solution: A special process server that acts as a proxy for less heavily used servers that receives all connections requests that no server is waiting for them. This process server spawns the requested server and allows it to inherit the existing connection with the user. CEN 4500, S. Masoud Sadjadi
Addressing • How a user process in host 1 establishes a connection with a time-of-day server in host 2. CEN 4500, S. Masoud Sadjadi
Elements of Transport Protocols • Addressing • Connection Establishment • Connection Release • Flow Control and Buffering • Multiplexing CEN 4500, S. Masoud Sadjadi
Connection Establishment • Connection establishment is not as easy as it sounds! • If the network can lose, store, and duplicate packets, then we have a problem! • Example • A user establishes a connection with a bank • Sends a message to the bank asking to transfer a large amount of money to the account of a not-entirely-trustworthy person • Then the user releases the connection. • Assume that each packet is duplicated and stored in the subnet • The duplicate packets pop up in the bank with the right order! CEN 4500, S. Masoud Sadjadi
Connection Establishment • Three-Way Handshake • Host1 chooses a sequence number, x, and sends a CONNECTION REQUEST TPDU to host 2. • Host2 replies with an ACK TPDU acknowledging x and announcing its own initial sequence number, y. • Host1 acknowledges Host2’s choice of an initial sequence number in the first data TPDU that is sends. CEN 4500, S. Masoud Sadjadi
Connection Establishment Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. (a) Normal operation, (b) Old CONNECTION REQUEST appearing out of nowhere. (c) Duplicate CONNECTION REQUEST and duplicate ACK. CEN 4500, S. Masoud Sadjadi
Elements of Transport Protocols • Addressing • Connection Establishment • Connection Release • Flow Control and Buffering • Multiplexing CEN 4500, S. Masoud Sadjadi
Connection Release • Releasing a connection is easier than establishing one • Types of connection release • Asymmetric • Like telephone system • May result in data loss (see next slide). • Symmetric • Treats the connection as two separate unidirectional connections. • Each direction is released independent of the other one. • Determining when all the work is done to disconnect is not obvious (two-army problem). CEN 4500, S. Masoud Sadjadi
Connection Release Abrupt disconnection with loss of data. CEN 4500, S. Masoud Sadjadi
Connection Release • The two-army problem. • The white army is larger than either of the two blue armies. • The blue armies need to synchronize their attacks. • How about three-way handshake? How about four-way? • In practice, one is usually prepared to take more risks! CEN 4500, S. Masoud Sadjadi Unreliable communication channel
Connection Release Four protocol scenarios for releasing a connection. • Normal case of a three-way handshake. (b) final ACK lost. The situation is saved by a timer. 6-14, a, b CEN 4500, S. Masoud Sadjadi
Connection Release (c) Response lost. We use timeout. (d) Response lost and subsequent DRs lost. After N retries, the senders gives up and disconnects. CEN 4500, S. Masoud Sadjadi
Elements of Transport Protocols • Addressing • Connection Establishment • Connection Release • Flow Control and Buffering • Multiplexing CEN 4500, S. Masoud Sadjadi
Flow Control and Buffering • The main difference with data link is that the router has only a few lines, but a host may have numerous connections. • This difference makes it impractical to implement the data link buffering strategy in the transport layer. • The receiver may, for example, maintain a single buffer pool shared by all connections. • Recall that the sender cannot trust the network layer’s acknowledgement, because the acknowledgement means only that the TPDU arrive, not that it was accepted! CEN 4500, S. Masoud Sadjadi
Flow Control and Buffering (a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per connection. CEN 4500, S. Masoud Sadjadi
Elements of Transport Protocols • Addressing • Connection Establishment • Connection Release • Flow Control and Buffering • Multiplexing CEN 4500, S. Masoud Sadjadi
Multiplexing • Multiplexing several conversations onto connections, virtual circuits, and physical links plays a role in several layers. • When a TPDU comes in, there should be a way to tell which process to give it to. • This situation is called upward multiplexing • If a user needs more bandwidth than one virtual circuit can provide, a way out Is to open multiple network connections and distribute the traffic among them • This situation is call downward multiplexing CEN 4500, S. Masoud Sadjadi