ns-2 tutorialIntroductionGoals of nsns statusComponents of nsns Software Structure: C++ and OtcloTcl and C++: The DualityInstallation and documentationSteps to set up the simulationExample : TCPScript to start namScreenshotsReferencesns-2 tutorialKarthik Sadasivam Banuprasad SamudralaCSCI 5931 Network SecurityInstructor : Dr. T. Andrew YangIntroductionNs-2 is a discrete event simulator targeted at network researchfocused on modeling network protocolswired, wireless, satelliteTCP, UDP, multicast, unicastweb, telnet, ftpad hoc routing, sensor networksinfrastructure: stats, tracing, error models, etcGoals of nssupport networking research and educationprotocol design, traffic studies, etc.protocol comparisonprovide a collaborative environmentfreely distributed, open sourceshare code, protocols, models, etc.allow easy comparision of similar protocolsincrease confidence in resultsmodels provide useful results in several situationsmultiple levels of detail in one simulatorns statusplatforms: basically all Unix and Windowssize: about 200k loc each C++ and Tcl, 350 page manualuser-base: >1k institutions, >10k usersreleases about every 6 months, plus daily snapshotsComponents of nsns, the simulator itselfnam, the Network AniMatorvisualize ns (or other) outputGUI input simple ns scenariospre-processing:traffic and topology generatorspost-processing:simple trace analysis, often in Awk, Perl, or Tclns Software Structure: C++ and OtclUses two languagesC++ for packet-processingfast to run, detailed, complete controlOTcl for controlsimulation setup, configuration, occasional actionsfast to write and changepros: trade-off running vs. writing speed, powerful/documented config languagecons: two languages to learn and debug inoTcl and C++: The DualityOTcl (object variant of Tcl) and C++ share class hierarchyTclCL is glue library that makes it easy to share functions, variables, etc.C++otclInstallation and documentationhttp://www.isi.edu/nsnam/ns/download ns-allinoneincludes Tcl, OTcl, TclCL, ns, nam, etc.mailing list: [email protected]documentation (see url above)Marc Gries tutorialns manualSteps to set up the simulationInitialize the simulatorDefine files for output (tracing)Set up the topologySet up the “agents”Set up the traffic between the nodesStart the simulationAnalyze the trace files to compute the parameters of interestExample : TCPset ns [new Simulator]set n0 [$ns node]set n1 [$ns node]n0 n1set ftp [new Application/FTP]$ftp attach-agent $tcp$ns at 0.2 "$ftp start"$ns at 1.2 ”exit"$ns run$ns duplex-link $n0 $n1 1.5Mb 10ms DropTailset tcp [new Agent/TCP]set tcpsink [new Agent/TCPSink]$ns attach-agent $n0 $tcp$ns attach-agent $n1 $tcpsink$ns connect $tcp $tcpsinkScript to start namset nf [open out.nam w]$ns namtrace-all $nfproc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0}# your code goes in here$ns at 12.0 "finish" # 12.0 is the simulation time in secsScreenshotsProject B.1 Project B.2References[1] slides by John Heidemannhttp://sce.cl.uh.edu/yang/teaching/csci5931netSecuritySpr05/johnh_class_slides_sp2003.ppt[2] ns2 website: http://www.isi.edu/nsnam/ns[3] ns-2 Tutorial: http://www.isi.edu/nsnam/ns/tutorial/nsindex.html [4] Tcl/Tk tutorial :
View Full Document