This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
نمایید .1 نصب را زیر های فایل .ابتدا sudo apt-get install build-essential
autoconf automake libxmu-dev gcc-4.3فایل. 2 در را زیر تغییرات شدید، مواجه خطا با اگر
ns-allinone-2.34/otcl-1.13/Makefile.in اعمالکنید.
CC = @CC@ بدهید تغییر زیر حالت :بهCC = gcc-4.3
1
در ns-allinone-2.34.tar.gzفایل. 3 کپی home/userراحالت Terminalکنید. از را فایل زیر دستور با و کنید باز را
. نمایید خارج زیپtar xvfz ./ns-allinone-2.34.tar.gz
دستور. 4 از استفاده :cdبا بروید فایل محل به $cd ns-allinone-2.34
( منبع از را نیاز مورد های پکیج و ها دانلود( repositoryفایل. کنید نصب و
دستور از استفقاده .source ~/.bashrc$ با نمایید ذخیره را تغییرات 3
و. 7 :validationتایید نصب $ cd ns-2.34 $ ./validate
. کشد می طول ای دقیقه چند و است زمانبر مرحله این کهپایان از باید nsدستور validationبعد و کنید تایپ را
. عالمت % دستور خروج برای ببینید .exitرا کنید اجرا را $ns
% $ $exit
4
NS2معرفی
5
Most UNIX and UNIX-like systems FreeBSD Linux Solaris
Windows 98/2000/2003/XPCygwin required Some work , some doesnt
6
NS – SimulatorNAM – Network AniMator
visual demonstration of NS outputPreprocessing
Handwritten TCL orTopology generator
Post analysisTrace analysis using Perl/TCL/AWK/MATLAB
7
From the user’s perspective, NS−2 is an OTcl interpreter that takes an OTcl script as input and produces a trace file as output.
8
ns-2 is an discrete event driven simulation Physical activities are translated to events Events are queued and processed in the order of their
scheduled occurrences Time progresses as the events are processed
1 2
Time: 1.5 sec Time: 1.7 sec
Time: 1.8 secTime: 2.0 sec
9
Discrete Event Scheduler
time_, uid_, next_, handler_
head_ ->
handler_ -> handle)(
time_, uid_, next_, handler_insert
head_ ->
Event Scheduler
10
Non-Real time schedulersImplementations : List , Heap , Calender Calender is default
Real time schedulersUsed for emulation for direct interaction with
real NT. Basic use of an event scheduler:
schedule simulation events, such as when to start an FTP application, when to finish a simulation, or for simulation scenario generation prior to a simulation run.
11
Simulation Scenario
Tcl Script
C++ Implementation
1 2
set ns_ [new Simulator]
set node_(0) [$ns_ node]
set node_(1) [$ns_ node]
class MobileNode : public Node {
friend class PositionHandler;public: MobileNode();
••
}
12
otcl: Object-oriented supporttclcl: C++ and otcl linkageDiscrete event schedulerData network (the Internet) components
tcl8.4
otcl
tclcl
ns-2EventScheduler
Netw
orkC
omponent
13
A ddr
R ep lica to r
M C a s t
M P a th
H a sh
C la ss ife r
D e la y
A ge nt
A p p lica tion
Q ueue
T ra ce
C on ne c to r
NSO je ct
T c lO b je ct
14
UDP
RBP
R eno
RB P
V eg as
S a ck1
N ewR eno
Tap
S in k
Fu llTC P
A dap tive
S RM
TCP DSDV AO DV TO RA DSR
A ge nt
Te ln e t
E xpo n en tia l
P are to
CBR
T ra ce
T ra ff ic
FTP
A pp lica tion
D ro p ta il
R E D
FQ
S FQ
DR R
CBQ
Q ueue
E nq
D eq
D ro p
T ra ce
15
NS-2 Directory Structure
sim
tk8.4 otcl Tcltcl8.4 ns-2 nam-1
tcl
ex test lib
...
...
tcl code
example
validation test
C++ code
tcl code core
16
Cla
ssifier
Cla
ssifier
Agent
Link
Agent
Agent
Node
Addr
Port
Node entry point
Local
Link Link
Agents are either protocol endpoints or related objects that generate/fill-in
packet fields.
Classifiers: packet demultiplexers.
17
18
Packets (events)packet
Size determined at compile
time
cmn header
Size determined at compile
time
tcp header
Size determined at compile
time
ip header
Size determined at compile
time
trace header
bits( )
accessdata( )
next_Size
determined at
simulation config
time
- packet size
- timestamp
- type
- UID
- interface label
19
Links
Enq Trace Deq Trace Rcv Trace
Drp Trace
Delay TTL
Drop head
QueueLink entry point
Links: keeps track of “from” and “to” node objects.blocked
20
Link
Link
Application
N1 N2
Classifier
Classifier
Agent
Node
Addr
Port
LocalC
lassifier
Classifier
Agent
Node
Addr
Port
Local
Enq Trace Deq Trace Rcv Trace
Drp Trace
Delay TTL
Drop head
Queue
Application
21
C++ is used for the creation of objects because of speed and efficiency.
NS-2 Code contains two sets of languages, namely C++ and OTcl.
OTcl is used as a front-end to setup the simulator, configure objects and schedule events because of its ease of use.
22
Why two languages? (Tcl & C++) C++: Detailed protocol simulations
require systems programming language byte manipulation, packet processing,
algorithm implementation Run time speed is important Turn around time (run simulation, find bug,
fix bug, recompile, re-run) is slower Tcl: Simulation of slightly varying
parameters or configurations quickly exploring a number of scenarios iteration time (change the model and re-
run) is more important23
Tcl or C++? Tcl
Simple Configuration, Setup, Scenario
If it’s something that can be done without modifying existing Tcl module.
C++Anything that requires processing
each packetNeeds to change behavior of existing
module 24
Shadowing
TclObject
Agent
Agent/DSDV
Agent/DSDV OTcl shadow object
Agent/DSDV C++ object
TclObject()
Agent()
DSDVAgent()
OTcl classhierarchy
C++ classhierarchy
25
Agent/DSDVConstructor
AgentConstructor
Invoke parent
TclObjectConstructor
Invoke parent
AgentDSDV()Constructor
Create C++
Agent()Constructor
Invoke parent
TCL
C++TclObject()
ConstructorInvoke parent
Do nothing,
returnbind and return
bind and return
OTcl shadow
init complete
init complete
26
NS-2 Directory Structure
sim
tk8.0 otcl Tcltcl8.0 ns-2 nam-1
tcl
ex test lib
...
...
tcl code
example
validation test
C++ code
tcl code core
27
مسیر 1. در و کنیم می دانلود یا نوشته را -ns/پروتکلalllinone-2.34/ns-2.34 قرار ها پروتکل سایر موازات به
. دهیم میبدهیم تغییر را زیر های فایل باید پروتکل کردن اضافه .برای