### Gate - Computer Networks - Ethernet

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

GATE-2005
1. In a network of LANs connected by bridges, packets are sent from one LAN to another through intermediate bridges. Since more than one path may exist between two LANs, packets may have to be routed through multiple bridges. Why is the spanning tree algorithm used for bridge-routing?

(a) For shortest path routing between LANs
(b) For avoiding loops in the routing paths
(c) For fault tolerance
(d) For minimizing collisions

Ans: Option (b)
Explanation:
The Spanning Tree Protocol is used by OSI Data Link Layer devices to create a spanning tree using the existing links (as the source graph) in order to avoid avoiding loops in the routing paths.

Note: To avoid infinite looping, Network Layer uses TTL (Time To Live) field.

GATE-2007

2. In Ethernet when Manchester encoding is used, the bit rate is:
(a) Half the baud rate
(b) Twice the baud rate
(c) Same as the baud rate
(d) None of the above

Ans: Option (a)
Explanation:
Manchester coding is the process by which digital information in a binary bit stream is converted into electrical signals for transmission. It uses a two-state transition of line voltage to represent one bit of information. In other words, two baud (voltage changes) are used for one bit (piece of information).

Manchester coding has the advantage of enabling data to be transmitted without the need for an extra clocking signal.

GATE-2003
3. A 2 km long broadcast LAN has 107 bps bandwidth and uses CSMA/CD. The signal travels along the wire at 2×108 m/s. What is the minimum packet size that can be used on this network?
(a) 50 bytes       (b) 100 bytes       (c) 200 bytes       (d) None of the above

Ans: Option (d)
Explanation:
In CSMA/CD, the transmitting node is listening for collisions while it transmits it's frame. Once it has finished transmitting the final bit without hearing a collision, it assumes that the transmission was successful. In this worst-case collision scenario, the time that it takes for a Node to detect that its frame has been collided with is twice the propagation delay. Hence to confirm that the collision has not occurred the condition for the minimum size of the packet is:
RTT = Transmission Time

Transmission Time = Length of packet / Bandwidth
RTT = 2 (d/v) = 2(2000/2×108

Therefore to find minimum size of the packet,
RTT = Length of packet / Bandwidth
Length of packet = RTT x Bandwith
= 2(2000/2×108) x 107 = 200bits = 25bytes

Therefore, minimum size of the packet = 25bytes

GATE-2004
4. A and B are the only two stations on an Ethernet. Each has a steady queue of
frames to send. Both A and B attempt to transmit a frame, collide, and A wins
the first backoff race. At the end of this successful transmission by A, both A and B attempt to transmit and collide. The probability that A wins the second backoff race is
(a) 0.5       (b) 0.625         (c) 0.75           (d) 1.0

Ans: Option (b)
Explanation:
In Ethernet networks, the Exponential back-off algorithm is commonly used to schedule re-transmissions after collisions. This algorithm gives waiting time for the stations that are involved in collision.
Waiting time for station = k x 51ms
K is randomly chosen from 0 to 2n-1 where n= no of collisions a station is involved.
51ms is a generic RTT for a standard Ethernet.

Station A and Station  both try to access a link at the same time. Since they detect a collision, A waits for a random time between 0 and 1 time units and so does B. It's given that A wins the first back-off race. Hence A has no need to wait and begins to use the link and B waits for 1 x 51ms (k=1 is the number selected by B according to the algorithm).  At the end of this successful transmission by A, both A and B attempts to transmit, and collide. A will once again choose a random back-off time between 0 and 1, but B will choose a back-off time between 0 and 3 – because this is his second time colliding in a row.
 Value of K selected by A Value of K selected by B Winner 0 0 X 0 1 A 0 2 A 0 3 A 1 0 B 1 1 X 1 2 A 1 3 A
Hence A has 5 chances to win out of 8 combinations.
Therefore that A wins the second backoff race = 5/8 = 0.625

Gate-2005
5. Suppose the round trip propagation delay for a 10 Mbps Ethernet having 48-bit jamming signal is 46.4 ms. The minimum frame size is:
(a) 94 (b) 416 (c) 464 (d) 512

Ans: Option (c)
Explanation:
As explained in question no 3, condition for the minimum size of the packet is:
RTT = Transmission Time
RTT = Length of packet / Bandwidth
Minimum frame size = RTT x Bandwidth
=  46.4ms x 10Mbps = 464bits.

GATE-2007
6. There are n stations in a slotted LAN. Each station attempts to transmit with a probability p in each time slot. What is the probability that ONLY one station transmits in a given time slot?
(a) (1-p)n-1    (b) np(1-p)n-1     (c) p(1-p)n-1    (d) 1-(1-p)n-1

Ans: Option (b)
Explanation:
Given,
n= total number of stations
p= probability of a station to transmit a packet
1-p = probability of a station not to transmit a packet
The probability that a particular station transmits and no body else transmits = p(1-p)n-1

The probability that any station can transmit among n stations = n p(1-p)n-1

### 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.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
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]);
}
aaaa nnnn
Explanation

### 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 :