CORE JOBS
Computer Networks interview questions
Short answers on the fundamentals, for the technical round of core-job interviews. 23 questions for CSE/IT students; the numericals show the working.
Companies do not publish their interview questions; these are ours.
Layering and switching
Layering & switching notesWhat is encapsulation in a layered network stack?
Each layer adds its own header to the data it gets from the layer above (the link layer also adds a trailer), and the receiver removes them in reverse order. A layer reads only its own header and treats everything inside as opaque payload, which keeps the layers independent.
What is the difference between datagram packet switching and virtual-circuit packet switching?
In datagram switching each packet carries the full destination address and is routed on its own, so packets can take different paths and arrive out of order. In virtual-circuit switching a path is set up first, packets carry a short circuit identifier and follow that path in order. Routers keep per-circuit state only in the second case.
A 12000-bit message is split into 4 packets of 3000 bits each and sent over 3 links in series (two store-and-forward routers between the hosts). Each link runs at 2 Mbps. Ignore propagation, queueing and header overhead. How long does the whole message take to arrive?
The message needs 9 ms from the first bit sent to the last bit received, because 6 packet times of 1.5 ms are needed when the packets pipeline over the three links.
WORKING
- Transmission time of one packet on one link: ms.
- With packets and links, the total is .
- ms.
Performance metrics
Performance notesWhat is the bandwidth-delay product, and what does it tell a sender?
It is the link bandwidth multiplied by a delay. With the round-trip time, it is the number of bits a sender can transmit before the first acknowledgement returns; with the one-way delay, it is the bits on the link at once. A sliding-window sender needs a window covering the round-trip product to keep the link busy. A smaller window leaves the link idle while it waits for acknowledgements.
What is the difference between transmission delay and propagation delay?
Transmission delay is the time to push all the bits of a packet onto the link: packet length divided by bandwidth. Propagation delay is the time for one bit to travel along the link: distance divided by signal speed. Doubling the bandwidth halves the first and leaves the second unchanged.
A stop-and-wait sender sends 1500-byte frames over a 10 Mbps link. The one-way propagation delay is 5 ms, and the acknowledgement is so small that its transmission time can be ignored. What is the link utilisation?
Link utilisation is about 10.7%, because the sender transmits for only 1.2 ms in every 11.2 ms cycle and then waits idle for the acknowledgement to return.
WORKING
- Frame size is bits.
- Transmission time: ms.
- Cycle time: ms.
- Utilisation: .
Why is the Go-Back-N sender window limited to for -bit sequence numbers, while Selective Repeat allows only ?
Go-Back-N has a receiver window of 1. With a sender window of , if every acknowledgement of a full window is lost, the retransmitted first frame carries the number the receiver now expects and is accepted as a new frame. Selective Repeat has a receiver window as large as the sender's, and the two windows together must fit in numbers, or the receiver would accept an old frame as new.
Data link layer
Data link & MAC notesHow does a CRC detect transmission errors?
The sender treats the data as a polynomial, appends zero bits ( is the degree of an agreed generator polynomial), divides by the generator using modulo-2 arithmetic and replaces the zeros with the -bit remainder, so the frame is divisible by the generator. The receiver divides again: a non-zero remainder means an error. If the generator has a non-zero constant term, it detects all burst errors of length or less.
Why does CSMA/CD need a minimum frame size?
The sender must still be transmitting when a collision signal returns from the farthest station, so the frame's transmission time must be at least twice the one-way propagation delay. A shorter frame could finish before the collision is heard, and the sender would wrongly treat it as delivered.
What is the difference between a hub and a switch in an Ethernet LAN?
A hub repeats every incoming bit on all other ports, so all its ports share one collision domain. A switch learns which MAC address is behind each port and forwards a frame only to the port of its destination, so each port is its own collision domain. Without VLANs, both still form a single broadcast domain.
Routing
Routing notesWhat is the difference between distance-vector and link-state routing?
A distance-vector router tells its neighbours its whole table of costs and updates its own with the Bellman-Ford rule, so it knows only distances and next hops. A link-state router floods information about its own links to every router, then runs Dijkstra on the full map. Link state converges faster but needs more memory and flooding.
Why does count-to-infinity happen in distance-vector routing, and what does split horizon do about it?
Routers trust the costs their neighbours advertise. After a link fails, two routers can each believe the other still has a route, and they raise the cost by one step per exchange. Split horizon stops a router advertising a route back to the neighbour it learned it from. It does not stop loops that involve three or more routers.
Router A is linked to B at cost 2 and to C at cost 5. B advertises a cost of 7 to reach network D, and C advertises a cost of 3. Using the distance-vector update, what cost does A record for D?
Router A records a cost of 8 to reach D, with C as the next hop, because 5 + 3 = 8 is smaller than 2 + 7 = 9.
WORKING
- Update rule: .
- Via B: .
- Via C: .
- The minimum is 8, so the next hop is C.
IPv4
IPv4 notesWhat is longest-prefix match, and why do routers use it?
When several routing entries match a destination address, the router uses the one with the longest prefix, meaning the most matching bits. CIDR lets a broad aggregate route and a more specific route overlap, and the specific route must win. The default route 0.0.0.0/0 matches everything and is therefore used last.
An IPv4 datagram of total length 4000 bytes (including a 20-byte header) must cross a link with an MTU of 1500 bytes. Into how many fragments is it split?
The datagram is split into 3 fragments, carrying 1480, 1480 and 1020 bytes of data, because the 3980 bytes of data cannot fit in two fragments of at most 1480 bytes.
WORKING
- Data in the datagram: bytes.
- Largest data per fragment: bytes, which is a multiple of 8, so it is allowed.
- Fragments needed: .
- The last fragment carries bytes.
Why is NAT used, and what does it cost?
NAT lets many hosts with private addresses share one public IPv4 address. The router rewrites the source address and port of outgoing packets and keeps a table to map replies back. It eases the shortage of IPv4 addresses. The cost is that outside hosts cannot start a connection to an inside host unless a mapping already exists.
TCP
TCP notesWhat happens in the TCP three-way handshake, and what is it for?
The client sends a SYN with its initial sequence number, the server replies with a SYN and ACK carrying its own initial sequence number, and the client sends an ACK. Both sides then agree on starting sequence numbers and know that the path works in both directions before any data is sent.
What is the difference between TCP flow control and congestion control?
Flow control stops the sender from overrunning the receiver's buffer, using the window the receiver advertises. Congestion control stops it from overrunning the network, using a congestion window the sender estimates from losses and acknowledgements. The sender may have in flight no more than the smaller of the two windows.
A TCP sender starts with a congestion window of 1 MSS in the first round, with a threshold of 16 MSS. No packets are lost. Slow start doubles the window each round and stops when it reaches the threshold, and after that the window grows by 1 MSS per round. What is the window in the 7th round?
The congestion window in the 7th round is 18 MSS: it doubles up to the threshold of 16 MSS in round 5, then grows by 1 MSS in each later round.
WORKING
- Slow start: rounds 1 to 5 give 1, 2, 4, 8, 16 MSS.
- The threshold of 16 is reached in round 5, so slow start ends.
- Congestion avoidance adds 1 MSS per round: round 6 is 17 MSS.
- Round 7 is 18 MSS.
Why does TCP react differently to a timeout and to three duplicate ACKs?
Three duplicate ACKs show that later segments are still arriving, so the network is working and probably only one segment was lost: TCP Reno sets the threshold to half the current window, cuts the window to that threshold and continues in congestion avoidance. A timeout suggests heavier congestion, so TCP sets the threshold to half the current window and drops the window to 1 MSS to restart slow start.
Application layer
DNS & HTTP notesWhat is the difference between a recursive and an iterative DNS query?
In a recursive query the server takes over the whole job, asks other servers as needed and returns the final answer. In an iterative query the server returns the best answer it has, often a referral to the next server, and the asker sends the next query itself. A host usually asks its local resolver recursively, and the resolver then queries the root, top-level and authoritative servers iteratively.
What do the DNS record types A, NS, CNAME and MX hold?
An A record maps a name to an IPv4 address (AAAA does the same for IPv6). An NS record names the authoritative name server for a zone. A CNAME record makes one name an alias of another, canonical name. An MX record names the mail server that accepts email for a domain.
A web page has a base HTML file and 5 small embedded objects. The round-trip time to the server is 100 ms. The browser uses non-persistent HTTP, opening one new TCP connection per object, one after another. Ignore transmission times and DNS lookup. How long does the page take to load?
The page takes 1200 ms, because each of the 6 objects needs 2 RTTs, one for the TCP handshake and one for the request and response.
WORKING
- Objects in total: .
- Each object needs 1 RTT for the TCP handshake and 1 RTT for the request and response, so 2 RTTs.
- Total: RTTs.
- ms.
More interview questions: Digital Electronics · Programming in C · Data Structures and Algorithms · Computer Organization and Architecture · Database Management and Warehousing · Operating Systems
Who hires and how they select: IT jobs for CSE/IT
Computer Networks: notes, formula sheet and past questions