December Code

Data link layer interview questions, with answers

The data link layer moves frames across a single link, whether Ethernet or Wi-Fi, and it is where addresses, shared media and error detection meet. Interview questions range from how ARP finds a MAC address to how Ethernet and Wi-Fi share a medium.

The answers below cover what the data link layer does, ARP, CSMA/CD and CSMA/CA, CRC error detection, VLANs and Hamming codes. Then take the free Computer Networks diagnostic — ten questions across every networking topic in the bank — to see which of these you can explain but not yet apply.

The questions, with answers

  1. 1.What does the data link layer do?

    In short: It frames network-layer packets for one link, addresses them with MAC addresses, detects errors, and controls access to shared media.

    The data link layer takes a packet from the network layer and wraps it in a frame for one hop: a header with the source and destination MAC addresses and a type field, and a trailer with a frame check sequence for error detection. It delimits frames so the receiver knows where each begins and ends, and on shared media it decides who may transmit, through medium access control. IEEE splits it into the MAC sublayer, which handles addressing and media access, and the logical link control sublayer. Ethernet and Wi-Fi are the dominant data link technologies.

  2. 2.How does ARP work?

    In short: A host broadcasts "who has this IP?", the owner replies with its MAC address, and the answer is cached.

    To send a packet to a local IP address, a host needs the destination's MAC address for the frame. It first checks its ARP cache. If the address is not there, it broadcasts an ARP request to every host on the local network asking which host owns that IP address. The owner replies directly with its MAC address, and the sender caches the mapping for a few minutes. For a destination on another network, the host resolves the MAC address of its default gateway instead. Because ARP trusts any reply, attackers can poison caches, which switches counter with dynamic ARP inspection.

  3. 3.What are CSMA/CD and CSMA/CA?

    In short: Media access methods: classic Ethernet listens and detects collisions to retransmit; Wi-Fi listens and tries to avoid collisions in advance.

    Both use carrier sense multiple access: a station listens and transmits only when the medium is idle. CSMA/CD, collision detection, was used by classic shared Ethernet: a station kept listening while sending, stopped when it detected a collision, sent a jam signal, and retried after a random, exponentially growing backoff. Switched full-duplex Ethernet has no collisions, so it no longer needs it. Wi-Fi cannot detect collisions while transmitting, so it uses CSMA/CA, collision avoidance: random backoff before sending, acknowledgement of every frame, and optionally RTS and CTS messages to reserve the medium.

  4. 4.How does a cyclic redundancy check (CRC) detect errors?

    In short: The sender appends the remainder of dividing the frame by a generator polynomial; the receiver repeats the division and expects zero.

    CRC treats the frame's bits as the coefficients of a polynomial and divides by an agreed generator polynomial using modulo-2 arithmetic, in which subtraction is XOR. The sender appends the remainder, the check value, to the frame, making the whole frame exactly divisible by the generator. The receiver divides what arrives by the same generator; a non-zero remainder means the frame was corrupted and it is discarded. A well-chosen generator of degree r detects all single-bit errors and all burst errors up to r bits long. Ethernet uses the 32-bit CRC-32, computed quickly in hardware.

  5. 5.What is a VLAN?

    In short: A virtual LAN: a switch's ports grouped into separate broadcast domains, with 802.1Q tags carrying VLAN membership between switches.

    A VLAN divides one physical switched network into several logical ones. Ports are assigned to VLANs, and a switch forwards frames, including broadcasts, only among ports in the same VLAN, so each VLAN is its own broadcast domain, as if on separate switches. Links between switches carry several VLANs as trunks, adding an IEEE 802.1Q tag to each frame to identify its VLAN. Traffic between VLANs must go through a router or a layer 3 switch. VLANs separate departments or guest networks, limit broadcast traffic and apply security policies without rewiring.

  6. 6.How does a Hamming code correct errors?

    In short: Parity bits at power-of-two positions each check an overlapping set of bits; the failing checks spell out the bad bit's position.

    A Hamming code places parity bits at positions 1, 2, 4, 8 and so on, and each parity bit covers the positions whose binary index contains its bit: position 1 checks 1, 3, 5, 7, position 2 checks 2, 3, 6, 7, and so on. At the receiver, recomputing the checks gives a syndrome, and read as a binary number, the failing checks point to the position of a single flipped bit, which is then corrected. Hamming(7,4) protects 4 data bits with 3 parity bits. Adding one overall parity bit also detects, but cannot correct, double-bit errors, as in ECC memory.

How the diagnostic asks it

One question from the Computer Networks bank, exactly as a sitting would show it. The bank has 4 on data link & error detection and 30 across Computer Networks.

Data Link & Error Detection · easyCN-015

Which protocol finds the MAC address that belongs to an IPv4 address on the local network?

  1. 1DNS
  2. 2DHCP
  3. 3ARPcorrect
  4. 4ICMP

To send a frame to a host on the same network, a sender needs its MAC address. ARP broadcasts a request asking which host has a given IPv4 address; the owner replies with its MAC address, and the sender caches the answer in its ARP table. DNS maps names to IP addresses, one level up. DHCP assigns IP addresses and other settings to hosts. ICMP carries error and diagnostic messages, such as those ping and traceroute use. IPv6 replaces ARP with Neighbor Discovery.

Measure it

Reading answers tells you what’s true. A diagnostic tells you what you get wrong.

10 Computer Networks questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.

What the readiness test measures · how the score is computed

By Harshit · updated