Layer-4: Transport Layer.
Transport Layer is responsible for end-to-end communication between the two devices. This includes taking data from the session layer and breaking it up into chunks called segments before sending it to layer 3. The transport layer on the receiving device is responsible for reassembling the segments into data so that the session layer can understand.
The transport layer is also responsible for flow control and error control. Flow control determines an optimal speed of transmission to ensure that a sender with a fast connection doesn’t overwhelm a receiver with a slow connection. The transport layer performs error control on the receiving end by ensuring that the data received is complete, and requesting retransmission if it isn’t received.
In the transport layer, there is a lot of things happen.
Fragmentation:- If there is a big packet that is coming from the session layer which can’t be kept in one packet so it will cut down the packet into smaller segments and it will decorate them in the correct order so that all the packets can be transmitted in proper order. Not necessary to keep fragmenting in all the packets.
There is normally 2 protocol that is very important in the transport layer, They are TCP & UDP, in the case of TCP, before it sends the data it verify whether the destination exists or not. And when a TCP-based application will send the data to a destination and if that data has been received by the destination device that should be acknowledged.
TCP also checks the error correction, if there is something is missing it will resend.
Lots of protocol out there that works on layer-4. Like TCP, UDP, RTP, etc.
UDP does not care about whether the destination is exist or not. UDP does not acknowledge the packet.
TCP uses protocol number 6 and the UDP protocol number is 17.
Difference between the protocol and port number.
When the packet is made up, in the L3 header there is a field called the protocol number and that protocol number is going to be informed to the transport layer, which protocol is going to be taken care of next in the upper layer .so if it is set 6 it means the TCP will take over next and if the port is set to 18, the UDP will take over next in the upper layer. if it is set 88 it means the EIGRP will take over next.
That’s why the protocol number is going to be used in the IP header.
TCP is a connection-oriented protocol, meaning that it establishes a connection between two devices before transferring data, and maintains that connection throughout the transfer process.
To establish a connection between two devices, TCP uses a method called a three-way handshake.
UDP, or User Datagram Protocol, is another one of the major protocols that make up the internet protocol suite. UDP is less reliable than TCP but is much simpler.
UDP is used for situations where some data loss is acceptable, like live video/audio, or where speed is a critical factor like online gaming.
DP is a connectionless protocol, meaning that it does not establish a connection beforehand as TCP does with its three-way handshake.
Next, UDP doesn’t guarantee that all data is successfully transferred. With UDP, data is sent to any device that happens to be listening, but it doesn’t care if some of it is lost along the way. This is one of the reasons why UDP is also known as the “fire-and-forget” protocol.
Difference Between TCP & UDP
Let’s see the difference between TCP & UDP.
|Connection status||Requires an established connection to transmit data (connection should be closed once the transmission is complete)||Connectionless protocol with no requirements for opening, maintaining or terminating a connection|
|Data sequencing||Able to sequence||Unable to sequence|
|Guaranteed delivery||Can guarantee delivery of data to the destination router||Cannot guarantee delivery of data to the destination|
|Retransmission of data||Retransmission of lost packets is possible||No retransmission of lost packets|
|Error checking||Extensive error checking and acknowledgment of data||Basic error checking mechanism using checksums|
|Method of transfer||Data is read as a byte stream; messages are transmitted to segment boundaries||UDP packets with defined boundaries; sent individually and checked for integrity on arrival|
|Speed||Slower than UDP||Faster than TCP|
|Broadcasting||Does not support Broadcasting||Does support Broadcasting|
|Optimal use||Used by HTTPS, HTTP, SMTP, POP, FTP, etc||Video conferencing, streaming, DNS, VoIP, etc|
The network layer is one of the most important protocols for network engineers.
In the world of networks, Every device has to have some sort of address to communicate which means without having an address you will not be able to identify the device in the network.
This is where the segmentation starts in the L3 network. let’s think about a flat LAN network and you need to separate them into a few sections. Once you will create the segment you can separate them into different types of networks.
In this layer, we do the routing and we use the logical address which we called an IP address. To communicate between two or more different networks you can use the Router.
Normally there 2 addresses, one is a logical and one is a physical address. The logical means it is IP Address and The reason we called logical address means this address can be changed if we want .and the physical means it is Mac address and its burned-in address.
When we put the IP address in the decimal and hexadecimal the devices are going to convert it to binary.
The device that comes under this layer is the router and multilayer switch and these are called layer 3 devices.
Routing vs Routed Protocol.
There are two types of protocol we have.
Routed protocols are basically to identify the host in the network. The address we have are IP, IPx, Apple Talk, etc. But Normally we use IP, it can be IPv4 or IPv6.
Routing protocols are basically for routing. The path we choose from source to destination to reach is going to be decided by the routing protocol.
There are many routing protocols we have like Rip, EIGRP, OSPF, BGP, etc.
Layer-2: Datalink Layer
It transforms the physical layer, a raw transmission facility into a reliable link. It is responsible for moving frames from one hop (node) to the next i.e Hop-to-Hop delivery.
Functions of Datalink Layers:
i. Framing: The layer divides the stream of bits received from the network layer into manageable data units called frames.
ii. Physical addressing: It adds a header to the frame to define the physical address of the sender and/or receiver of the frame.
iii. Flow Control: It provides a flow control mechanism to avoid a fast transmitter from overrunning a slow receiver by buffering the extra bits.
iv. Error control: It is achieved by adding a trailer at the end of the frame. It also uses a mechanism to prevent duplication of frames.
v. Access Control: The layer determines which device has control over the link at any given time when two or more devices are connected to the same link.
The data link layer is further divided into two sub-layers, which are as follows:
Logical Link Control (LLC): This sublayer of the data link layer deals with multiplexing, the flow of data among applications and other services, and LLC is responsible for providing error messages and acknowledgments as well.
Media Access Control (MAC): MAC sublayer manages the device’s interaction, responsible for addressing frames, and also controls physical media access.
The data link layer receives the information in the form of packets from the Network layer, it divides packets into frames and sends those frames bit-by-bit to the underlying physical layer.
The physical layer is responsible for the physical cable or wireless connection between network nodes. It defines the connector, the electrical cable, or wireless technology connecting the devices, and is responsible for the transmission of the raw data, which is simply a series of 0s and 1s while taking care of bit rate control.
Devices used at the physical layer: Hubs, Repeaters, Network interface cards (NICs), Cables (Ethernet, fiber-optic, serial, etc.)
The physical layer produces the representation and groupings of bits for each type of media as:
Copper cable: The signals are patterns of electrical pulses.
Fiber-optic cable: The signals are patterns of light.
Wireless: The signals are patterns of microwave transmissions.