Home

Advertisement

How to Install NS-2 on Fedora

  • Aug. 26th, 2008 at 9:38 PM
wondering

STEP 1

From terminal login as super user and do the following.(internet must also be connected in order to install the package dependencies.

yum install autoconf
yum install automake
yum install gcc-c++
yum install libX11-devel
yum install xorg-x11-proto-devel
yum install libXt-devel
yum install libXmu-devel

STEP 2

From terminal download ns-allinone-2.30 and type the following commands

$ wget http://www.isi.edu/nsnam/dist/ns-allinone-2.30.tar.gz
$ tar -xzf ns-allinone-2.30.tar.gz
$ cd ns-allinone-2.30.tar.gz
$. /install

STEP 3

Now go to /etc folder and type

gedit ~/.bashrc

Add the following lines to the end of it. Remember replace “/usr/local/” by your installation path like “/home/kazim”. And accordingly also change the version numbers. This is for ns 2.30.

# LD_LIBRARY_PATH
OTCL_LIB=/usr/local/ns-allinone-2.30/otcl-1.12
NS2_LIB=/usr/local/ns-allinone-2.30/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/usr/local/ns-allinone-2.31/tcl8.4.14/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/usr/local/ns-allinone-2.30/bin:/usr/local/ns-allinone-2.30/tcl8.4.13/unix:/usr/local/ns-allinone-2.30/tk8.4.13/unix
NS=/usr/local/ns-allinone-2.30/ns-2.30/
NAM=/usr/local/ns-allinone-2.30/nam-1.12/
PATH=$PATH:$XGRAPH:$NS:$NAM

Let it take effect immediately

source ~/.bashrc

Note: the step described above is important; otherwise, you cannot run ns successfully.
or you can restart your X windows.i.e. logout and then login, or reboot your system, to make it work.)

Now, the installation has been completed. If you try:
$ ns

Then a “%” will appear on the screen.type “exit” to quit the mode and back to “$”

If you miss out step 1 you may get the following errors

Build XGraph-12.1
============================================================
loading cache ./config.cache
checking for a BSD compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking whether make sets ${MAKE}… yes
checking for working aclocal… missing
checking for working autoconf… missing
checking for working automake… missing
checking for working autoheader… missing
checking for working makeinfo… missing
checking if malloc debugging is wanted… no
checking for gcc… no
checking for cc… no
configure: error: no acceptable cc found in $PATH
make: *** No targets specified and no makefile found. Stop.
Can not create xgraph; But xgraph is an optional package, continuing…

If you miss step 3

At the prompt when you type ns you will get
Ns command not found

Source: http://www.edaboard.com/ftopic297674.html

wondering
# attach a new Agent/MessagePassing/Flooding to each node on port $MESSAGE_PORT
for {set i 0} {$i < $num_nodes} {incr i} {
    set a($i) [new Agent/MessagePassing/Flooding]
    $n($i) attach  $a($i) $MESSAGE_PORT
    $a($i) set messages_seen {}

    set if_($i) [$n($i) set netif_(0)]

}

# then you can set the transmission power for each node individually :
for {set i 0} {$i < 10} {incr i} {

    if { $i < 5} {
        # transmission range: 40m
        $if_($i) set Pt_ 8.5872e-4   
    } else {
        # transmission range: 100m
        $if_($i) set Pt_ 7.214e-3   
    }
}   

[ns2] Adjusting Transmission Range

  • Jun. 17th, 2008 at 11:50 PM
wondering
from http://blog.empas.com/blhole/read.html?a=10042170

$NS_HOME/indep-utils/propagation/threshold.cc
를 다음 명령으로 컴파일한다.
$ g++ -o threshold threshold.cc
 
Phy/WirelessPhy set RXThresh_ 3.652e-10
위의 기본 RXThresh_값을 기준으로 하여 거리에 대한 Pt를 결정한다.

예제
$ ./threshold -m TwoRayGround -Pt 7.214e-3 100m
distance = 100
propagation model: TwoRayGround
Selected parameters:
transmit power: 0.007214
frequency: 9.14e+08
transmit antenna gain: 1
receive antenna gain: 1
system loss: 1
transmit antenna height: 1.5
receive antenna height: 1.5
Receiving threshold RXThresh_ is: 3.65209e-10
 
 
-Pt 0.11542 200m
-Pt 0.58432 300m
 
        // Assume AT&T's Wavelan PCMCIA card -- Chalermek
        //      Pt_ = 8.5872e-4; // For 40m transmission range.
        //      Pt_ = 7.214e-3;  // For 100m transmission range.
        //      Pt_ = 1.7615e-2   ;# 125m
        //      Pt_ = 0.2818; // For 250m transmission range.
$NS2/mac/wireless-phy.cc
 
# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 1.559e-11
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set bandwidth_ 2e6
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0
Phy/WirelessPhy set debug_ false
위의 값들중에서 Pt_ (transmission power)만을 변경하여 간단하게 transmission range를 조정할 수 있다.

How to Install NS-2 on Ubuntu

  • Apr. 10th, 2008 at 4:14 AM
wondering
from http://alkautsarpens.wordpress.com/2008/02/05/install-ns231-for-ubuntu-gutsy-710/

$ tar -xzvf ns-allinone-2.33.tar.gz
$ cd ns-allinone-2.33
$ sudo apt-get install build-essential autoconf automake libxmu-dev

Now run this command :
$./install

$ gedit ~/.bashrc

    Add the following lines to the end of it. Remember replace
    “/home/networklab/ns/” by something like “/home/yourname/”
    ——————————————————————————————–
    # LD_LIBRARY_PATH
    OTCL_LIB=/home/networklab/ns/ns-allinone-2.33/otcl-1.13
    NS2_LIB=/home/networklab/ns/ns-allinone-2.33/lib
    X11_LIB=/usr/X11R6/lib
    USR_LOCAL_LIB=/usr/local/lib
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_
    LIB:$USR_LOCAL_LIB

    # TCL_LIBRARY
    TCL_LIB=/home/networklab/ns/ns-allinone-2.33/tcl8.4.14/library
    USR_LIB=/usr/lib
    export TCL_LIBRARY=$TCL_LIB:$USR_LIB

    # PATH
    XGRAPH=/home/networklab/ns/ns-allinone-2.33/bin:/your/path/
    ns-allinone-2.33/tcl8.4.14/unix:/your/path/ns-allinone-2.33/tk8.4.14/unix
    NS=/home/networklab/ns/ns-allinone-2.33/ns-2.33/
    NAM=/home/networklab/ns/ns-allinone-2.33/nam-1.13/
    PATH=$PATH:$XGRAPH:$NS:$NAM
    ————————–


Let it take effect immediately:
$ source ~/.bashrc

Note: if ns unsuccessfully. you can restart your X windows, or reboot your system, to make it work Now,the installation has been completed. then try:

$ ns

Then a “%” will appear on the screen.type “exit” to quit the mode and back to “$”

Validation :
$ cd ns-2.33
$ ./validate

Tags:

[scrap] Network Simulator for Wireless

  • Mar. 31st, 2008 at 1:10 AM
wondering
http://www.winlab.rutgers.edu/~zhibinwu/html/network_simulator_2.html

Introduction

Ns-2 is a widely used tool to simulate the behavior of wired and wireless networks. Useful general information can be found at

Official ns-2 website (http://www.isi.edu/nsnam/ns/
An ns-2 Documentation generated by Doxygen is in http://www-rp.lip6.fr/ns-doc/ns226-doc/html/index.htm
Two good tutorials about ns-2.
     Wireless tutorial by Marc Greis
     ns by example
My presentation: ns2 tutorial for wireless simulation  WINLAB, June 2003
My Lecture : Introduction to ns2 ECE 330:543 Class Lecture, Oct. 2007
Another good tutorial of ns-2

Installation & Debug

Install ns-2.27 in Red Hat Linux
Install ns 2.28 in Debian with gcc 4.0 or above
Debug ns-2 with gdb

Simulation Configuration

  1. Basic simulation scripts of wireless scenarios.
  2. Traffic, Topology and Mobility generation in ns-2
  3. Analyze CMU traces (for wireless simulation) and awk code.
  4. Header and Address Handling in ns-2
  5. Understanding OTcl syntax in ns-2

Physical Layer

  1. Demystify TwoRayGround Propagation Model
  2. Introduce Ricean Fading to produce probabilistic Link Error
  3. Why list-based improvements in channel.cc of ns-2.27 cause problems?

MAC layer

  1. Interfacing MAC
  2. Understand IEEE 802.11 MAC Standard
  3. Analysis of the 802.11 MAC code
  4. Simulation example: Measuring the effects of RTS/CTS on 802.11 link
  5. Practice: Implement Multi-Rate MAC
  6. Discussion of bugs and issues of IEEE802.11 MAC implementation

Routing

  1. Analysis of the DSR sourcecode in ns-2.
  2. Analysis of the DSDV in network simulator-2.
  3. How to produce a new Routing Agent with Fixed Routing Table.
  4. Calculate Routing Performance Metric from trace file

Summary of ns-2 bugs for wireless simulation

channel.cc List-based improvement causes "Segmentation Fault".
mac-802_11.cc: Bug in Defer timer causes "Event UID not valid!".
dsdv.cc: double IP header bug.

Tags:

Unicast and Brocast in Ns-2

  • Mar. 27th, 2008 at 11:49 PM
wondering

http://nuraini.net/2007/09/16/unicast-an
d-broadcat-packet-on-ns2/

Those following code are some example code for sending packet unicast and broadcast on NS2.

void protocol::unicast(Packet *p, nsaddr_t destination)
{
hdr_cmn* hdrcmn = HDR_CMN(p);
hdr_ip* iphdr = HDR_IP(p);
// set all the necessary things for the common header
hdrcmn->next_hop_ = destination;
hdrcmn->prev_hop_ = this->addr();
hdrcmn->direction() = hdr_cmn::DOWN;
// take a look its name on packet.h
hdrcmn->ptype() = PT_PROTOCOLNAME;
hdrcmn->addr_type() = NS_AF_INET;
// setting the ip header
iphdr->saddr() = this->addr();
iphdr->sport() = 254; // 1-254
iphdr->daddr() = destination;
iphdr->dport() = 254; // 1-254
iphdr->ttl() = 32;
Scheduler::instance().schedule(ll, p, 0.0);
}

void protocol::broadcast(Packet *p)
{
hdr_cmn* hdrcmn = HDR_CMN(p);
hdr_ip* iphdr = HDR_IP(p);
// set all the necessary things for the common header
hdrcmn->next_hop_ = IP_BROADCAST;
hdrcmn->prev_hop_ = this->addr();
hdrcmn->direction() = hdr_cmn::DOWN;
// setting the ip header
iphdr->saddr() = this->addr();
iphdr->sport() = 254; // 1-254
iphdr->daddr() = IP_BROADCAST;
iphdr->dport() = 254; // 1-254
iphdr->ttl() = 32;
Scheduler::instance().schedule(ll, p, 0.0);
}

The above codes can be called anywhere on sourcecode.cc (anyname.cc). For example :

int protocol::command(int argc, const char*const* argv)
{
if (argc == 4) {
if (strcmp(argv[1], "sendData“) == 0)
{
Packet* newpkt = allocpkt();
//some packet configuration
this->broadcast(newpkt);
return (TCL_OK);
}
}


When the node will receive it ?
We should make recv procedure.

void protocol::recv(Packet* pkt, Handler*)
{
hdr_cmn* hdrcmn = HDR_CMN(pkt); //Access the common header for the received packet:
hdr_ip* hdrip = HDR_IP(pkt); // Access the IP header for the received packet:
cout << "node " << this->addr() << "received from node " << hdrcmn->prev_hop_;
}

Tags: