NSG
NSG ns2
NSG2NSG1 NSG2
NSG2 ns2
1.
2.
3.
WirelessNode
4.
5.
Agent
TCPTCP/TahoeTCP/RenoTCP/NewrenoTCP/VegasTCPSinkUDP
NULL
6.
7.
8.
9.
NSG2 http://wushoupong.googlepages.com/nsg
NSG2 Java Runtime
1. Java
JRE JDK Java
JRE JDK
JAVA http://java.sun.com/javase/downloads/index.jsp
NSG2 DOS NSG2
NSG2 C:\nsg2\ java -jar nsg2.jar 2
2. NSG2
NSG2
NSG2 NSG2
ns2
Node
...
.tcl ns2
NSG2
NSG2 NSG2
Node ns2
Node x,y,z
Node
NSG2 Node
NSG2 ns2
3
NSG2
1.
Hand mode
2.
Node mode
3.
Link mode
4.
Agent mode
5.
Application mode
3. NSG2
Hand mode
Hand mode
Node
Hand mode
Node mode
Node mode Node
Node NSG
Node NAM Node
Node Node
Routing protocol
NSG2 NSG
Node 250m
Node 250m NSG2
Node
Node Node mode Node
Node
Agent mode
Agent mode Node ns2
Agent NSG2 TCP UDP
Node
Agent Agent Node
Agent Application
Application Application Application
Application
CBR Transmission rate packet size
Parameters
TCL TCL
ns2
1.
NSG
-1 -1
TCL NSG NSG
-50 NSG
2.
3.
Agent TCL
Agent Agent
NSG
NSG
4
4.
Node
1.
2.
3.
4.
5.
Duplex-link DropTail
Queue limit 10
1.
2.
3.
5.
Step2 Node Node
Node Node 6
6 : node
Step3 Node Link mode Link
Ctrl+3
1.
Link-typeduplex-link
2.
Queue typeDropTail
3.
Capacity2Mbps
4.
Propagation delay10ms
5.
Queue size10
7 : node
Step5 Agent mode Agent Ctrl+4
Agent type UDP Packet size
1500 bytes n0 n1 Agent Agent type
NULL n4n5 NULL Agent Agent
Agent
Agentudp0null2udp1null3
8
8 : Agents
Step6 Application mode Application Ctrl+5
Application type CBR
Start time 1 Stop time 4
1500bytes 1Mbps n0 CBR
ApplicationStart time 2 Stop
time 3 n1 CBR Application 9
9 : Application
Step7 Parameters Ctrl+6
10:
Step8 TCL Ctrl+7
11
11.
Step9 Save Alt+S TCL
ns2
# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>
#===================================
#
Simulation parameters setup
#===================================
set val(stop)
5.0
end
#===================================
#
Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
;# time of simulation
right-down
left-down
left-down
right-down
right
#===================================
#
Agents Definition
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set null2 [new Agent/Null]
$ns attach-agent $n4 $null2
$ns connect $udp0 $null2
$udp0 set packetSize_ 1500
#Setup a UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
set null3 [new Agent/Null]
$ns attach-agent $n5 $null3
$ns connect $udp1 $null3
$udp1 set packetSize_ 1500
#===================================
#
Applications Definition
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 1500
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns at 1.0 "$cbr0 start"
$ns at 4.0 "$cbr0 stop"
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 1500
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns at 2.0 "$cbr1 start"
$ns at 3.0 "$cbr1 stop"
#===================================
#
Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
NSG NAM
NAM NSG NAM File -1 NSG
NAM 12 NAM
2.1 n2
12
Trace Trace
d drop