Introduction to ns-2: “The” Network SimulatorNs-2, the network simulatorNs FunctionalityNs componentsNs Software Structure: C++ and OTCLSteps when using NsCreating a Basic Ns ModelCreating Event SchedulerCreating Network (Nodes + Links)Transport and Traffic ModelsCreating Transport Channels: TCPCreating Traffic over TCP ChannelsCreating Transport Channels: UDPCreating Traffic over UDP ChannelsTracingTracing via MonitorsWalk-through exampleNs Trace file : NS-trace.txtFlow Monitor Trace : packet-trace.txtResults - Queue StatisticsResults - Flow StatisticsPerformance Queue Statistics1Introduction to ns-2:“The” Network SimulatorDaniel FigueiredoNovember, 2004Goals: tutorial overview of nsflavor of ns: simple example, model specification, execution and trace analysis2Ns-2, the network simulatorAcademic project over 10 years oldfreely distributed, open sourceCurrently maintained by ISI DARPA + NSF projects~ 200K LoC, 392 page manualLarge user base mostly academics“de facto” standard in networking researchMain website: www.isi.edu/nsnam/ns3Ns FunctionalityDiscrete event simulatorTraffic models and applicationsWeb, FTP, telnet, audio, sensor netsTransport protocolsTCP (Reno, SACK, etc), UDP, multicastRouting and queueingstatic routing, DV routing, multicast, ad-hoc routingqueueing disciplines: drop-tail, RED, FQLink layerwired, wireless, satellite Infrastructuretracing, visualization, error models, etcmodify or create your own modules4Ns componentsNs, the simulator itself (this is all we’ll have time for)nam, the Network AniMator visualize Ns (or other) outputGUI input simple Ns scenariospre-processing:traffic and topology generatorspost-processing:simple trace analysis, often in Awk, Perl, or TclTutorial: http://www.isi.edu/nsnam/ns/tutorialNs by example: http://nile.wpi.edu/NS/5Ns Software Structure: C++ and OTCLUses two languagesC++ for packet-processingper packet processingfast to run, detailed, complete controlOTCL for control [our focus]simulation setup, configuration, occasional actionsfast to write and change6Steps when using NsCreate OTCL script with network modelnodes, links, traffic sources, sinks, etc.Parameterize simulation objectsqueue sizes, link speeds, TCP flavor and parameters (more than 30)Collect statisticsdump everything to trace, post process itgather stats during simulation within OTCL scriptmodify Ns source codeRun Ns multiple timesconfidence intervals7Creating a Basic Ns ModelCreate the event schedulerCreate nodes and linksCreate connectionCreate traffic sources/sinksEnable tracing8Creating Event SchedulerCreate schedulerset ns [new Simulator]Schedule event$ns at <time> <event><event>: any legitimate Ns/TCL commandsStart scheduler$ns run9Creating Network (Nodes + Links)Nodesset n0 [$ns node]set n1 [$ns node]Links: connect together two nodes$ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type><delay> determines propagation delay<queue_type> determines queueing policy•DropTail, RED, CBQ, FQ, SFQ, DRR10Transport and Traffic ModelsTwo layer approachTransports:TCP, UDP, multicast, etc.transport protocol instances attach to nodesTraffic (applications): (known as agents)Web, ftp, telnet, audio, etc.application instances attach to transport protocol instancesgenerates traffic into transport protocol11Creating Transport Channels: TCPsource and sinkset t_src [new Agent/TCP/Newreno]set t_dst [new Agent/TCPSink]“Newreno” flavor of TCP attach to nodes and each other$ns attach-agent $n0 $t_src$ns attach-agent $n1 $t_dst$ns connect $t_src $t_dst12Creating Traffic over TCP ChannelsFTPcreate traffic modelset ftp [new Application/FTP]default is “infinite” file sizeattach to TCP channel$ftp attach-agent $t_srcschedule start time$ns at <time> “$ftp start”13Creating Transport Channels: UDPsource and sinkset u_src [new Agent/UDP]set u_dst [new Agent/NULL]attach them to nodes, then connect to each other$ns attach-agent $n0 $u_src$ns attach-agent $n1 $u_dst$ns connect $u_src $u_dst14Creating Traffic over UDP ChannelsCBRset cbr [new Application/Traffic/CBR]$cbr set packetSize_ 512$cbr set interval_ 0.250$cbr attach-agent $u_src$ns at <time> “$cbr start”15Tracing Trace packets on individual linksTracefile format:<event> <time> <from> <to> <pkt> <size>--<flowid> <src> <dst> <seqno> <aseqno>+ 1 0 2 tcp 900 ------- 1 0.0 3.1 7 15- 1 0 2 tcp 900 ------- 1 0.0 3.1 7 15r 1.00234 0 2 tcp 900 ------- 1 0.0 3.1 7 15+ enqueue- dequeuer received droptimenodes involvedin this eventpackettypepacketlengthpacketflagsflowIDsourcedest addressesseqnumberpacketID16Tracing via MonitorsQueue monitorqueue to access the linkFlow monitorparticular flow within queueset fmon [$ns makeflowmon Fid]$ns attach-fmon $link $fmon$ns at <time> “puts $fmon set pdrops_”to specify a link, we need:•set link [$ns link $n0 $n1]17Walk-through example2 FTP/TCPsources1 On-Off (voice)UDP sourceacksFTP/TCPdestOnOff/UDPCBR/UDPdest2 Mbps full duplex5 msec prop delay100 packet bufferDrop-tail policy acks1 Mbps full duplex10 msec prop delay700 packet bufferDrop-tail policy10 FTP/TCPsources1 CBR/UDPsourceTCP SACKW_max = 32MSS = 1400TCP NewRenoW_max = 32MSS = 140001218Ns Trace file : NS-trace.txt...+ 11.533441 1 2 tcp 1440 ------- 12 1.2 2.4 96 2092r 11.535694 1 2 tcp 1440 ------- 12 1.2 2.4 65 1527- 11.537214 1 2 exp 180 ------- 100 0.2 2.13 284 1528- 11.538654 1 2 cbr 1440 ------- 101 1.11 2.14 155 1530r 11.547214 1 2 tcp 1440 ------- 12 1.2 2.4 66 1529+ 11.54728 1 2 tcp 1440 ------- 12 1.2 2.4 97 2095r 11.548654 1 2 exp 180 ------- 100 0.2 2.13 284 1528+ 11.55 1 2 cbr 1440 ------- 101 1.11 2.14 211 2096- 11.550174 1 2 tcp 1440 ------- 12 1.2 2.4 67 1534r 11.560174 1 2 cbr 1440 ------- 101 1.11 2.14 155 1530- 11.561694 1 2 exp 180 ------- 100 0.2 2.13 285 1532+ 11.56222 1 2 tcp 1440 ------- 12 1.2 2.4 98 2097- 11.563134 1 2 tcp 1440 ------- 12 1.2 2.4 68 1537r 11.571694 1 2 tcp 1440 ------- 12 1.2 2.4 67 1534r 11.573134 1 2 exp 180 ------- 100 0.2 2.13 285 1532- 11.574654 1 2 exp 180 ------- 100 0.2 2.13 286 1536...19Flow Monitor Trace : packet-trace.txt...10 356 1394.6939635123624 1262 906 0 4 7 3 0 10.5 367 1575.3875777393503 1325
View Full Document