Transcript Slide 1

Network Simulator
and problems in
installing
Introduction
Problems in installing
 Wired networks

 modified
example2.tcl
 commands in OTcl
 usual problems in compiling
 running the simulation
Problems in installing



Installation of NS2 is very easy if you pay attention on the following
instructions.
However, installing for me was very hard and it last very long time, about 10
days. There is a lot of problems I have meet, such as download speed,
choosing the right server for downloading, installing the correct version of
NS2. Now I will show you the best and most safe way for installing the NS2.
Installing Cygwin:
First problem in installation of NS2 is Cygwin platform for Windows. On my
computer I have Windows XP Service Pack 3 (SP3). I try to download
cygwin , following instruction step by step from book by Apidach
Booranawong, except I choose to download all components of Cygwin. But I
have no success. At some point (usually about 99% of downloading) I get
this message “Download incomplete. Try again?”. If you choose “Yes” the
installation will start all over again and you have to wait few hours (depend
on download speed) to complete your work. If you choose “No” your Cygwin
platform will be installed on your computer, but it will not be ready to support
NS2. Another big problem is to choose right server for downloading the
Cygwin. This is the most important step. When you start the installation after
step 11 (page 5, Apidach Booranawong, “Network Simulator NS2”), you will
need to choose some ftp or http for downloading. I choose many download
sites, but most of them are very slow or not available or far away from
Thailand, which is very important. And again I have’t success.
At this point I decided to start all over again, from the root. I do the following:
Problems in installing






Guide for installing Cygwin:
Choose right server for downloading. Always chose that one with word
MIRROR or MIRRORS. For example you can choose:
http://mirror.averse.net or http://mirror.calvin.edu. If you choose between
http and ftp, you better choose http.
Don’t install every component of Cygwin (it lasts too long because you have
to select file by file, there is no option select all). Install components shown
on page No.2, Apidach Booranawong, “Network Simulator NS2”. Entire X11
and these packages: gcc, gcc-gcc+, gawk, tar, gzip, make, patch, perl,
w32api.
If your download speed is high, you will finish the job very fast and safe.
After installation you must have these 3 files: .bash_profile .bashrc
.inputrc, under c:\cygwin\home\MyComputerName. If you don’t have it, your
installation failed.
If you still can’t install Cygwin uninstall Windows XP Service Pack 3 (SP3)
and install Windows XP Service Pack 2 (SP2) and repeat steps 1,2,3,4.
Problems in installing

Installing NS2: “couldn’t execute” problem
Second problem can be the version of Network Simulator. There is many
version, for example “ns-allinone-2.28”, “ns-allinone-2.29” and the latest
version at this moment “ns-allinone-2.33”. I choose to install ns-allinone2.29, because this version have examples of some simulation inside folder
c:\cygwin\home\MyComputerName\ns-allinone-2.33\ns-2.33\nstutorial\examples. The version ns-allinone-2.33 does not have implemented
examples inside. It doesn not have folder ns-tutorial\examples. After
installation of ns-allinone-2.29, there was a problem. I try to run command
“ns example2.tcl” to see if my NS is working, but I get this message:
running nam...
ns: finish: couldn't execute "nam": no such file or directory
while executing
"exec nam out.nam &"
(procedure "finish" line 8)
invoked from within
“finish”
Problems in installing


The problem was in version on Network Animator (NAM). When you
download ns-allinone-2.28 or ns-allinone-2.29 or ns-allinone-2.30 you
automatically get “nam-1.11” which has a bug. You can fix the bug by
replacing the “NULL” with “0” in line 73 of file “agent.h” in nam-1.11
directory. Then set the path to c:\cygwin\home\MyComputerName\nsallinone-2.33\ns-2.33 \nam-1.11 and then compile it again, run the
command ./configure. I try it, but everything was same like before. I don’t
know why.
So I choose do uninstall ns-2.29, by deleting the directory ns-allinone-2.29,
ns-allinone-2.33.tar.gz and deleting the file .bash_history under
c:\cygwin\home\MyComputerName . Don’t delete these files: .bash_profile,
.bashrc, .inputrc. I downloaded ns-allinone-2.33.tar.gz, and after installation
everything was OK.
Guide for installing NS2:
Install this verson of NS: ns-allinone-2.33.tar.gz. It’s the fastest and most
safe way to make your NS usable. Now you have to copy the directory
“examples” from your collegue which already have NS. Put this directory
under the c:\cygwin\home\MyComputerName\ns-allinone-2.33\ns-2.33\nstutorial. Then check if your NS is working, by running the simulation. You
have to type “ns example2.tcl”, but set the path first. Good luck!
Wired networks

original example2.tcl:
CBR
UDP
0
2
UDP
CBR
1
3
NULL
Wired networks

my modified example:
NULL
CBR
UDP
0
4
NULL
CBR
UDP
FTP
1
TCP
3
2
5
SINK
source code is:
#create a simulator object
set ns [new Simulator]
#create 6 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
#define different color for data flow
# number of color is fid = flow id
$ns color 1 blue
$ns color 2 red
#open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#create links between the nodes
$ns duplex-link $n0 $n3 1Mb 10ms DropTail
$ns duplex-link $n1 $n3 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 10ms DropTail
$ns duplex-link $n3 $n4 1Mb 10ms DropTail
$ns duplex-link $n3 $n5 2Mb 20ms DropTail
#define a 'finish ' pocedure
proc finish {} {
global ns nf
$ns flush-trace
#close the trace file
close $nf
#execute nam on trace file
exec nam out.nam &
exit 0
}
#create the position of nodes in NAM
$ns duplex-link-op $n0 $n3 orient right-down
$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n3 orient right-up
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link-op $n3 $n5 orient right-down
1
2
#set queue size of LINK (n3-n4) to 10
$ns queue-limit $n3 $n4 10
#create a FTP traffic source and attach it to the tcp0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ftp0 set type_ FTP
#monitor the queue for the link between n3 and n4
$ns duplex-link-op $n3 $n4 queuePos 0.5
#create a NULL agent (a traffic sink) and attach it to the n4
set null0 [new Agent/Null]
$ns attach-agent $n4 $null0
#create a UDP agent and attach it to the n0
set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0
#create a NULL agent (a traffic sink) and attach it to the n5
set null1 [new Agent/Null]
$ns attach-agent $n5 $null1
#create a CBR traffic souce and attach it to the udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#create a SINK agent and attach it to the n4
set sink0 [new Agent/TCPSink]
$ns attach-agent $n4 $sink0
#create a UDP agent and attach it to the n1
set udp1 [new Agent/UDP]
$udp1 set class_ 1
$ns attach-agent $n1 $udp1
#connect the traffic sources with the traffic sinks
$ns connect $tcp0 $sink0
$ns connect $udp0 $null0
$ns connect $udp1 $null1
#create a CBR traffic souce and attach it to the udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
#schedule events for CBR and FTP agents
$ns at 0.8 "$cbr0 start"
$ns at 1.0 "$ftp0 start"
$ns at 1.2 "$cbr1 start"
$ns at 4.0 "$cbr0 stop"
$ns at 4.5 "$ftp0 stop"
$ns at 4.8 "$cbr1 stop"
#create a TCP agent and attach it to the n2
set tcp0 [new Agent/TCP]
$tcp0 set class_ 2
$ns attach-agent $n2 $tcp0
#call the procedure finish after 5 sec of simulation time
$ns at 5.0 "finish"
3
#run the simulation
$ns run
4
Wired networks

usual problems in compiling

first usual problem is the topology of the network. Topology must have
sense. For example you can’t connect one source with two sink and
send the packages at the same time. Every source has to be connected
with one sink.
 second usuall problem is error in syntax. For example if you replace
character $ with # in front of the command $ns, you will get the error
message.Or if you type “set sink0 [new Agent/TCPsink]” instead “set
sink0 [new Agent/TCPSink]” you will again get the error message.
Wired networks
 running
the simulation:
after checking the topology of network, syntax errors we can run the
simulation. First thing we have to do is to set the path first. In my case:
c:\cygwin\home\Sasa\ns-allinone-2.33\ns-2.33\ns-tutorial\examples and
then run the simulation with command “ns NameOfExample.tcl”
Wired networks
THE END