330 likes | 742 Views
TCP/IP Network Simulation. Jahwan Koo Intelligent HCI Convergence Research Center Sungkyunkwan University jhkoo@songgang.skku.ac.kr. Talk Objectives. Appreciate the role of simulation in performance evaluation Understand the steps of simulation methodology Classify various simulation tools
E N D
TCP/IP Network Simulation Jahwan KooIntelligent HCI Convergence Research CenterSungkyunkwan Universityjhkoo@songgang.skku.ac.kr
Talk Objectives • Appreciate the role of simulation in performance evaluation • Understand the steps of simulation methodology • Classify various simulation tools • Become familiar with popular simulation tools
Research To study (something) thoroughly so as to present in a detailed, accurate manner Development Mathematical Experimental Simulation Methodology Basic Concepts Case Study How are you doing research?
Simulation? • Robert.E Shannon, “Introduction to the art and science of simulation” • the process of designing a model of a real system and conducting experiments with this model for the purpose of understanding the behavior of the system and /or evaluating various strategies for the operation of the system • Advantages • Describe the behavior of a system • Use the model to predict future behavior, i.e. the effects that will be produced by changes in the system or in its method of operation
Classification • General-purpose programming languages (GPPL) • “Plain” simulation languages (PSL) • Simulation packages (SP)
Advantages & Disadvantages • GPPLs • Advantages • Available in almost all computer systems & platforms • Almost all researchers know at least one GPPL very well • Provide total control over the software development process • Disadvantages • Lack of support for a discrete-event simulation • Spend considerable time and effort writing routines for event handling & random number generation • Model constructions take a very long time • PSLs • Advantages • Basic support for a discrete-event simulation • Disadvantages • Not available in all computer systems & platforms • The need of programming expertise in a new language • Lack of built-in libraries for TCP/IP networks • SPs • Advantages • Highest level of simulation tools • Basic support for a discrete-event simulation • Built-in libraries for TCP/IP networks
NS History • 1989: REAL network simulator • 1995: DARPA VINT project at LBL, Xerox PARC, UCB, and USC/ISI • Present: DARPA SAMAN project and NSF CONSER project • Collaboration with other researchers including CIRI
NS Status • Periodical release (ns-2.1b9a, July 2002) • ~200K LOC in C++ and Otcl, • ~100 test suites and 100+ examples • 371 pages of ns manual • Daily snapshot (with auto-validation) • Stability validation • http://www.isi.edu/nsnam/ns/ns-tests.html • Platform support • FreeBSD, Linux, Solaris, Windows and Mac • User base • > 1k institutes (50 countries), >10k users • About 300 posts to ns-users@isi.edu every month
NS Functionalities • Wired world • Routing DV, LS, PIM-SM • Transportation: TCP and UDP • Traffic sources:web, ftp, telnet, cbr, stochastic • Queuing disciplines:drop-tail, RED, FQ, SFQ, DRR • QoS: IntServ and Diffserv • Emulation • Wireless • Ad hoc routing and mobile IP • Directed diffusion, sensor-MAC • Tracing, visualization, various utilities
NS Components • Ns, the simulator itself • Nam, the network animator • Visualize ns (or other) output • Nam editor: GUI interface to generate ns scripts • Pre-processing: • Traffic and topology generators • Post-processing: • Simple trace analysis, often in Awk, Perl, or Tcl
NS Models • Traffic models and applications: • Web, FTP, telnet, constant-bit rate, real audio • Transport protocols: • unicast: TCP (Reno, Vegas, etc.), UDP • Multicast: SRM • Routing and queuing: • Wired routing, ad hoc rtg and directed diffusion • queuing protocols: RED, drop-tail, etc • Physical media: • Wired (point-to-point, LANs), wireless (multiple propagation models), satellite
NS Resources • Ns Homepage • http://www.isi.edu/nsnam/ns/ • Ns and nam build questions • http://www.isi.edu/nsnam/ns/ns-build.html • Ns mailing list: ns-users@isi.edu • Ns manual and tutorial (in distribution) • TCL: http://dev.scriptics.com/scripting • Otcl tutorial (in distribution): ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial.html
* * Unix Linux Windows #1 Basic Concept Commands Shell #3 C Fundamental Installation #2 #6 Unix System Programming #4 C++ Fundamental Management Guidelines & Activities Main Topics Technical Paper Presentation #7 #8 Network Concept NS-2 #5 Study Guidelines-1
Study Guidelines-2 Step 1) Prepare a Linux Machine and Install Redhat Linux Operating System • http://www.redhat.com Step 2) Download NS All-in-One version(2.29.tar.gz) and Install it on your machine • http://www.isi.edu/nsnam/ns/ns-tests.html Step 3) Practice step-by-step Examples • http://perform.wpi.edu/NS/index.html Step 4) Read numerous technical papers, understand network concepts, and select main topics or problems • Related papers using NS-2 Step 5) Execute modeling and simulation • By Simulation Methodology • Use a simulation language like Otcl, C++ • Use graph and chart drawing tools such as gnuplot, excel, MatLab
Overview • Developed by UCB/LBNL/VINT groups (http://www.isi.edu/nsnam/ns/) • Very popular software • Object-oriented simulator • Represents Network components & network characteristics by various classes • Written in C++ & object-oriented tcl (Otcl) scripts
Model Construction & Parameter Setting • A network model in ns is constructed by interconnecting several components, called ns object. • Built from a hierarchical C++ class structure • http://www.isi.edu/nsnam/nsdoc-classes/index.html
NsObject • NsObject • Base class for all derived classes • Methods • handle method to handle events • recv method to process received packets • Connector • Derive to links related objects (Queue, Delay) and nodes related objects (Agents) • Trace • Used to collect data about packets in the network during the simulation • Classifier • Examines packets & forward them to the appropriate destination • By passing the packet object to the recv method of the object • Unicast address classifier • Multicast address classifier • Replicator
Major Objects-1 • Nodes • Represent clients, hosts, routers, or switches • A node s1 can be created as follows: set s1 [$ns node] • Classifiers • Determine the outgoing interface object • Address Classifiers : support unicast packet forwarding • Multicast Classifiers : classify packets based on both source and destination group address • Multipath Classifiers : support equal cost multipath forwarding • Replicators : deliver copies of the same packet to multiple receivers • Links • Used to connect nodes to form a network topology • Support for a variety of links $ns <link-type> <n1> <n2> <bandwidth> <delay> <queue-type> • link-type : simplex-link, duplex-link, or duplex-intserv-link • queue-type : DropTail, Fair Queueing (FQ), Stochastic Fair Queuing (SFQ), Deficit Round Robin scheduling (DRR), Random Early Detection (RED), or Class Based Queuing (CBQ) • Example $ns duplex-link $s1 $r1 8Mb 5ms DropTail
Major Objects-2 • Agents • Have several fields to construct the appropriate packet • Source address, destination address, packet size, IP flow identifier, IP priority, flags, time to live • Can be set using the set command • Attached to a node using the attach-agent command • UDP agents • Commonly use when rate-based traffic generators (CBR or Pareto) are used at the application level. set udp_agent [new Agent/UDP] $ns attach-agent <node> $udp_agent $udp_agent set <field> <field-value> • TCP agents • Create set tcp_agent [new Agent/<tcp-agent-type>] • connect between two agents $ns connect <source agent> <destination agent> • Parameters • Window settings (window_), ECN bit (ecn_), timer granularity (tcpTick_), congestion window, ssthresh setting. $tcp_agent set window_ 15 $tcp_agent set ecn_ 1
Major Objects-3 • Applications • Produce data on top of the transport layer (UDP or TCP) • Attached to the transport end points by the attach-agent command • Start (stop) sending data at specified times using the start (stop) command • Main application supported by ns • FTP, Telnet, WWW, etc • Example) a TCP agent is used as the transport layer and an FTP application runs on top of it. set tcp_agent [new Agent/TCP] $ns attach-agent $source $tcp_agent set ftp_app [new Application/FTP] $ftp_app attach-agent $tcp_agent $ns at 10.0 “$ftp_app start” $ns at 20.0 “$ftp_app stop”
Major Objects-4 • Traffic Generators • Automate generation of traffic according to a desired pattern & load • Exponential ON-OFF • Generate packets at a fixed rate during the ON periods, while no packets are sent during the OFF periods. • Exponential distribution • Size of packets being generated, average ON time, average OFF time, and sending rate set expapp [new Application/Traffic/Exponential] $expapp set packetsize_ 1000 $expapp set rate_ 500k $expapp set burst_time_ 100ms $expapp set idle_time_ 30ms • Pareto ON-OFF • Pareto distribution • Self-similar traffic can be generated by aggregating several Pareto ON-OFF sources • The shape of the pareto distribution can be set as follows: set parapp [new Application/Traffic/Pareto] $parapp set shape 1.0
Major Objects-5 • Traffic Generators • Constant Bit Rate (CBR) • Generates packets at a constant rate • Random noise can be introduced to vary the time between sending of packets • Constant packet sizes • Sending rate, interval between packets, size of packets, a flag to specify introduction of random noise, maximum number of packets that can be sent set cbrapp [new Application/Traffic/CBR] $cbrapp set maxpkts_ 10000 $cbrapp set packetsize_ 5000 $cbrapp set rate_ 16kb $cbrapp set interval_ 1ms $cbrapp set random 1
Data Collection-1 • Tracing • Records each packets as it arrives at a node, departs a node, or is dropped at a link or queue. • Useful in debugging or verification of the simulation code • To collect the trace record of every packet $ns trace-all <tracefile> • Structure of trace files • Event Type : enqueue (+), dequeue (-), drop (d), receive (r) • Src, Dst addr : “node.port” • Example
Data Collection-2 • Monitoring • Monitor counts, such as number of packets dropped, for all traffic in the network, for specific links, or for specific flows • Monitoring objects are inserted into the network topology at specific places. • To create a trace object between a src and a dest node $ns create-trace <type> <tracefile> <src> <dest> • type Enqueue, Deque, Drop, or Recv • To add a trace agent to trace the TCP congestion window variable $ns add-agent-trace $tcp_agent tcp_agent $ns monitor-agent-trace $tcp_agent $tcp_agent tracevar cwnd_
Simulation Execution • An object of class Simulator must be created as follow: set ns [new Simulator] • To start an application at a specified time $ns at <time> “<command>” • Example) An FTP source can be started at time 0.0 $ns at 0.0 “$ftp_app atart” • To terminate ns • by calling the finish procedure $ns at 2.0 “finish” • To execute ns $ns run
ns Examples-1 • A Simple Network Topology
ns Examples-2 • Evaluating TCP Performance • Step 1: Design Network Model • Step 2 : Select Performance Metrics • Observe the throughput of the FTP connection • Monitor the rate of sequence number increase over time • Step 3 : Select Variables • Buffer size at R1 to examine the effect of buffer size on the TCP throughput • Step 4 : Construct Model & Set Parameters • Create the four nodes • Connect nodes with link • Create TCP source & sink agent • Connect source to sink • Attach FTP application to TCP transport protocol
ns Examples-2 (Con’t) • Step 4 : Construct Model & Set Parameters (Cont’) • Create the four nodes set n0 [$ns node] set R1 [$ns node] set R2 [$ns node] set n1 [$ns node] • Connect nodes with link $ns duplex-link $n0 $R1 10Mb 1ms DropTail $ns duplex-link $R1 $R2 1Mb 3ms DropTail $ns duplex-link $R2 $n1 10Mb 1ms DropTail • Create TCP source & sink agent set tcp0 [new Agent/TCP] $ns attach-agent $n0 $tcp0 set tcpsink0 [new Agent/TCPSink] $ns attach-agent $n1 $tcpsink0 • Connect source to sink $ns connect $tcp0 $tcpsink0 • Attach FTP application to TCP transport protocol set ftp0 [new Application/FTP] $ftp0 attach-agent $tcp0
ns Examples-2 (Con’t) • Step 5 : Data Collection • Use tracing for collecting the sequence numbers $ns trace-all [open out.tr w] • Use monitoring for collecting the throughput data #Define “bytes_” in TCP sink agent (tcp-sink.cc) void TcpSink::recv(Packet* pkt, Handler*) { ... Some line before bytes_ += hdr_cmn::access(pkt) -> size(); Double now = Scheduler::instance().clock(); ... Some line after } #Bind variables in agent’s constructor TcpAgent::TcpAgent() : Agent(PT_TCP), ... { ... Some line before bind(“seqno_”, &seqno_); ... Some line after } TcpSink::TcpSink(Acker* acker) : Agent(PT_ACK), acker_(acker), save_(NULL) { ... Some line before bind(“bytes_”, &bytes_); ... Some line after }
ns Examples-2 (Con’t) #Initialize variables in ns-default.tcl to be linked to OTcl Agent/TCP set seqno_ 0 Agent/TCPSink set bytes_ 0 #Open output file for writing data set f1 [open seq.dat w] set f2 [open thruput.dat w] set f3 [open delay.dat w] #Call output variable in Tcl and write data to output file set seq [$tcp0 set seqno_] set bw [$tcpsink0 set bytes_] set delay [$tcpsink0 set e2e_delay_] puts $f1 “$now $seq” puts $f2 “$now [expr $bw/$time*8/1000]” puts $f3 “$now [expr $delay*1000]” #Recompile ns
ns Examples-2 (Con’t) • Step 6 : Simulation Execution #Set simulation time, run FTP sources for 10 seconds $ns at 0.0 “$ftp0 start” $ns at 10.0 “$ftp0 stop” $ns at 0.0 “record” $ns at 10.0 “finish” $ns run • Step 7 : Presentation & Analysis of Simulation Results exec awk { { if (($1 == “r”) && ($4 == “0”) && ($5 == “ack”)) print $2, $11 } } out.tr > datafile