DOC PREVIEW
SBU CSE 590 - Wireless networking and Systems

This preview shows page 1-2-16-17-18-33-34 out of 34 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Wireless Networking and Systemsns2- Network SimulatorGoal of this tutorialOverviewSimple two node wired networkSlide 6Slide 7Adding traffic to the linkSlide 9Slide 10Slide 11Simulate a simple topology – UDP TrafficSlide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21TCP TrafficSlide 23Slide 24Slide 25Slide 26Slide 27Slide 28Complex topology and link failureSlide 30Slide 31Slide 32Wireless Linear TopologyHave fun with ns2 !!!Wireless Networking and SystemsCSE 590ns2 tutorialns2- Network SimulatorOne of the most popular simulator among networking researchers.Discrete event, Packet level simulatorEvents like ‘received an ack packet’, ‘enqueued a data packet’ Network protocol stack written in C++Tcl (Tool Command Language) used for specifying scenarios and events.Unix Based. Runs also in windows using cy gwinSimulates both wired and wireless networks.Goal of this tutorialUnderstand how to write Tcl scripts to simulate simple network topologies and traffic patterns.Analyze the trace files and understand the performance of the protocols.OverviewWiredCreating a simple two node network topologyAdding traffic to the linkUDP trafficTCP trafficFault injectionWirelessTCP performance on a linear chain of n nodesSimple two node wired networkn0 n1#Create a simulator objectset ns [new Simulator]Step 1:Step 2:#Open trace filesset f [open out.tr w]$ns trace-all $fSimple two node wired networkn0 n1#Create two nodesset n0 [$ns node]set n1 [$ns node]Step 3:Step 4:#Create a duplex link between the nodes$ns duplex-link $n0 $n1 1Mb 10ms DropTailSimple two node wired network#Create a simulator objectset ns [new Simulator]#Open trace filesset f [open out.tr w]$ns trace-all $f#Define a 'finish' procedureproc finish {} { global ns $ns flush-trace exit 0}#Create two nodesset n0 [$ns node]set n1 [$ns node]#Create a duplex link between the nodes$ns duplex-link $n0 $n1 1Mb 10ms DropTail#Call the finish procedure after 5 seconds of simulation time$ns at 5.0 "finish"#Run the simulation$ns runAdding traffic to the linkn0 n1udpudp#Create a UDP agent and attach it to node n0set udp0 [new Agent/UDP]$ns attach-agent $n0 $udp0Adding traffic to the linkn0 n1udpudp# Create a CBR traffic source and attach it to udp0set cbr0 [new Application/Traffic/CBR]$cbr0 set packetSize_ 500$cbr0 set interval_ 0.005$cbr0 attach-agent $udp0cbrcbrAdding traffic to the linkn0 n1udpudpcbrcbr#Create a Null agent (a traffic sink) and attach it to node n1set null0 [new Agent/Null]$ns attach-agent $n1 $null0nullnullAdding traffic to the linkn0 n1udpudpcbrcbr#Connect the traffic source with the traffic sink$ns connect $udp0 $null0#Schedule events for the CBR agent$ns at 0.5 "$cbr0 start"$ns at 4.5 "$cbr0 stop“nullnullSimulate a simple topology – UDP Traffic#Create a simulator objectset ns [new Simulator]#Open trace filesset f [open out.tr w]$ns trace-all $f#Define a 'finish' procedureproc finish {} {global ns$ns flush-traceexit 0}#Create four nodesset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]n0n1n2 n3sendersenderrouterreceiverSimulate a simple topology – UDP Traffic#Create links between the nodes$ns duplex-link $n0 $n2 1Mb 10ms DropTail$ns duplex-link $n1 $n2 1Mb 10ms DropTail$ns duplex-link $n3 $n2 1Mb 10ms SFQn0n1n2 n3sendersenderrouterreceiver#Create a UDP agent and attach it to node n0set udp0 [new Agent/UDP]$udp0 set class_ 1$ns attach-agent $n0 $udp0Simulate a simple topology – UDP Trafficn0n1n2 n3sendersenderrouterreceiverSimulate a simple topology – UDP Traffic# Create a CBR traffic source and attach it to udp0set cbr0 [new Application/Traffic/CBR]$cbr0 set packetSize_ 500$cbr0 set interval_ 0.005$cbr0 attach-agent $udp0n0n1n2 n3sendersenderrouterreceiver#Create a UDP agent and attach it to node n1set udp1 [new Agent/UDP]$udp1 set class_ 2$ns attach-agent $n1 $udp1Simulate a simple topology – UDP Trafficn0n1n2 n3sendersenderrouterreceiver# Create a CBR traffic source and attach it to udp1set cbr1 [new Application/Traffic/CBR]$cbr1 set packetSize_ 500$cbr1 set interval_ 0.005$cbr1 attach-agent $udp1Simulate a simple topology – UDP Trafficn0n1n2 n3sendersenderrouterreceiver#Create a Null agent (a traffic sink) and attach it to node n3set null0 [new Agent/Null]$ns attach-agent $n3 $null0Simulate a simple topology – UDP Trafficn0n1n2 n3sendersenderrouterreceiver#Connect the traffic sources with the traffic sink$ns connect $udp0 $null0$ns connect $udp1 $null0Simulate a simple topology – UDP Trafficn0n1n2 n3sendersenderrouterreceiver#Schedule events for the CBR agents$ns at 0.5 "$cbr0 start"$ns at 1.0 "$cbr1 start"$ns at 4.0 "$cbr1 stop"$ns at 4.5 "$cbr0 stop"#Call the finish procedure after 5 seconds of simulation time$ns at 5.0 "finish"#Run the simulation$ns runSimulate a simple topology – UDP TrafficTrace Analysishttp://nsnam.isi.edu/nsnam/index.php/NS-2_Trace_FormatsTCP Traffic0, 1, 2 are senders3 is a Gateway4 receivers1s3G rsendersendergatewayreceivers2senderTCP Traffic#Create a TCP agent and attach it to node s1set tcp1 [new Agent/TCP/Reno]$ns attach-agent $s1 $tcp1$tcp1 set window_ 8$tcp1 set fid_ 1TCP Traffic#Create a TCP agent and attach it to node s2set tcp2 [new Agent/TCP/Reno]$ns attach-agent $s2 $tcp2$tcp2 set window_ 8$tcp2 set fid_ 2#Create a TCP agent and attach it to node s3set tcp3 [new Agent/TCP/Reno]$ns attach-agent $s3 $tcp3$tcp3 set window_ 4$tcp3 set fid_ 3TCP Traffic#Create TCP sink agents and attach them to node rset sink1 [new Agent/TCPSink]set sink2 [new Agent/TCPSink]set sink3 [new Agent/TCPSink]$ns attach-agent $r $sink1$ns attach-agent $r $sink2$ns attach-agent $r $sink3TCP Traffic#Connect the traffic sources with the traffic sinks$ns connect $tcp1 $sink1$ns connect $tcp2 $sink2$ns connect $tcp3 $sink3TCP Traffic#Create FTP applications and attach them to agentsset ftp1 [new Application/FTP]$ftp1 attach-agent $tcp1set ftp2 [new Application/FTP]$ftp2 attach-agent $tcp2set ftp3 [new Application/FTP]$ftp3 attach-agent $tcp3TCP Traffic#Define a 'finish' procedureproc finish {} { global ns $ns flush-trace exit 0}$ns at 0.1 "$ftp1 start"$ns at 0.1 "$ftp2 start"$ns at 0.1 "$ftp3 start"$ns at 5.0 "$ftp1 stop"$ns at 5.0 "$ftp2 stop"$ns at 5.0 "$ftp3 stop"$ns at 5.25 "finish"$ns runComplex topology and link failure0123456senderreceiverComplex topology and link


View Full Document

SBU CSE 590 - Wireless networking and Systems

Download Wireless networking and Systems
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Wireless networking and Systems and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Wireless networking and Systems 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?