npte

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

README

Network Performance Testing Environment

Build Status codecov

npte (Network Performance Testing Environment) tests how a network client behaves on a realistic access link, using isolated network namespaces, traffic shaping, and optional lightweight containers.

It is a collection of small, composable primitives: create and connect namespaces (netns), attach a host-NATed uplink (gateway), shape a link with tc/netem (netem), and optionally run commands inside a systemd-nspawn container (container). The star command wires a fixed topology for the common case.

Linux-only. Most subcommands require root and use external commands (ip, tc, iptables, sysctl, systemd-nspawn, debootstrap, runuser). Run npte doctor to check for dependencies.

Install

You need Go >= 1.25.

go install -v github.com/bassosimone/npte@latest
sudo install -m555 "$(go env GOPATH)/bin/npte" /usr/local/sbin/npte
rm "$(go env GOPATH)/bin/npte"

We prefer not installing at $(go env GOPATH)/bin/npte because that path is owned and writable by the invoking user: a tool that root runs via sudo should not live somewhere an unprivileged process can replace it, and the absolute path baked into the npte sudoers snippet has to be one that only root can modify.

For local development, go build . is fine; the resulting binary will report its version as (devel).

Quick Start

npte doctor       # check required host tools are installed
npte tutorial     # render the embedded walkthrough
npte --help       # interactive help

Tutorial

Run npte tutorial to see the full table of contents and read the embedded chapters. They are also browsable on GitHub at internal/cli/tutorial/chapters/.

Subcommands

  • doctor — check required host tools are installed.

  • tutorial — render the embedded tutorial chapters.

  • netns — primitive operations on a single network namespace.

  • gateway — turn a namespace into a host-NAT'd internet gateway.

  • netem — apply or clear traffic shaping on a single <ns> <if>.

  • containerdebootstrap + systemd-nspawn helpers, with optional binding to an existing namespace.

  • star — compose a fixed three-node client/router/server topology out of the netns primitives.

  • sudoers — print sudoers NOPASSWD configuration for selected subcommands.

All the subcommands that modify the kernel state also support the --dry-run flag, which prints a round-trippable shell script to stdout instead of executing.

License

SPDX-License-Identifier: GPL-3.0-or-later

Direct Dependencies

History

npte implements the strategy described in ooni/probe#1803.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
cli/container
Package container implements the container subcommand.
Package container implements the container subcommand.
cli/doctor
Package doctor implements the doctor subcommand.
Package doctor implements the doctor subcommand.
cli/gateway
Package gateway implements the gateway subcommand.
Package gateway implements the gateway subcommand.
cli/netem
Package netem implements the netem subcommand.
Package netem implements the netem subcommand.
cli/netns
Package netns implements the netns subcommand.
Package netns implements the netns subcommand.
cli/star
Package star implements the star subcommand.
Package star implements the star subcommand.
cli/sudoers
Package sudoers implements the sudoers subcommand.
Package sudoers implements the sudoers subcommand.
cli/tutorial
Package tutorial implements the tutorial subcommand.
Package tutorial implements the tutorial subcommand.
deps
Package deps declares the external commands that npte is allowed to execute and resolves their absolute path at runtime.
Package deps declares the external commands that npte is allowed to execute and resolves their absolute path at runtime.
logx
Package logx implements logging.
Package logx implements logging.
registry
Package registry tracks the network namespaces that npte manages.
Package registry tracks the network namespaces that npte manages.
subprocess
Package subprocess contains code to exec subprocesses.
Package subprocess contains code to exec subprocesses.
testable
Package testable contains code to make npte testable.
Package testable contains code to make npte testable.
testenv
Package testenv provides a shared test stub for testable.Env.
Package testenv provides a shared test stub for testable.Env.
validate
Package validate contains validators for user-supplied identifiers.
Package validate contains validators for user-supplied identifiers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL