Markus Löning

Software Engineering & Machine Learning

Network engineering

Posted at Jul 24, 2025 23:07:58 — Last modified at Nov 13, 2025 18:52:04

Intro

I recently had to think more about network engineering. Here are my notes from reading Beej’s Guide to Network Programming and Computer Networking: A Top-Down Approach.

Overview

Five-layer version of Open System Interconnection (OSI) model:

LayerNameProtocol Data UnitFunctionDiagnostic Tools
5ApplicationDataProtocols for data exchange, resource sharing and remote file access (e.g. HTTP, SMTP, LDAP, DNS)Loggers, debuggers
4TransportSegmentLogical communication between processes on network hosts, including segmentation, reliability and multiplexing (e.g. TCP, UDP, ICMP)netstat, nc (netcat), tcpdump
3NetworkPacket, DatagramLogical communication between network hosts, including addressing, routing and traffic control (e.g. IPv4, IPv6, ICMP)ifconfig, route, ping, traceroute
2Data linkFrameTransmission of data between network hosts connected by a physical layer (e.g. Ethernet, WiFi)arp, ndp, tcpdump
1PhysicalBit, SymbolTransmission of raw streams over a physical medium (e.g. copper/fibre wires, WiFi/radio waves)Hardware status lights, ifconfig

Level 5 is sometimes broken down further (7-layer model), but for a high-level understanding, the differences are not critical; they all concern the application.

Intuitively, the layers works like a postal system. When sending a message, each layer passes its message (payload) down to the next layer, which wraps it in its own envelope, adding its own layer-specific information (headers) (see encapsulation). At reception, the reverse happens. Starting from the physical layer, each layer unwraps the message using the information in the headers and passes it up to the next layer (de-encapsulation). Each layer only acts on its layer-specific headers, leaving the rest untouched. In practice, encapsulation and de-encapsulation is more complex: a message may be split up into multiple segments, which in turn are split up into multiple datagrams.

Most complexity is designed to be in the network-edge devices (end systems), including the application and transport layer. Network-core devices, including everything from the network layer and below, are designed to be simple.

Upper layers are constrained by services provided by lower layers (e.g. physical limitations like bandwith or transmission delay), but can build services on top to remedy lower-level limitations (e.g. TCP provides reliable data transfer on the transport layer on top of the unreliable network layer IPv4 protocol).

Physical layer

Network interface

Switch

Services

services provided by link layer:

Error detection and correction

Channel partitioning protocols

Random access protocols

Taking turns protocols

Switched LAN

Address Resolution Protocol (ARP)

Ethernet

Local area network (LAN)

Virtual LAN (VLAN)

Network layer: data plane

Control vs data plane

Router

Components

Input port processing (destination-based forwarding)

Switching

Output port processing

Queuing

Internet Protocol (IP)

Monitoring and diagnostics

IPv4

Datagram

total of 20 bytes IPv4 headers + 20 bytes TCP headers

Addresing

IP address assignment

Dynamic Host Configuration Protocol (DHCP)

protocol flow for assigning an IP address to a new host:

  1. a new host send a UDP broadcast discovery message to 255.255.255.255:67 (port 67 is reserved for DHCP)
  2. server(s) respond with UDP broadcast offer message, containing proposed address, lease time and ID of the discovery message
  3. client sends request message choosing from received offer(s)
  4. server responds with acknowledgement

Private IP addresses

Network Address Translation (NAT) and Server Name Indication (SNI)

Proxies and firewalls

IPv6

Datagram

fields:

Generalized forwarding and software defined networking (SDN)

OpenFlow protocol

Middle boxes

Network layer: control plane

Routing algorithms

Distance-vector algorithms (decentralized)

Autonomous systems (AS) and intra-AS routing protocol

Open-Shortest Path First (OSPF) protocol

Inter-AS routing (among Internet Service Providers)

glues together thousands of Internet Service Providers in the Internet

Border Gateway Protocol (BGP)

IP Anycast

example:

Control plane

components

Controller

OpenFlow API

controller -> switch:

switch -> controller:

Internet control message protocol (ICMP)

Network management

Transport layer

Principles for choosing transport layer protocols

TCP/IP protocol stack

UDP

Segment structure

Reliable data transfer

Essential components include:

which require the following features:

TCP

Segment structure

Network congestion control

Costs of congested networks

Control strategies

Ports

If the subnet mask is like the stream name and the IP address like the house number, then the port is like a room number.

Monitoring and diagnostics:

Application layer

High-level design of network applications

Client/server

Server is

For example, HTTP web servers.

Peer-to-peer (P2P)

For example, BitTorrent.

Sockets

Bind (server) and connect (client)

Domain name system (DNS)

Monitoring and diagnostics:

Hypertext Transfer Protocol (HTTP)

MPEG-DASH

Quick UDP Internet Connections (QUIC)-HTTP/2

Content Distribution Network (CDN)

Let’s Encrypt

Security

Monitoring, diagnostics and debugging

Packet sniffing

tcpdump usage

Alternatively, use Wireshark.

Creating traffic

nc (netcat) usage:

Tracking traffic across the network

Tools

macOS

Linux

Many of the above macOS tools are also available on Linux.

Resources

For more recommendations, see this HackerNews thread.