48
THE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh Cooperative sub-group BBCR group Feb 2012

The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

  • Upload
    habao

  • View
    219

  • Download
    2

Embed Size (px)

Citation preview

Page 1: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

THE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh Cooperative sub-group BBCR group Feb 2012

Page 2: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

References • http://nsnam.isi.edu/nsnam/index.php/User_Information

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

• http://www.isi.edu/nsnam/ns/tutorial/index.html • Introduction to NS2(PPT), Prepared by Changyong Jung

2

Page 3: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Outline • Introduction on Network Simulator • Installation • Architecture of NS-2 • OTcl • Simulation Examples

3

Page 4: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Introduction • Network Simulator (NS)

• Discrete event network simulator • Implements

• Transport layer protocols such as TCP ( reno, tahoe, vegas, sack) and UPD

• Router queue management mechanism such as Drop Tail, RED • Routing algorithms such as Dijkstra and Ad-hoc Routing (DSDV, DSR,

AODV, TORA) • MAC layer protocols (802.11, 802.3, TDMA) • Sensor Network (diffusion, gaf), Satellite protocols, and many others • Traffic source behavior such as FTP, Telnet, Web, CBR and VBR

• NS versions: • NS-1, NS-2, NS-3

4

Page 5: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Introduction • NS-1:

• LNBL Simulator tool • Developed by the network research group at the Lawrence

Berkeley National Laboratory (1989). • Derived from REAL simulator • Simulation description language: TCL

5

Page 6: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Introduction • NS-2:

• Object oriented (OTcl instead of TCL) • Built in C++ and provides a simulation interface through OTcl • Developed by UC Berkeley

• Difficult for the first time user • Few user friendly manuals • Needs scripting language, queuing theory and modeling techniques

knowledge • Complaint about inconsistent results • BUGs!!!

6

Page 7: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Introduction • NS-3:

• Maintaining backward compatibility with ns-2? (2005) • YANS (Yet Another Network Simulator) -> NS-3 base • NS-3.1 (2008) , NS-3.11(2011) • Built in C++ and Phyton • Make it simpler • No support for some protocols which were supported in ns-2

7

Page 8: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Installation • http://nsnam.isi.edu/nsnam/index.php/Downloading_and_install

ing_ns-2

• Installing on Unix-based systems

• Installing on Windows using Cygwin

• Installing on Mac

• The following “How to install” slides are brought from Introduction to NS2(PPT), Prepared by Changyong Jung

8

Page 9: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install -Window XP- • Go to Website: http://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Nam_Under_Windows_9x/2000/XP_Using_Cygwin

• Read “Requirements and Installation Tips” Carefully. • Download cygwin.exe from http://www.cygwin.com/

• Click the “cygwin.exe”

9

Page 10: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Cygwin Installation

10

Page 11: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install

11

Page 12: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Select browse for “cygwin” file( I selected as “default”)

12

Page 13: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Local package directory (I recommend c:\cygwin).

13

Page 14: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Select to Install all ( I recommend it) • You can select “install”, “default”, “uninstall”, “install”, and “reinstall” behind the first

line “all”. If you select “install”, then all sub items will be automatically selected. Otherwise you may lose some items.

14

Page 15: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Select download site

15

Page 16: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Installing

16

Page 17: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Finishing Installing

17

Page 18: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • NS2 Installation • Download ns-allinone-2.29.2.tar.gz from Website and

Save it to the c:/cygwin /usr/local • Unpack it: tar xvfz ns-allinone-2.29.2.tar.gz • Click on desktop icon “cygwin”

18

Page 19: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install

19

Page 20: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Type “cd ..” to go to the upper folder(“cd” must be low case. And

there is one space between “d” and “.”) • Type “cd ..” again.

20

Page 21: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • “cd usr”, go to folder “usr” • “cd local”, go to folder “local”

21

Page 22: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Find “install.exe”

22

Page 23: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Start to run the installation “./install”

23

Page 24: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Installing

24

Page 25: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Installing

25

Page 26: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Configure system variables and library paths • After finishing installing, following window appears

26

Page 27: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Configure system variables • Go to “My computer” and click “view system information”

27

Page 28: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Go to “advanced” Tab and Click “Environmental variables”

28

Page 29: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install

29

Page 30: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Highlight “path” which is “system variable” box and press the “Edit”

button.

30

Page 31: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install

31

Page 32: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Add the following path separated with “;” make sure to

not change the existing path. /usr/local/ns-allinone-2.29.2/bin /usr/local/ns-allinone-2.29.2/tcl8.4.11/unix /usr/local/ns-allinone-2.29.2/tk8.4.11/unix

32

Page 33: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install • Go to cygwin and type the following content Export LD_LIBRARY_PATH=/usr/local/ns-allinone-

2.29/otcl-1.11 Export LD_LIBRARY_PATH=/usr/local/ns-allinone-2.29/lib Export TCL_LIBRARY_PATH=/usr/local/ns-allinone-

2.29/tcl8.4.11/library

33

Page 34: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

How to Install

34

Page 35: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

NS-2 Architecture

NS Simulator Library

Network Component

Objects Network Setup

Modules Event

Scheduler Objects

• The event scheduler and the basic network component objects in the data path are written and compiled using C++.

• To use NS, you program in OTcl script language

35

Page 36: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Plumbing Network Setup: • Creating possible data paths among network objects. • The power of NS comes from plumbing.

Event is a packet ID that is unique for a packet • scheduled time • the pointer to an object that handles the event. An event scheduler • keeps track of simulation time • fires all the events in the event queue

Event Scheduling

36

Page 37: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

NS-2 Architecture OTcl and C++

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

37

Page 38: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

OTcl

Executing a test file: ns ex-tcl.tcl

Results:

38

Page 39: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Event Scheduler

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

39

1. Real-time scheduler 2. Non-real-time scheduler

• List • Heap • Calendar

. . . set ns [new Simulator] $ns use-scheduler Heap $ns at 300.5 "complete_sim" . . . proc complete_sim {} { . . . }

Page 40: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Network Component N

ode:

• Unicast or Multicast

• Routing Protocol Link

: • Tracing • Queue monitor

Unicast - $ns rtproto type - type: Static, Session, DV, cost, multi-path Multicast - $ns multicast (right after set $ns [new Scheduler]) - $ns mrtproto type - type: CtrMcast, DM, ST, BST

create-trace {type file src dst}

40

Page 41: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Partial OTcl class hierarchy

41

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

Page 42: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Other important tasks

Post simulation: Trace analysis Queue Monitor Troubleshooting: Installation problems Simulation Problems

42

Page 43: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

NS Results

Network Animator (NAM) • A graphical simulation display tool • Developed as a part of VINT project • Has a nice graphical user interface • Can graphically present information

NS Simulation

Text-based results NAM

43

Page 44: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Simulation Example

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

44

Page 45: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

45

Page 46: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Where to find…

/ns-2/tcl/lib ns-lib.tcl: The simulator class and most of its member function definitions ns-default.tcl: The default values for configurable parameters ns-packet.tcl: The packet header format initialization implementation other OTcl files: implementation of compound network objects or the front end (control part) of network objects

46

Page 47: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Summary

Network Simulator (NS): is an object-oriented discrete-event network simulator. Implements different network protocols. is written in C++ and OTcl. (NS-2) It was the first step to be familiar with NS. Keep going…

47

Page 48: The first Step to become familiar with network …bbcr.uwaterloo.ca/~m6ismail/CoNET/Slides/Intro-NS.pdfTHE FIRST STEP TO BECOME FAMILIAR WITH NETWORK SIMULATOR (NS) Neda Mohammadizadeh

Thank You

48