Diapositive 1

Download Report

Transcript Diapositive 1

ns-3 Introduction
Tom Henderson (University of Washington)
July 2014
Modified by Sara Mehar (university of burgundy)
April 2015
1
Agenda (ns-3 PART1)
• ns-3 project overview
– Why use ns-3?
– What is ns-3?
– Project organization
• Getting started with ns-3
– Installation
– Examples
• Future directions
2
Goal!!
•Learn about the ns-3 project and its goals
•Understand the software architecture,
conventions, and basic usage of ns-3
•Read and modify an example ns-3 script
•Learn how you might extend ns-3 to conduct your
own research
3
Why use ns-3?
• to study network performance or protocol
operation in a controllable or scalable
environment
• a tool aligned with the experimentation needs
of modern networking research
• a tool that elevates the technical rigor of
network simulation practice
• Full Oriented Object programming
• Much faster than other simulators
• Support group and mailing list
4
Why use ns-3?
• Project provides three annual software releases
• Users interact on mailing lists and using Bugzilla bug
tracker
• Code may be proposed for merge
– Code reviews occur on a Google site
• Maintainers (one for each module) fix or delegate bugs,
participate in reviews
• Project has been conducting annual workshop and
developer meeting around SIMUTools through 2013
– ns-3 Annual Meeting in Atlanta, May 2014
• Google Summer of Code (March-August) five of the past
six summers
5
ns-3: An Open Source Network
Simulator
• ns-3 is a discrete-event network simulator
targeted for research and educational use
model developers
Research
ns-3 software
NS-3 Consortium
ns-3 maintainers
Education
6
What is ns-3: Discrete event network
simulator
• Model of the evolution of a networked
system through discrete events in time
• Used for experimentation and education
7
ns-3 simulation basics
• Simulation time advances in discrete jumps from
event to event
• C++ functions schedule events to occur at
specific simulation times
• A simulation scheduler orders the event
execution
• Simulation::Run() gets it all started
• Simulation stops at specific time or when events
end
8
Software overview
• ns-3 is written in C++, with bindings available
for Python
– simulation programs are C++ executables or
Python programs
– ~350,000 lines of C++ (estimate based on cloc
source code analysis)
• ns-3 is a GNU GPLv2-licensed project
• ns-3 is mainly supported for Linux, OS X, and
FreeBSD
• ns-3 is not backwards-compatible with ns-2
9
Software overview
The following platforms are lightly supported:
Windows Visual Studio 2012
Windows Cygwin 1.7
Some aspects of ns-3 depend
specifically Linux) support, such as
or TapBridge (link) features,
components are not enabled on
versions cited above.
on Unix (or
the emulation
and those
the Windows
10
Software orientation
Key differences from other network
simulators:
1) Command-line, Unix orientation
2) Simulations and models written directly in
C++ and Python
11
ns timeline
1990
2000
2010
1988: REAL (Keshav)
regular
releases
1990s: ns-1
1996: ns-2
1997-2000: DARPA VINT
2001-04: DARPA SAMAN, NSF CONSER
2006: NSF CISE CRI Awards
Inputs: yans,
GTNetS, ns-2
ns-3 core development (2006-08)
June 2008: ns-3.1
June 2014: ns-3.20
12
Relationship to ns-2
• ns is a discrete-event network simulator for
Internet systems
– protocol design, multiple levels of abstraction
– written in multiple languages (C++/OTcl)
• ns has a companion network animator
called nam
– hence, has been called the nsnam project
ns-3 is a research-oriented, discrete event simulator
13
Relationship to ns-2
ns-3 is a new simulator, without backward compatibility
Similarities to ns-2:
• C++ software core
• GNU GPLv2 licensing
• ported ns-2 models: random variables, error models,
OLSR, Calendar Queue scheduler
Differences:
• Python scripting (or C++ programs) replaces OTcl
• most of the core rewritten
• new animators, configuration tools, etc. are in work
• ns-2 is no longer actively maintained/supported
14
Software organization
• Two levels of ns-3 software and libraries
1) Several supporting libraries, not system-installed, can be in parallel to ns-3
Netanim
pybindgen
2) ns-3 modules exist
within the ns-3 directory
Click routing
ns-3
module
module
module
module
module
module
15
ns-3 Software organization
16
ns-3 Software organization
17
ns-3 Software organization
18
utilities
Current models
devices
bridge
mesh
csma
spectrum
emu
applications
internet
(IPv4/v6)
energy
tap-bridge
protocols
visualizer
aodv
configstore
dsdv
flow-monitor
olsr
netanim
click
stats
mpi
point-topoint
lte
uan
virtualnet-device
mobility
nix-vectorrouting
network
topologyread
propagation
lr-wpan
wifi
wimax
core
openflow
BRITE
19
utilities
Current models
devices
bridge
csma
emu
point-topoint
Smart pointers
Dynamic types
Attributes
lte
mesh
Node class
NetDevice ABC
Address types
spectrum
(Ipv4, MAC, etc.)
Queues
Socket ABC
Ipv4 ABCs
Packet sockets
applications
internet
(IPv4/v6)
energy
Packets
Packet Tags
Packet Headers
mpifile writing
Pcap/ascii
tap-bridge
uan
Callbacks
Tracing
Logging
virtualRandom Variables
net-device
protocols
visualizer
aodv
configstore
dsdv
flow-monitor
olsr
netanim
click
stats
mobility
network
nix-vectorEvents
Scheduler
routing
Time arithmetic
topologyread
propagation
lr-wpan
wifi
wimax
core
openflow
BRITE
20
20
Example : AODV protocol
21
Example : AODV protocol
22
Python bindings
• ns-3 uses a program called PyBindGen to
generate Python bindings for all libraries
v
v
v
Intermediate
Python
program
C++
header
(py)gccxml
PyBindGen
v
C++
bindings
code
Python
module
C++ compiler
23
NetAnim
• "NetAnim" by George Riley and John Abraham
– see the 'ns-3share' channel on YouTube
pyviz
24
Emulation support
• Support moving between simulation and testbeds or live
systems
• A real-time scheduler, and support for two modes of
emulation
• Linux is only operating system supported
• Must run simulator in real time
– GlobalValue::Bind (“SimulatorImplementationType”,
StringValue (“ns-3::RealTimeSimulatorImpl”));
• Must enable checksum calculations across models
– GlobalValue::Bind (“ChecksumEnabled”, BooleanValue
(true));
• Must sometimes run as root
25
ns-3 emulation modes
ns-3 has been designed for integration into
testbed and virtual machine environments.
We have addressed this need by providing two
kinds of net devices:
The first kind, which we call an Emu NetDevice
allows ns-3 simulations to send data on a “real”
network.
The second kind, called a Tap NetDevice allows a
“real” host to participate in an ns-3 simulation as if
it were one of the simulated nodes.
26
ns-3 emulation modes
real machine
virtual
machine
ns-3
virtual
machine
ns-3
ns-3
real
machine
real
machine
Testbed
1) ns-3 interconnects real or virtual
machines
2) testbeds interconnect ns-3
stacks
Various hybrids of the above are possible
27
Agenda
• ns-3 project overview
– What is ns-3?
– Why use ns-3?
– Relationship to ns-2
• Getting started with ns-3
– Installation
– Examples
• Future directions
28
Getting started with ns-3
• Finding what you need
• Contributing to the project
29
Resources
Web site:
http://www.nsnam.org
Mailing lists:
https://groups.google.com/forum/#!forum/ns-3-users
http://mailman.isi.edu/mailman/listinfo/ns-developers
Wiki:
http://www.nsnam.org/wiki/
Tutorial:
http://www.nsnam.org/docs/tutorial/tutorial.html
IRC: #ns-3 at freenode.net
30
Suggested steps
• Work through the ns-3 tutorial
• Browse the source code and other project
documentation
– manual, model library, Doxygen, wiki
– ns-3 Consortium tutorials (March 2013)
• http://www.nsnam.org/consortium/activities/annual
-meeting-march-2013/
• Ask on ns-3-users mailing list if you still
have questions
– We try to answer most questions
31
APIs
• Most of the ns-3 API is documented with
Doxygen
– http://www.stack.nl/~dimitri/doxygen/
32
Reading existing code
• Much insight can be gained from reading ns-3
examples and tests, and running them
yourselves
• Many core features of ns-3 are only
demonstrated in the core test suite
(src/core/test)
• Stepping through code with a debugger is
informative
– callbacks and templates make it more challenging
than usual
33
FAQs
• Does ns-3 have a Windows version?
– Yes, for Visual Studio 2012
– http://www.nsnam.org/wiki/Ns-3_on_Visual_Studio_2012
• Does ns-3 support Eclipse or other IDEs?
– Instructions have been contributed by users
– http://www.nsnam.org/wiki/HOWTO_configure_Eclipse_with_ns-3
• Is ns-3 provided in Linux or OS X package
systems (e.g. Debian packages)?
– No
34
Contributing
• Any amount of help is appreciated!
– Reporting stale documentation to
[email protected]
– Contributing small patches
– Writing new documentation
– Reporting bugs
– Fixing bugs
– Reviewing code of others
– Contributing new code
– Becoming a maintainer
35
New project ideas
• Visit the wiki under "Project Ideas" tab
– http://www.nsnam.org/wiki/Project_Ideas
• Students, consider to apply for Google
Summer of Code 2015
– A 10-week summer job that mentors a student
project on ns-3
– Students apply in March 2015 timeframe
– http://www.nsnam.org/wiki/GSOC2014Projects
36
Skills requirement
To write a new protocols or modules
C++
Python (plus)
To do analysis and tests
Shell, awk, or Python, ….
Networking basic skills:
IPv4 address utilization, Lan, wifi, …
37
Getting started
This section is aimed at getting a user to a
working state starting with a machine that
may never have had ns-3 installed. It covers
Ubuntu platform, prerequisites, ways to obtain
ns-3, ways to build ns-3, and ways to verify
your build and run simple programs.
38
Installation (Prerequisites)
Link:
•https://www.nsnam.org/docs/tutorial/html/gettingstarted.html#overview
•https://www.nsnam.org/wiki/Installation
Example for Ubuntu 14.10 release; other
releases or other Debian-based systems may
slightly vary.
C++ (release):
apt-get install gcc g++
39
Installation: (Prerequisites)
Python (release):
apt-get install python python-dev
Note: qt4 development tools (Note: qt4, not qt5)
needed for NetAnim animator
apt-get install qt4-dev-tools
…..Other libraries may be required (depends on
the project)
40
Installation: ns-3 tarball
$ cd
$ mkdir workspace
$ cd workspace
$ wget http://www.nsnam.org/release/ns-allinone3.22.tar.bz2
$ tar xjf ns-allinone-3.22.tar.bz2
$ ls
bake
constants.py ns-3.22
README
build.py netanim-3.105 pybindgen-0.16.0.886
util.py
41
Installation: Building ns-3
$ ./build.py --enable-examples --enable-tests
Waf: Leaving directory `/path/to/workspace/ns-allinone3.22/ns-3.22/build'
'build' finished successfully (6m25.032s)
Modules built:
antenna
aodv
applications
bridge
buildings
config-store
core
csma
csma-layout
….
Modules not built (see ns-3 tutorial for explanation):
brite
click
openflow
Visualizer
42
Installation: Building ns-3 with WAF
Configure the optimized code build
$ ./waf clean
$ ./waf --build-profile=optimized --enableexamples --enable-tests configure
Or
Configure the Debug build
$ ./waf clean
$ ./waf --build-profile=debug --enable-examples -enable-tests configure
43
Installation: Build
The build system is now configured and you can
build the debug versions of the ns-3 programs by
simply typing
./waf
Testing ns-3
$ ./test.py -c core
92 of 92 tests passed (92 passed, 0 failed, 0
crashed, 0 valgrind errors)
44
NS-3 installation video
https://www.youtube.com/watch?v=Fbk89Nb7M0&feature=youtu.be
45
Example
Run:
./waf --run hello-simulator
#include "ns3/core-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("HelloSimulator");
int
main (int argc, char *argv[])
{
NS_LOG_UNCOND ("Hello Simulator");
}
46
Example
Run:
./waf --run hello-simulator
47
Path to examples
/workspaceNS/ns-allinone-3.22/ns3.22/examples/tutorial
48
Example2: First.cc
0
Client
1
Server
49
Example2: First.cc
50
Example2: First.cc
///include
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
///ns3 namespace groups all ns-3-related declarations
using namespace ns3;
//declares a logging component called
FirstScriptExample, allows you to enable and disable
console message logging
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
51
Example2: First.cc
int
main (int argc, char *argv[])
{//time resolution to one nanosecond
Time::SetResolution (Time::NS);
LogComponentEnable
("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable
("UdpEchoServerApplication", LOG_LEVEL_INFO);
///Node creation
NodeContainer nodes;
nodes.Create (2);
52
Example2: First.cc
///PointToPoint link
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate",
StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay",
StringValue ("2ms"));
//NetDevice
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
53
Example2: First.cc
//Internet Stack
InternetStackHelper stack;
stack.Install (nodes);
//Ipv4 network
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign
(devices);
54
Example2: First.cc
//Server UDP application configuration
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install
(nodes.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
55
Example2: First.cc
//Client UDP application configuration
UdpEchoClientHelper echoClient
(interfaces.GetAddress (1), 9);
echoClient.SetAttribute ("MaxPackets",
UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue
(Seconds (1.0)));
echoClient.SetAttribute ("PacketSize",
UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install
(nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
56
Example2: First.cc
//Start and stop the simulation
Simulator::Run ();
Simulator::Destroy ();
return 0;
57
Example3: create new module
Path where ns-3 is installed
cd /home/master/1er/1erPhd/tools/tarballs/nsallinone-3.17/ns-3.17/src/
782 ./create-module.py dhvn
Create a new module automatically, for example AAA
./create-module.py AAA
58
Agenda
• ns-3 project overview
– What is ns-3?
– Why use ns-3?
– Project organization
• Getting started with ns-3
– Installation
– Example
• Future directions
59
Development Priorities
• Software modularity and long-term maintenance
• Improved integration of direct code execution
• Improved integration with container-based and
testbed-based experiment infrastructures
• Simulation-based experiment management
• Usability
60
Modularity
• Open source project maintains a (more stable) core
• Models migrate to a more federated development
process
"bake" tool (Lacage
and Camara)
Components:
• build client
• "module store"
server
• module metadata
Figure source: Daniel Camara
61
SAFE: Simulation Automation
Framework
• Data collection, transient analysis, management of
independent replications, graphical configuration and
visualization
• In ns-2 realm, similar to projects like ANSWER,
ns2measure, and Akaroa2
Server host
Experiment
execution
manager
Results
database
Simulation
ns-3
client
Simulation
ns-3
client
Simulation
ns-3
Client hosts
client
Figure source: Felipe Perrone
62
Usability
• Animation and visualization
PyVis (Carneiro)
NetAnim (Riley and Abraham)
• Linkage to external tools (topology, mobility, statistics)
pyvizhelper APIs
• Improved
NetAnim
63
Questions?
64
Bibliography
•Tom Henderson (University of Washington), “ ns-3
overview,”
•https://www.nsnam.org/docs/tutorial/html/gettingstarted.html
•https://www.nsnam.org/wiki/Installation
65