Simulations: ns2 simulator part I a

Similar documents
Part 3: Network Simulator 2

Network Simulator 2. Telematica I (CdL Ing. INF) Ing. Giuseppe Piro.

DMN1 : COMMUNICATION PROTOCOL SIMULATION. Faculty of Engineering Multimedia University

An Introduction to NS-2

The Network Simulator Fundamentals. Downloads and further info at:

Mohammad Hossein Manshaei 1393

ns-2 Tutorial Exercise (1)

Network Simulator 2: Introduction

NS-2 Tutorial. Kumar Viswanath CMPE 252a.

Tutorial Schedule. Introduction Ns fundamentals Ns programming internal Extending ns-2 Simulator. Sep. 25,

The Transport Control Protocol (TCP)

Introduction. Ns Tutorial Ns Goals. SAMAN and CONSER Projects. Ns Status. Ns functionalities

Project Network Simulation CSE 5346/4346

Modeling of data networks by example: ns-2 (I)

EE 122: Computer Networks Network Simulator ns2

S Ns2 simulation exercise

S Ns2 simulation exercise

PART A SIMULATION EXERCISES

John Heidemann, USC/ISI and Polly Huang, ETH-Zurich 14 March 2002

Simulation with NS-2 and CPN tools. Ying-Dar Lin Department of Computer Science, National Chiao Tung University

Part 6. Confidence Interval

ns-2 Tutorial Contents: Today Objectives of this week What is ns-2? Working with ns-2 Tutorial exercise ns-2 internals Extending ns-2

USE OF THE NETWORK SIMULATOR NS-2 TOOL IN LECTURES

Comparison of Different Types of Sources of Traffic Using SFQ Scheduling Discipline

S Quality of Service in Internet. Introduction to the Exercises Timo Viipuri

ns-2 Tutorial (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Jianping Wang, 2002 cs757 1

Simple Data Link Protocols

CSE 573S Protocols for Computer Networks (Spring 2005 Final Project)

FACULTY OF ENGINEERING

Network Simulator Version 2 for VANET

S Ns2 simulation exercise

1 What is network simulation and how can it be useful?

REVA INSTITUTE OF TECHNOLOGY AND MANAGEMENT. Kattigenahalli, Jala Hobli, Yelahanka, Bangalore

LAN-WAN-LAN end-to-end Network Simulation with NS2

Flow Control Packet Marking Scheme: to identify the sources of Distributed Denial of Service Attacks

LAMPIRAN. set ns [new Simulator]

Performance Evaluation. of Input and Virtual Output Queuing on. Self-Similar Traffic

QoS in Network Simulator 2

Brief Overview and Background

Part 3. Result Analysis

CDA6530: Performance Models of Computers and Networks. Chapter 10: Introduction to Network Simulator (NS2)

NS-2: A Free Open Source Network Simulator

International Journal of Intellectual Advancements and Research in Engineering Computations. Efficient routing protocol for MANET using.

Modeling of data networks by example: NS-2 (II)

Simulation in Cyber Security

Executive Overview. D1.3.2-VanetMobiSim/Ns-2: A VANET simulator for CARLINK

Experiences with the ns-2 Network Simulator - Explicitly Setting Seeds Considered Harmful

Network Simulator 2 (NS2)

Keywords- NS2, OPNET, NETSIM, JSIM

Performance Analysis of TCP Variants

Performance of high-speed TCP Protocols over NS-2 TCP Linux

The simulation and emulation verification that was based on NS-2

NSIS for NS-2. N4 TCP connection. Figure 1: TCP connection reuse

Comparison of Different Network Simulation Tools. University of Bremen Communication Networks

INTEGRATED DEVELOPMENT ENVIRONMENT FOR NS-2

COMPARISON OF DIFFERENT VERSIONS OF TCP IN

Multi Service Link Layers: An Introduction

Simulation and Analysis of Impact of Buffering of Voice Calls in Integrated Voice and Data Communication System

Performance Analysis of Wired, Wireless and Optical Network using NS2

Hybrid Control and Switched Systems. Lecture #17 Hybrid Systems Modeling of Communication Networks

NS internals. Velibor Markovski Communication Networks Laboratory School of Engineering Science Simon Fraser University

CHAPTER 3: LITERATURE REVIEW 3.1 NEED FOR SIMULATION ENVIRONMENT IN WSN

[1] Chowdhury, A. K., Ibrahim, M., Shanmugam, V., Singh, A. K. (2013). [2] Chowdhury, A. K., Raj, N., Singh, A. K., Area efficient MAX operator for

4. Simulation Model. this section, the simulator and the models used for simulation are discussed.

International Journal of Scientific Research and Modern Education (IJSRME) ISSN (Online): ( Volume I, Issue I,

UNIVERSITY OF NAIROBI STABILITY OF TCP/IP PROTOCOLS

Part 5. Wireless Network

Technical University of Crete Electronic & Computer Engineering Department TCP Performance over UMTS Network

CS 5520/ECE 5590NA: Network Architecture I Spring Lecture 13: UDP and TCP

Evaluation Strategies. Nick Feamster CS 7260 February 26, 2007

Chapter 5. Simulation Environment. Chapter 5 Simulation Environment... V Network Simulator... V NS-2 Installation...

Congestion Control Without a Startup Phase

Implementation of Wired and Wireless Networks, Analysis Simulation and Result Comparison Using Ns2

Delayed ACK Approach for TCP Performance Improvement for Ad Hoc Networks Using Chain Topology

ANALYSIS OF VARIOUS TCP SUB-VERSIONS AND MECHANISM FOR CONGESTION AVOIDENCE

Assignment 3 Solutions 2/10/2012

Investigations on TCP Behavior during Handoff

Routing Protocols Simulation of Wireless Self-organized Network Based. on NS-2. Qian CAI

Wireless Networks - Preliminaries

Appendix B. Standards-Track TCP Evaluation

Emulab Tutorial. Getting Started

Network Simulator 2: Introduction

Appendix A. Methodology

Introduction to Network Simulators

Different Layers Lecture 21

Traffic Behaviour of VoIP in a Simulated Access Network

Distributed File Systems Part II. Distributed File System Implementation

Analysis of Reno: A TCP Variant

ANALYSIS OF SMART DEVICE GAME PROTOCOL

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

TKN. Technische Universität Berlin. Circuit Switching Module for ns-2. Filip Idzikowski. Berlin, March 2009

TCP Congestion Control

SIMULATION FRAMEWORK MODELING

Performance Evaluation of TCP Westwood. Summary

Using the NCTUns 2.0 Network Simulator/Emulator to Facilitate Network Researches

TCP Congestion Control in Wired and Wireless networks

Congestion Control In The Internet Part 2: How it is implemented in TCP. JY Le Boudec 2014

Congestion Control Techniques In Transport Layer For Wired Connections

PERFORMANCE ANALYSIS OF AF IN CONSIDERING LINK UTILISATION BY SIMULATION WITH DROP-TAIL

Fundamental Questions to Answer About Computer Networking, Jan 2009 Prof. Ying-Dar Lin,

Transcription:

Simulations: ns2 simulator part I a Lecturer: Dmitri A. Moltchanov E-mail: moltchan@cs.tut.fi http://www.cs.tut.fi/ moltchan/modsim/ a Based on: Eitan Altman and Tania Jimenez NS Simulator for Beginners,... http://www-sop.inria.fr/maestro/personnel/eitan.altman/ns.htm

Overview Lecture: Ns2 simulator 2

1. Overview Characteristics: discrete-event; network simulator; basically TCP/IP networks; wired and wireless components included. Intended usage: research; development; education. Developing: research institutes and universities; freely distributed and open source. Lecture: Ns2 simulator 3

1.1. History of developing Briefly: 1989: REAL simulator by UCB; 1990: ns1: LBL; 1995: ns2 DARPA VINT project (Virtual InterNet Testbed) currently: ns2 supported by DARPA projects. Current status: ns2 runs on: almost all UNIX and Linux and Win 95/98/2000/XP. current stable version: 2.29 released in Oct. 22, 1995 roughly 1 release in 6 months + daily snapshots. web page: http://www.isi.edu/nsnam/ns/ > 200000 line of codes; > 1000 institutions; > 10000 users; > 400 pages of short manual. Lecture: Ns2 simulator 4

1.2. Components ns2 distribution consists of: ns2 itself; nam: Network AniMator visualizing ns2 output; GUI for simple scenarios. Mandatory support tools: tcl/tk: script language otcl: object-oriented tcl; TclCL: tcl library. Pre-processing tools: traffic and topology generators. Post-processing tools: trace analysis: awk, sed, perl, tcl. very simple and not recommended. Lecture: Ns2 simulator 5

1.3. Installation Differs for: Unix/Linux; Windows. Two types are available: Via compilation; get all-in-one package ; get pieces and then compile. Obtaining binaries. easiest way to run on Win platform. Hints and notes: to compile on Windows you need Cygwin (Unix emulation); Size of all-in-one is around 320Mb (v2.29). Lecture: Ns2 simulator 6

Building from pieces (Unix/Linux): get Otcl, TclCL and ns2; unpack in some temp folder at the same level; cd into the OTcl directory; run./configure; run make; cd into the TclCL directory; run./configure; run make; cd into the ns directory; run./configure; run make; Verify that it built correctly and runs by running./validate. Note: ns2 all-in-one contains install script (just run it). Lecture: Ns2 simulator 7

1.4. Support Documentation: mailing list: ns-users@isi.edu to get in send message to the address with subscribe ns-users in the body; to browse archive go to http://www.isi.edu/nsnam/ns/. ns manual: available at http://www.isi.edu/nsnam/ns/; is only a short reference guide. tutorials: a number is available on http://www.isi.edu/nsnam/ns/; faq: http://www.isi.edu/nsnam/ns/ns-faq.html; de-facto tutorial: http://www.isi.edu/nsnam/ns/tutorial/index.html; installation and bug fixes: http://www.isi.edu/nsnam/ns/ns-problems.html; E. Altman, T. Jimenez: http://www-sop.inria.fr/maestro/personnel/eitan.altman/ns.htm. Lecture: Ns2 simulator 8

2. Ns 2 architecture Object-oriented structure: advantage: code reuse; shortcomings: performance. Software structure: uses two languages to separate control and processing: C++: packet processing; Otcl: control. Packet processing: C++ makes it fast and detailed; C++ makes it scalable. Control: Otcl makes it easy to create scenarios; Otcl makes it easy to understand third party scripts. Lecture: Ns2 simulator 9

2.1. Scalability and extensibility Scalability: per-packet processing must be fast; separating control and packet handling. Extensibility: must be easy to add new objects; object trees to understand hierarchy: in C++; in Otcl. C++ and Otcl trees are split: if not needed nothing have to be changed at a certain level; helps a lot! Lecture: Ns2 simulator 10

Otcl and C++ share class hierarchy; TclCL provides sharing of variables and functions between C++ and Otcl. Lecture: Ns2 simulator 11

Otcl class hierarchy: http://www-sop.inria.fr/planete/software/ns-doc/ns-current/; C++ class hierarchy: http://www.isi.edu/nsnam/nsdoc-classes/index.html. Lecture: Ns2 simulator 12

2.2. Simple script Lecture: Ns2 simulator 13

2.3. Tcl basics Tcl language: semantics is similar to perl; one can check tutorial at: http://www.msen.com/%7eclif/tcltutor.html; real programming language to create network topology; tcl is used by Otcl to include advanced objects. Tcl contains: lists, arrays, associative arrays etc.; procedures and functions; flow controls: if, while, for, etc. Lecture: Ns2 simulator 14

Lecture: Ns2 simulator 15

2.4. Otcl basics codes can be reused (for example, different version of TCP). Lecture: Ns2 simulator 16

2.5. Viewing source code Where to find: C++: /whereyouinstalled/ns-(ver)/ where (ver) is your version of ns2 (e.g. 2.1b9a). Otcl: /whereyouinstalled/ns-(ver)/tcl/lib/ ns-default.tcl: default values for ns2 objects; other Otcl definitions. /whereyouinstalled/ns-(ver)/tcl/ specialized objects in subdirs. Lecture: Ns2 simulator 17

3. Simulations Basic steps: Create the simulation environment; event list, scheduler, etc.; Create the network: nodes and links between them. Create connections: TCP, UDP (in some sense). Create applications: CBR flow, FTP, WWW traffic. Trace network elements: trace queue, trace flow. Lecture: Ns2 simulator 18

3.1. Creating environment The following are the common commands: Create event scheduler: set ns [new Simulator]; Schedule events: $ns at <time> <event>; Start scheduler: $ns run. Stop and close everything: $ns at $x exit. where $x is some instant of time. Note: before closing you must take additional actions: flush all traces to files; close all files. Lecture: Ns2 simulator 19

3.2. Generating RVs Create new generator: set rng [new RNG]; $rng seed 0. RNs from other distributions: using class RNG: uniform: $rng uniform a b. using class RandomVariable: distributions: uniform, exponential, hyperexponential, Pareto; Lecture: Ns2 simulator 20

3.3. Creating the network Nodes: set n0 [$ns node]. Links and queuing: $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue type>; <queue type>: DropTail, RED, CBQ, FQ, SFQ, DRR; example: link with 10 Mbps, 10 ms delay, buffer size 100, RED buffer control Lecture: Ns2 simulator 21

3.4. Creating connections Creating UDP flow In one command: $ns create-connection <src type> <src node> <dst type> <dst node> <packet class>; example: $ns create-connection UDP $n0 Null $n1 1. Other sources: TCP (we will consider); RTP source, RTCP source. TCP for wireless links. Lecture: Ns2 simulator 22

Creating TCP flow In one command: $ns create-connection <src type> <src node> <dst type> <dst node> <packet class>; example: $ns create-connection TCP $n0 TCPSink $n1 1. Some included TCP versions: TCP: Tahoe TCP (slow start and AIMD); TCP/Reno: Reno TCP (... + fast retransmit/fast recovery); TCP/NewReno: TCP Reno with improved fast retransmit; TCP/Sack: TCP SACK (Selective ACK). Lecture: Ns2 simulator 23

3.5. Creating traffic on top of UDP CBR: Constant bit rate; set src [new Application/Traffic/CBR]. Exponential or Pareto ON/OFF: on/off times are exponentially distributed; set src [new Application/Traffic/Exponential]; set src [new Application/Traffic/Pareto]. Connecting to transport: $udp defined earlier; $src attach-agent $udp. Lecture: Ns2 simulator 24

ns2 includes support for traffic traces: What <file> should look like: each record consist of two 32 bit field; inter-packet time (msec) and packet size (in bytes). For exmaple: there is converter for MPEG frame size file to ns2. Lecture: Ns2 simulator 25

3.6. Creating traffic on top of TCP FTP: set ftp [new Application/FTP]; attaching to TCP: $ftp attach-agent $tcp. Telnet: set telnet [new Application/Telnet]; attaching to TCP: $telnet attach-agent $tcp. Lecture: Ns2 simulator 26

3.7. Starting/stopping traffic sources Starting and stopping times scheduled as events to the scheduler: $ns at <time> <event>. Starting: $ns at 1.0 $ftp start ; sends infinitely long; the same for CBR, telnet and on/off sources. Stopping: $ns at 5.0 $ftp stop ; the same for CBR, telnet and on/off sources. Sending for example 1000 packets: $ns at 7.0 $ftp produce 1000 ; works for FTP only. Lecture: Ns2 simulator 27

3.8. Tracing Trace packets on all links of the network: $ns trace-all [open test.out w]. Tracing on specific links: $ns trace-queue $n0 $n1. Lecture: Ns2 simulator 28

3.9. Monitoring Queue monitor: set qmon [$ns monitor-queue $n0 $n1]; for packet arrivals and drops: set parr [$qmon set parrivals ]; set drops [$qmon set pdrops ]. Flow monitor: enable flow monitoring: set fmon [$nssim makeflowmon Fid]; $nssim attach-fmon [$nssim link $n0 $n1] $fmon. count arrivals and drops for flow with id xx: set fclassifier [$fmon classifier]; set flow1 [$fclassifier lookup auto 00xx]; set parr [$flow1 set parrivals ]; set pdrops [$flow1 set pdrops ]. Lecture: Ns2 simulator 29

3.10. Generic methodology Lecture: Ns2 simulator 30

3.11. Other functionalities ns2 also provides: errors on the data-link layer; LAN and WLAN; Routing; Multicasting; Mobile IP; DiffServ. Lecture: Ns2 simulator 31

4. nam Nam (Network AniMator): packet-level animation; almost integrated with ns2. controls node link packet time Lecture: Ns2 simulator 32

Lecture: Ns2 simulator 33

5. Xgraph Allows to make graphs: frequently used with ns2; simple visualizer. Lecture: Ns2 simulator 34

6. Example Task: three-node star bottleneck topology. #Create a simulator object set ns [new Simulator] #Define different colors for data flows $ns color 1 Blue $ns color 2 Red #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a finish procedure proc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0 } Lecture: Ns2 simulator 35

#Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 10ms DropTail $ns duplex-link $n3 $n2 1Mb 10ms SFQ #Orientation of links $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right #Monitor the queue for the link between node 2 and node 3 $ns duplex-link-op $n2 $n3 queuepos 0.5 Lecture: Ns2 simulator 36

#Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetsize 500 $cbr0 set interval 0.005 $cbr0 attach-agent $udp0 #Create a UDP agent and attach it to node n1 set udp1 [new Agent/UDP] $ns attach-agent $n1 $udp1 Create a CBR traffic source and attach it to udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetsize 500 $cbr1 set interval 0.005 $cbr1 attach-agent $udp1 Lecture: Ns2 simulator 37

#Create a Null agent (a traffic sink) and attach it to node n3 set null0 [new Agent/Null] $ns attach-agent $n3 $null0 #Connect the traffic sources with the traffic sink $ns connect $udp0 $null0 $ns connect $udp1 $null0 #Schedule events for the CBR agents $ns at 0.5 $cbr0 start $ns at 1.0 $cbr1 start $ns at 4.0 $cbr1 stop $ns at 4.5 $cbr0 stop Call the finish procedure after 5 seconds of simulation time $ns at 5.0 finish Run the simulation $ns run Lecture: Ns2 simulator 38

Lecture: Ns2 simulator 39