Tải bản đầy đủ (.ppt) (58 trang)

NS 3 training huong dan su dung NS3

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2.13 MB, 58 trang )

ns-3 Training
Computer and Communication Network Lab
Department of Electrical Engineering
National Sun Yat-Sen University

5/13/2013


Topics


Getting Started ns-3





A First ns-3 Script




What is ns-3?
Installation

Two tutorial examples

A simple example for this project


Complete the remaining parts


2


Getting Started ns-3


Please read the following documents
• ns-3 overview





ns-3 Tutorial




/> /> />
ns-3 Manual


/>

What is ns-3?


ns-3 is a discrete-event network simulator for
Internet systems






ns-3 allows researchers to study Internet protocols
and large-scale systems in a controlled environment
ns-3 is a new simulator (not backwards-compatible
with ns-2)

ns-3 is a free, open source software project
organized around research community
development and maintenance


the target user community is networking researchers
and educators

4


Extensible Software Core


Written in C++ with optional Python interface


extensively documented API (doxygen):




/>5


Node Basics


An ns-3 Node is a husk of a computer to which
applications, stacks, and NICs are added

6


Tracing and Statistics
Tracing is a structured form of simulation output
 Example (from ns-2):




Problem: Tracing needs vary widely



would like to change tracing output without editing the
core
would like to support multiple outputs
7


ns-3 Has A New Tracing Model



ns-3 solution: decouple trace sources from trace
sinks



Benefit: Customizable trace sinks
8


Downloading ns-3


/>

Latest release: ns-3.16 (2012/12/21)

9


Problems under Windows


Cygwin or MinGW



If you do use Cygwin or MinGW and use Logitech
products





it can cause Cygwin or MinGW DLLs to die in mysterious
way

Note that NSC is not supported on OSX or Cygwin.


Network Simulation Cradle
10


Building ns-3 (1/5)


# ./build.py

11


Building ns-3 (2/5)


# ./waf -d optimized configure


ns-3 uses the waf build system


12


Building ns-3 (3/5)


# ./waf -d debug configure

13


Building ns-3 (4/5)


# ./test.py -c core

14


Building ns-3 (5/5)

15


Running a Script


./waf --run hello-simulator

16



Building Your Script
# cp examples/tutorial/first.cc scratch/myfirst.cc
 ./waf


17


Building Your Script


# ./waf --run scratch/myfirst

18


A First ns-3 Script


/ns-allinone-3.10/ns-3.10/examples/tutorial
• first.cc
• third.cc


Boilerplate


The first line in the file is an emacs mode line.





The ns-3 simulator is licensed using the GNU
General Public License.


20


Module Includes


The code proper starts with a number of include
statements.




../../build/debug/ns3

21


Ns3 Namespace


The next line in the first.cc script is a namespace
declaration.





Logging


22


Main Functions


The next lines of the script you will find are,



ns3 提供的 log 訊息分成了以下幾個等級:
1.NS_LOG_ERROR — Log error messages;
2.NS_LOG_WARN — Log warning messages;
3.NS_LOG_DEBUG — Log relatively rare, ad-hoc debugging messages;
4.NS_LOG_INFO — Log informational messages about program progress;
5.NS_LOG_FUNCTION — Log a message describing each function called;
6.NS_LOG_LOGIC – Log messages describing logical flow within a function;
7.NS_LOG_ALL — Log everything.
8.NS_LOG_UNCOND – Log the associated message unconditionally.

23



Topology Helpers


Create the ns-3 Node objects that will represent
the computers in the simulation.




We are constructing a point to point link


24


Topology Helpers


We will need to have a list of all of the NetDevice
objects that are created


25


×