Markus Löning

Software Engineering & Machine Learning

Network engineering

Posted at Jul 24, 2025 23:07:58 — Last modified at Sep 3, 2025 09:02:29

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:

LayerProtocol Data Unit (PDU)FunctionDiagnostic tools
5 ApplicationDataHigh-level protocols such as for continuous data exchange, resource sharing, or remote file access (e.g. HTTP, SMTP, LDAP, DNS)Loggers, debuggers
4 TransportSegmentReliable transmission of data segments between nodes, including segmentation, acknowledgement, and multiplexing (e.g. TCP, UDP, ICMP)netstat, nc (netcat), tcpdump
3 NetworkPacket, DatagramMulti-node network communication, including addressing, routing, and traffic control (e.g. IPv4, IPv6, ICMP)ifconfig, route, ping, traceroute
2 Data linkFrameTransmission of data frames between two nodes connected by a physical layer (e.g. Ethernet, WiFi)arp, ndp, tcpdump
1 PhysicalBit, SymbolTransmission and reception of raw streams over a physical medium (e.g. copper/fibre wires, WiFi/radio waves)Hardware status lights, ifconfig

Level 5 can be broken down further, but for a high-level understanding, the differences are not critical; they all concern the application.

Like a postal system, 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 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 because a message may be split up into multiple segments, which are then 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 (complexity on edges).

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 even with IPv4 as an unreliable network layer 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

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 street name or zip code and the IP address like the house number, then the port is like a room number.

Monitoring and diagnostics:

Application layer

Network application design

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)

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.