Computer Network Notes
Computer Network Notes
The transport layer is the fourth layer in the open systems interconnection(OSI)
network model. The OSI model divides the tasks involved with moving information
between networked computers into seven smaller, more manageable task groups.
Each of the seven OSI layers is assigned a task or group of tasks.
The transport layer's tasks include error correction as well as segmenting and de-
segmenting data before and after it's transported across the network. This layer is
also responsible for flow control and making sure that segmented data is
delivered over the network in the correct sequence. Layer 4 (the transport layer)
uses the transmission control protocol (TCP) & user data protocol (UDP) to carry
out its tasks. The transport layer takes services from the Network layer and
provides services to the Application layer
On the sender’s side: The transport layer receives data (message) from the
Application layer and then performs Segmentation, divides the actual message
into segments, adds source and destination’s port numbers into the header of the
segment, and transfers the message to the Network layer.
On the receiver’s side: The transport layer receives data from the Network layer,
reassembles the segmented data, reads its header, identifies the port number, and
forwards the message to the appropriate port in the Application layer.
2. Draw the diagram of the TCP header and explain the use of the following:
1. Source and destination port address:A 16-bit field that holds the port address
of the application that is sending the data segment.
A 16-bit field that holds the port address of the application in the host that is
receiving the data segment.
5. What is UDP? What is the maximum and minimum size of a UDP datagram?
Also, discuss the use of UDP.
User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the
Internet Protocol suite, referred to as UDP/IP suite. Unlike TCP, it is an unreliable
and connectionless protocol. So, there is no need to establish a connection prior
to data transfer.
Though Transmission Control Protocol (TCP) is the dominant transport layer
protocol used with most Internet services; provides assured delivery, reliability,
and much more but all these services cost us additional overhead and latency.
In UDP, the header size is 8 bytes, and the packet size is up to 65,535 bytes. But
this packet size is not possible as the data needs to be encapsulated in the IP
datagram, and in an IP packet, the header size can be 20 bytes; therefore, the
maximum of UDP would be 65,535 minus 20. The size of the data that the UDP
packet can carry would be 65,535 minus 28 as 8 bytes for the header of the UDP
packet and 20 bytes for the IP header.
Application of UDP:
• Used for simple request-response communication when the size of data is
less and hence there is lesser concern about flow and error control.
• It is a suitable protocol for multicasting as UDP supports packet switching.
• UDP is used for some routing update protocols like RIP(Routing Information
Protocol).
• Normally used for real-time applications which can not tolerate uneven
delays between sections of a received message.
• The following implementations use UDP as a transport layer protocol: NTP
(Network Time Protocol), DNS (Domain Name Service), BOOTP, DHCP, NNP
(Network News Protocol), Quote of the day protocol, TFTP, RTSP, and RIP.
• The application layer can do some of the tasks through UDP- Trace Route,
Record Route, and Timestamp.
• UDP takes a datagram from Network Layer, attaches its header, and sends it
to the user. So, it works fast.
• UDP is a null protocol if you remove the checksum field.
6. Explain the header format of TCP.
TCP stands for Transmission Control Protocol. It is a transport layer protocol that
facilitates the transmission of packets from source to destination. It is a
connection-oriented protocol which means it establishes the connection prior to
the communication that occurs between the computing devices in a network. This
protocol is used with an IP protocol, so together, they are referred to as a TCP/IP.
• Source port: It defines the port of the application, which is sending the
data. So, this field contains the source port address, which is 16 bits.
• Destination port:It defines the port of the application on the receiving side.
So, this field contains the destination port address, which is 16 bits.
• Sequence number:This field contains the sequence number of data bytes in
a particular session.
• Acknowledgment number:When the ACK flag is set, then this contains the
next sequence number of the data byte and works as an acknowledgment
for the previous data received. For example, if the receiver receives the
segment number 'x', then it responds with 'x+1' as an acknowledgment
number.
• HLEN:It specifies the length of the header indicated by the 4-byte words in
the header. The size of the header lies between 20 and 60 bytes. Therefore,
the value of this field would lie between 5 and 15.
• Reserved:It is a 4-bit field reserved for future use, and by default, all are set
to zero.
• Flags:There are six control bits or flags:
• URG: It represents an urgent pointer. If it is set, then the data is
processed urgently.
• ACK: If the ACK is set to 0, then it means that the data packet does
not contain an acknowledgment.
• PSH: If this field is set, then it requests the receiving device to push
the data to the receiving application without buffering it.
• RST: If it is set, then it requests to restart a connection.
• SYN: It is used to establish a connection between the hosts.
• FIN: It is used to release a connection, and no further data exchange
will happen.
• Window size:It is a 16-bit field. It contains the size of data that the receiver
can accept. This field is used for the flow control between the sender and
receiver and also determines the amount of buffer allocated by the receiver
for a segment. The value of this field is determined by the receiver.
• Checksum:It is a 16-bit field. This field is optional in UDP, but in the case of
TCP/IP, this field is mandatory.
• Urgent pointer:It is a pointer that points to the urgent data byte if the URG
flag is set to 1. It defines a value that will be added to the sequence number
to get the sequence number of the last urgent byte.
• Options:It provides additional options. The optional field is represented in
32-bits. If this field contains data less than 32-bit, then padding is required
to obtain the remaining bits.
23. How does the transport layer ensure that the complete message arrives at
the destination and in the proper order?
Through the use of error detection codes, such as a checksum, the transport layer
ensures the data is not corrupted by sending an acknowledgment message to the
sender.
24. What is the procedure for compressing data using run-length encoding?
Run-length encoding (RLE) is a simple form of lossless data compression that
runs on sequences with the same value occurring many consecutive times. It
encodes the sequence to store only a single value and its count.
For example, consider a screen containing plain black text on a solid white
background. There will be many long runs of white pixels in the blank space and
many short runs of black pixels within the text.
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWW
WWWWWWWWWWWWWBWWWWWWWWWWWWWW
With a run-length encoding (RLE) data compression algorithm applied to the
above hypothetical scan line, it can be rendered as 12W1B12W3B24W1B14W.
This can be interpreted as a sequence of twelve W’s, one B, twelve W’s, three B’s,
etc.
25. Explain the TCP header and working of TCP protocol and differentiate
between TCP and UDP with frame format.
The Transmission Control Protocol (TCP) header is the first 24 bytes of a TCP
segment that contains the parameters and state of an end-to-end TCP socket. The
TCP header is used to track the state of communication between two TCP
endpoints. Since TCP segments are inserted (encapsulated) in the payload of the
IP packet the TCP header immediately follows the IP header during transmission.
TCP does not need to keep track of which systems are communicating, it only
needs to track which end-to-end sockets are currently open. Internet Protocol
handles the logical addressing, routing, and host-to-host connectivity.
Working:In TCP, the connection is established by using three-way handshaking.
The client sends the segment with its sequence number. The server, in return,
sends its segment with its own sequence number as well as the acknowledgment
sequence, which is one more than the client sequence number. When the client
receives the acknowledgment of its segment, then it sends the acknowledgment
to the server. In this way, the connection is established between the client and the
server.