Skip to content

Instantly share code, notes, and snippets.

@n1chre
Last active December 17, 2016 13:52
Show Gist options
  • Save n1chre/01d7af1e1e66960ad94a939e81852729 to your computer and use it in GitHub Desktop.
Save n1chre/01d7af1e1e66960ad94a939e81852729 to your computer and use it in GitHub Desktop.
Installation script for ns2 simulator
#! /usr/bin/env bash
cd ~/Downloads
# must be named like this
TAR_FILE='ns-allinone-2.35.tar.gz'
# this will be the directory
DIR_NAME='ns-allinone-2.35'
# install dependencies
sudo apt-get install -y tcl8.5-dev tk8.5-dev build-essential autoconf automake perl xgraph libxt-dev libx11-dev libxmu-dev
# install everything
tar -xf ${TAR_FILE}
cd ${DIR_NAME}
./install
# export needed variables
NS_PATH=`pwd`
cat << EOF >> ~/.bashrc
NS_PATH=${NS_PATH}
PATH=\$PATH:\$NS_PATH/bin:\$NS_PATH/tcl8.5.10/unix:\$NS_PATH/tk8.5.10/unix
LD_LIBRARY_PATH=\$NS_PATH/otcl-1.14/lib:\$NS_PATH/lib
TCL_LIBRARY=\$NS_PATH/tcl8.5.10/library:\$NS_PATH/tk8.5.10/library
export PATH
export LD_LIBRARY_PATH
export TCL_LIBRARY
EOF
source ~/.bashrc
# edit 1.0: add test script
cat << EOF | ns
set ns [new Simulator]
set nf [open out.nam w]
\$ns namtrace-all \$nf
proc finish {} {
global ns nf
\$ns flush-trace
close \$nf
exec nam out.nam &
exit 0
}
\$ns at 5.0 "finish"
\$ns run
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment