Transport Layer Complete Study Guide – Data Communication Chapter 3

What is the Transport Layer?

My dear students, welcome to Chapter 3! Today we are going to learn about the Transport Layer, which is the 4th layer in the OSI model. Now, let me ask you a simple question before we start. Have you ever wondered how, when you open your browser and also a messaging app at the same time, the right data goes to the right application? The transport layer does exactly that job.

The transport layer is responsible for process-to-process delivery of the entire message. Notice the words carefully — it says process-to-process, not just computer-to-computer. A process is simply an application program running on a host, like your web browser, your email client, or your messaging app.

Now, here is an important difference. The network layer (layer 3) handles source-to-destination delivery of individual packets. But here is the problem: the network layer does not recognize any relationship between those packets. It treats each packet independently, as if each piece belonged to a separate message. The transport layer, on the other hand, ensures that the whole message arrives intact and in order. It handles both error control and flow control at the source-to-destination level.

Key Exam Note
Network layer = delivers individual packets from source to destination (host-to-host).
Transport layer = delivers the complete message from process to process (process-to-process).

Major Functions of the Transport Layer

Let me list the major functions for you in a simple way:

1. It enables multiple applications to communicate over the network at the same time on a single device.

2. It ensures all the data is received reliably and in order by the correct application (if required).

3. It employs error handling mechanisms to detect and correct problems.

Five Responsibilities of the Transport Layer

Now, let us look at each responsibility one by one. These are very important for your exam, so please pay close attention.

1. Service-Point Addressing (Port Addressing)

Think about this: your computer runs several programs at the same time. You might have a browser open, an email client running, and maybe a file transfer application. When data arrives at your computer, how does the system know which program should receive which data?

The answer is service-point addressing. The transport layer header includes a type of address called a service-point address, which is also known as a port address.

How addressing works at different layers:+——————+ +——————+ +——————+ | Data Link Layer | –> | Network Layer | –> | Transport Layer | | Node-to-Node | | Host-to-Host | | Process-to-Process| | Uses MAC Address | | Uses IP Address | | Uses Port Number | +——————+ +——————+ +——————+

The network layer gets each packet to the correct computer; the transport layer gets the entire message to the correct process on that computer. This is a very common exam sentence, so remember it well!

Exam Questions – Service-Point Addressing

Q1. Which layer is responsible for process-to-process delivery?

  1. a) Data Link Layer
  2. b) Network Layer
  3. c) Transport Layer
  4. d) Physical Layer

Q2. What type of address does the transport layer use to identify the correct process?

  1. a) MAC address
  2. b) IP address
  3. c) Port address
  4. d) Physical address

Q3. True or False: The network layer recognizes the relationship between packets belonging to the same message.

Answers with Explanations

Q1 Answer: (c) Transport Layer. The transport layer handles process-to-process delivery. The data link layer handles node-to-node delivery, and the network layer handles host-to-host delivery.

Q2 Answer: (c) Port address. The transport layer uses port numbers (service-point addresses) to identify the correct process. MAC addresses are used at the data link layer, and IP addresses at the network layer.

Q3 Answer: False. The network layer treats each packet independently. It does not recognize any relationship between packets. The transport layer is the one that ensures the complete message is reassembled correctly.

2. Segmentation and Reassembly

A message from the application layer can be very large. The transport layer divides the message into transmittable segments. Each segment is given a sequence number. These sequence numbers are very important because they allow the transport layer at the receiving end to reassemble the message correctly, even if the segments arrive out of order. They also help to identify and replace packets that were lost during transmission.

Key Exam Note
Segmentation = breaking a large message into smaller pieces called segments.
Reassembly = putting the segments back together in the correct order at the destination.
Each segment gets a sequence number for proper reassembly.
Exam Questions – Segmentation and Reassembly

Q1. Why does the transport layer divide a message into segments?

  1. a) To make the message smaller for storage
  2. b) To enable reassembly and identify lost packets using sequence numbers
  3. c) To compress the data
  4. d) To encrypt the data

Q2. Each segment contains a ________ number that helps in reassembling the message at the destination.

Q3. What happens if a segment is lost during transmission? How does the transport layer handle it?

Answers with Explanations

Q1 Answer: (b). Segments are given sequence numbers that allow the receiver to reassemble them in order and to identify which specific segment was lost so it can be retransmitted.

Q2 Answer: Sequence. The sequence number is added to each segment by the transport layer.

Q3 Answer: If a segment is lost, the transport layer at the receiver notices a gap in the sequence numbers. It then asks the sender to retransmit the missing segment. The sequence numbers make it possible to identify exactly which segment is missing.

3. Flow Control

Flow control at the transport layer works similarly to flow control at the data link layer, but there is an important difference. Flow control at the transport layer is performed end to end, not across a single link. This means the sender and receiver adjust the rate of data transfer based on the receiver’s ability to handle data, even though the data may travel through many intermediate links.

Remember the Difference
Data Link Layer flow control = across a single link (between two adjacent nodes).
Transport Layer flow control = end to end (between source process and destination process).

4. Error Control

Just like flow control, error control at the transport layer is also different from the data link layer. Error control at the transport layer is performed process-to-process, not across a single link. The sending transport layer makes sure that the entire message arrives at the receiving transport layer without error — no damage, no loss, and no duplication. Error correction is usually achieved through retransmission.

5. Connection Control

The transport layer can operate in two modes:

A. Connectionless: Each segment is treated as an independent packet. There is no connection establishment before sending, and no connection release after. Think of it like sending a postcard — you just drop it in the mailbox without checking if the receiver is ready.

B. Connection-oriented: A connection is first established with the transport layer at the destination machine. Then data is transferred. After all data is transferred, the connection is terminated. Think of it like making a phone call — you first establish the call, talk, and then hang up.

Connectionless vs Connection-Oriented:Connectionless: Sender —-[Segment]—-> Receiver (no setup needed)Connection-Oriented: Sender —-[Connection Request]—-> Receiver Sender <--[Connection Confirm]----- Receiver Sender ----[Data Segments]---------> Receiver Sender —-[Connection Release]—-> Receiver

Process-to-Process Delivery

Now let me explain this concept very clearly because students often get confused here. Let us revise the delivery types at each layer:

LayerDelivery TypeWhat It Delivers
Data Link LayerNode-to-NodeFrames between two neighboring nodes over a single link
Network LayerHost-to-HostDatagrams between two hosts (computers)
Transport LayerProcess-to-ProcessEntire message between specific processes (applications)

Real communication on the Internet is not between two nodes or two hosts. Real communication takes place between two processes (application programs). At any moment, several processes may be running on the source host and several on the destination host. The transport layer uses port numbers to deliver data from the correct process on the source to the correct process on the destination. Two processes communicate in a client/server relationship.

Exam Questions – Process-to-Process Delivery

Q1. The data link layer handles ________ delivery, the network layer handles ________ delivery, and the transport layer handles ________ delivery.

Q2. Real communication on the Internet takes place between:

  1. a) Two nodes
  2. b) Two hosts
  3. c) Two processes
  4. d) Two routers

Q3. Why is process-to-process delivery needed instead of just host-to-host delivery?

Answers with Explanations

Q1 Answer: Node-to-Node, Host-to-Host, Process-to-Process.

Q2 Answer: (c) Two processes. Although data travels between hosts, the actual meaningful communication happens between application programs (processes) running on those hosts.

Q3 Answer: Because a single host can run multiple applications (processes) at the same time. For example, you might be browsing a website and downloading a file simultaneously. Host-to-host delivery only gets the data to the right computer. Process-to-process delivery ensures the data reaches the correct application on that computer.


TCP Segment Format – Detailed Breakdown

A packet in TCP is called a segment. The segment consists of a 20 to 60 byte header, followed by data from the application. The header is 20 bytes if there are no options, and up to 60 bytes if options are included. Let me walk you through each field one by one.

TCP Segment Header Format (20–60 bytes):0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port | Destination Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acknowledgment Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data | |U|A|P|R|S|F| | | Offset | Reserved |R|C|S|S|Y|I| Window | | | |G|K|H|T|N|N| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum | Urgent Pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options (if any) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Source Port Address (16 bits)

This field defines the port number of the application program on the host that is sending the segment. It tells the receiver which process sent the data.

Destination Port Address (16 bits)

This field defines the port number of the application program on the host that is receiving the segment. It tells the receiver which process should get the data.

Sequence Number (32 bits)

This is a very important field. It defines the number assigned to the first byte of data in this segment. TCP numbers every single byte that it transmits. The sequence number tells the destination which byte in the overall stream is the first byte in this segment. During connection establishment, each party uses a random number generator to create an Initial Sequence Number (ISN).

Acknowledgment Number (32 bits)

This field defines the byte number that the receiver is expecting to receive next. If the receiver has successfully received all bytes up to byte number x, it sets the acknowledgment number to x + 1. This is called cumulative acknowledgment. Acknowledgment and data can also be sent together in the same segment — this is called piggybacking.

Header Length (4 bits)

This field indicates the number of 4-byte words in the TCP header. Since the header can be between 20 and 60 bytes, the value of this field ranges from 5 (5 × 4 = 20 bytes) to 15 (15 × 4 = 60 bytes).

Important Formula
\[\text{Header Length (bytes)} = \text{Data Offset} \times 4\]

Where Data Offset is the 4-bit header length field value (5 to 15).

Control Flags (6 bits)

These are six individual bits, each with a specific purpose:

FlagFull NamePurpose
URGUrgentUrgent pointer field is valid
ACKAcknowledgmentAcknowledgment number field is valid
PSHPushDeliver data to application immediately
RSTResetReset the connection
SYNSynchronizeUsed during connection establishment
FINFinishUsed during connection termination

Window Size (16 bits)

This field defines the size of the sliding window, in bytes, that the other party must maintain. The maximum window size is 65,535 bytes (because 16 bits = 2^16 = 65,536 values). This value is called the receiving window (rwnd) and is determined by the receiver. The sender must follow this limit for flow control.

Checksum (16 bits)

This field contains the checksum for error detection. Unlike UDP where the checksum is optional, in TCP the checksum is mandatory. For the TCP pseudo header, the protocol field value is 6.

Urgent Pointer (16 bits)

This field is valid only when the URG flag is set. It defines a number that must be added to the sequence number to find the last urgent byte in the data section.

Options (0 to 40 bytes)

Optional information can be included in the TCP header, up to 40 bytes.

Key Exam Notes – TCP Header
  • Minimum header size = 20 bytes, Maximum = 60 bytes
  • Header length field value range = 5 to 15 (in 4-byte units)
  • Sequence number = number of the first byte in the segment
  • Acknowledgment number = next expected byte (cumulative)
  • Checksum in TCP is mandatory (optional in UDP)
  • TCP pseudo header protocol field value = 6
  • Maximum window size = 65,535 bytes

Solved Example: Reading a TCP Header from Hexadecimal

This type of question comes very often in exams. Let me teach you step by step how to solve it.

Detailed Solution – Step by Step

(a) Source Port Number:

The first 16 bits (4 hexadecimal digits) = 0532

Converting from hexadecimal to decimal:

\[0 \times 16^3 + 5 \times 16^2 + 3 \times 16^1 + 2 \times 16^0 = 0 + 1280 + 48 + 2 = \boxed{1330}\]

(b) Destination Port Number:

The next 4 hexadecimal digits = 0017

\[0 \times 16^3 + 0 \times 16^2 + 1 \times 16^1 + 7 \times 16^0 = 0 + 0 + 16 + 7 = \boxed{23}\]

Note: Port 23 is the well-known port for Telnet! This tells us the destination application is Telnet.

(c) Sequence Number:

The next 8 hexadecimal digits = 00000001

\[0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 = \boxed{1}\]

(d) Acknowledgment Number:

The next 8 hexadecimal digits = 00000000

\[\boxed{0}\]

Note: The ACK number is 0, which means this is likely a SYN segment (connection establishment), where the acknowledgment number is not yet valid.

(e) Length of the Header:

Look at the 13th byte onward: 5002. The first hex digit 5 is the data offset (header length field).

\[\text{Header Length} = 5 \times 4 = \boxed{20 \text{ bytes}}\]

This means there are no options in this header (minimum size).

Practice Question – Try It Yourself!

Problem: A TCP header dump in hexadecimal is given as:

10A0 0050 00001000 00001001 5018 FFFF 00000000

Find: (a) Source port, (b) Destination port, (c) Sequence number, (d) Acknowledgment number, (e) Header length.

Answer

(a) Source Port: 10A0 = \(1 \times 4096 + 0 \times 256 + 10 \times 16 + 0 = 4096 + 160 = \boxed{4256}\)

(b) Destination Port: 0050 = \(0 + 0 + 5 \times 16 + 0 = \boxed{80}\) (HTTP!)

(c) Sequence Number: 00001000 = \(\boxed{4096}\)

(d) Acknowledgment Number: 00001001 = \(\boxed{4097}\)

(e) Header Length: Data offset = 5, so \(5 \times 4 = \boxed{20 \text{ bytes}}\)


Transport Layer Addressing – Port Numbers

Now, let me explain port numbers very clearly. At every layer, we need an address to deliver data to the correct destination:

LayerAddress TypePurpose
Data Link LayerMAC AddressChoose one node among several on a network
Network LayerIP AddressChoose one host among millions on the Internet
Transport LayerPort NumberChoose one process among several running on a host

Port numbers are 16-bit integers, ranging from 0 to 65,535. The client program uses a randomly chosen port number (called an ephemeral port). The server process must use a specific, well-known port number so that clients can find it.

IANA Port Number Ranges

The Internet Assigned Numbers Authority (IANA) divides port numbers into three ranges:

RangeNameDescription
0 to 1,023Well-Known PortsAssigned and controlled by IANA. Used by server processes. Examples: 21 (FTP), 23 (Telnet), 25 (SMTP), 80 (HTTP)
1,024 to 49,151Registered PortsNot assigned by IANA but can be registered to prevent duplication
49,152 to 65,535Dynamic/Ephemeral PortsNot controlled or registered. Used by client processes as temporary ports
Important Well-Known Port Numbers to Remember
FTP = 21 | Telnet = 23 | SMTP = 25 | HTTP = 80 | HTTPS = 443
These are the most commonly asked port numbers in exams!

Port Numbers in Client-Server Communication

Let me explain this with a simple real-life example. Imagine you go to a large office building (the host). You want to meet a specific person (the process). The building address is the IP address, and the person’s office room number is the port number.

When a client sends a message:

  • The destination port is the well-known port of the server service (e.g., 80 for HTTP)
  • The source port is a randomly generated ephemeral port to track this specific conversation
  • This allows multiple simultaneous conversations — for example, many clients can request web pages from the same server at the same time, and each conversation is tracked by different source ports

Socket Addresses

A socket address is the combination of an IP address and a port number. Process-to-process delivery needs a pair of socket addresses:

Socket Address
\[\text{Socket Address} = \text{IP Address} + \text{Port Number}\]

A complete connection needs: Client Socket Address + Server Socket Address

That is: Source IP + Source Port + Destination IP + Destination Port

Socket Address Example:Client Server +——————+ +——————+ | IP: 192.168.1.10 | | IP: 10.0.0.1 | | Port: 51000 | <=========> | Port: 80 | | (ephemeral) | | (well-known) | +——————+ +——————+ Client Socket Server Socket 192.168.1.10 : 51000 10.0.0.1 : 80
Exam Questions – Port Numbers and Socket Addresses

Q1. What is the range of well-known port numbers?

  1. a) 0 to 255
  2. b) 0 to 1,023
  3. c) 1,024 to 49,151
  4. d) 49,152 to 65,535

Q2. Which port number is used by HTTP?

  1. a) 21
  2. b) 23
  3. c) 25
  4. d) 80

Q3. The combination of an IP address and a port number is called a ________ address.

Q4. Port numbers ranging from 49,152 to 65,535 are called ________ ports.

Q5. Why can a server process not use a randomly chosen port number?

Answers with Explanations

Q1 Answer: (b) 0 to 1,023. These are the well-known ports controlled by IANA and used by server processes.

Q2 Answer: (d) 80. HTTP uses port 80. FTP uses 21, Telnet uses 23, and SMTP uses 25.

Q3 Answer: Socket. A socket address uniquely identifies a process on a host.

Q4 Answer: Dynamic (or Ephemeral). These ports are used temporarily by client processes.

Q5 Answer: If a server used a random port number, the client would not know which port to connect to. Well-known port numbers are standardized so that clients always know exactly which port to use for a specific service (e.g., port 80 for web services).


Multiplexing and Demultiplexing

Now, class, let me ask you a question. What happens when multiple applications on your computer want to send data at the same time, but there is only one network connection? The transport layer solves this using multiplexing and demultiplexing.

Multiplexing (At the Sender)

At the sender side, several processes may need to send packets. But there is only one transport layer. This is a many-to-one relationship. The transport layer accepts messages from different processes (identified by their port numbers), adds headers, and passes them to the network layer through a single connection.

Demultiplexing (At the Receiver)

At the receiver side, the relationship is one-to-many. The transport layer receives datagrams from the network layer, removes the header, and delivers each message to the appropriate process based on the port number in the header.

Multiplexing and Demultiplexing:SENDER SIDE (Multiplexing) RECEIVER SIDE (Demultiplexing)Process A (Port 80) \ Process B (Port 21) –+–> [Transport Layer] –> [Network] –> [Network] –> [Transport Layer] –+–> Process X (Port 80) Process C (Port 25) / |–> Process Y (Port 21) |–> Process Z (Port 25) Many-to-One One-to-Many
Exam Questions – Multiplexing and Demultiplexing

Q1. Multiplexing at the transport layer is a ________ relationship.

  1. a) One-to-one
  2. b) Many-to-one
  3. c) One-to-many
  4. d) Many-to-many

Q2. Demultiplexing uses which field to deliver data to the correct process?

  1. a) IP address
  2. b) MAC address
  3. c) Port number
  4. d) Sequence number

Q3. True or False: Demultiplexing happens at the sender side.

Answers with Explanations

Q1 Answer: (b) Many-to-one. Multiple processes send data to a single transport layer — that is multiplexing.

Q2 Answer: (c) Port number. The port number in the transport layer header identifies which process should receive the data.

Q3 Answer: False. Demultiplexing happens at the receiver side (one-to-many). Multiplexing happens at the sender side (many-to-one).


Connectionless vs Connection-Oriented Services

Connectionless Service

In a connectionless service, packets are sent with no need for connection establishment or connection release. The packets are not numbered. They may be delayed, lost, or arrive out of sequence. There is no acknowledgment. UDP is connectionless.

Connection-Oriented Service

In a connection-oriented service, a connection is first established between sender and receiver. Then data is transferred. At the end, the connection is released. TCP is connection-oriented.

Reliable vs Unreliable Services

A reliable transport layer protocol implements flow and error control. It is slower but ensures all data arrives correctly. A unreliable protocol is faster but does not guarantee delivery. It is suitable for real-time applications.

ProtocolConnection TypeReliability
UDPConnectionlessUnreliable
TCPConnection-orientedReliable
SCTPConnection-orientedReliable
Exam Questions – Service Types

Q1. Which of the following is a connectionless and unreliable protocol?

  1. a) TCP
  2. b) SCTP
  3. c) UDP
  4. d) IP

Q2. TCP is a ________-oriented and ________ transport protocol.

Q3. True or False: In a connectionless service, packets are numbered and acknowledged.

Answers with Explanations

Q1 Answer: (c) UDP. UDP is connectionless and unreliable. TCP and SCTP are connection-oriented and reliable. IP is a network layer protocol, not a transport layer protocol.

Q2 Answer: Connection, reliable. TCP = Connection-oriented, Reliable.

Q3 Answer: False. In connectionless service, packets are NOT numbered and there is NO acknowledgment. These features exist in connection-oriented services.


Transport Layer Protocols

Simple Protocol

This is the most basic protocol — connectionless with no flow control and no error control. It assumes the receiver can immediately handle any packet. There is no acknowledgment, no sequencing, and no retransmission.

Stop-and-Wait Protocol

This is a connection-oriented protocol that uses both flow and error control. The sender and receiver both use a sliding window of size 1. Here is how it works:

  1. The sender sends one packet at a time
  2. The sender waits for an acknowledgment before sending the next one
  3. A checksum is added to detect corrupted packets
  4. The sender keeps a copy of the packet until the acknowledgment arrives
Stop-and-Wait Protocol:Sender Receiver |—-[Packet 1]————————–>| | | |<---[ACK 1]-----------------------------| | | |----[Packet 2]-------------------------->| | | |<---[ACK 2]-----------------------------| | |* Sender waits for ACK before sending next packet * Window size = 1

Go-Back-N (GBN) Protocol

The Go-Back-N protocol is more efficient than Stop-and-Wait. The key idea is that the sender can send several packets before receiving acknowledgments, but the receiver can only buffer one packet. Important points:

  • The sender keeps copies of sent packets until acknowledgments arrive
  • The receiver keeps track of only one variable (the next expected packet)
  • There is no need to buffer out-of-order packets — they are simply discarded
  • If a packet is lost or corrupted, the receiver discards all subsequent packets and the sender must go back and retransmit all packets from the lost one onward
  • This protocol is inefficient if the network loses many packets
Go-Back-N Example (Window size = 4):Sender Receiver |—[Frame 0]————————>| (accepted) |—[Frame 1]————————>| (accepted) |—[Frame 2]—X (LOST) | (discarded) |—[Frame 3]————————>| (out of order, DISCARDED) |<---[ACK 0]--------------------------| |<---[ACK 1]--------------------------| | (No ACK for 2, timeout!) |---[Frame 2]------------------------>| (retransmitted) |—[Frame 3]————————>| (retransmitted) |<---[ACK 2]--------------------------| |<---[ACK 3]--------------------------|

Selective-Repeat (SR) Protocol

The Selective-Repeat protocol solves the inefficiency of Go-Back-N. Instead of retransmitting everything, it resends only the packets that were actually lost. Important points:

  • The receiver can buffer out-of-order packets
  • Only the lost or corrupted packets are retransmitted
  • The receiver forwards packets to the transport layer only when they arrive in order and acknowledgments arrive on time
  • More efficient than Go-Back-N, but more complex at the receiver side
Key Exam Note – Protocol Comparison
Simple: No flow control, no error control, connectionless
Stop-and-Wait: Window size = 1, connection-oriented, flow + error control
Go-Back-N: Sender sends multiple, receiver buffers only 1, discards out-of-order
Selective-Repeat: Sender sends multiple, receiver buffers multiple, retransmits only lost packets
Exam Questions – Transport Layer Protocols

Q1. In the Stop-and-Wait protocol, what is the window size?

  1. a) 0
  2. b) 1
  3. c) N
  4. d) Unlimited

Q2. What happens to out-of-order packets in Go-Back-N protocol?

  1. a) They are buffered
  2. b) They are delivered to the application
  3. c) They are discarded
  4. d) They are retransmitted immediately

Q3. Which protocol retransmits only the lost packets, not all subsequent ones?

  1. a) Stop-and-Wait
  2. b) Go-Back-N
  3. c) Selective-Repeat
  4. d) Simple Protocol

Q4. True or False: Go-Back-N is efficient when the network loses many packets.

Answers with Explanations

Q1 Answer: (b) 1. In Stop-and-Wait, both sender and receiver use a sliding window of size 1.

Q2 Answer: (c) They are discarded. In Go-Back-N, the receiver can only buffer one packet. Any out-of-order packet is simply discarded.

Q3 Answer: (c) Selective-Repeat. Selective-Repeat only retransmits the packets that were actually lost. Go-Back-N retransmits the lost packet and all packets sent after it.

Q4 Answer: False. Go-Back-N is inefficient when the network loses many packets because it retransmits all packets from the lost one onward, even if some of them were received correctly.


User Datagram Protocol (UDP) – Complete Details

UDP stands for User Datagram Protocol. It is called a connectionless, unreliable transport protocol. It does not add much to the services of IP except to provide process-to-process communication using port numbers. It performs very limited error checking.

Now you might wonder: if UDP is so basic, why would anyone use it? Here is the answer: UDP has very low overhead, which makes it fast. If a process wants to send a small message and does not care much about reliability, UDP is a great choice.

UDP Header Format

UDP packets are called user datagrams. They have a fixed-size header of 8 bytes:

UDP Header (8 bytes fixed):0 7 8 15 16 23 24 31 +——–+——–+——–+——–+ | Source Port | Dest Port | +——–+——–+——–+——–+ | Length | Checksum | +——–+——–+——–+——–+ | Data (variable length) | +————————————–+

Source Port (16 bits): Port number of the sending process.

Destination Port (16 bits): Port number of the receiving process.

Length (16 bits): Total length of the user datagram (header + data).

Checksum (16 bits): Used for error detection. Optional in UDP!

What UDP Does NOT Do

  • No flow control
  • No error control (beyond optional checksum)
  • No connection control
  • No segmentation and reassembly
  • No sequence numbers

All these functions must be handled by the application layer programs if needed. Because UDP cannot segment and reassemble, it can only transmit small portions of data that fit into a single datagram.

What UDP DOES Do

  • Service-point addressing (using port numbers)
  • Process-to-process delivery

When is UDP Used?

  1. Simple request-response communication — when you need a quick exchange with little concern for reliability
  2. Applications with internal flow and error control — for example, TFTP (Trivial File Transfer Protocol) has its own error control
  3. Multicasting — UDP supports multicasting, TCP does not
  4. Management protocols — like SNMP (Simple Network Management Protocol)
  5. Route updating protocols — like RIP (Routing Information Protocol)

Solved Example: Reading a UDP Header from Hexadecimal

Worked Example

Problem: The following is a dump of a UDP header in hexadecimal format:

0632 000D 001C E217

Find: (a) Source port, (b) Destination port, (c) Total length, (d) Length of data.

Detailed Solution

(a) Source Port: First 4 hex digits = 0632

\[0 \times 16^3 + 6 \times 16^2 + 3 \times 16^1 + 2 \times 16^0 = 0 + 1536 + 48 + 2 = \boxed{1586}\]

(b) Destination Port: Next 4 hex digits = 000D

\[0 + 0 + 0 + 13 = \boxed{13}\]

(c) Total Length: Next 4 hex digits = 001C

\[0 + 0 + 1 \times 16 + 12 = 16 + 12 = \boxed{28 \text{ bytes}}\]

(d) Length of Data:

Formula
\[\text{Data Length} = \text{Total Length} – \text{UDP Header Size}\] \[\text{Data Length} = 28 – 8 = \boxed{20 \text{ bytes}}\]

Remember: UDP header is always 8 bytes (no options, no variable length).

Exam Questions – UDP

Q1. What is the size of the UDP header?

  1. a) 8 bytes
  2. b) 20 bytes
  3. c) 16 bytes
  4. d) 60 bytes

Q2. Which of the following is NOT a feature of UDP?

  1. a) Process-to-process delivery
  2. b) Flow control
  3. c) Port addressing
  4. d) Connectionless delivery

Q3. True or False: The checksum field in UDP is mandatory.

Q4. UDP is suitable for ________ because it supports multicasting.

Q5. Why can UDP only transmit small amounts of data at a time?

Answers with Explanations

Q1 Answer: (a) 8 bytes. UDP has a fixed 8-byte header with no options.

Q2 Answer: (b) Flow control. UDP does NOT perform flow control. It does perform process-to-process delivery and port addressing.

Q3 Answer: False. The checksum in UDP is optional. In TCP, it is mandatory.

Q4 Answer: Multicasting. UDP supports multicasting; TCP does not have this capability built in.

Q5 Answer: Because UDP cannot perform segmentation and reassembly. It does not use sequence numbers. Therefore, all data must fit into a single user datagram.


TCP (Transmission Control Protocol) – Complete Details

Now we come to the most important protocol in the transport layer. TCP is a connection-oriented, reliable transport protocol. Unlike UDP, TCP provides many services that ensure data is delivered correctly and in order.

TCP Services

  1. Process-to-Process Communication — using port numbers, just like UDP
  2. Stream Delivery Service — data is sent as a continuous stream of bytes
  3. Full-Duplex Communication — data can flow in both directions at the same time
  4. Connection-Oriented Service — connection is established before data transfer
  5. Reliable Service — error control and flow control ensure reliable delivery

Stream Delivery Service

This is a very important concept. In UDP, a process sends messages with predefined boundaries. Each message becomes one datagram. But in TCP, there are no boundaries. TCP allows the sending process to deliver data as a stream of bytes, and the receiving process reads it as a stream of bytes. Think of it like water flowing through a pipe — there is no concept of where one “piece” of water ends and the next begins.

UDP vs TCP Data Delivery:UDP (Message-oriented): [Message 1] [Message 2] [Message 3] | | | v v v [Datagram 1][Datagram 2][Datagram 3] <-- boundaries preservedTCP (Stream-oriented): [Byte][Byte][Byte][Byte][Byte][Byte][Byte][Byte][Byte]... | | v v [========= Segment 1 =========][==== Segment 2 ====] <-- no boundaries, just a continuous stream of bytes -->

Sending and Receiving Buffers

Because the sending and receiving processes may not write or read data at the same speed, TCP uses buffers for storage. There are two buffers: a sending buffer and a receiving buffer, one for each direction. These are usually implemented as circular arrays of byte locations. The buffers can be hundreds or thousands of bytes in size.

How TCP Creates Segments

The sending process writes bytes into the sending buffer. TCP then groups a number of bytes together, adds a header, and creates a segment. The segment is then given to the IP layer for transmission. All of this is transparent to the receiving process.

TCP Segment Numbering System

Byte Numbering: TCP numbers every single byte in a connection. Numbering is independent in each direction. The numbering does not start from 0. Instead, TCP generates a random number between 0 and 2^32 – 1 as the number of the first byte. This random starting number is called the Initial Sequence Number (ISN).

Sequence Number: The sequence number of a segment is simply the byte number of the first byte carried in that segment.

Worked Example – Sequence Numbers

Problem: A TCP connection is transferring a file of 8,000 bytes. The first byte is numbered 10,001. What are the sequence numbers for each segment if data is sent in four segments, each carrying 2,000 bytes?

Detailed Solution

Each segment carries 2,000 bytes. The sequence number of each segment is the number of its first byte:

Segment 1: Sequence Number = 10,001 (covers bytes 10,001 to 12,000)

Segment 2: Sequence Number = 12,001 (covers bytes 12,001 to 14,000)

Segment 3: Sequence Number = 14,001 (covers bytes 14,001 to 16,000)

Segment 4: Sequence Number = 16,001 (covers bytes 16,001 to 18,000)

Pattern to remember: Next sequence number = Previous sequence number + Number of bytes in previous segment

\[12,001 = 10,001 + 2,000\]

\[14,001 = 12,001 + 2,000\]

And so on. This pattern works every time!

Important Formulas for Sequence Numbers
\[\text{Sequence Number of next segment} = \text{Previous Sequence Number} + \text{Bytes in previous segment}\] \[\text{Acknowledgment Number} = \text{Last byte received safely} + 1\]

Acknowledgment Number

Since TCP is full-duplex, both parties send and receive data at the same time. Each party uses an acknowledgment number to confirm the bytes it has received. The acknowledgment number defines the number of the next byte expected. It is cumulative, meaning if a party uses 5643 as an acknowledgment number, it has received all bytes up to 5642.

Important: Cumulative Acknowledgment
If ACK = 5643, it means all bytes from the beginning up to byte 5642 have been received safely.
It does NOT mean 5,643 bytes have been received (because byte numbering may not start from 0).

Full-Duplex Communication

TCP allows data to flow in both directions at the same time. Each TCP connection has a sending buffer and a receiving buffer, and segments move in both directions simultaneously.

Connection-Oriented Service

TCP creates a virtual connection (not physical). The process is: establish connection → exchange data → terminate connection. Even though the segments travel through IP datagrams that may take different paths, TCP creates the illusion of a dedicated connection.

Flow Control in TCP

The receiver controls the amount of data the sender can transmit. This prevents the receiver from being overwhelmed. TCP uses a byte-oriented flow control with the window size field in the header. The maximum window size is 65,535 bytes.

Error Control in TCP

TCP provides reliability through error control. It handles:

  • Corrupted segments — detected using checksum
  • Lost segments — detected using timeouts and acknowledgments
  • Out-of-order segments — stored temporarily but not delivered to the process until in order
  • Duplicated segments — detected using sequence numbers

Error detection and correction uses three tools:

  1. Checksum — mandatory 16-bit checksum in every segment. If corrupted, the segment is discarded and treated as lost.
  2. Acknowledgment — confirms receipt of data segments. ACK segments are never acknowledged themselves.
  3. Timeout — if an acknowledgment is not received within a certain time, the segment is retransmitted.

Congestion Control

TCP also considers congestion in the network. The amount of data sent is not only controlled by the receiver (flow control) but also by the level of congestion in the network. If the network is congested, TCP reduces its sending rate.

Key Exam Notes – TCP
  • TCP is connection-oriented, reliable, stream-oriented
  • TCP header size = 20 to 60 bytes (20 minimum, 60 maximum)
  • Checksum is mandatory in TCP
  • Sequence number = byte number of the first byte in the segment
  • Acknowledgment number = next expected byte (cumulative)
  • ISN is a random number between 0 and 2^32 – 1
  • Three error control tools: Checksum, Acknowledgment, Timeout
  • Maximum window size = 65,535 bytes
  • TCP provides: flow control, error control, congestion control
Exam Questions – TCP

Q1. The sequence number in a TCP segment refers to:

  1. a) The number of the segment
  2. b) The number of the first byte in the segment
  3. c) The total number of bytes sent
  4. d) The number of the last byte in the segment

Q2. If the acknowledgment number in a TCP segment is 5001, what does it mean?

  1. a) 5001 bytes have been received
  2. b) All bytes up to 5000 have been received safely
  3. c) The next segment should carry 5001 bytes
  4. d) The connection is using byte 5001

Q3. Which of the following is NOT a tool used by TCP for error control?

  1. a) Checksum
  2. b) Acknowledgment
  3. c) Timeout
  4. d) Encryption

Q4. TCP numbers bytes starting from a random number called the ________.

Q5. True or False: TCP delivers out-of-order segments to the receiving process.

Q6. Explain the difference between flow control and congestion control in TCP.

Answers with Explanations

Q1 Answer: (b). The sequence number is the byte number of the first byte carried in that segment, not the segment number itself.

Q2 Answer: (b). An acknowledgment number of 5001 means all bytes from the beginning up to byte 5000 have been received safely. The receiver now expects byte 5001 next. This is the cumulative nature of TCP acknowledgments.

Q3 Answer: (d) Encryption. TCP uses checksum, acknowledgment, and timeout for error control. Encryption is not an error control tool.

Q4 Answer: Initial Sequence Number (ISN). TCP generates a random ISN between 0 and 2^32 – 1.

Q5 Answer: False. TCP stores out-of-order segments temporarily but NEVER delivers them to the process. It guarantees that the process receives data in order.

Q6 Answer: Flow control is controlled by the receiver — it tells the sender how much data it can handle using the window size. Congestion control is controlled by the network conditions — TCP reduces its sending rate when it detects congestion in the network, regardless of what the receiver’s window allows.


Quick Comparison: UDP vs TCP

FeatureUDPTCP
ConnectionConnectionlessConnection-oriented
ReliabilityUnreliableReliable
Header Size8 bytes (fixed)20–60 bytes (variable)
Flow ControlNoYes
Error ControlOptional checksum onlyChecksum + ACK + Retransmission
SequencingNoYes (byte numbering)
SegmentationNoYes
ChecksumOptionalMandatory
DeliveryMessage-orientedStream-oriented
MulticastingYesNo
SpeedFaster (less overhead)Slower (more overhead)
Window SizeN/AUp to 65,535 bytes
Final Practice Questions – Mixed Concepts

Q1. A TCP segment has a data offset field value of 7. What is the header length?

  1. a) 7 bytes
  2. b) 28 bytes
  3. c) 35 bytes
  4. d) 14 bytes

Q2. The maximum window size in TCP is:

  1. a) 32,767 bytes
  2. b) 65,535 bytes
  3. c) 1,024 bytes
  4. d) 65,536 bytes

Q3. The protocol field value in the TCP pseudo header is ________.

Q4. In Go-Back-N, the receiver discards out-of-order packets because it can buffer only ________ packet(s).

Q5. True or False: ACK segments in TCP consume sequence numbers and are acknowledged.

Q6. List three applications where UDP is preferred over TCP and explain why.

Answers with Explanations

Q1 Answer: (b) 28 bytes. Header Length = Data Offset × 4 = 7 × 4 = 28 bytes.

Q2 Answer: (b) 65,535 bytes. The window size field is 16 bits, so maximum = 2^16 – 1 = 65,535 bytes.

Q3 Answer: 6. The TCP pseudo header uses protocol value 6. (UDP uses 17.)

Q4 Answer: One (1). The Go-Back-N receiver can buffer only one packet at a time.

Q5 Answer: False. ACK segments do NOT consume sequence numbers and are NOT acknowledged. Only data segments and control segments that consume a sequence number are acknowledged.

Q6 Answer: (1) DNS — needs fast queries, small data, can retry if lost. (2) SNMP — network management needs quick, simple exchanges. (3) Video streaming/VoIP — real-time applications where speed matters more than perfect reliability; a lost packet is better than a delayed one. (Other valid answers: TFTP, RIP, DHCP.)

Challenge Exam Questions – Transport Layer

Dear students, these questions are designed to test your deep understanding. Try each one before checking the answer!

MCQ

Q1. A TCP connection has an Initial Sequence Number (ISN) of 1059. If the first segment carries 1,500 bytes of data, what is the sequence number of the second segment?

  1. a) 1059
  2. b) 1500
  3. c) 2559
  4. d) 2560

Answer: (c) 2559.

The sequence number of the second segment = ISN + bytes in first segment = 1059 + 1500 = 2559. Remember: the sequence number is the byte number of the first byte in the segment, so the next segment starts at byte 2559.

MCQ

Q2. In the TCP header, the data offset field has a value of 10 (in decimal). What is the size of the TCP header?

  1. a) 10 bytes
  2. b) 40 bytes
  3. c) 20 bytes
  4. d) 50 bytes

Answer: (b) 40 bytes.

Header Length = Data Offset × 4 = 10 × 4 = 40 bytes. The data offset field value 10 means 10 four-byte words = 40 bytes. This also tells us there are 20 bytes of options (40 – 20 = 20).

MCQ

Q3. Which of the following statements about TCP and UDP is CORRECT?

  1. a) Both TCP and UDP provide flow control
  2. b) Both TCP and UDP have mandatory checksums
  3. c) TCP provides reliable delivery; UDP does not
  4. d) Both TCP and UDP support segmentation and reassembly
MCQ

Q4. A receiver sends an acknowledgment number of 3001. Which of the following is true?

  1. a) The receiver has received exactly 3001 bytes
  2. b) The receiver has received all bytes up to byte 3000
  3. c) The receiver has received byte 3001 but not byte 3000
  4. d) The receiver wants to receive 3001 more bytes

Answer: (b).

The acknowledgment number is cumulative. ACK = 3001 means the receiver has safely received all bytes from the beginning up to byte 3000, and it now expects byte 3001 next. It does NOT mean 3001 bytes total were received, because numbering may not start from 0.

MCQ

Q5. In the Go-Back-N protocol with a window size of 5, the sender has sent frames 0, 1, 2, 3, and 4. Frame 2 is lost. What does the sender retransmit?

  1. a) Only frame 2
  2. b) Frames 2, 3, and 4
  3. c) Frames 0 through 4
  4. d) Only frame 3

Answer: (b) Frames 2, 3, and 4.

In Go-Back-N, when frame 2 is lost, the receiver discards frame 3 and frame 4 (out-of-order packets are discarded). The sender must “go back” to frame 2 and retransmit frame 2 and all frames sent after it (frames 3 and 4). Frames 0 and 1 were already acknowledged, so they are not retransmitted.

MCQ

Q6. A client wants to access a web server. Which port numbers will be used?

  1. a) Source: 80, Destination: ephemeral port
  2. b) Source: ephemeral port, Destination: 80
  3. c) Source: 80, Destination: 80
  4. d) Source: ephemeral port, Destination: 443

Answer: (b).

The client uses a randomly generated ephemeral port as the source port. The destination port is the well-known port of the service being requested — port 80 for HTTP. Option (d) would be correct for HTTPS, but the question says “web server” without specifying HTTPS.

Fill in the Blank

Q7. The transport layer header must include a ________ address to ensure process-to-process delivery.

Answer: Service-point (or Port). The service-point address, also called a port address or port number, identifies the specific process on a host.

Fill in the Blank

Q8. In TCP, the ISN is generated using a ________ number generator, and it is a number between 0 and ________.

Answer: Random, 2^32 – 1 (or 4,294,967,295). TCP uses a random number generator to create the Initial Sequence Number, which can be any value from 0 to 2^32 – 1. This is for security and to avoid confusion with old connections.

Fill in the Blank

Q9. The combination of an IP address and a port number is called a ________ address, and a pair of these (client + server) is needed for a complete TCP connection.

Answer: Socket. A socket address = IP address + port number. A complete connection requires four pieces of information: source IP, source port, destination IP, destination port — forming a pair of socket addresses.

Fill in the Blank

Q10. ________ is a relationship at the sender side (many-to-one), while ________ is a relationship at the receiver side (one-to-many).

Answer: Multiplexing, Demultiplexing. Multiple processes feed into one transport layer (multiplexing = many-to-one). One transport layer delivers to multiple processes (demultiplexing = one-to-many).

Fill in the Blank

Q11. Port numbers from ________ to ________ are the ephemeral (dynamic) ports used by client processes.

Answer: 49,152 to 65,535. These are the dynamic/ephemeral ports. They are not controlled or registered by IANA and can be used by any client process as temporary ports.

True / False

Q12. True or False: TCP is a message-oriented protocol that preserves message boundaries.

Answer: False. TCP is a stream-oriented protocol, NOT message-oriented. It does NOT preserve message boundaries. Data is sent as a continuous stream of bytes. UDP is message-oriented.

True / False

Q13. True or False: Flow control at the transport layer is performed across a single link between two adjacent nodes.

Answer: False. Flow control at the transport layer is performed end to end (between the source process and destination process). Flow control across a single link is done at the data link layer.

True / False

Q14. True or False: Error control at the transport layer is performed process-to-process, and error correction is usually achieved through retransmission.

Answer: True. Unlike the data link layer where error control is across a single link, transport layer error control is process-to-process. The main method of error correction is retransmission of lost or corrupted segments.

True / False

Q15. True or False: A server process can use any random port number because the client will discover it automatically.

Answer: False. A server process MUST use a well-known port number so that clients know which port to connect to. If servers used random ports, clients would not know how to reach the service. Well-known ports are standardized by IANA.

True / False

Q16. True or False: The Selective-Repeat protocol is less efficient than Go-Back-N when the network frequently loses packets.

Answer: False. Selective-Repeat is MORE efficient than Go-Back-N when packets are frequently lost. Go-Back-N retransmits the lost packet AND all subsequent packets, wasting bandwidth. Selective-Repeat retransmits ONLY the lost packets.

Short Answer

Q17. Explain the difference between node-to-node delivery, host-to-host delivery, and process-to-process delivery. Which layer handles each type?

Answer:

Node-to-node delivery: Delivery of frames between two directly connected neighboring nodes over a single link. Handled by the Data Link Layer using MAC addresses.

Host-to-host delivery: Delivery of datagrams between two hosts (computers) that may be far apart, possibly through multiple intermediate routers. Handled by the Network Layer using IP addresses.

Process-to-process delivery: Delivery of the complete message from a specific application (process) on the source host to the correct application (process) on the destination host. Handled by the Transport Layer using port numbers.

Short Answer

Q18. What is a socket address? What four pieces of information are needed for a complete TCP connection?

Answer: A socket address is the combination of an IP address and a port number. It uniquely identifies a process running on a specific host. For a complete TCP connection, four pieces of information are needed: (1) Source IP address, (2) Source port number, (3) Destination IP address, (4) Destination port number. These form a pair of socket addresses — the client socket address and the server socket address.

Short Answer

Q19. Why does the transport layer need segmentation and reassembly, but UDP does not provide this feature? What limitation does this place on UDP?

Answer: Segmentation is needed when the message from the application is too large to fit into a single packet. TCP handles this by dividing the message into segments, numbering each byte, and reassembling them at the destination. UDP does NOT perform segmentation or reassembly because it has no sequence numbers. This means UDP can only transmit small amounts of data that fit into a single user datagram. If the application has a large message, it must handle segmentation itself or use TCP instead.

Short Answer

Q20. List and explain the three tools TCP uses for error detection and correction.

Answer:

1. Checksum: A mandatory 16-bit value in every TCP segment. The receiver calculates the checksum and compares it with the value in the header. If they do not match, the segment is corrupted and is discarded (treated as lost).

2. Acknowledgment: The receiver sends an acknowledgment number to confirm which bytes have been received. This lets the sender know which data has arrived safely and which may be missing.

3. Timeout: The sender starts a timer when it sends a segment. If the acknowledgment does not arrive before the timer expires, the sender assumes the segment was lost and retransmits it.

Calculation

Q21. A TCP header dump is given in hexadecimal as: 1F40 0050 00002000 00002001 6002 FFF0 00000000

Find: (a) Source port number, (b) Destination port number, (c) Sequence number, (d) Acknowledgment number, (e) Header length in bytes, (f) Window size in decimal.

Detailed Solution:

(a) Source Port: 1F40 = \(1 \times 4096 + 15 \times 256 + 4 \times 16 + 0 = 4096 + 3840 + 64 + 0 = \boxed{8000}\)

(b) Destination Port: 0050 = \(0 + 0 + 5 \times 16 + 0 = \boxed{80}\) (HTTP)

(c) Sequence Number: 00002000 = \(2 \times 16^3 = 2 \times 4096 = \boxed{8192}\)

(d) Acknowledgment Number: 00002001 = \(8192 + 1 = \boxed{8193}\)

(e) Header Length: Looking at 6002, the data offset (first hex digit) = 6. So \(6 \times 4 = \boxed{24 \text{ bytes}}\). This means there are 4 bytes of options (24 – 20 = 4).

(f) Window Size: FFF0 = \(15 \times 4096 + 15 \times 256 + 15 \times 16 + 0 = 61440 + 3840 + 240 + 0 = \boxed{65,520 \text{ bytes}}\)

Calculation

Q22. A UDP header dump is: 001E 0035 0024 1A2B

Find: (a) Source port, (b) Destination port, (c) Total length, (d) Data length.

Detailed Solution:

(a) Source Port: 001E = \(1 \times 16 + 14 = \boxed{30}\)

(b) Destination Port: 0035 = \(3 \times 16 + 5 = \boxed{53}\) (DNS!)

(c) Total Length: 0024 = \(2 \times 16 + 4 = \boxed{36 \text{ bytes}}\)

(d) Data Length: Total length – UDP header = \(36 – 8 = \boxed{28 \text{ bytes}}\)

Calculation

Q23. A TCP connection starts with ISN = 20,000 at the sender. The sender transmits 5 segments of 1,000 bytes each. Write the sequence number for each segment and the acknowledgment number the receiver will send after receiving all 5 segments.

Solution:

Segment 1: Sequence Number = 20,000 (bytes 20,000 to 20,999)

Segment 2: Sequence Number = 21,000 (bytes 21,000 to 21,999)

Segment 3: Sequence Number = 22,000 (bytes 22,000 to 22,999)

Segment 4: Sequence Number = 23,000 (bytes 23,000 to 23,999)

Segment 5: Sequence Number = 24,000 (bytes 24,000 to 24,999)

Acknowledgment after all 5: Last byte received = 24,999. ACK = 24,999 + 1 = 25,000

Pattern: Each sequence number increases by 1,000 (the segment size). The final ACK = ISN + total bytes = 20,000 + 5,000 = 25,000.

Calculation

Q24. A TCP segment has a header length field (data offset) of 12. Calculate: (a) The header length in bytes, (b) The size of the options field.

Solution:

(a) Header Length: \(12 \times 4 = \boxed{48 \text{ bytes}}\)

(b) Options Size: Total header (48) – Minimum header (20) = \(\boxed{28 \text{ bytes}}\)

The maximum possible options size is 40 bytes (when header = 60 bytes). Here, 28 bytes of options are present, which is within the limit.

MCQ

Q25. Which of the following correctly describes the relationship between TCP segmentation and IP fragmentation?

  1. a) TCP segments messages; IP fragments segments
  2. b) TCP and IP both segment messages at the same layer
  3. c) TCP segments messages into segments; IP may further fragment these segments into smaller packets
  4. d) IP segments messages; TCP does not

Answer: (c). TCP segments the application’s message into TCP segments. These segments are then passed to IP. If a TCP segment is still too large for the underlying network, IP may fragment it further into smaller IP datagrams. They work at different layers and perform different (but related) functions.

Short Answer

Q26. A student says: “UDP is useless because it does not provide reliability.” Do you agree? Give three reasons why UDP is still useful.

Answer: No, I disagree. UDP is very useful in many situations:

1. Speed: UDP has minimal overhead (only 8-byte header, no connection setup), making it much faster than TCP. For applications where speed is more important than perfect reliability, UDP is better.

2. Applications with built-in error control: Some applications like TFTP have their own flow and error control mechanisms. They do not need TCP’s reliability features.

3. Multicasting and broadcasting: UDP supports multicasting, which TCP does not. Applications like video conferencing, live streaming, and route updating protocols (RIP) need this capability.

4. Simple request-response: For small queries like DNS lookups, the overhead of TCP’s connection setup is unnecessary.

MCQ

Q27. In TCP, what does the term “piggybacking” mean?

  1. a) Sending data without a header
  2. b) Including an acknowledgment in a data segment
  3. c) Using multiple connections simultaneously
  4. d) Sending the same segment twice

Answer: (b). Piggybacking means the receiver includes an acknowledgment number in a data segment that it is sending in the opposite direction. This saves bandwidth because a separate ACK segment is not needed. Since TCP is full-duplex, both sides can send data and acknowledgments at the same time.

True / False

Q28. True or False: The network layer treats each packet independently and does not recognize any relationship between packets belonging to the same message.

Answer: True. This is a fundamental characteristic of the network layer. It handles each packet as an independent unit. The transport layer is responsible for recognizing the relationship between packets and reassembling them into the original message.

Fill in the Blank

Q29. TCP provides ________ communication, which means data can flow in both directions at the same time, with each direction having its own sending and receiving ________.

Answer: Full-duplex, buffers. TCP’s full-duplex service allows simultaneous two-way communication. Each direction has its own sending buffer (at the sender) and receiving buffer (at the receiver).

Short Answer

Q30. Compare the Go-Back-N and Selective-Repeat protocols in terms of: (a) Receiver buffering capability, (b) Retransmission strategy, (c) Efficiency in error-prone networks.

Answer:

(a) Receiver buffering: Go-Back-N can buffer only 1 packet. Selective-Repeat can buffer multiple packets (up to the window size).

(b) Retransmission strategy: Go-Back-N retransmits the lost packet AND all packets sent after it. Selective-Repeat retransmits ONLY the lost packets.

(c) Efficiency in error-prone networks: Selective-Repeat is much more efficient when the network frequently loses packets because it avoids unnecessary retransmissions. Go-Back-N wastes bandwidth by retransmitting correctly received packets that arrived after the lost one.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top