NetAnim Installation Guide (macOS)

NetAnim is an essential tool for visualizing network simulations from ns-3. While it's often bundled with ns-3, you might need to install it manually. This guide will walk you through the entire process on a modern macOS system, using the command line and common development tools.

## Step 1: Install Prerequisites

Before you can build NetAnim, you need to set up your Mac for development.

  1. Install Xcode Command Line Tools: This package provides essential compilers and tools like make and git. Open your Terminal and run:

    Bash

    xcode-select --install
    
  2. Install Homebrew: Homebrew is a package manager that makes it easy to install software on macOS.

    Bash

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    

## Step 2: Install the Qt Dependency

NetAnim's graphical interface is built using the Qt framework. You can install it easily with Homebrew.

  • On an Apple Silicon Mac (M1/M2/M3): It's often best to install Qt version 5.

    Bash

    brew install qt@5
    
  • On an Intel Mac: You can install the latest version.

    Bash

    brew install qt
    

After installation, you must add Qt's tools to your shell's PATH.

  1. Open your Zsh configuration file:

    Bash

    nano ~/.zshrc
    
  2. Add the correct line for your setup.

    • For qt@5 on Apple Silicon: export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"

    • For qt@6 on Apple Silicon: export PATH="/opt/homebrew/opt/qt/bin:$PATH"

    • For qt@5 on Intel: export PATH="/usr/local/opt/qt@5/bin:$PATH"

  3. Save the file (Ctrl + X, Y, Enter) and reload your shell:

    Bash

    source ~/.zshrc
    

## Step 3: Get the NetAnim Source Code

You can download the source code directly using git. This gives you the latest version.

Bash

git clone https://gitlab.com/nsnam/netanim.git
cd netanim

## Step 4: Build the Executable with CMake 🛠️

Modern versions of NetAnim use CMake to handle the build process.

  1. Create a Build Directory: From the netanim root directory, create a separate folder for the build files. This is a best practice that keeps the source directory clean.

    Bash

    mkdir build
    cd build
    
  2. Configure the Build: Run cmake and point it to the parent directory, where the main CMakeLists.txt configuration file is located.

    Bash

    cmake ..
    
  3. Compile the Code: Run make to compile the source code and link it against the Qt libraries.

    Bash

    make
    

## Step 5: Run NetAnim ✅

If the build completes without errors, the NetAnim executable will be located inside the build directory. You can now run it from the Terminal.

Bash

./NetAnim

The NetAnim application window should appear on your screen, ready to visualize your network simulation data!

Updated on