180 likes | 334 Views
NS Simulator for beginners. Chapter 2 & 3. ns Simulator Preliminaries 2009-09-02 Thiep M. Ha thiep03@yahoo.com. Contents. Initialization and termination Definition of a network of links and nodes Agents and applications Scheduling events Visualisation: using nam Tracing
E N D
NS Simulator for beginners Chapter 2 & 3. ns Simulator Preliminaries 2009-09-02 Thiep M. Ha thiep03@yahoo.com
Contents • Initialization and termination • Definition of a network of links and nodes • Agents and applications • Scheduling events • Visualisation: using nam • Tracing • Random variables
Initialization and termination • An ns simulation starts with the command • Creating output files (trace files or nam files)
Initialization and termination • The termination of the program • At the end of the ns program we should call the procedure “finish” and specify at what time the termination should occur.
Definition of a network of links and nodes • Definition of a node • Definition of a link • In NS, an output queue of a node is implemented as a part of each link whose input is that node. • Definition of the buffer capacity of the queue related to each link
Definition of a network of links and nodes • Form of a simplex link • Duplex link is constructed from two parallel simplex links.
Definition of a network of links and nodes • Defining nodes, links and assigning queue size
Agents and applications • FTP over TCP
Agents and applications • CBR over UDP
Scheduling events • The Tcl script defines when event should occur. • Format • Examples • The scheduler is started when running ns, i.e. through the command $ns run.
Visualisation: using nam • Giving node position (for NAM)
Tracing • Tracing objects in a simplex link • EnqT registers information concerning a packet that arrives and is queued at the input queue of the link. • DrpT handles the information concerning the dropped packet. • DeqT registers information at the instant the packet is dequed. • RecvT gives us information about packets that have been received at the output of the link.
Tracing • Structure of trace files • Event: event type. • r: receive (at the output of the link) • +: enqueued • -: dequeued • d: dropped • Time: the time at which the events occurs. • From node: givens the input node of the link at which the events occurs. • To node: gives the output node of the link at which the events occurs. • Pkt id: unique id of the packet
Tracing • Example • Tracing a subset of events
Random variables • Seeds and generators • The seed value of 0 results in the generation of a new random variable each time we run the simulation. • In contrast, if we use other seeds then each time we run the simulation, the same sequence of random variables that are generated in a simulation will be generated. • Creating random variables • Creating a new generator • When actually creating a random variable, we have to define its distribution type and its parameters.