sudo apt-get install geomview
If you get this message, "No package 'gtk+-2.0' found",
gtk+-2.0 = libgtk2.0-dev
sudo apt-get install libgtk2.0-dev
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-allinon
e-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/uni x
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
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
}
}
$NS_HOME/indep-utils/propagation/thresho
예제
distance = 100
propagation model: TwoRayGround
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
// Pt_ = 8.5872e-4; // For 40m transmission range.
// Pt_ = 7.214e-3; // For 100m transmission range.
// Pt_ = 0.2818; // For 250m transmission range.
# 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
Crash Warning System Monitors Nearby Traffic And Warns Of Possible Collisions
ScienceDaily (2008-01-13) -- Scientists have demonstrated in the lab a collision warning system for cars that could alert the driver several seconds in advance of an imminent impact. The device could save thousands of lives and usher in the first steps towards the 'connected car'. It knows its location, can talk to other cars and can tell the future. Are we entering the era of truly automated cars? ... > read full article
Connecting with Minicom
- First, configure Minicom
- As root, run minicom -s
- Under "Serial Port Setup" choose the following
- Serial Device: /dev/ttyUSB0
If you are not sure which tty is connected, "dmesg" after unplug or plug it. - Bps/Par/Bits: 115200 8N1
- Hardware Flow Control: No (this is important)
- Software Flow Control: No
- Serial Device: /dev/ttyUSB0
- Hit [ESC] until you return to the main configuration menu
- Select "Save Setup as dfl" to save the default setup
- Select "Exit from Minicom" to exit the program
- Connect the serial cable to the serial port on your computer and to the serial port on the Gumstix
- Run Minicom again with minicom -o. This tells it to skip all the modem initialization strings, which are unnecessary when communicating with the Gumstix. You may need to do this as root if your normal login doesn't have permission to access the serial port.
- Plug the power adapter into the power jack of the Gumstix. When connected and powered, you should see a message from U-Boot followed by the normal Gumstix boot sequence in the minicom window.
- Log in for the first time with username root and password gumstix
- When finished, you can exit Minicom by typing [CTRL-A] then pressing Q. This exits without running the normal modem reset sequence, which will only send garbage to the Gumstix
Transferring files
To send a file to the Gumstix:
- Run 'rz' on the Gumstix. No parameters are needed, generally.
- From the terminal, send a file using ZModem. In Minicom, this is done with [Ctrl-A] and then S, which brings up a file selection dialog.
To receive a file from the Gumstix:
- Transmit the file(s) using 'sz', specifying them as arguments.
- The terminal, ideally, will detect and accept the transfer automatically.
- if you encounter a "Failure executing protocol" error, trying to send a file with Zmodem under minicom, you should install a Y/Z modem. apt-get install lrzsz
from http://docwiki.gumstix.org/Connecting_vi
- sudo apt-get install build-essential libncurses5-dev bison flex texinfo zlib1g-dev gettext libssl-dev libc6-dev make g++ gcc automake1.9 subversion libpng12-dev libjpeg62-dev libfreetype6-dev pkg-config fbset libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev libglib-2.0-dev lrzsz mtd-tools
problem with libglib-2.0-dev! - svn co -r1541 http://svn.gumstix.com/gumstix-buildroot/t
runk gumstix-buildroot
username:root, password:root - cd gumstix-buildroot/
- make defconfig
select target architecture & cpu type (Xscale for connex 400 xm) - make
Gumstix: A Newbie' First Experience
http://www.robomontreal.com/Gumstix_Newb
$ 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.3
NS2_LIB=/home/networklab/ns/ns-allinone-2.3
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_L
LIB:$USR_LOCAL_LIB
# TCL_LIBRARY
TCL_LIB=/home/networklab/ns/ns-allinone-2.3
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/networklab/ns/ns-allinone-2.3
ns-allinone-2.33/tcl8.4.14/unix:/your/pa
NS=/home/networklab/ns/ns-allinone-2.33/n
NAM=/home/networklab/ns/ns-allinone-2.33/n
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
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/h
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
- Basic simulation scripts of wireless scenarios.
- Traffic, Topology and Mobility generation in ns-2
- Analyze CMU traces (for wireless simulation) and awk code.
- Header and Address Handling in ns-2
- Understanding OTcl syntax in ns-2
Physical Layer
- Demystify TwoRayGround Propagation Model
- Introduce Ricean Fading to produce probabilistic Link Error
- Why list-based improvements in channel.cc of ns-2.27 cause problems?
MAC layer
- Interfacing MAC
- Understand IEEE 802.11 MAC Standard
- Analysis of the 802.11 MAC code
- Simulation example: Measuring the effects of RTS/CTS on 802.11 link
- Practice: Implement Multi-Rate MAC
- Discussion of bugs and issues of IEEE802.11 MAC implementation
Routing
- Analysis of the DSR sourcecode in ns-2.
- Analysis of the DSDV in network simulator-2.
- How to produce a new Routing Agent with Fixed Routing Table.
- 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.
- How Google Maps Works
http://www.codeproject.com/KB/scrapbook/googlemap.aspx - GPS Visualizer
http://www.gpsvisualizer.com/ - KML for Google Earth and Maps
http://code.google.com/apis/kml
- Quick Command Reference
http://www.pixelbeat.org/cmdline.html - Debian Package Management
http://qref.sourceforge.net/Debian/reference/ch-package.en.html - Vi Reference Card
http://www.digilife.be/quickreferences/QRC/Vi%20Reference%20Card.pdf
http://tnerual.eriogerg.free.fr/vim.html - Regular Expression
http://gnosis.cx/publish/programming/regular_expressions.html
http://www.linuxforums.org/applications/demystifying_regular_expressions.html
- Find a text within files
command: grep -R <text> *
example: grep -R korea *
http://mailman.isi.edu/pipermail/ns-user
Wireless Flooding in ns-2
http://yans.inria.fr/code/ns-2/?diff/105
http://nuraini.net/2007/09/16/unicast-an
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_;
}