The Transport Layer
Transport layer is responsible for maintaining flow of control. The transport layer takes the data from each application, and integrates it all into a single stream. This layer is also responsible for providing error checking and performing data recovery when necessary. In essence, the Transport layer is responsible for ensuring that all of the data makes it from sending host to receiving host.
It deals with data transport issues between systems. It offers reliability, establishes virtual circuits, detects/recovers from errors, and provides flow control.
How OSI model works?
The OSI reference model is actually used to describe how data that is generated by a user, such as email message, moves through a number of intermediary forms until it is converted into a stream of data that can actually be placed on the network media and sent out over the network. The model also describes how a communication session is established between two devices, such as two computers, on the network.
Since other types of devices, such as printers and routers, can be involved in network communication, devices(including computers) on the network are actually referred to as nodes. Therefore, a client computer on the network or a server on the network would each be referred to as a node.
While sending data over a network, it moves down through the OSI stack and is transmitted over the transmission media. When the data is received by a node, such as another computer on the network, it moves up through the OSI stack until it is again in a form that can be accessed by a user on that computer.
Each of the layers in the OSI model is responsible for certain aspect of getting user data in to a format that can be transmitted on the network. Some layers are for establishing and maintaining the connection between the communicating nodes, and other layers are responsible for the addressing of the data so that it can be determined where the data originated (on which node) and where the data’s destination is.
An important aspect of the OSI model is that each layer in the stack provides services to the layer directly above it. Only the Application Layer, which is at the top of the stack, would not provide services to a higher-level layer.
The process of moving user data down to OSI stack on a sending node (again, such as a computer) is called encapsulation. The process of moving raw data received by node a node up the OSI stack is referred to as de-encapsulation.
To encapsulate means to enclose or surround, and this is what happens to data that is created at the application layer and then moves down through the other layers of OSI model. A header, which is a segment of information affixed to the beginning of the data, is generated at each layer of the OSI model, except for the physical layer. This means that the data is encapsulated in succession of headers - first the Application layer header, then Presentation layer header, and so on. When the data reaches the physical layer, it is like a candy bar that has been enclosed in several different wrappers.
When the data is transmitted to a receiving node, such as a computer, the data travels up the OSI stack and each header is stripped off of the data. First, the Dala Link layer header is removed, then the Network layer header, and so on. Also, the headers are not just removed by receiving computer; the header information is read and used to determine what the receiving computer should do with the received data at each layer of OSI model.
In OSI model, the sending computer uses these headers to communicate with the receiving computer and provide the receiving computer with useful. As the data travels up the levels of the peer computer, each header is removed by its equivalent protocol. These headers contain different information depending on the layer they receive the header from , but tell the peer layer important information, including packet size, frames, and datagrams.
Control is passed from one layer to the next, starting at the application layer in one station and proceeding to the bottom layer, over the channel to the next station and back up the hierarchy. Each layer’s header and data are called packages. Although it may seem confusing, each layer has a different name for its service data unit.
The TCP/IP model is a networking model with a set of communication protocols for the Internet and similar networks. It is commonly known as TCP/IP, because its Transmission Control Protocol (TCP) and Internet Protocol (IP) were the first networking protocol defined in this model. The TCP/IP model, similar to OSI model, has a set of layers. The OSI has seven layers and the TCP/IP has four or five layers depending on the different preferences. Some people use the Application, Transport, Internet and Network Access layer. Others split the Network Access layer into the Physical and data link components. The OSI model and the TCP/IP models were created independently. The TCP/IP network model represents reality in the world, whereas the OSI mode represents an ideal.o
Transport Layer in TCP/IP model
Transport layer (also called Host-to-Host protocol) in the TCP/IP model provides more or less the same services with its equivalent Transport layer in the OSI model. This layer acts as delivery service used by the application layer. Again the two protocols used are TCP and UDP. The choice is made based on the application’s transmission reliability requirements. It also ensures that the data arrives at the application on the host for which it is targeted. Transport layer manages the flow of traffic between two host or devices. The transport layer also handles all error detection and recovery. It uses checksums, acknowledgements, and timeouts to control transmission and end to end verification.
- Provides communication session management between the nodes/computers.
- Defines the level of service and status of the connection used when transporting data.
TCP and UDP
Computers running on internet communicate to each other using either the transmission control protocol (TCP) or the User Datagram Protocol (UDP). When we write Java programs that communicate over the network, we are programming at the application layer. Typically, we don’t need to concern with the TCP and UDP layers. Instead, we can use the classes in the java.net package. These classes provide system-independent networks communication. However, to decide which java classes our program should use, we do need to understand how TCP and UDP differ.
TCP [Transmission Control Protocol]
When two applications want to communicate to each other reliably, they establish a connection and send data back and forth over the connection. This is analogous to making a telephone call. If we want to speak to a person who is in another country, a connection is established when we dial the phone number and the other party answers. We send data back and forth over the connection by speaking to one another over the phone lines. Like the phone company, TCP guarantees that data sent from one end of the connection actually gets to the other end and in the same order it was sent. Otherwise, an error is reported.
TCP provides a point-to-point channel for applications that require reliable communications. The HTTP, FTP and Telnet are all examples of application that require a reliable communication channel. The order in which the data is sent and received over the network is critical to the success of these applications. When HTTP is used to read from a URL, the data must be received in the order in which is was sent. Otherwise, we end up with a jumbled HTML file, a corrupt zip file, or some other invalid information.
Definition: TCP is a connection-based protocol that provides a reliable flow of data between two computers.
Transport protocols are used to deliver information from one port to another and thereby enable communication between application programs. They use either a connection-oriented or connectionless method of communication. TCP is a connection oriented protocol and UDP is a connectionless transport protocol.
The reliability of communication between the source and destination programs is ensured through error-detection and error-correction mechanism that are implemented with TCP. TCP implements the connection as a stream of bytes from source to destination. This feature allows the use of the stream I/O classes provided by java.io.
UDP [User Datagram Protocol]
The UDP protocols provides for communication that is not guaranteed between two applications on the network. UDP is not connection-based like TCP. But, it sends independent packets of data (called datagrams) from one application to another. Sending datagrams is much like sending a letter through the postal service: The order of delivery is not important and is not guaranteed, and each message is independent of any other.
Definition: UDP is a protocol that sends independent packets of data, called datagrams, from one computer to another with no guarantees about arrival UDP is not connection-based.
For many applications, the guarantee of reliability is critical to the success of the transfer of information from one end of the connection to the other. However, other forms of communication don’t require such strict standards. In fact, they may be slowed down by the extra overhead or the reliable connection may invalidate service altogether.
Consider, for example, a clock server that sends the current time to its client when required to do so. If the client misses a packet, it doesn’t really make sense to resend it because the time will be incorrect when the client receives it one the second try. If the client makes two requests and receives packets from the server out of order, it doesn’t really mater because the client can figure out that the packets are out of order and make other request. The reliability of TCP is unnecessary in this instance because it causes performance degradation and many hinder the usefulness of the service. Another example of a service that doesn’t need the guarantee of a reliable channel is the ping command. The purpose of the ping command is to test the communication between two programs over the network. In fact, ping needs to know about dropped or out-of-order packets to determine how good or bad the connection is. A reliable channel would invalidate this service altogether.
The UDP connectionless protocol differs from the TCP connection-oriented protocol in that it doesn’t establish a link for the duration of the connection. An example of a connectionless protocol is postal main. TO main something, you just write down a destination address (and an option return address) on the envelope of the item you’re sending and drop it in a mailbox. When using UDP, an application program writes the destination port and IP address on a datagram and then sends the datagram to its destination. UDP is less reliable than TCP because there are no delivery-assurance or error-detection and error-correction mechanisms built into the protocol. Application protocol such as FTP, SMTP, HTTP use TCP to provide reliable stream-based communication between client and server programs. Other protocols, such as the Time protocol, use UDP because speed of delivery is more important that end-to-end delivery.