NS-2 Tutorial - Part 2 -
description
Transcript of NS-2 Tutorial - Part 2 -
University of Texas at Arlington
CSE 4346/5346 Networks II
1
NS-2 TutorialNS-2 Tutorial- Part 2 -- Part 2 -
Choe, Hyun Jung (Stella)Choe, Hyun Jung (Stella) Spring 2008Spring 2008
Networks IINetworks IIDepartment of Computer Science and EngineeringDepartment of Computer Science and Engineering
The University of Texas at ArlingtonThe University of Texas at Arlington
University of Texas at Arlington
CSE 4346/5346 Networks II
2
GTA Office HoursGTA Office Hours
Monday and Thursday 2:30 PM ~ 3:30 PM
NH 239
University of Texas at Arlington
CSE 4346/5346 Networks II
3
OutlineOutline
• Simulation Examples
- Visualization: nam, xgraph
- Analysis example: awk
• Project
- Overview
- Submission Guideline
• Q & A
University of Texas at Arlington
Simulation ExamplesSimulation Examples
University of Texas at Arlington
CSE 4346/5346 Networks II
5
simple.tclsimple.tcl
#Create a simulator object
set ns [new Simulator]
#Open the NAM trace file
set nf [open out.nam w]
$ns namtrace-all $nf
# Open trace file
set tf [open out.tr w]
$ns trace-all $tf
University of Texas at Arlington
CSE 4346/5346 Networks II
6
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
exit 0
}
University of Texas at Arlington
CSE 4346/5346 Networks II
7
#Create four nodesset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]
#Create links between the nodes$ns duplex-link $n0 $n2 2Mb 10ms DropTail$ns duplex-link $n1 $n2 2Mb 10ms DropTail$ns duplex-link $n2 $n3 1.7Mb 20ms DropTail
University of Texas at Arlington
CSE 4346/5346 Networks II
8
#Setup a TCP connectionset tcp [new Agent/TCP]$ns attach-agent $n0 $tcpset sink [new Agent/TCPSink]$ns attach-agent $n3 $sink$ns connect $tcp $sink$tcp set fid_ 1
#Setup a FTP over TCP connectionset ftp [new Application/FTP]$ftp attach-agent $tcp$ftp set type_ FTP
University of Texas at Arlington
CSE 4346/5346 Networks II
9
#Setup a UDP connectionset udp [new Agent/UDP]$ns attach-agent $n1 $udpset null [new Agent/Null]$ns attach-agent $n3 $null$ns connect $udp $null$udp set fid_ 2
#Setup a CBR over UDP connectionset cbr [new Application/Traffic/CBR]$cbr attach-agent $udp$cbr set type_ CBR$cbr set packet_size_ 1000$cbr set rate_ 1mb
University of Texas at Arlington
CSE 4346/5346 Networks II
10
#Schedule events for the CBR and FTP agents$ns at 0.1 "$cbr start"$ns at 1.0 "$ftp start"$ns at 4.0 "$ftp stop"$ns at 4.5 "$cbr stop"
#Detach tcp and sink agents (not really necessary)$ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-a
gent $n3 $sink"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
University of Texas at Arlington
CSE 4346/5346 Networks II
11
#Print CBR packet size and intervalputs "CBR packet size = [$cbr set packet_size_]"
puts "CBR interval = [$cbr set interval_]"
#Run the simulation$ns run
University of Texas at Arlington
CSE 4346/5346 Networks II
12
TCP: Default ParametersTCP: Default Parameters
# max bound on window sizeAgent/TCP set window_ 100# congestion windows Agent/TCP set cwnd_ 10# initial/reset value of cwndAgent/TCP set windowInit_ 1# MSS sizeAgent/TCP set packetSize_ 1500
University of Texas at Arlington
CSE 4346/5346 Networks II
13
NAMNAM#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute NAM on the trace file
exec nam out.nam &
exit 0
}
University of Texas at Arlington
CSE 4346/5346 Networks II
14
awkawk
Set awkCodeTr { if ( NF == 12 ) {
event =$1time = $2
if (event = “d”) { dropCount += 1; print time, dropCount >> “drop.a”;}
}}
University of Texas at Arlington
CSE 4346/5346 Networks II
15
XGRAPHXGRAPH
• exec xgraph -bb -tk -x time -y lossRatio -bg White -geometry 540x405 /tmp/team3/fs.xg &
University of Texas at Arlington
CSE 4346/5346 Networks II
16
Using VariablesUsing Variables
set testTime 60.0………………
$ns at $testTime “$cbr0 stop”$ns at $testTime “$cbr1 stop”$ns at $testTime “tcp stop”$ns at [expr $testTime + 1.0] “finish”
University of Texas at Arlington
CSE 4346/5346 Networks II
17
DiffServDiffServ
• To provide QoS by dividing traffic into different categories, scheduling packets accordingly
• Major components- Policy- Edge router- Core router
• Implementation- virtual queues, causing packets from one virtual
queue to be dropped more frequently than packets from another.
University of Texas at Arlington
CSE 4346/5346 Networks II
18
DiffServ ConfigurationDiffServ Configuration
• $dsredq set numQueues_ 1• $dsredq setNumPrec 2
• $dsredq configQ 0 1 10 20 0.10• $dsredq setSchedularMode WRR
•$ns simplex-link $edge $core 10Mb 5ms dsRED/edge
•$ns simplex-link $core $edge 10Mb 5ms dsRED/core
University of Texas at Arlington
CSE 4346/5346 Networks II
19
# Set DS RED parameters from Edge to Core:
set qEC [[$ns link $edge $core] queue]
$qEC meanPktSize $packetSize
$qEC set numQueues_ 1
$qEC setNumPrec 2
$qEC addPolicyEntry [$s1 id] [$dest id] TokenBucket 10 $cir0 $cbs0
$qEC addPolicyEntry [$s2 id] [$dest id] TokenBucket 10 $cir1 $cbs1
$qEC addPolicerEntry TokenBucket 10 11
$qEC addPHBEntry 10 0 0
$qEC addPHBEntry 11 0 1
$qEC configQ 0 0 20 40 0.02
$qEC configQ 0 1 10 20 0.10
University of Texas at Arlington
CSE 4346/5346 Networks II
20
# Set DS RED parameters from Core to Edge:
set qCE [[$ns link $core $e1] queue]
$qCE meanPktSize $packetSize$qCE set numQueues_ 1$qCE setNumPrec 2$qCE addPHBEntry 10 0 0$qCE addPHBEntry 11 0 1$qCE configQ 0 0 20 40 0.0293$qCE configQ 0 1 10 20 0.10
University of Texas at Arlington
ProjectProject
University of Texas at Arlington
CSE 4346/5346 Networks II
22
Phase 1Phase 1
• Purpose- To be familiar with NS2- To master how to configure network topology
• Stepsi. Setup system environmentii. Run specified two example filesiii. Establish specified network topologyiv. Establish traffic flowsv. Submit your file
You are free to experiment various parameters if your simulation satisfies requirements, specified topology and traffic flows!
University of Texas at Arlington
CSE 4346/5346 Networks II
23
Phase 2Phase 2
• Purpose- To know how to trace/monitor/analyze simulation
results - To understand different characteristics of TCP and
UDP congestion control
• Requirements- Simulate your program with specified parameter
values- Generate result graphs to verify the performance- Compare and analyze the results- Make a comprehensive analysis report
University of Texas at Arlington
CSE 4346/5346 Networks II
24
TopologyTopology
2 Mbps, 10ms5 Mbps, 5/10ms 1 Mbps, 10ms
R1 R4
R2
R3
R5 R6
Host 1
Host 2
Host 3
Host 4
Host 5
Host 6
University of Texas at Arlington
CSE 4346/5346 Networks II
25
Phase 3Phase 3
• Purpose- To help the student master the concepts and
practices quality of service (QoS) and traffic management
• Requirement- Use Differentiated Service modules- Try to satisfy specified QoS requirements
University of Texas at Arlington
CSE 4346/5346 Networks II
26
Phase 4Phase 4
• Purpose- To help the student master the concepts and
practices of traffic engineering - To compare and analyze the relationship of
measured performance metrics
• Requirement- Measure additional QoS metrics- Compare the results
University of Texas at Arlington
CSE 4346/5346 Networks II
27
Submission FormatSubmission Format
• Analysis Report- *.ps or *.pdf
• Readme - *.txt
• phase#_last name.* - phase4_choe.tcl, phase4_choe.ps,
phase4_choe.tar.gz
University of Texas at Arlington
CSE 4346/5346 Networks II
28
CompressionCompression
• mkdir phase1• cp files phae1• tar –cvf project.tar ./phase1• gzip phase1.tar
phase1.tar.gz [email protected]
Please DO NOT include trace files!
University of Texas at Arlington
CSE 4346/5346 Networks II
29
Hard Deadline Hard Deadline
• Hard copy- to Gergely Záruba prior to the beginning of class on the due date
• Soft copy- to [email protected] prior to the beginning of class on the due date
• Late submissions will receive 10% (of the total possible grade) deduction. They will also be amortized 20% (of the total possible grade) each day after the assignment was due.