Sign inSign up

huakson/ns3-simulator

By huakson

•Updated 11 months ago

Image
0

167

huakson/ns3-simulator repository overview

⁠🐳 NS-3.42 Docker - Network Simulator Container

Complete Docker solution for NS-3 (Network Simulator 3) featuring pre-built images, easy-to-use wrapper scripts, batch processing, and a full development environment with Jupyter Lab.

Docker Hub NS-3 Version Alpine Linux Arch


⁠🌟 Key Features

  • āœ… Pre-built Images: Get started in seconds, not 30 minutes of compilation.
  • āœ… 3 Operation Modes: Runtime (CLI), Batch (Python), and Dev (Jupyter).
  • āœ… Volume Mapping: Automatic sync for scratch/ scripts and results/ data.
  • āœ… Development Ready: Includes gdb, valgrind, and cmake tools.
  • āœ… Smart Wrappers: Scripts that handle binary execution transparently.

ā šŸ—ļø Architecture Support

ArchitectureSupport StatusAction Required
Intel/AMD (amd64)āœ… NativeJust pull and run. Pre-built on Docker Hub.
Apple M1/M2 / ARMāš ļø Manual BuildRequires building locally (see instructions below).

Note for Mac M1/M2 Users: The pre-built image is amd64. It runs via Rosetta emulation (slower). For native speed, use ./scripts/buildx-push --runtime --arm64-only to build your own image.


ā šŸš€ Quick Start

⁠1. Initialize

This command pulls the image and sets up the environment.

make init
⁠2. Run a Simulation

Run the included example directly:

./scripts/ns3 run wifi-simple

Or run your own code by placing .cc files in the scratch/ folder:

# Example: If you have scratch/my-sim.cc
./scripts/ns3 run my-sim

ā šŸŽÆ Usage Modes

⁠Mode 1: Runtime (CLI)

Lightweight mode for running simulations and getting results. Uses the runtime image (~500MB).

# Syntax
./scripts/ns3 run <simulation-name> [args]

# Example with arguments
./scripts/ns3 run "wifi-simple --distance=100 --time=20"
⁠Mode 2: Batch Processing

Perfect for parameter sweeps. Writes Python scripts in scratch/ that execute multiple simulations.

  1. Create a python script in scratch/ (e.g., batch-experiment.py).
  2. Run it using the batch wrapper:
make batch CMD="python3 scratch/batch-experiment.py"

Results are automatically saved to results/.

⁠Mode 3: Development Environment (Jupyter Lab)

Full environment with Jupyter Lab, C++ tools, and Python bindings. Perfect for data analysis and debugging.

Start the environment:

docker compose --profile dev up -d ns3-dev

Access Jupyter:

  1. Check the logs to get the access token:
    docker compose logs ns3-dev | grep "http://127.0.0.1:8888"
    
  2. Open the URL in your browser.

Jupyter Lab Environment

Stop the environment:

make down

ā šŸ“ Project Structure

ns3-docker/
ā”œā”€ā”€ scratch/              # šŸ“ PUT YOUR CODE HERE (.cc files)
ā”œā”€ā”€ results/              # šŸ“Š OUTPUTS (CSV, logs, traces)
ā”œā”€ā”€ scripts/              # šŸ”§ Wrapper scripts (ns3, ns3-build, etc)
ā”œā”€ā”€ examples/             # šŸ“š Reference examples
ā”œā”€ā”€ Dockerfile            # Multi-stage definition
ā”œā”€ā”€ docker-compose.yml    # Service orchestration
└── public/               # Assets for README

ā šŸ› ļø Advanced Commands

CommandDescription
make ns3-buildRe-compiles all scripts in scratch/
make shellOpens a bash shell inside the container
make clean-allCleans build artifacts and removes containers
make rebuildForces a rebuild of the Docker image locally

ā šŸ¤ Contributing & Building

If you want to modify the Docker image or build for ARM64:

# Build locally
make build

# Push to your own Docker Hub (requires .env configuration)
make push-latest

ā šŸ“„ License

This project is licensed under MIT. NS-3 is licensed under GNU GPLv2.

Maintained by: Huakson⁠ Docker Hub: huakson/ns3-simulator⁠

Tag summary

Content type

Image

Digest

sha256:c4746b271…

Size

721.1 MB

Last updated

11 months ago

docker pull huakson/ns3-simulator:3.42-dev