Overview of VANET Project(2011) on NS2 Perspective Part 1 of 2 Jae-Myeong Lee Human-centric Mobile Computing Lab.

Slides:



Advertisements
Similar presentations
Introduction to Programming Java Lab 1: My First Program 11 January JavaLab1.ppt Ping Brennan
Advertisements

Wireless Communication : LAB 3
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
1 ns-2 Tutorial, part 2 Dave Anderson, Xiaowei Yang (Modified from Polly Huang’s slides)
An Introduction to NS-2 * Gayatri Swamynathan CS 276 TA *some slides are from a presentation by Haobo Yu & Nader Salehi, USC/ISI.
LAB 3 NS2 Preliminaries. Contents TCL/OTCl Fundamentals Creating Network Setting Connections Generating Traffic Inserting Errors Configuring for multicast.
5-Jul-141 S.Pushpalatha, Associate Professor, PSNACET.
Introduction to NS. Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Principles of Object-Oriented Software Development The language Java.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
C++ fundamentals.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
CSC3170 Introduction to Database Systems
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Javascript and the Web Whys and Hows of Javascript.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Introduction to Python
Introduction to NS2 -Network Simulator- -Prepared by Changyong Jung.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
Programming With C.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 6 l Array Basics l Arrays and Methods l Programming with Arrays.
An Introduction to Python Blake Brogdon. What is Python?  Python is an interpreted, interactive, object-oriented programming language. (from python.org)
Internet Computing KUT Youn-Hee Han
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Introduction to Generics
Ns-2 Tutorial (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Jianping Wang, 2002 cs757 1.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Lab 2, Network Simulator ns2 Shiv Kalyanaraman Yong Xia (TA) Satish Raghunath Sept 4,
TCL TK. Tcl/Tk C functions can become Tcl commands that are invoked interactively Tk = scriptable, portable user interface –Windows, X (Unix), MacOS,
Java Class Structure. Class Structure package declaration import statements class declaration class (static) variable declarations* instance variable.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CSCI 51 Introduction to Programming Dr. Joshua Stough February 24, 2009.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
1 NS-2: the network simulator 15 September 2005 Network Lab., SNU Changjee Joo.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Perl & TCL Vijay Subramanian, Modified from : perl_basics_06.ppt.
C# Part 1 Intro to C#. Background Designed to be simple, modern, general- purpose, OO, programming language Strong type checking, array bounds checking,
Jae Chung and Mark Claypool
(Modified from Polly Huang’s and last year’s original)
The need for Programming Languages
Objects as a programming concept
Introduction to NS Srinath Perur.
Programming Language Concepts (CIS 635)
CSE 303 Concepts and Tools for Software Development
TCL/TK Tool Command Language/Tool Kit.
Exception Handling Chapter 9.
CSC 113 Tutorial QUIZ I.
Java Programming Language
An Introduction to Java – Part I, language basics
Classes & Objects: Examples
Object Oriented Programming
A Mathematical Programming Language
Govt. Polytechnic,Dhangar
Network Performance modelling and simulation
LCC 6310 Computation as an Expressive Medium
Presentation transcript:

Overview of VANET Project(2011) on NS2 Perspective Part 1 of 2 Jae-Myeong Lee Human-centric Mobile Computing Lab.

Today’s Agenda What is NS2? Introduction to Tcl Basic syntax and concepts of Tcl, oTcl, Tclcl NS2 Structure overview Our project’s structure

What is NS2? NS2 is abbreviation of Network Simulator 2. Open-sourced and free to use on research and education – Free in non-commercial use Simulates network communication Unix-based simulator – Simulation in MS-Windows, it can be run in Cygwin environment. No support for external plugin

What is NS2? (Cont.) Written in C++, compiled with g++ compiler Uses oTcl as main script language. – oTcl is object-oriented extension of Tcl script language. – Tcl, or Tool Command Language is lightweight script language. We used NS2 to simulate VANET network communication.

Introduction to Tcl NS2 uses Tcl as a main language. – You have to understand Tcl first, to know NS2. Tcl is pretty simple language, we can learn it in a moment. We are going to figure out basis of Tcl, oTcl, Tclcl.

Basic Tcl Comment: can comment with ‘#’ symbol – On a blank line: ‘#’ # blank line comment – After a command: ‘;#’ * ; is a command token. $ns run ;# run ns simulator Using Tcl Interpreter in user-interactive mode: – Can input command only. not values. – If there is a return value from command, it will be printed to screen. – $ tcl % 1  Error % puts “Hello world!”  OK Using Tcl Interpreter in script(batch) mode: $ tcl filename.tcl Using variables with set command: – set x 10;# set x’s value to 10 – set x;# get x’s value

Basic Tcl (Cont.) Passing parameter as return value of another command – set y [set x];# x’s value is copied to variable y. A variable can be accessed by $(variable) notation. – In expression, $a means a’s value. – set cmd “puts”;# set cmd’s value as string “puts” – $cmd “hello”;# same to puts “hello”. – set y [expr $x];# set y’s value as x’s value. – puts “$x is ten”;# refer variable’s value in a string. “expr” command: evaluate the expression passed as argument – expr 1+1;# 2 is printed (in interactive mode)

Basic Tcl (Cont.) User-defined function – proc { } { …;# commands return ;# optional } – Example: proc pow {x n} { ;# power function with recursion if {$n == 1} { return $x } set part [pow $x [expr $n-1]] ;# recursive call return [expr $x*$part] } set y [pow 2 16];# now, y is puts $y

Basic Tcl (Cont.) ETC – Control flows if {condition} { action } else { action } while {condition} { action } for {initialization} {condition} {step} { action } Example of for statement: for {set i 0} {$i < 10} {incr i} { puts “$\i == $i” } ;# incr command increases a variable one. – Using file I/O set file [open “input.txt” r+] ;# open file handle (r+ means read/write/no creation) set line [gets $file] ;# read a line puts $line ;# print to screen puts –nonewline $file “hello!”;# if give a file handle to puts(), it will work in files. close $file ;# close file handle

Basic oTcl oTcl extends object-oriented features in existing Tcl syntax. – Create a class Class Person ;# just simple – Add new method to a class Person instproc init {age} {;# ”init” is constructor method $self instvar age_;# ready a public member variable to class ;# $self is same to this in C++ or Java. set age_ $age;# initialize member variable’s value } – Create a subclass: There are two method to do this. # Using Naming Convention (Parent/Child is a subclass of class Parent) Class Person/Child # Using –superclass directive Class Child –superclass Person – Creating a new instance object of a class (use new command) set myperson [new Person];# now, $myperson is instance of class Person

Basic oTcl (Cont.) – Setting and getting of member variable (extension of set command) $myperson set age_ 10 ;# set $myperson’s age_ to 10. puts [$myperson set age_] ;# get $myperson’s age_ and print it – Call a method $myperson greet;# just simple. ;# $instance_variable – Call superclass’ constructor function when initialize Example in our project: Agent/Traff instproc init args {;# notice that we didn’t put {} brackets around args ;# it means, $args is an array, which has arguments. $self next $args;# next method passes the argument to superclass’ constructor # (… do something …) }

Basic Tclcl Tclcl was made for cooperation of oTcl and C++. All oTcl objects are expressed in TclObject C++ class. TclObject’s methods – void TclObject::bind(const char *var, datatype *value); Bind a C++ variable as member variable, into oTcl language space. var is a member variable name, to use in oTcl. – int TclObject::invoke(const char *method, …); Invoke a method of oTcl object. – static TclObject *TclObject::New(const char *className); Create a new instance of specified class. – static TclObject *TclObject::lookup(const char *name); Lookup existing instance object, from oTcl space. Example: TclObject *ns = TclObject::lookup(“simulator_”); ns->invoke(“run”); // call $simulator_’s run (same to, $simulator_ run in oTcl)

NS2 Structure Overview NS2 is written in C++, which interacts with oTcl through Tclcl. Class Hierarchy in C++ TclObject NsObject Connector Queue Delay Agent Trace Classifier AddrClassifier McastClassifier Other Objects Tclcl Library NS2 Library NS2 Subclasses Other Objects in oTcl

NS2 Structure Overview (Cont.) Order of simulation – oTcl Interpreter interprets a Tcl script. $ ns myscript.tcl or $ ns (in user-interactive mode) – Tcl script will set up events and simulation parameters with Tcl codes. – Tcl script will calls Simulator::run(). Example code: set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” ;# put a command into event queue $ns at 1.5 “exit” $ns run – Simulator::run() calls Scheduler::run() internally. Simulator instproc run {} { $self check-smac # … return [$scheduler_ run] } ;# on ns-2.34/tcl/lib/ns-lib.tcl

NS2 Structure Overview (Cont.) Source code directory path – Main NS2 classes are in ns-directory/common/*.cc ns-directory/common/*.h – Main NS2 Tcl scripts are in ns-directory/tcl/lib/*.tcl – Simulator and scheduler is defined in Simulator: ns-directory/common/simulator.cc ns-directory/common/simulator.h Scheduler: ns-directory/common/scheduler.cc ns-directory/common/scheduler.h ns-directory/tcl/lib/ns-scheduler.tcl

Our project’s structure No use existing event queue (scheduler). – The reason why: Event is not fixed and unknown in every simulation, because event is just depending on Quadstone Paramics. – We made new scheduler Object in oTcl space named TraffCalendarScheduler, which is inherited from CalendarScheduler – And also we made new Simulator object, named SimTraff. – TraffCalendarScheduler::run() waits for event from Q-Paramics. We will discuss it next week, in more details.

Thank you! Any questions?