← Back to section · Tutorials & Labs
Two-Machine and VM Lab Topologies: Putting Client and Server in Their Places
Build a two-machine topology for PQC protocol experiments: choosing among the three VM network modes, static addresses and connectivity checks, injecting delay and loss with tc netem, and finally documenting the topology so it can be reset in one step.
Many PQC experiments do run on a single machine: client and server share the loopback interface and the handshake completes just the same. But single-machine setups have built-in blind spots. The loopback link has no real latency or loss, so large certificate chains and large key_share values cross it without pressure; the capture point shares a machine with the system under test, and clocks and load interfere with each other. As soon as the question becomes “what happens under real network conditions” or “show me the bytes actually on the wire”, client and server must be split across two machines. This tutorial builds a reusable two-machine topology from two virtual machines, and completes it with link conditioning, documentation and reset.
Choosing Among the Three Network Modes
A VM network adapter usually offers three modes; tell them apart before touching anything. In NAT mode the VM borrows the host’s address to reach the outside world; the outside cannot see the VM, and VMs cannot reach each other by default — it is fit only for installing packages, not for two-machine experiments. Bridged mode attaches the VM directly to the host’s LAN: the VM receives an address like a real machine and can be reached by other devices, which suits experiments that must interoperate with real hardware, at the price of being subject to LAN policy and mixing experiment traffic into the production network. Host-only mode carves an isolated network inside the host: VMs and the host can reach each other, nothing goes outside — the default choice for two-machine protocol experiments, with a clean topology, controllable addresses and no leaked traffic, preserved as a whole when the work is done. The practical combination: one adapter in host-only mode carrying the experiment traffic, plus a NAT adapter used only for package installation and switched off once the experiment starts, so background traffic such as auto-updates cannot contaminate the samples.
Topology Setup Steps
Using VirtualBox or a comparable hypervisor, the steps are as follows. First, create a host-only network in the platform and note its subnet (for example 192.168.56.0/24); that subnet is the experiment’s address book. Second, give each VM a host-only adapter and a fixed address: the server becomes 192.168.56.10, the client 192.168.56.11, written into the system network configuration or netplan — never left to DHCP, because address drift breaks the names written into scripts and certificates. Third, solve name resolution locally: register each machine’s address and experiment name (such as pqc-server) in the other’s /etc/hosts, and always use the names in experiments, so the subjectAltName in issued certificates naturally matches the names actually used. Fourth, verify connectivity: bidirectional ping, working mutual ssh, then a baseline bandwidth round with iperf3 (iperf3 -s on one side, iperf3 -c 192.168.56.10 on the other), and record the baseline numbers in the topology document. Only fifth comes the service: deploy the test service on the server side (for instance a TLS server with oqs-provider) and prepare capture and test scripts on the client side. Do not reverse the order — prove the network innocent before suspecting the application.
Conditioning the Link: tc netem
The biggest differences between a real network and the lab loopback are delay, jitter and loss, and Linux’s tc with netem injects all three precisely, in software. On the client adapter:
sudo tc qdisc add dev eth0 root netem delay 50ms 10ms loss 1%
sudo tc qdisc show dev eth0
# Remove when the experiment is over:
sudo tc qdisc del dev eth0 root
This adds a 50 ms base delay, ±10 ms jitter and 1% loss to the egress link. Note that netem applies in the egress direction, so configure both machines to model bidirectional conditions. With it you can answer a string of questions a single machine cannot: how many retransmissions does ML-KEM’s large key_share suffer at 1% loss, and how much does total handshake time grow; how many extra round trips do the additional kilobytes of an ML-DSA certificate chain cost under high delay. After each condition set, record the tc qdisc show output together with the results; after clearing a condition, re-measure the baseline before the next set, so leftover conditions cannot contaminate later samples. This is the real value of the experiment topology: the link stops being an uncontrolled background and becomes a variable you can set, record and reproduce.
The Step Not to Skip: Clock Synchronization
The variable most easily overlooked in two-machine experiments is the two machines’ clocks. TLS certificate validation reads the client’s clock, and half of all “certificate not yet valid” or “certificate expired” errors are fake failures caused by a drifting client VM clock; aligning captures and logs depends even more on both ends sharing a clock — a connection the client log says started at 10:00:01 must be findable on the same time axis in the server’s capture, and with more than a few seconds of skew, correlation analysis turns into guesswork. The fix is simple but must become a habit: enable NTP synchronization on both VMs (distributions generally ship systemd-timesyncd or chrony — confirm the service is running), and after every boot or snapshot restore, glance at the synchronization state with timedatectl before starting the experiment. VM clocks jump most readily when resuming from suspend and snapshot restores, so put “check the clocks” on the pre-experiment checklist, next to checking connectivity. With this link in place, the two-machine topology has genuinely eliminated interference from non-protocol factors.
Documenting the Topology and Resetting It
As soon as the topology stands, write a one-page document with five items: the subnet and the fixed addresses of both machines; each machine’s role and the services installed on it; the baseline bandwidth numbers; the list of link-condition presets (none / 50 ms + 1% / custom as needed); and the reset procedure. Reset is what makes a topology reusable: take a snapshot of both VMs in the clean state — network working, services installed, no experiment run yet — so any experiment round that dirties the environment can return to the start by restoring snapshots; keep service configuration files and certificates in the experiment repository and re-run the deployment script from the document after a restore. With the document and snapshots in place, the topology supports the whole experiment series instead of being rebuilt for every tutorial.
Wrapping Up
A two-machine topology costs a one-time setup and pays back across every protocol experiment: isolated variables, an independent capture point, and programmable link conditions. Before the next capture or performance comparison, stand this topology up first — it is the bench surface of the PQC lab itself.
Tags: Virtual MachinesNetwork TopologynetemExperiment Design