sankar NS2

Embed Size (px)

Citation preview

  • 8/3/2019 sankar NS2

    1/47

    Network Simulator Tutorial

    Sankar.P,

    AP\ECE

    Jerusalem College of Engineering27-1-2012 1

  • 8/3/2019 sankar NS2

    2/47

    Network SimulationMotivation:

    Learn

    fundamentals ofevaluatingnetwork

    performance viasimulation

    Overview:

    fundamentals of

    discrete eventsimulation

    ns-2 simulation

    Jerusalem College of Engineering27-1-2012 2

  • 8/3/2019 sankar NS2

    3/47

    What is simulation?

    system boundary

    exogenous inputsto system

    (the environment)

    system under study(has deterministic rulesgoverning its behavior)

    real life

    Program boundary

    pseudo random inputsto system

    (models environment)

    system under study(has deterministic rulesgoverning its behavior)

    simulated life

    observer

    observerJerusalem College of Engineering27-1-2012 3

  • 8/3/2019 sankar NS2

    4/47

    Why Simulation?

    real-system not available, iscomplex/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 numericaltechniques not available

    Jerusalem College of Engineering27-1-2012 4

  • 8/3/2019 sankar NS2

    5/47

    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 minreal time could be hours of simulated time)

    art: determining right level of model complexity

    statistical uncertainty in results

    Jerusalem College of Engineering27-1-2012 5

  • 8/3/2019 sankar NS2

    6/47

    History and Status

    Columbia NEST

    UCB REAL

    ns-1 ns-2

    ns-3 100K lines of C++

    70K lines of OTcl

    30K lines of test suite

    20K lines of documentation

    Jerusalem College of Engineering27-1-2012 6

  • 8/3/2019 sankar NS2

    7/47

    What is NS2 Discrete event simulator

    A package of tools that simulatesbehavior of networks

    Create Network Topologies

    Log events that happen under any load

    Analyze events to understand thenetwork behavior

    Wired and wireless

    Jerusalem College of Engineering27-1-2012 7

  • 8/3/2019 sankar NS2

    8/47

    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

    Jerusalem College of Engineering27-1-2012 8

  • 8/3/2019 sankar NS2

    9/47

    OTCL and C++: Duality

    27-1-2012 Jerusalem College of Engineering 9

    C++ OTcl

    Pure C++objects

    Pure OTcl

    objects

    C++/OTcl splitobjects

  • 8/3/2019 sankar NS2

    10/47

    Extending the TCL Interpreter

    27-1-2012 Jerusalem College of Engineering 10

    OTcl: object-orientedTcl

    TclCL: C++ and OTcllinkageDiscrete eventscheduler

    Data networkcomponents

    Link layer and upEmulation support

    Tcl

    OTcl

    TclCLEvent

    Scheduler

    NetworkComponents

    C/C++

  • 8/3/2019 sankar NS2

    11/47

    Using NS2

    Problem

    Simulationmodel

    Setup/runsimulation

    with ns

    Resultanalysis

    Modifyns

    Jerusalem College of Engineering27-1-2012 11

  • 8/3/2019 sankar NS2

    12/47

    NS2 environment

    27-1-2012 Jerusalem College of Engineering 12

  • 8/3/2019 sankar NS2

    13/47

    Simulation setup

    27-1-2012 Jerusalem College of Engineering 13

    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 fileand nam view.

  • 8/3/2019 sankar NS2

    14/47

    Simulation Configurations

    27-1-2012 Jerusalem College of Engineering 14

    Copy the implemented algorithms in to queuefolder in NS2 (nsallinone2.29/ns2.29/queue).

    Change the default settings of the file ns-default.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.

  • 8/3/2019 sankar NS2

    15/47

    Cont..

    27-1-2012 Jerusalem College of Engineering 15

    Make the new environment for simulation.

    Write the tcl code for create the networktopology and simulation

    Create traffic and analyze the network using

    trace and verify the packet flow using networkanimator.

  • 8/3/2019 sankar NS2

    16/47

    Wired Network

    Jerusalem College of Engineering27-1-2012 16

  • 8/3/2019 sankar NS2

    17/47

    Coding(Cont)

    Jerusalem College of Engineering27-1-2012 17

  • 8/3/2019 sankar NS2

    18/47

    Coding(Cont)

    Jerusalem College of Engineering27-1-2012 18

  • 8/3/2019 sankar NS2

    19/47

    Coding(Cont)

    Jerusalem College of Engineering27-1-2012 19

  • 8/3/2019 sankar NS2

    20/47

    Network Created

    Jerusalem College of Engineering27-1-2012 20

  • 8/3/2019 sankar NS2

    21/47

    OUTPUT

    (FLOW

    1)

    Jerusalem College of Engineering27-1-2012 21

  • 8/3/2019 sankar NS2

    22/47

    Output(Flow 2)

    Jerusalem College of Engineering27-1-2012 22

  • 8/3/2019 sankar NS2

    23/47

    Output (congestion)

    Jerusalem College of Engineering27-1-2012 23

  • 8/3/2019 sankar NS2

    24/47

    Ou

    tpu

    t ( Flow 2 Stopped)

    Jerusalem College of Engineering27-1-2012 24

  • 8/3/2019 sankar NS2

    25/47

    Tracing and MonitoringPacket tracing:

    On all links: $ns trace-all [open out.tr w]On one specific link: $ns trace-queue $n0 $n1$tr

    -- + 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-allE 2.267203 0 4 TCP slow_start 0 210 1

    Jerusalem College of Engineering27-1-2012 25

  • 8/3/2019 sankar NS2

    26/47

    Tracing and Monitoring-2Visualize trace in nam

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

    Variable tracing in namAgent/TCP set nam_tracevar_ true$tcp tracevar srtt_$tcp tracevar cwnd_

    Monitor agent variables in nam$ns add$ns add--agentagent--trace $trace $tcptcp $$tcptcp$ns monitor$ns monitor--agentagent--trace $trace $tcptcp$srm0$srm0 tracevartracevar cwndcwnd__$ns delete$ns delete--agentagent--trace $trace $tcptcp

    Jerusalem College of Engineering27-1-2012 26

  • 8/3/2019 sankar NS2

    27/47

    Inserting Errors

    27-1-2012 Jerusalem College of Engineering 27

    Creating Error Module

    set loss_module [new ErrorModel]

    $loss_module set rate_ 0.01$loss_module unit pkt$loss_module ranvar [newRandomVariable/Uniform]$loss_module drop-target [new Agent/Null]

    Inserting Error Module

    $ns lossmodel $loss_module $n0 $n1

  • 8/3/2019 sankar NS2

    28/47

    Network Dynamics

    27-1-2012 Jerusalem College of Engineering 28

    Link failuresHooks in routing module to reflect routing changes

    Four models$$nsns rtmodelrtmodel TraceTrace $$nn00 $$nn11$$nsns rtmodelrtmodel ExponentialExponential {}

    $$nn00

    $$nn11$$nsns rtmodelrtmodel DeterministicDeterministic {} $$nn00

    $$nn11$$nsns rtmodelrtmodel--atat up|downup|down $$nn00 $$nn11

    Parameter list[][] [][]

  • 8/3/2019 sankar NS2

    29/47

    27-1-2012 Jerusalem College of Engineering 29

    Wireless network

  • 8/3/2019 sankar NS2

    30/47

    27-1-2012 Jerusalem College of Engineering 30

    Mobile node Modules

  • 8/3/2019 sankar NS2

    31/47

    27-1-2012 Jerusalem College of Engineering 31

    Cont

  • 8/3/2019 sankar NS2

    32/47

    27-1-2012 Jerusalem College of Engineering 32

    Cont

  • 8/3/2019 sankar NS2

    33/47

    27-1-2012 Jerusalem College of Engineering 33

    Mobile Node Diagram-DSDV

  • 8/3/2019 sankar NS2

    34/47

    27-1-2012 Jerusalem College of Engineering 34

    Mobile Node Diagram-DSR

  • 8/3/2019 sankar NS2

    35/47

    27-1-2012 Jerusalem College of Engineering 35

    Running a simulation scenario

  • 8/3/2019 sankar NS2

    36/47

    27-1-2012 Jerusalem College of Engineering 36

    Setting up variables

  • 8/3/2019 sankar NS2

    37/47

    27-1-2012 Jerusalem College of Engineering 37

    Cont

  • 8/3/2019 sankar NS2

    38/47

    27-1-2012 Jerusalem College of Engineering 38

    Configuring Mobile nodes

  • 8/3/2019 sankar NS2

    39/47

    27-1-2012 Jerusalem College of Engineering 39

    Configuring Movement

  • 8/3/2019 sankar NS2

    40/47

    27-1-2012 Jerusalem College of Engineering 40

    Set up traffic Flow

  • 8/3/2019 sankar NS2

    41/47

    27-1-2012 Jerusalem College of Engineering 41

    Set Stop Time and Start Simulation

  • 8/3/2019 sankar NS2

    42/47

    27-1-2012 Jerusalem College of Engineering 42

    Trace File

  • 8/3/2019 sankar NS2

    43/47

    27-1-2012 Jerusalem College of Engineering 43

    Reading Trace File

  • 8/3/2019 sankar NS2

    44/47

    27-1-2012 Jerusalem College of Engineering 44

    Cont

  • 8/3/2019 sankar NS2

    45/47

    27-1-2012 Jerusalem College of Engineering 45

    Cont

  • 8/3/2019 sankar NS2

    46/47

    27-1-2012 Jerusalem College of Engineering 46

    Wireless support in ns continuouslyevolvingMany other contributed models (not

    integrated into ns distribution) include:Mobiwan, GPRS, Bluehoc and blueware, CIMSetcAvailable from ns contributed code page at

    http://www.isi.edu/nsnam/ns/nscontributed.html

    Marc Greis Tutorial

    Support Materials

  • 8/3/2019 sankar NS2

    47/47

    27-1-2012 Jerusalem College of Engineering 47

    Thank You