Network Interface

This article is not assessed by the IB but may be helpful to deepen your understanding. Plus, I think it's cool.

Big Idea
A network interface is the defined boundary—both physical and logical—through which a host system exchanges data with a network. It translates between the host’s internal data structures and the on-the-wire bit streams, enforcing link-level protocols, managing addressing, and providing the entry and exit point for all inbound and outbound traffic. 

You can think of a network interface as the “door” or “portal” between your computer and the wider network. Just as a door controls what comes in and out of a room, the network interface governs how data packets enter and leave the host, translating between internal formats and the on-the-wire signals and enforcing the rules of the link-layer protocols.

Please also understand that most computers have multiple interfaces for networks; wireless, wired, and bluetooth are all different interfaces through which network traffic can travel. 


1. Physical and Data-Link Layer Components

1.1 Network Interface Card (NIC)

  • Hardware Function: A dedicated adapter—wired (Ethernet) or wireless (Wi-Fi)—that implements the physical (Layer 1) and media-access control (sub-layer of Layer 2) functions.
  • Key Elements:
    • Transceiver: Converts digital frames to electrical, optical or RF signals and vice versa.
    • MAC Controller: Enforces framing, error detection (CRC), and collision or carrier-sense protocols (e.g., CSMA/CD for Ethernet).
    • DMA Engine & Buffers: Offloads memory transfers and stores packets awaiting processing.
    • Interrupts & MSI-X: Notify the host CPU of received frames or transmit completion.

1.2 Link-Layer Protocols

  • Ethernet (IEEE 802.3): Defines frame format, MAC addressing, speed negotiation (10 Mb/s to 100 Gb/s+), and fault detection.
  • Wi-Fi (IEEE 802.11): Adds association/authentication, media sharing via CSMA/CA, and encryption (WPA2/3).
  • Virtual LANs (802.1Q): Tag Ethernet frames with VLAN identifiers, allowing a single NIC port to serve multiple logical networks.

2. Logical Interfaces and Operating-System Integration

2.1 Logical Interface Abstraction

  • Definition: A software-defined endpoint—identified by a unique name (e.g., eth0, wlan0, lo)—that the kernel presents to network-stack modules and applications.
  • Types:
    • Physical Interface: Directly bound to a NIC.
    • Loopback (<strong>lo</strong>): Internal interface that routes traffic back to the host without emitting frames on the wire.
    • Tunnel Interfaces: Encapsulate packets for VPNs (e.g., GRE, IPsec) or IPv6-over-IPv4.
    • Bridge Interfaces: Aggregate multiple ports into a single broadcast domain.
    • Bonding/Link Aggregation: Combines multiple physical NICs for redundancy or increased throughput (IEEE 802.3ad).

2.2 Driver and Protocol Stack Interaction

  • Device Driver: Kernel module that initializes the NIC, programs its registers (MAC address, MTU, DMA buffers), and registers interrupt handlers.
  • Network Stack Hooks:
    1. Transmit Path: Applications hand off IP packets to the socket layer → encapsulation into Ethernet frames → driver DMA → NIC transmits.
    2. Receive Path: NIC interrupts on frame arrival → DMA copies into kernel buffers → driver hands frame to link-layer handler → de-encapsulation and delivery to the IP layer or raw sockets.
  • Offloading Features: Checksumming, segmentation offload (TSO/LRO), VLAN tag insertion/removal to reduce CPU load.

3. Addressing and Configuration

3.1 MAC and IP Addresses

  • MAC (Media Access Control) Address: 48-bit hardware identifier, unique to each NIC, used for link-layer forwarding.
  • IP Address Assignment:
    • Static Configuration: Administrator sets IP address, netmask, gateway on the interface.
    • Dynamic Host Configuration Protocol (DHCP): Interface obtains addressing information from a DHCP server at boot or on link-state change.

3.2 Interface Parameters

  • MTU (Maximum Transmission Unit): Largest payload size per frame; mismatches can cause fragmentation and throughput degradation.
  • Duplex & Speed: Negotiated or statically set; mismatches (e.g., half-duplex vs. full-duplex) lead to collisions and packet loss.
  • Link State (<strong>UP</strong>/<strong>DOWN</strong>): Indicates whether physical and data-link layers are operational; affects routing table entries and ARP behaviors.

4. Advanced Interface Concepts

4.1 Virtualization and Containers

  • Virtual NICs (vNICs): Software-only interfaces provisioned to virtual machines or containers; mapped onto physical NICs via hypervisor bridges.
  • SR-IOV (Single Root I/O Virtualization): NIC hardware provides multiple virtual functions, each appearing as an independent PCIe device to guest OSes, for near-bare-metal performance.

4.2 Quality of Service (QoS) and Traffic Shaping

  • Queuing Disciplines (qdiscs): Kernel modules that schedule packet transmission based on priority, bandwidth limits or traffic classes (e.g., HTB, FQ_CoDel).
  • Ingress/Egress Policing: Rate-limit or drop flows that exceed configured thresholds to enforce SLAs.

Conclusion
A network interface bridges the physical medium and the host’s software stack, encompassing hardware circuitry, driver logic and protocol abstractions. Mastery of its components—NIC capabilities, link-layer behaviors, logical interface types, addressing and advanced features like virtualization and QoS—is essential for designing, troubleshooting and optimizing LAN performance and reliability.