NS 2tutorial (1)

Embed Size (px)

Citation preview

  • 8/12/2019 NS 2tutorial (1)

    1/20

    1

    NS-2 Tutorial

    COMP 7810 09R2

    University of ManitobaMarch 4, 2009

  • 8/12/2019 NS 2tutorial (1)

    2/20

    2

    Goal and Outline

    Goal of this tutorial

    Lead you to get started using NS-2

    Outline

    Introduction - Whats NS?

    Steps in Using NS-2 (through examples)

    Development and Your Project

  • 8/12/2019 NS 2tutorial (1)

    3/20

    3

    Whats NS?

    NS is a packet-levelsimulator

    Started with Keshavs REAL in 1989

    Been revised in Berkeley, then others

    Overview

    Major engine (network components) written in C++

    User-interface is tcl script

  • 8/12/2019 NS 2tutorial (1)

    4/20

    4

    My First Tcl Script

  • 8/12/2019 NS 2tutorial (1)

    5/20

    5

    Test it out!

    Go to

    http://www.cs.umanitoba.ca/~yliu/TEACH/NS

    2/TUTORIAL

  • 8/12/2019 NS 2tutorial (1)

    6/20

    6

    My First OTcl Script

  • 8/12/2019 NS 2tutorial (1)

    7/20

    7

    NS-2 Simulated Components

    Protocols

    TCP, UDP, DCCP, SCTP, TFRC, Wi-Fi, etc.

    Network model

    Nodes, links, topology, channel schedulers, buffer

    management, etc.

    Traffic model

    Applications: FTP, CBR, MPEG, etc. Traffic traces

  • 8/12/2019 NS 2tutorial (1)

    8/20

    8

    NS-2 Simulated Components (II)

    All implemented by students/researchers like

    you and me

    Each release has a few more contributed

    components added

    Many are still being developed

    Well documented steps to use and to add to

    NS-2

  • 8/12/2019 NS 2tutorial (1)

    9/20

    9

    General Steps In Using NS-2

    Obtaining NS-2 (made available for you)

    Writing an OTcl script. E.g., a.tcl

    Run the simulation. Just type ns a.tcl

    Post-process the trace generated

    Plot graphs and include in your papers

  • 8/12/2019 NS 2tutorial (1)

    10/20

    10

    Obtaining NS-2

    Available to you here in CS

    Linux version 2.33 installed on neram-02 (a

    networks lab Linux machine)

    Each student is given a separate complete

    copy of NS-2

    Email me if you dont know how to access yours

  • 8/12/2019 NS 2tutorial (1)

    11/20

    11

    Obtaining NS-2 (for your home PC)

    Available for both Linux and Windows

    For Windows, you need VMware or cygwin

    For Linux, install all-in-one package requires only

    four commands tar xzvf ns-allinone-2.33.tar.gz

    cd ns-allinone-2.33

    ./install

    source setup.csh (Note this script was written by our systemadmin Gilbert, you may need to copy it over and customize it a little bit)

    You are ready to go

  • 8/12/2019 NS 2tutorial (1)

    12/20

    12

    Writing An OTcl Script

    Use NS-2, take a look at ns-simple.tcl

  • 8/12/2019 NS 2tutorial (1)

    13/20

    13

    Writing An OTcl Script (II)

    Add to NS-2 Write a new network layer component

    Write a new transport layer protocol

    Write a new application Steps

    Writing new components in .cc and .h (often free

    implementations are available)

    Add to existing header files in package

    Add to Makefile and re-compile

  • 8/12/2019 NS 2tutorial (1)

    14/20

    14

    Add To NS-2

    Step-by-step instructions for a few examples

    available in NS by Example from WPI

    On Transport, Application, and Network Layers

    respectively

    Web site

    http://nile.wpi.edu/NS/

  • 8/12/2019 NS 2tutorial (1)

    15/20

    15

    Run The Simulation

    Plug in the trace file names

  • 8/12/2019 NS 2tutorial (1)

    16/20

    16

    Run the Simulation to Collect Traces

    Entire packet level event trace dump to file

  • 8/12/2019 NS 2tutorial (1)

    17/20

    17

    Post-Process the Trace Generated

    Through scripting languages such as Perl,

    awk, (ba)sh (shell scripts)

    Or spread sheet such as Excel

    See example ns-simple-trace.tcl to generate

    trace out.tr

    Perl and awk combined to produce jitter.txt

  • 8/12/2019 NS 2tutorial (1)

    18/20

    18

    Plot the Graphs

    Gnuplot, very handy tool to give nice graphs

    See example gp, a Gnuplot script that I

    wrote

    The generated .ps file can be easily added to

    LaTeX for paper / report writing

  • 8/12/2019 NS 2tutorial (1)

    19/20

    19

    Development

    Editor (you need a comfortable way to edit

    files under Linux)

    Vi, Emacs, pico, what else do people use?

    Make

    A very simple utility to automate compilation

  • 8/12/2019 NS 2tutorial (1)

    20/20

    20

    Your Course Project

    Some tools to play with

    OTcl, editor, make, perl, gnuplot

    nam to avoid (an animator not essential to

    simulation)

    Need to add to NS-2?

    Search for existing implementations on the net

    first Have fun!