Skip to main content

GATE-Computer Networks-TCP/IP

Previous GATE questions with solutions on Computer Networks (TCP/IP) - CS/IT

1. The transport layer protocols used for real time multimedia, file transfer, DNS and email, respectively are
(a) TCP, UDP, UDP and TCP
(b) UDP, TCP, TCP and UDP
(c) UDP, TCP, UDP and TCP
(d) TCP, UDP, TCP and UDP

Ans: option(c)
Real Time Multimedia: Data packets should be delivered faster. Also it can be unreliable. Therefore UDP.
File Transfer: For example downloading a file. It should be secure and reliable. Therefore TCP.
DNS: uses both UDP and TCP for its transport. But to acheive efficiency DNS uses UDP. To start a TCP connection a minimum of three packets are required (SYN out, SYN+ACK back, ACK out). UDP uses a simple transmission model with a minimum of protocol mechanism. UDP has no handshaking dialogues.
Email: uses SMTP protocol which uses TCP protocol.

Standard applications using UDP include:
  • Trivial File Transfer Protocol (TFTP)
  • Domain Name System (DNS) name server
  • Remote Procedure Call (RPC), used by the Network File System (NFS)
  • Simple Network Management Protocol (SNMP)
  • Lightweight Directory Access Protocol (LDAP)
TCP is utilized extensively by 
  • World Wide Web (WWW)
  • E-mail
  • File Transfer Protocol
  • Secure Shell
  • Peer-to-Peer file sharing

2. The subnet mask for a particular network is Which of the following pairs of IP addresses could belong to this network.
(a) &
(b) &
(c) &
(d) &

Ans: option (d)
Here is the question is: Which of the following pair of IP addresses belongs to the given network. Applying a subnet mask to an IP address separates network address from host address.

So you have to find the network-id from the IP address using the given subnet mask. Below shows the example of how to find a network-id from given Subnet mask and IP address

The network bits are represented by the 1's in the subnet mask, and the host bits are represented by 0's. Performing a bitwise logical AND operation on the IP address with the subnet mask produces the network address. For example, applying the Class C subnet mask to our IP address produces the following network address:

IP:     1101 1000 . 0000 0011 . 1000 0000 . 0000 1100  (
Mask: 1111 1111 . 1111 1111 . 1111 1111 . 0000 0000  (
         1101 1000 . 0000 0011 . 1000 0000 . 0000 0000  (

Therefore the network-id is:

Hence doing the above for all the options, you will find that option (d) belongs to the same network.

3. The routing table of a router is shown below

On which interface will router forward packets addressed to destinations and respectively?
a)Eth1 and Eth2      b)Eth0 and Eth2
c)Eth0 and Eth3      d)Eth1 and Eth3

Ans: option(a)
Perform AND operation between incoming IP address and Subnet-mask and then compare the result with the destination. Note that if there is a match between multiple Destinations, then select the destination with longest length subnet mask. For example,, matches with and But the packet's addressed to will be forwarded to Eth1.

If a result is not matching with any of the given destinations then the packet is forwarded to the default interface (here Eth2). Therefore the packet's addressed to will be forwarded to Eth2.

4. One of the header fields in an IP datagram is the Time to Live (TTL) field. Which of the following statements best explains the need for this field?(a) It can be used to priortize packets
(b) It can be used to reduce delays
(c) It can be used to optimize throughput
(d) It can be used to prevent packet looping

Ans: (d)

5. Suppose computers A and B have IP addresses and respectively and they both use the same netmask N. Which of the values of N given below should not be used if A and B should belong to the same network?
(a) (b)
(c) (d)

Ans: option (d)
Apply subnet mask to the IP address, i.e. perform AND operation between IP address and subnet mask. If the result is equal for both IP address A & B then we can use that subnet mask else not. Applying subnet mask to all options we find that option (d) cannot be used.

6. Consider an instance of TCP’s Additive Increase Multiplicative Decrease(AIMD) algorithm where the window size at the start of the slow start phase is 2 MSS and the threshold at the start of the first transmission is 8 MSS. Assume that a time out occurs during the fifth transmission. Find the congestion window size at the end of the tenth transmission.
(a) 8 MSS (b) 14 MSS (c) 7 MSS (d) 12 MSS

Ans: option (c)
Read Slow Start Algorithm:
Read AIMD Algorithm:

Note: Got through the above two links before you get into the solution.
Its given that initial Threshold is: 8MSS

Window Size
Slow Start Phase
Threshold reaches;  According to AIMD increase by 1MSS
Timeout occurs. New Threshold = 10/2 = 5MSS
Reset to Slow Start State
Slow Start Phase
Threshold reaches.
According to AIMD increase by 1MSS

Hence the answer is: 7MSS (since it transmitted 7 segments during 10th transmission)

7. In the slow start phase of the TCP congestion control algorithm, the size of the congestion window
(a) does not increase (b) increases linearly
(c) increases quadratically (d) increases exponentially

Ans: option (d)
Read Slow Start Algorithm:

8. If a class B network on the Internet has a subnet mask of, what is the maximum number of hosts per subnet?
(a) 1022 (b) 1023 (c) 2046 (d) 2047

Ans: option (c)
Convert the subnet mask into binary format. = 11111111.11111111.11111000.00000000
Number of 1's in the subnet mask indicates the Network-ID and the Subnet-ID part
Number of 0's in the subnet mask indicates the Host-ID part

Maximum number of Hosts per subnet = 211 = 2048
where 11 = Number of 0's in the Subnet Mask.

Out of 2048 values, 2 addresses are reserved, hence we remove them (2048-2 = 2046). 
Note: In the host part of the address:- all bits as 1 is reserved as broadcast address and all bits as 0 is used as network address of subnet.

Hence option (c) is the answer.

9. Which of the following system calls results in the sending of SYN packets?
(a) socket (b) bind (c) listen (d) connect

Ans: option (d)

A typical TCP client and server application issues a sequence of TCP system calls to attain certain functions. 

The socket system call creates a new socket and assigns the protocol and resources to the created socket descriptor.

The bind system call associates a local network transport address with a socket. For a client process, it is not mandatory to issue a bind call. The kernel takes care of doing an implicit binding when the client process issues the connect system call. It is often necessary for a server process to issue an explicit bind request before it can accept connections or start communication with clients.

The listen call indicates to the protocol that the server process is ready to accept any new incoming connections on the socket. There is a limit on the number of connections that can be queued up, after which any further connection requests are ignored.

The connect system call is normally called by the client process to connect to the server process.

To know more on TCP system call sequences:

10. What is the maximum size of data that the application layer can pass on to the TCP layer below?
(a) Any size (b) 216 bytes-size of TCP header
(c) 216 bytes (d) 1500 bytes

Ans: option (a)
Application layer can forward any size of data to the transport layer. Transport layer in turn divides the data into several data packets.

11. The protocol data unit(PDU) for the application layer in the Internet stack is
(a) Segment (b) Datagram (c) Message (d) Frame

Ans: (c)
PDU for Application Layer - Message
PDU for Internet Layer - Datagram
PDU for Transport Layer - Segment
PDU for Link Layer - Frame

12. Which of the following transport layer protocols is used to support electronic mail?
(a) SMTP (b) IP (c) TCP (d) UDP

Ans: (c)
Application Layer protocol for sending email is SMTP (Simple Mail Transfer Protocol). SMTP is a connection oriented protocol, therefore it uses TCP at Transport Layer.
IP - It is a network layer protocol.
UDP - is a connection-less transport layer protocol.

13. In the IPv4 addressing format, the number of networks allowed under Class C addresses is
(a) 214 (b) 27 (c) 221 (d) 224

Ans: option (c)
of networks
Number of Hosts
Start address
End address
Class A
Class B
Class C
Class D (multicast)
    not defined
    not defined
Class E (reserved)
    not defined
    not defined
* Having all 0's or all 1's either in the network-id or in the host-id is not allowed, because they are meant for special purposes and are reserved.

14. An organization has a class B network and wishes to form subnets for 64 departments. The subnet mask would be:
(a) (b) (c) (d)

Ans: option (d)
Number of 1's in the subnet mask indicates the Network-ID and the Subnet-ID part
Number of 0's in the subnet mask indicates the Host-ID part

Since Class B network, network-ID consists of 16 bits, and host-id consists of 16 bits. Since we need 64 subnetworks, we have to borrow 6 bits for subnet-ID. Therefore, subnet mask will be

GATE - 2013
15. Assume that source S and destination D are connected through two intermediate routers labeled R. Determine how many times each packet has to visit the network layer and the data link layer during a transmission from S to D.

(a) Network layer – 4 times and Data link layer-4 times
(b) Network layer – 4 times and Data link layer-3 times
(c) Network layer – 4 times and Data link layer-6 times
(d) Network layer – 2 times and Data link layer-6 times

Ans: option (c)

The above figure will give you the clear explanation of the answer. Note that, a router is considered a Layer 3 device because its primary forwarding decision is based on the information in the Layer 3 IP packet, specifically the destination IP address.


Popular posts from this blog

C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
int const * p=5; printf("%d",++(*p));
Compiler error: Cannot modify a constant value.
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
Answer: mmmm
aaaa nnnn

Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
    1. Booking
    2. Availability checking
    3. Cancellation
    4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

 My Solution :

#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<string.h>#include<iostream.h>#include<time.h>#include<iomanip.h>#include<fstream.h>char f[10]="f";char s[10]="s";int addr,ad,flag,f1,d,m,i,amt;float tamt; class login {public:char id[100];char pass[100];char*password;void getid(){ cout<<"Enter your id:";gets(id); password=getpass("Enter the password:");strcpy(pass,password);}void displayid(){ cout<<"Id:";puts(id); cout<<"Password:";puts(pass);}}; class detail {public:in…

Hackerrank > SQL > Basic Select

01-Select All
Given a City table, whose fields are described as +-------------+----------+ | Field       | Type     | +-------------+----------+ | ID          | int(11)  | | Name        | char(35) | | CountryCode | char(3)  | | District    | char(20) | | Population  | int(11)  | +-------------+----------+
write a query that will fetch all columns for every row in the table.

My Solution
02-Select by ID
Given a City table, whose fields are described as