290 likes | 397 Views
NS-2 Tutorial - Part 2 -. Choe, Hyun Jung (Stella) Spring 2008 Networks II Department of Computer Science and Engineering The University of Texas at Arlington. GTA Office Hours. Mon day and Thu rsday 2:30 PM ~ 3:30 PM NH 239 choe@uta.edu. Outline. Simulation Examples
E N D
NS-2 Tutorial - Part 2 - Choe, Hyun Jung (Stella) Spring 2008 Networks II Department of Computer Science and EngineeringThe University of Texas at Arlington
GTA Office Hours Monday and Thursday 2:30 PM ~ 3:30 PM NH 239 choe@uta.edu
Outline • Simulation Examples • Visualization: nam, xgraph • Analysis example: awk • Project • Overview • Submission Guideline • Q & A
simple.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
#Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf exit 0 }
#Create four nodes set 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
#Setup a TCP connection set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP
#Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2 #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb
#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-agent $n3 $sink" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish"
#Print CBR packet size and interval puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]" #Run the simulation $ns run
TCP: Default Parameters # max bound on window size Agent/TCP set window_ 100 # congestion windows Agent/TCP set cwnd_ 10 # initial/reset value of cwnd Agent/TCP set windowInit_ 1 # MSS size Agent/TCP set packetSize_ 1500
NAM #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 }
awk Set awkCodeTr { if ( NF == 12 ) { event =$1 time = $2 if (event = “d”) { dropCount += 1; print time, dropCount >> “drop.a”; } } }
XGRAPH • execxgraph -bb -tk -x time -y lossRatio -bg White -geometry 540x405 /tmp/team3/fs.xg &
Using 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”
DiffServ • To provide QoS by dividing traffic into different categories, scheduling packetsaccordingly • Major components • Policy • Edge router • Core router • Implementation • virtual queues, causing packets from one virtual queue to be dropped morefrequently than packets from another.
DiffServ 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
# 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
# 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.02 93 $qCE configQ 0 1 10 20 0.10
Phase 1 • Purpose • To be familiar with NS2 • To master how to configure network topology • Steps • Setup system environment • Run specified two example files • Establish specified network topology • Establish traffic flows • Submit your file • You are free to experiment various parameters if your simulation satisfies requirements, specified topology and traffic flows!
Phase 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
Host 1 Host 4 Host 2 Host 5 Host 3 Host 6 R2 R1 R4 R5 R6 R3 2 Mbps, 10ms 1 Mbps, 10ms 5 Mbps, 5/10ms Topology
Phase 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
Phase 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
Submission Format • Analysis Report • *.ps or *.pdf • Readme • *.txt • phase#_last name.* • phase4_choe.tcl, phase4_choe.ps, phase4_choe.tar.gz
Compression • mkdir phase1 • cp files phae1 • tar –cvf project.tar ./phase1 • gzip phase1.tar • phase1.tar.gz • choe@uta.edu • Please DO NOT include trace files!
Hard Deadline • Hard copy • to Gergely Záruba prior to the beginning of class on the due date • Soft copy • to choe@uta.eduprior 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.