Download presentation
Presentation is loading. Please wait.
Published byFelix Fleming Modified over 8 years ago
1
NS-2 Simulator 최 종 훈 2008.01.31.
2
2 Contents About NS Installation Based on Linux Based on Windows Architecture Using NS-2 Example References
3
3 History NEST – Testbed Columbia University REAL network simulator UC Berkley in 1988 NS-1 In 1995 VINT project at LBL, Xerox PARK, UCB, USC/ISI NS-2 In 1996 C++ and OTCL developed by MIT instead of TCL NS-3 started on July 1, 2006 About NS
4
4 Introduction Discrete event simulator Targeted at network research Packet-level Link layer and up Wired and wireless About NS
5
5 Platforms Most UNIX and UNIX-like systems FreeBSD or NetBSD Linux Sun Solaris Windows 9x/2000/XP With Cygwin (http://www.cygwin.com/) With VMWare (http://www.vmware.com/download/player/) About NS
6
6 Functionality of NS Wired Point-to-point link, LAN Unicast/multicast routing Transport Application layer Wireless Mobile IP Ad hoc routing Sensor network Tracing, visualization, various utilities About NS
7
7 Getting NS-2 Getting the pieces or everything at once http://www.isi.edu/nsnam/ns/ns-build.html http://www.isi.edu/nsnam/ns/ns-build.html Current Version Sep. 3, 2007 : ns-2.32 released. Mar. 10, 2007: ns-2.31 released. Getting manuals http://www.isi.edu/nsnam/ns/tutorial/index.html http://www.isi.edu/nsnam/ns/tutorial/index.html http://www-sop.inria.fr/maestro/personnel/Eitan.Altman/COURS- NS/n3.pdf http://www-sop.inria.fr/maestro/personnel/Eitan.Altman/COURS- NS/n3.pdf http://www.isi.edu/nsnam/ns/ns-documentation.html http://www.isi.edu/nsnam/ns/ns-documentation.html http://nile.wpi.edu/NS/ http://nile.wpi.edu/NS/ Installation
8
8 Installation on UNIX system Installation tar -xzf ns-allinone-2.29.3.tar.gz cd ns-allinone-2.29./install Please put /home/myusername/ns-allinone-2.29/bin:/home/myusername/ns-allinone- 2.29/tcl8.4.11/unix:/home/myusername/ns-allinone-2.29/tk8.4.11/unix into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph. IMPORTANT NOTICES: (1) You MUST put /home/myusername/ns-allinone-2.29/otcl-1.11, /home/myusername/ns- allinone-2.29/lib, into your LD_LIBRARY_PATH environment variable. If it complains about X libraries, add path to your X libraries into LD_LIBRARY_PATH. If you are using csh, you can set it like: setenv LD_LIBRARY_PATH If you are using sh, you can set it like: export LD_LIBRARY_PATH=
9
9 Installation on UNIX system (2) You MUST put /home/myusername/ns-allinone-2.29/tcl8.4.11/library into your TCL_LIBRARY environmental variable. Otherwise ns/nam will complain during startup. (3) [OPTIONAL] To save disk space, you can now delete directories tcl8.4.11 and tk8.4.11. They are now installed under /home/myusername/ns-allinone-2.29/{bin,include,lib} Installation cd ns-2.29./validate
10
10 Installation on Windows system http://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Nam_Und er_Windows_9x/2000/XP_Using_Cygwin http://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Nam_Und er_Windows_9x/2000/XP_Using_Cygwin http://www.cygwin.com/ http://www.cygwin.com/ Since version 2.1b9, ns has used Cygwin/gcc instead of Visual C++ Installation
11
11 Object-Oriented C++ and OTcl Modular approach Reusability Maintenance Data/Control separation Scalability Split C++/OTcl object C++ for data Per packet action OTcl for control Periodic or triggered action Architecture
12
12 Class Hierarchy Architecture
13
13 Directory Structure Architecture TK8.0OTcltclclTcl8.0ns-2nam-1 tcl extest lib... examples validation tests C++ code OTcl code ns-allinone mcast
14
14 Using NS Problem Simulation model Setup/run simulation with ns Result analysis Modify ns
15
15 Interactive Mode # ns % set ns [new Simulator] _o3 % $ns at 1 “puts \“Hello World!\”” 1 % $ns at 1.5 “exit” 2 % $ns run Hello World! # Using NS
16
16 Batch Mode simple.tcl set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run # ns simple.tcl Hello World! # Using NS
17
17 Tutorial-1 Using NS set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf set tf [open out.tr w] $ns trace-all $tf proc finish {} { global ns nf tf $ns flush-trace close $nf close $tf exec nam out.nam & exit 0 } $ns at 5.0 "finish" $ns run Create the simulator object Open a file for nam trace data “finish” procedure Closes the trace file and starts nam Execute the finish procedure after 5.0 seconds Open a file for trace data
18
18 Tutorial-2 Using NS set n0 [$ns node] set n1 [$ns node] $ns duplex-link $n0 $n1 1Mb 10ms DropTail Creates two nodes and assigns them to the handle “n0” and “n1” connect the nodes n0 and n1 with a duplex link with the bandwidth 1Megabit, a delay of 10ms and a DropTail queue
19
19 Tutorial-3 Using NS set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ns attach-agent $n1 $null0 $ns connect $udp0 $null0 Create a UDP agent and attach it to node n0 Create a CBR traffic source and attach it to udp0 Create a Null agent and attach it to node n1 Connect the two agents
20
20 Tutorial-4 Using NS $ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop" tell the CBR agent when to send data and when to stop sending
21
21 Visualization Tools nam-1 (Network AniMator Version 1) Packet-level animation Well supported by ns xgraph Convert from ns trace to xgraph format Using NS
22
22 NAM Using NS set nf [open out.nam w] $ns namtrace-all $nf
23
23 xgraph Using NS set tf [open out.tr w] $ns trace-all $tf -- -- + 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 - 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0 raw2xg 를 이용한 xgraph 변환 /ns-allinone-2.29/ns-2.29/bin/raw2xg Raw2xg –a out.tr > out.xg
24
24 xgraph Using NS
25
25 Example
26
26 References http://nsnam.isi.edu/nsnam/index.php/Main_Page http://www.isi.edu/nsnam/ns/ http://nile.wpi.edu/NS/ 배성수, 한종수, “ 네트워크 시뮬레이터 (NS2 기초와 활 용 ),” 세화, 2005. 한국통신학회, “NS-2 단기 강좌 튜토리얼 및 무선 네트워 크 시뮬레이션,” 2006.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.