Date post: | 16-Jul-2015 |
Category: |
Engineering |
Upload: | rahul-hada |
View: | 259 times |
Download: | 4 times |
1
Introduction to NS3
[Current release ns-3.21 ,Ongoing ns-3.22 tentative release Jan'15]
Rahul HadaMobile – 9001806370Email – [email protected]
Trainers
2
Workshop Outline
● Day-1– Introduction to NS3
– Prerequisites of software/packages
– Installation of NS3
– Configure NS3 with eclipse
– NS3 Architecture
– Reading code sample topology code
● Day-2– Mobility model
– Wifi Model
– Writing code [wireless network]
– Analysis of AODV routing protocol
– Attributes
– Tracing
– Gnuplot
3
RoadMap
● Session-1– First Half
● Introduction● Interface● Installation● Configuration● Folder Structure
– Second Half● Reading Code(Example-1)● Writing Code (Example-2)
4
NS-3 Overview
● Network Simulator version 3● Rewritten from scratch● An open source discrete event simulator
– Event model packet transmission , receipt , timers etc.
– Future events maintained in sorted Event List
– Processing events results in zero or more new events
● Developed for research and education.
5
NS-3 Overview
● It is started in year mid 2006– Still under heavy development
● Partially funded by US NSF “Community Resource Initiative”(CRI) grant
● Official funded by partners:– Univesity of Washington
● Tom Henderson , Craig Dowell
– INRIA,Sophia Antipolis● Mathiey Lacage
– Georgia Tech University(Atlanta)● Raj Bhattacharjea
6
NS-3 Basic
● Written in C++– Extensive use of Templates , Smart Pointer
Callback
– C++ namespace (ns3)
● Simulation programs are C++ executables● Python is used to bind public API's provided● NS3 is built as a library which may be linked
to a C++ main program defines the simulation topology and start the simulation.
7
Use of LibraryNS3 Library
<linked>
Building Topology & Start Simulation
MySim.ccMain Program
8
Key Features
● Trace output in ascii , or pcap format– Using existing pcap tools (Wireshark)
● Numerous trace points enabled via callbacks● Doxygen Documentation● Quarterly Releases● Attention to realism● Emulation mode
– Integration with real network/packets
– Real-time scheduling
9
Installation of NS3
● Best Platform is Linux – Step-1 Download – Step-2 Build Projects – Step-3 Testing– Step-4 Run Example
Easy to Install!!!!
10
Prerequisite package for Ubuntu● Mininal requirements:
– gcc,g++,python,python-dev● Debugging and GNU Scientific Library (GSL) support:
– gdb valgrind,gsl-bin,libgsl0-dev,libgsl0ldbl● Network Simulation Cradle (nsc):
– flex,bison● Reading pcap packet traces:
– tcpdump,wireshark● Database support for statistics framework:
– sqlite,sqlite3,libsqlite3-dev● Xml-based version of the config store:
– libxml2,libxml2-dev● A GTK-based configuration system:
– libgtk2.0-0, libgtk2.0-dev
11
Prerequisitesudo apt-get install gcc g++ python python-dev gdb valgrind gsl-bin libgsl0-dev libgsl0ldbl flex bison tcpdump sqlite sqlite3 libsqlite3-dev\ libxml2 libxml2-dev libgtk2.0-0 libgtk2.0-dev\ vtun lxc doxygen graphviz imagemagick texlive \texlive-latex-extra texlive-generic-extra \texlive-generic-recommended texinfo dia \texlive-extra-utils texi2html python-pygraphviz \python-kiwi python-pygoocanvas libgoocanvas-dev \mercurial bzr libboost-all-dev
12
NS3Development Environment
● IDE – Eclipse CDT
● To READ and MODIFY code easily
● Doxygen– Documentation System for C,C++ etc.
● To UNDERSTAND the NS3 platform
13
Download
● Using a Tarball– Download from following link
● http://www.nsnam.org/ns-3-21/
14
Building● Building with build.py
– build.py program is used
– Command [goto directory ns-allinone/]● ./build.py --enable-examples --enable-tests
– By default test and examples are not set to build
● Building with waf– ./waf program is used
– Configure your project to build optimized version● ./waf clean● ./waf -d optimized –enable-example –enable-tests configure● ./waf clean● ./waf -d debug –enable-example –enable-tests configure
15
Open Ternimal
16
Goto ns3-allinone folder
17
18
Testing NS3
● By running – ./test.py -c core
● Output– 92 of 92 tests passed(92 passed , 0 failed , 0 crahed, 0 valgrind errors)
19
Running a Script
● Running Hello World Program– ./waf –run hello-simulator
● Running Example– Copy script's in example to scratch folder and it
will automatically be build it we run Waf.● cp examples/tutorial/first.cc scratch/
– Now Run your first script● ./waf –run scratch/first
– Check Output
20
Run Hello Simulator
Run first example
21
Output of first example program
22
Configure NS3 with Eclipse
● Download Linux version of Eclipse IDE for C/C++ Developer
– Step-1 Install Eclipse and Configure Mercurial
– Step-2 Configure Waf Builder
– Step-3 Configure Debugger
– Step-4 Create new source code and , run it● Use Eclipse for creating new source code, but run ns-3
for running it
23
Install Eclipse
Using synaptic
Search eclipse
24
Configure Eclipse
● Open Eclipse– Goto Help -> Install new Software
– http://cbes.javaforge.com/update– Click add
– and , select mercurialeclipse
– Click Next ->Click Finish
● Create new C++ Project and with your preferred name● Choose ns3 path
– /home/tiger/ns-allinone-3.xx/ns-3.xx
● Right click on the project and go to Team-Share Project.Then click on Next and select local Mercurial.
25
Install Plug-in[Mercurial]
26
Create C++ Project
27
NS3 Path
28
NS3 Source
29
Configure Waf Builder
● Right click on project and click on Properties.Then click on C/C++ build.After that unchecked the boxes :– Use default build command
– Generate make file automatically
● Insert this path as build command – /home/xxxx/ns-allinone-3.xx/ns.xx/waf
● Insert this path as build directory – /home/xxxx/ns-allinone-3.xx/ns.xx/build
● Click in Behavior tab and remove the all option in front of the Build (Incremental build) checkbox and then write build
30
31
Configure Debugger
● Go to Run-> Debug Configuration and create a New configuration
● Click on Browse button under the project section and select your project
● Click on the Search Project button under the C/C++ Application section and type scratch-simulator
● Go to Environment Tab and click on New button to create a new variable.You will need these– LD_LIBRARY_PATH
– /home/xxxx/ns-allinone3.xx/ns-3.xx/build● Be sure the “Append Environment to native environment”
is selected
32
Configure Debugger
33
Install NetAnim
● Latest version: NetAnim 3.105● Prerequisites
– Mercurial● sudo apt-get install mercurial
– QT4 development packages ● sudo apt-get install qt4-dev-tools
● Download NetAnim– http://code.nsnam.org/netanim
● Building and Starting NetAnim– cd netanim
– make clean
– qmake NetAnim.pro
– make
34
Video Lectures
● Objective – Contribution of CODE and VIDEO in NS3● Link
– https://newdemy.com/course/ns3-tutorials/
● Spreading Knowledge● Free! Online Course on NS3● Instructors
– Rahul Hada
– Hitesh Choudhary
35
36
● Write a command to build ns3 ?● How many source file are in ns3?● How to run example/second.cc topology
script ?● Why we are using Eclipse and Doxygen ?
37
To be continued...