ns-3 Installation Guide (MacOS)

This guide will walk you through downloading, building, and verifying NS3 installation.

Step 1: Prerequisites

First, ensure you have the necessary tools installed on your macOS system. You can install them using Homebrew.

# Install essential build tools
brew install python3 cmake mercurial

# For C++ compilation
brew install llvm 
# Or ensure you have Xcode Command Line Tools installed
# xcode-select --install

Step 2: Download NS3

We will use the ns-3-allinone package, which simplifies the download and build process.

  1. Navigate to your main projects directory:

    cd /Users/fathanpranaya/Projects/ns3/
    
  2. Clone the ns-3-allinone repository. This will create a new ns-allinone directory.

    git clone https://gitlab.com/nsnam/ns-3-allinone.git
    
  3. Enter the newly created directory:

    cd ns-3-allinone
    
  4. Use the download.py script to fetch all of the necessary NS3 source code modules.

    python3 download.py
    

Step 3: Build NS3

This is the most important step. We will use the provided build script to compile NS3 and its Python bindings.

  1. From inside the ns-3-allinone directory, run the build script. This process can take a significant amount of time (20-60 minutes depending on your machine).

    python3 build.py --enable-examples --enable-tests
    

    This command compiles NS3 and ensures the Python bindings, examples, and tests are all built correctly.

  2. After the build completes successfully, you will have a new NS3 directory inside ns-3-allinone, such as ns-3.41or a similar version number.

Step 4: Verify the Installation

Let's run a test to make sure everything works as expected.

  1. Navigate into the NS3 directory:

    # Replace 'ns-3.41' with the actual version directory that was created
    cd ns-3.41
    
  2. Run a test simulation using the ./ns3 wrapper.

    ./ns3 run hello-simulator
    

    If the installation was successful, you should see the output: Hello Simulator.

You now have a clean, working installation of NS3 in a predictable location!

Updated on