Sie sind auf Seite 1von 47

Network Simulator Tutorial

Sankar.P, AP\ECE

27-1-2012

Jerusalem College of Engineering

Network Simulation
Motivation: Learn fundamentals of evaluating network performance via simulation
27-1-2012

Overview: fundamentals of discrete event simulation ns-2 simulation

Jerusalem College of Engineering

What is simulation?
system boundary exogenous inputs to system (the environment) system under study (has deterministic rules governing its behavior) real life

observer

Program boundary

pseudo random inputs to system (models environment)


27-1-2012

system under study (has deterministic rules governing its behavior)


Jerusalem College of Engineering

simulated life
3

observer

Why Simulation?
real-system not available, is complex/costly or dangerous (eg: space simulations, flight simulations) quickly evaluate design alternatives (eg: different system configurations) evaluate complex functions for which closed form formulas or numerical techniques not available
27-1-2012 Jerusalem College of Engineering 4

Simulation: advantages/drawbacks*
advantages:
      sometimes cheaper find bugs (in design) in advance generality: over analytic/numerical techniques detail: can simulate system details at arbitrary level

drawbacks:
caution: does model reflect reality large scale systems: lots of resources to simulate (especially accurately simulate)  may be slow (computationally expensive 1 min real time could be hours of simulated time)  art: determining right level of model complexity  statistical uncertainty in results
27-1-2012 Jerusalem College of Engineering 5

History and Status


Columbia NEST UCB REAL ns-1 ns-2 ns-3
   
27-1-2012

100K lines of C++ 70K lines of OTcl 30K lines of test suite 20K lines of documentation
Jerusalem College of Engineering 6

What is NS2
Discrete event simulator A package of tools that simulates behavior of networks
 Create Network Topologies  Log events that happen under any load  Analyze events to understand the network behavior

Wired and wireless


27-1-2012 Jerusalem College of Engineering 7

NS Software Structure: C++ and OTCL


Uses two languages C++ for packet-processing
 per packet processing  fast to run, detailed, complete control

OTCL for control


 simulation setup, configuration, occasional actions  fast to write and change

27-1-2012

Jerusalem College of Engineering

OTCL and C++: Duality

Pure C++ objects

Pure OTcl objects

C++

C++/OTcl split objects

OTcl

27-1-2012

Jerusalem College of Engineering

Extending the TCL Interpreter


OTcl: object-oriented Tcl TclCL: C++ and OTcl linkage Discrete event scheduler Data network components
Link layer and up Emulation support
27-1-2012 Jerusalem College of Engineering 10

Network Components TclCL OTcl Tcl C/C++ Event Scheduler

Using NS2
Problem

Result analysis

Simulation model

Modify ns

Setup/run simulation with ns

27-1-2012

Jerusalem College of Engineering

11

NS2 environment

27-1-2012

Jerusalem College of Engineering

12

Simulation setup
Create event scheduler (Calendar scheduling ). Turn on tracing. Create network. Setup routing and Insert errors. Create transport connection. Create traffic. Transmit application level data. Trace out the simulated output using trace file and nam view.
27-1-2012 Jerusalem College of Engineering 13

Simulation Configurations
Copy the implemented algorithms in to queue folder in NS2 (nsallinone2.29/ns2.29/queue). Change the default settings of the file nsdefault.tcl (nsallinone2.29/ns2.29/tcl/lib/ ns-default.tcl). Change the settings in the Makefile.in for creating object files. Configure the network using ./configure.

27-1-2012

Jerusalem College of Engineering

14

Cont..
Make the new environment for simulation. Write the tcl code for create the network topology and simulation Create traffic and analyze the network using trace and verify the packet flow using network animator.

27-1-2012

Jerusalem College of Engineering

15

Wired Network

27-1-2012

Jerusalem College of Engineering

16

Coding(Cont)

27-1-2012

Jerusalem College of Engineering

17

Coding(Cont)

27-1-2012

Jerusalem College of Engineering

18

Coding(Cont)

27-1-2012

Jerusalem College of Engineering

19

Network Created

27-1-2012

Jerusalem College of Engineering

20

OUTPUT (FLOW 1)

27-1-2012

Jerusalem College of Engineering

21

Output(Flow 2)

27-1-2012

Jerusalem College of Engineering

22

Output (congestion)

27-1-2012

Jerusalem College of Engineering

23

Output ( Flow 2 Stopped)

27-1-2012

Jerusalem College of Engineering

24

Tracing and Monitoring


Packet tracing:
On all links: $ns trace-all [open out.tr w] On one specific link: $ns trace-queue $n0 $n1$tr
<Event> <time> <from> <to> <pkt> <size> -- <fid> <src> <dst> <seq> <attr>

+ 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 - 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0

We have new trace format

Event tracing (support TCP right now)


Record event in trace file: $ns eventtrace-all E 2.267203 0 4 TCP slow_start 0 210 1

27-1-2012

Jerusalem College of Engineering

25

Tracing and Monitoring-2


Visualize trace in nam
$ns namtrace-all [open test.nam w] $ns namtrace-queue $n0 $n1

Variable tracing in nam


Agent/TCP set nam_tracevar_ true $tcp tracevar srtt_ $tcp tracevar cwnd_

Monitor agent variables in nam


$ns add-agent-trace $tcp $tcp add-agent$tcp $ns monitor-agent-trace $tcp monitor-agent$tcp $srm0 tracevar cwnd_ cwnd_ $ns delete-agent-trace $tcp delete-agent$tcp

27-1-2012

Jerusalem College of Engineering

26

Inserting Errors
Creating Error Module

set loss_module [new ErrorModel] $loss_module set rate_ 0.01 $loss_module unit pkt $loss_module ranvar [new RandomVariable/Uniform] $loss_module drop-target [new Agent/Null]
Inserting Error Module

$ns lossmodel $loss_module $n0 $n1

27-1-2012

Jerusalem College of Engineering

27

Network Dynamics
Link failures Hooks in routing module to reflect routing changes Four models $ns rtmodel Trace <config_file> $n0 $n1 config_file> $ns rtmodel Exponential {<params>} $n0 $n1 {<params>} $ns rtmodel Deterministic {<params>} $n0 {<params>} $n1 $ns rtmodel-at <time> up|down $n0 $n1 rtmodelParameter list [<start>] <up_interval> up_interval> <down_interval> down_interval> [<finish>]

27-1-2012

Jerusalem College of Engineering

28

Wireless network

27-1-2012

Jerusalem College of Engineering

29

Mobile node Modules

27-1-2012

Jerusalem College of Engineering

30

Cont

27-1-2012

Jerusalem College of Engineering

31

Cont

27-1-2012

Jerusalem College of Engineering

32

Mobile Node Diagram-DSDV

27-1-2012

Jerusalem College of Engineering

33

Mobile Node Diagram-DSR

27-1-2012

Jerusalem College of Engineering

34

Running a simulation scenario

27-1-2012

Jerusalem College of Engineering

35

Setting up variables

27-1-2012

Jerusalem College of Engineering

36

Cont

27-1-2012

Jerusalem College of Engineering

37

Configuring Mobile nodes

27-1-2012

Jerusalem College of Engineering

38

Configuring Movement

27-1-2012

Jerusalem College of Engineering

39

Set up traffic Flow

27-1-2012

Jerusalem College of Engineering

40

Set Stop Time and Start Simulation

27-1-2012

Jerusalem College of Engineering

41

Trace File

27-1-2012

Jerusalem College of Engineering

42

Reading Trace File

27-1-2012

Jerusalem College of Engineering

43

Cont

27-1-2012

Jerusalem College of Engineering

44

Cont

27-1-2012

Jerusalem College of Engineering

45

Support Materials
 Wireless support in ns continuously evolving  Many other contributed models (not integrated into ns distribution) include: Mobiwan, GPRS, Bluehoc and blueware, CIMS etc  Available from ns contributed code page at http://www.isi.edu/nsnam/ns/nscontri buted.html  Marc Greis Tutorial
27-1-2012 Jerusalem College of Engineering 46

Thank You

27-1-2012

Jerusalem College of Engineering

47

Das könnte Ihnen auch gefallen