Transport Layer
Transport layer is used to transfer data between the end to end user, ensuring a reliable communication. It has two main protocols, TCP and UDP.
TCP is connection oriented protocol, in which each computer sends acknowledge to every data it received. It is used in messaging app which ensure that the sent message has been received by the other user.
UDP is connection-less protocol, in which the computer does not wait for the acknowledge from the other computer. Example, streaming a video on youtube.
Port
Port is a 16 bit number that is used to direct traffic to the specific services that is running on a computer network. For example, the port 80 denotes the web service (http). 1-1023 ports are called as the system ports. 1024-49151 ports are called as the registered ports. These ports are used by the users for their own server applications. Remaining all are Dynamic ports.
Firewall
Firewall is used to block traffic, that doesn’t met the certain criteria. For example, the server opens the port 80 for listening http request and denied access to other request like FTP(21). So, when a user request for the port 21, the firewall will automatically deny the access at the entry level
Application Layer.
In OSI model, the application layer is further divided into 3 Session, Presentation and Application. Session layer is used for opening, closing, establishing and terminating session between the end to end application. Presentation layer is used for formatting and converting data and ensuring whether the data is presentable for one application which is sent through network in other application. Application layer provides interfaces and protocols that are needed for the users. HTTP, SMTP, FTP, etc. are some example of application layer.
Working of all layers together
Let us consider computer A wants to open a connection with computer B. The computer A will create a TCP with a specific source port(4000) and destination port(5000). The computer B will open make the port 5000 to listen for incoming connections. This process will take place in transport layer.
In Network layer, IP datagram will be created with specific source and the destination IP address with checksum. This will encapsulate the TCP with IP datagram.
In Datalink layer, ethernet frame will be created with the respective source and destination MAC address with checksum. This will encapsulate IP datagram with the Ethernet frame. If the MAC address of the Computer B is unknown, it will check in ARP table for MAC address for the respective IP. Even though if not found, then the computer A will send a broadcast to all computer in local network. By this method, the local MAC address of the node or router will be found.
The computer A will send the frame to router. The router will perform checksum operations in Ethernet frame to check the data loss or inconsistency of data and then it splits ethernet frame and remove it. Following this, it will check the IP datagram for any loss. If no loss exists then it splits IP datagram from it. Now the new IP datagram and Ethernet frame will be created with new source and destination along with the checksum. If a frame travels from one router to another, TTL (Time to Live) field will be reduced by one. The most common TTL field is 64.
After all, the frame will be sent to the respective IP network and then it further sends it to the computer B. This is the single synchronize request from computer A to B. Following this, the Computer B will send Syn and Ack to computer A following all the steps. Then the computer A will send Ack to computer B. This process is called Three – way handshaking.