Transportlayer is residing between the application and network layers which is a centralpiece of layered network architecture. It has the role of providingcommunication services directly to the application processes running on different hosts. In this chapter, wewill discuss about:
- UDP and TCP transport-layer protocols.
- The relationship between the transport and network layers.
- How two entities can communicate reliably over a medium that may lose and corrupt data.
- How to control the transmission rate of transport-layer entities in order to avoid, recover from, congestion within the network.
3.1 Introduction and Transport-Layer Services
- A transport-layer protocol provides for logical communication between application processes running on different hosts. This logical communication means that the hosts running the processes are directly connected (looks like directly connected).
- Transport-layer protocols are implemented in the end systems but not in network routers. On the sending side, the transport layer converts the application-layer messages it receives from a sending application process into transport-layer packets (also known as transport-layer segments). This is done(possibly) breaking the application messages into smaller chunks and adding a transport-layer headers to each chunk to create the transport -layer segment. The transport-layer then passes the segment to the network layer at the sending end system, where the segment is encapsulated within a network-layer packet (datagram) and sent to the destination. The network routers act only on the network-layer fields of the datagram. (They do not examine the fields of the transport-layer segment). On the receiving side, the network layer extracts the transport-layer segment from the datagram and passes the segment to the transport layer.
- TCP and UDP
3.1.3Relationship Between Transport and Network Layers
- Transport layer lies just above the network layer
- Whereas a transport-layer protocol provides logical communication between processes running on different hosts, a network-layer protocol provides logical communication between hosts.
3.1.2Overview of the Transport Layer in the Internet
- UDP provides an unreliable, connectionless service to the invoking application.
- TCP provides a reliable, connection-oriented service to the invoking application.
- The network layer has a IP protocol which provides best-effort deliver service, but it makes no guarantees. (not guarantee the integrity, not guarantee the order of the segments, not guarantee the segment delivery) IP is said to be an unreliable service. Each host has an IP address.
- UDP and TCP extend IP's delivery service between two end systems delivery to two processes running on the end systems. This is called transport-layer multiplexing and demultiplexing.
- UDP and TCP also provide integrity checking by including error detection fields in their segments' headers.
- Process-to-process service and error detection are the only two services that UDP provides.
- TCP provides reliable data transfer (using flow control, sequence numbers, acknowledgments, and timers). Thus, TCP ensures that data is delivered from sending process to receiving process, correctly and in order. TCP also provide congestion control.
- TCP congestion control prevents any one TCP connection from swamping the links and routers between communication hosts with an excessive amount of traffic. It also strives to give each connection traversing a congested link an equal share of the link bandwidth.
3.2 Multiplexing and Demultiplexing
Multiplexingand demultiplexing service is needed for all computer networks.
Thequestion is how to direct the received data to the specific process?
- A process can have one or more sockets where is the door between the process and the network. These sockets act as intermediary tools.
- Each transport-layer segment has a set of fields in the segment for this purpose. At the receiving end, the transport layer examines these fields to identify the receiving socket and then directs the segment to that socket. This job is called demultiplexing.
- For multiplexing, the sending side will gather data chunks at the source host from different sockets, encapsulating each data chunk with header information to create segments, and passing the segments to the network layer.
From thediscussion above, we known that transport-layer multiplexing requires
- Sockets have unique identifiers
- Each segment has special fields that indicate the socket to which the segment is to be delivered. These special fields are the source port number field and the destination port number field.
Featuresof the port number:
- Each port number is a 16-bit number, ranging from 0 to 65535
- The port numbers ranging from 0 to 1023 are called well-known port number and are restricted, which means that they are reserved for use by well-known application protocols such as HTTP (80) and FTP (21)
In UDP,each socket in the host could be assigned a port number, and when a segmentarrives at the host, the transport layer examines the destination port numberin the segment and directs the segment to the corresponding socket. Thesegment's data then passes through the socket into the attached.
- Suppose a process in Host A, with UDP port 19157, wants to send a chunk of application data to a process with UDP port 46428 in Host B
- The transport layer in Host A creates a transport-layer segment that includes the application data, the source port number, the destination port number, and two other values
- The transport layer then passes the resulting segment to the network layer
- The network layer encapsulates the segment in an IP datagram and makes a best-effort attempt to deliver the segment to the receiving host
- The segment arrives at the receiving Host B
- The transport layer at the receiving host examines the destination port number in the segment and delivers the segment to its socket
- A UDP socket is fully identified by a two-tuple consisting of a destination IP address and a destination port number. Thus, if two UDP segments have different source IP address and source port numbers, but have the same destination IP address and destination port number, then the two segments will be directed to the same destination process via the same destination socket
Connection-Oriented Multiplexing and Demultiplexing
A TCPsocket is identified by a four-tuple: (source IP address, source port number,destination IP address, destination port number). Thus, when a TCP segmentarrives from the network to a host, the host uses all four values to direct thesegment to the appropriate socket. Thus, two arriving TCP segments withdifferent source IP addresses or source port numbers will be directed to twodifferent sockets.
A TCPserver application has a "welcoming socket" that waits forconnection-establishment requests. When it accept a connection, the serverprocess then creates a new socket. The newly created connection socket isidentified by these four values. All subsequently arriving segments whosevalues matches will be demultiplexed to thissocket.
Persistent HTTP and non-persistent HTTP
- If the client and server are using persistent HTTP, then throughout the duration of the persistent connection the client and server exchange HTTP messages via the same server socket.
- If the client and server use non-persistent HTTP, then a new TCP connection is created and closed for every request, and hence a new socket is created and later closed for every request.