Professional Documents
Culture Documents
" ! NS2
! !
A +0
5
6
7
8
12
14
16
18
21
23
27
!D!
%Q- 8Q- -JE 8- !
-JE 8- ! --
TCL !% --
NS2 8K w!-1% -6 D%Y
-
J' -E1
agents and application -@z -D6 %
} 8 -|!
A6 Ns2 Formatting
Network Animator (Nam) w!-1% P6
-,
/
= D %E @- - P 8K-@6 G$
$D 8$6
,@
$
K ($ -$ 8$6 -$ $, 8 $ % ($ $
$! $
!| S| 86@
D 2 }% .
-
z
?Q
8$$K$$ %
6$$ -$$6J -$$- -$$ 8 $$D 8$$6 TCL ($$
%E ! -
K % 8K !P6 -.8
% G -6 ns2 8K w!-1%-, 2, 1 -DA6 86-$
$J
=$$ $$ ! N 8$$6 $$JP6$$!
?$$! - -$$ nam G$$|! 8=$$ 6$$
%6 ; 2- -D G,@6= P6
% -61- ! w- GJ$E J$E8! $
!% 6 .
!!!!!
G S1- P - 8K ns2
( % 0 1 0 % ,,,,
" ! "T+T
= -- 8K 8 1989 !%E VINT= ' ! GJ'-J
- 8K Real Network Simulator 8
!--@
! 8K -1% G!-8
Berkeley Lab= '
- .
!-
!P6
= -- 8K 8 2006--6: 8
| 8K
! 1000 ! %| ! % |! %
P6! 10000
- %
' G, - 300 8-
( ?V% 8.
!-
Ns home page
http://www.isi.edu/nsnam/ns
- ! 4% - ns-allinone-2.33-$ 8$K 2008
June %
' 8K ns2 %( = ns3 26 S= (
V6 .%
- D 6' G 6A G 8K D
86 -$1 ! 8$K $A -$A$ 8$6
2006 A-1 SDD -% D ' | 2008 A 8K 1--$
Y
) WNS2(workshop ns2-
$ % 8$
<=$ ' $ $-$| 8$K
!-$$ -J$$E ! $$-$$ 8-A$$,-$$ 8 $$EV-A $$6 - G$$8$$J
; <- 8D6 -- -JE . network simulation
" !
!-1 J -:8
%6 - 8A 8 -
-$1 J! $! $ % ; $ -J$E 8$66$
Object GJE -
A %
6 2 ( J% ( - 6OTCL,C++ -$
* -$$ $$-$$A %$$K ' $$ ?$$- C++ $$K $$6 8$$P6$$ $$ Compiler
%6 !% -A - 8
K OTcl P6 !@ interpreter % %@6!%.-
P6-K C++-@J
- 8K -
6% =@A6 -$
S$6% ; $ -$1 J
| 6- %$6 ; 86 -$6 8$K %$ -$A =$@A6 ?$! TCL $ 8$K $M -$
1
=$$@A6%$$ $$J
8$$K$$
6 G8$$' 8$$ !
- $$ $$AP6$$ -$$
S$$6JK!%$$
P6 ! -? % =@A6 %
6 ! G -. 6
%Y D -- 86 -
6 -:8! - ns2 8 - discrete event simulator
8$AP6$ !@
$
$
D6 %$6
8$6$ !%$Y $ --$ $ 6$ $$
P6- 1 !
! ; ! -
1- -$
% 6 $ <=$!-$ G$,
-
! 6 26= %@6! V . ID
* 8K! 0.2 6- ! ! $1 -$ G$, -!$A
K FTP --$ ($
|K
= ! 6} %
- V% w= $ $D
- 2$6 ($%$
= D
- Handler 6 - ! ! ( 8-A
Classes -
z
?! }% 86
8K - -! Y-P6.6
* :Simulator
%$$6=$$ *$$J $$*$$J 8$$K 8$$- -$$ 8=$$ %Y $$$$ 6$$ $$D
-- 6 ( ! !
- interfaces
86 (
M
-- -6 A ! -A 1 ; .
-- ! -
! instance G= *J
! P1 8A= *J
1 N
! A -E1 26 JE
-
6M. -
DA
%6
%
6 %Q-
- J 6
D%J6 1
-
% .procedure
?! G!-
6@- .
: Y+[A :
%Y%
D %6 8K TCL: 8
- ?z1 set %6
N$ $D%1 8$6 $ 8$K -
$Q %$68$
! J - V 4 %6! ! V % %
! V 8Q- ; 2$1 ,1
1 -1- %6=< $! 8$ -$ $ ; 8$
K scripting languages
* integer, float , double, Boolean $D G$ <%$
1 !
A -1- ! |$
= 1 -1- DA . %6
result: a=6
result: b=4
result: a=4
result: a=9
result: a=4.3
: -|!
set a 6
set b 4
set a $b
set a [expr 5+$b]
set a $b.3
:
A : ]\
: if %'
if expr script
: -|!
set x 2
if $x>1 {}
or if $x>1 {} elseif $x<-3 {} else {}
:
+ A / :
:for, while, foreach D
: for loop D
for script expr script script
: D
: -|!
for {set i 0} {$i<5} {incr i} {}
:while loop D
:-|!
while $x > 2 {}
:foreach loop D
. %-A
! K @,! ?! G
D 8
foreach listvar list body
:D
: -|!
set total 0
foreach num {1 2 3 4 5} {
set total [expr $total+$num]
}
. 15 D = total %6 D @= =< A w-AK
: Procedure +B : .
. -% java, c++ G|! % - 8K G|! % %6
: 8 % %
D%Y
proc name arguments {body}
: -|!
: -
A! % D V GD6 % %
6
proc decr x {
expr $x-1
}
decr 3 ; => x=3
- % 8K -AQ D - D
K % 8K return - ;
10
11
12
13
: !
$D GJ$' ($ $
$%
6$ 8-$ 8$K $
$! $J6 -
6
JE
router -$
$
$ *$1 J! J$' $%
-1 -| G (
K node
: 8-6- -
6-6J D1
set pc1 [$ns node]
set pc2 [$ns node]
set pc3 [$ns node]
set router [$ns node]
pc1 %$6= $ ( %@ %P ! - 8 node
$%
6 -$AV ($ $P 8$K A$K $ns -$ -$! node A$, $1 $! $
G$$ $$6 = $$ Simulator *$$J $$! object $$ -$$ $$ ns 2$$ %$$6!
N 2A! -A A, -6- DAK --
D
6 G-@6
. * -!K $ns class/method %Y
$ P6$1 -$
% -$DK -$
% $D1 J
%
6 }DK ( 6 -AV
-$
( -
} ! 6
} ! 8A
86 duplex-link
$ P6$1 }DK } %1 -A -
( 81-| -
! 81-|
$$ A( $$ 26$$,K $$-6J $$@ -$$! }$$DK $$} $$ 8$$A
8$$ simplex-link
: 8-6
$ns duplex-link $n0 $n1 <bandwidth> <delay> <queue>
=-A-|! 8K
$ns duplex-link $pc1 $router 5mb 2ms DropTail
$ns duplex-link $pc2 $router 5mb 2ms DropTail
$ns duplex-link $pc3 $router 5mb 2ms DropTail
%$6 D! GV-A
8 parameter ! ! GD6 duplex-link
Queue =-! Queue 1 GV-A = 8K
DropTail, RED, CBQ G$|! -$! P $! $ ! $ -$ Queue
-$! -$ $ -$! P =< G
K%
S1%61 ( % J
Queue *6$! 8$A
-$
8K 86 DropTail 8} DK %=1 J -
,@
GJ$$E -
$Q 1 -A$$ %$$ $$! G=$$ $$! $$ = $$ $$! P=< $$ $$D6K
:%4
14
Queue
Drop packet
?% - ! queue -A
K ! 6$ 6$ =$ ! $ $P ! $=$G
= S N=< P!
= ;$K $D $J
$K queue -$ S$1--$A
* 8$$K queue $$, 8$$J 6$$! $$ !$$
| $$! %$$! $$ S$$ 6$$ $$V -
$$Q
-
N 6= ! !- 86- 8 -
.-
J
% - D% P6$- simplex-link $ J6$ 8$6 -$ 6
21 3} 8K-.
hg :
tcl $$$ $$$-$$$ - $$$A@%-$$$
8$$$A; 2$$$1 $$$J ! $$$ -$$$G$$$ parameter%$$$K K-$$$! %$$$ $$$ }$$$DK; 8
$$$K=$$$@A $$$A $$$
.w!-1%
--$$$ $$$A P!-$$$ $$$ $$$, $$$6J $$$1 -$$$A
K $$$ DropTail $$ <=$$
$$6J% $$D; 8
$$ -$ z 8$$K $$=$$@A6
-K % %J S-%,
.case sensitive (A
- -z -6 !% ?! ms, mb. D
15
17
: " ]
FTP $$ -$$ -$$
$$D -$$
$$! $$1 J! J$$' $$ J6$$ -$$A-|!
. -
CBR - % -
D % -
:*
!- w!-1%
20
22
23
24
:+
-Y % 6 ( % S %1 AK -A 8K -
! G ! GE -A ,D
GE - -- -AV -JK 21 D
%
GJE JE ! 8 J D1 K K GE6 GE 6 --
-D 6-D -- = N!- % A D D 8A
86 (
-
A -
! GE * <- D
% @ K ,V
-- ! -
1 26( .26
:+i.
- %z 6 ( ! K ( : S
' (
GJ' -
J@ G-! D %J6 %, =K-1
% -
86.JE
! - |- = ! 6J 2 Edit 6-
6 8K 2-
GJ' G
%
(A- %
%6 D!- -
A- N -
}z% 6 N(
!-J.
% -! D %J6 %,
.D
:
= P6 -
-D
6 ( ' GJ%P- 8K! !
6N
P6- trace-annotate%' 86
-K -
6= 8K 6J=<
8K %
= ! = <.
25
=<
| 1--A 8K -
!P61 86 ' J P6 TCL6K 6
=< =K-A %Y Nam w!-1% 6K%Y N 8K cmd 6KA
8K terminal 6K JAnam.exe(windows) or nam(linux) -6
%
6K
-6 :
=<
8KA ! -V -6P1 File .new
N 6 ( }z
D -! 8K }z % }P
%} ( }z
D ( (6
D | 1- (6 6 'GJ
JE= %1<.
-@ D G= V w!-1% %E
- - G,@6 '- 8K 0 %
*.
6 -
1
% ?Q V !D6
26
-
1
.....81-| 0 -E1 -%V
d+
-The ns Manual,
http://www.isi.edu/nsnam/ns/ns-documentation.html
- Ns distribution download
- http://www.isi.edu/nsnam/ns/ns-build.html
- Installation problems and bug-fix
- http://www.isi.edu/nsnam/ns/ns-problems.html
- Ns-users mailing list
- Ns-users@isi.edu
- See http://www.isi.edu/nsnam/ns/ns-lists.html
- Archives from above URL
- Lots of slides displayed later
27