190 likes | 307 Views
Overview. This Lecture Internet Protocols (4) Source: chapter 15 This Lecture TCP/UDP (1) Source: chapter 17 Next Lecture TCP/UDP (2) Source: chapter 17. Transport layer. The transport layer is at the heart of the whole protocol hierarchy
E N D
Overview • This Lecture • Internet Protocols (4) • Source: chapter 15 • This Lecture • TCP/UDP (1) • Source: chapter 17 • Next Lecture • TCP/UDP (2) • Source: chapter 17
Transport layer • The transport layer is at the heart of the whole protocol hierarchy • It is the first layer which does not involve intermediate nodes. It just involves end-to-end communication. • Its task is to provide a reliable, cost-effective data transport from the source machine to the destination machine, independent of the physical networks in use • There are two types of transport services: connection-oriented and connectionless, similar to the corresponding network services
Transport layer • Functions of transport layer • Connection management • set-up and release connections • Flow and error control • Error detection • Why error detection is needed in transport layer, given the data link layer has done it hop by hop? • Intermediate nodes/routers may cause errors while processing packets • The software within the transport layer that does the work is called the transport entity
Transport layer • Why are there two distinct layers, i.e., network and transport layers? • Network layer is part of the communication subnet and is run by the carriers • The network layer may offer connection-oriented service which may be unreliable • The users have no control over the subnet, so the only possibility to improve the quality of service is to put another layer on top of the network layer • The transport service interface for the higher layer can be designed to be independent of the network service interface, which may vary considerably from network to network • The primary function of the transport layer can be regarded as enhancing the quality of service provided by the network layer • Transport Protocol Data Unit (TPDU) is used to name the messages sent between transport entities
Transport layer • Transport layer uses primitives, provided by network layer, to send and receive data • Transport entities use NL_send(TPDU, NL_address) and NL_recv(TPDU) to send/receive TPDU • TPDU is put in the payload of network packet which is put in the payload of data link frame • TPDU in TCP is called TCP segment, packet in IP is called IP packet
QoS • Quality of Service (QoS) should be supported in the transport layer • QoS can be charaterized by a number of parameters, such as the parameters in flow specification • Throughput, transit delay, error ratio • The transport service allows the user to specify preferred and minimum unacceptable values for these parameters at the time a connection is set up • Some of the parameters also apply to connectionless transport • It is up to the transport layer to examine these parameters, and depending on the kind of network services available to it, determine whether it can provide the required service
QoS negotiation • The transport user makes a proposal on some QoS parameters • The transport layer may immediately realize that some of them are unacceptable and report failure (together with the reasons) to the users • If the transport layer can not achieve the desired goal (e.g. 600 Mbps throughput), but it can achieve a lower but still acceptable one (150Mbps), it then sends the lower rate and the minimum acceptable rate to the destination • The destination machine may change the QoS to an acceptable level or reject the connection attempt • Finally the originating transport user is informed of the result
Transport service • Two main differences between the transport service and the network service • The network service is intended to model the service offered by real (unreliable) networks, while the (connection-oriented) transport service is reliable • The network service is used only by the transport entities, while the transport service is used by application programs directly and must be convenient and easy to use • The transport service provides (interface) primitives to allow application programs to access the transport service • LISTEN: wait for a connection • CONNECT: initiate a connection • SEND: send data • RECEIVE: get data or wait for data • DISCONNECT: initiate a release
Example • Example • consider an application with a server and a number of remote clients
Transport layer operation • Connection establishment • The server executes a LISTEN primitive, which blocks the server until a client turns up • A client executes a CONNECT primitive, which blocks the client , and send a TPDU (encapsulating the information of the connection request) to the server via the underlying network layer • When the TPDU arrives at the server side, the transport entity checks to see that the server is blocked on a LISTEN (i.e. interested in handling a connection request). • It then unblocks the server and sends a CONNECTION ACCEPTED TPDU back to the client • When this TPDU arrives at the client side, the client is unblocked and the connection is established • 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 method normally used is to define transport addresses to which processes can listen for connection requests • In Internet, transport addresses are (IP address, local port) pairs
Transport layer operation • Data exchange • Either party can do a (blocking) RECEIVE to wait for the other party to do a SEND • When the DATA TPDU arrives, the receiver is unblocked • As long as both sides can keep track of whose turn it is to send, this scheme works fine • Each TPDU sent will be (eventually) acknowledged. These acknowledgements, timers, and re-transmissions are managed by the transport entities using the network layer protocol and are not visible to the transport users • Connection release • Asymmetric disconnection: either transport user can issue a DISCONNECT primitive, which results in a DISCONNECT TPDU being sent to the remote transport entiry. Upon arrival, the connection is released • Symmetric disconnection: when one side does a DISCONNECT, that means it has no more data to send, but is still willing to accept data from its partner. A connection is released when both sides have done a DISCONNECT
Problems in connection setup • Simple connection (two-way handshake) • Entity 1 send a TPDU to entity 2, saying “good morning, I would like to talk with a process with port number pn” • Entity 2 receives the TPDU and ask the process if it accept the request • If the process agrees, entity 2 sends a TPDU saying “ok, you can talk now”, and connection is established • Problem with establishing a connection occurs when the subnet can lose, store, and duplicate packets • Consider the following scenario • A user establishes a connection with a bank • Sends messages telling the bank to transfer a large amount of money to the account of a not entirely trustworthy person • And then releases the connection • What happens if all packets in the above process are duplicated and stored in the subnet?
Solution for connection problem • Unique sequence number • To avoid the problem, each TPDU uses a sequence number and is acknowledged • The sequence number is determined using a counter and ensured to be different from the sequence number or acknowledged number of existing TPDU wandering in the network • Three-way handshake protocol • Transport entity A transmits a connection request (in a TPDU) which is accompanied by different sequence number x • When entity B receives the request, it sends A a connection acceptance TPDU acknowledging the sequence number x and initiates a new sequence number y • Entity A acknowledges the acceptance with the sequence number y
Examples • How three-way handshaking can prevent false connection requests
Disconnect • Asymmetric release is abrupt and may result in data loss • Symmetric release • One way to avoid data loss is to use symmetric release, in which each direction is released independently of the other • A host can continue to receive data even after it has sent a DISCONNECT TPDU • The symmetric release acts as below • A says:”I am done. Are you done too?” • If B responds:”I am done too. Bye.” • Then the connection can be safely released • This way does not always work
Disconnect • The two-army problem • A white army is encamped in a valley • On both of the surrounding hillsides are blue armies • The white army is larger than either of the blue armies alone, but together they are larger than the white army • If either blue army attacks by itself, it will be defeated, but if the two blue armies attack simultaneously, they will be victorious • The communication medium between the two blue armies is to send messengers on foot down into the valley, where they might be captured and the message lost • The question is, does a protocol exist that allows the blue armies to win absolutely? • The answer is that NO.
Disconnect • The same answer applies to the absolutely safe disconnection • Just substitute “disconnect” for “attack”. If neither side is prepared to disconnect until it is convinced that the other side is prepared to disconnect too, the disconnection will never happen • In practice, one is usually prepared to take more risks when releasing connections than attacking white armies, so the situation is not entirely hopeless
Disconnect • Three-way handshake combined with a timer • Timer is used: if there is no TPDU from the other party for some time, disconnect anyway • The protocol can fail if the initial DR and n retransmissions are all lost: the sender will give up and delete the connection, while the other side knows nothing about the attempts to disconnect and is still fully active • This situation is called half-open connection
Summary • Concepts • Transport layer • Transport entity • Transport address • TPDU • QoS • Two-army problem • Differences between transport layer and network layer • Connection establishment and release • three-way handshake protocol for connection establishment • Three-way handshake combined with timer for connection release