Mô phỏng, đánh giá hiệu năng mạng là một vấn đề được nghiên cứu gần đây,Sử dung NS2 có thể gây rắc rối cho người dung vì sử dung các ngôn ngữ khác và khó viết kịch bản cũng như them các module.NS3 là bộ mô phỏng mạng dung C++ và dễ dàng cho việc phát triển cũng như them mới module
Trang 1ns-3 Training
Computer and Communication Network Lab Department of Electrical Engineering National Sun Yat-Sen University
5/13/2013
Trang 2 Two tutorial examples
A simple example for this project
Complete the remaining parts
2
Trang 4 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
Trang 5Extensible Software Core
Written in C++ with optional Python interface
extensively documented API (doxygen):
http://www.nsnam.org/doxygen-release/index.html
5
Trang 6Node Basics
An ns-3 Node is a husk of a computer to which applications, stacks, and NICs are added
6
Trang 7Tracing 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
Trang 8ns-3 Has A New Tracing Model
ns-3 solution: decouple trace sources from trace sinks
Benefit: Customizable trace sinks
8
Trang 9Downloading ns-3
http://www.nsnam.org/
Latest release: ns-3.16 (2012/12/21)
9
Trang 10Problems under Windows
Note that NSC is not supported on OSX or Cygwin
Network Simulation Cradle
10
Trang 11Building ns-3 (1/5)
11
# /build.py
Trang 12Building ns-3 (2/5)
12
# /waf -d optimized configure
ns-3 uses the waf build system
Trang 13Building ns-3 (3/5)
13
# /waf -d debug configure
Trang 14Building ns-3 (4/5)
14
# /test.py -c core
Trang 15Building ns-3 (5/5)
15
Trang 16Running a Script
16
/waf run hello-simulator
Trang 17Building Your Script
17
# cp examples/tutorial/first.cc scratch/myfirst.cc
/waf
Trang 18Building Your Script
18
# /waf run scratch/myfirst
Trang 19A First ns-3 Script
• /ns-allinone-3.10/ns-3.10/examples/tutorial
• first.cc
• third.cc
Trang 20 The first line in the file is an emacs mode line
The ns-3 simulator is licensed using the GNU
General Public License
20
Trang 231.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
Trang 26Internet Stack Helper
Protocol stacks installed on our nodes
Trang 28 UdpEchoClientHelper
28
Trang 29 What we need to do at this point is to actually
run the simulation
Trang 30Building Your Script
Drop your script into the scratch directory
Trang 31Building Your Script
You can now run the example
31
Trang 32Building a Wireless Network Topology
Add the Wifi and the mobility modules
The network topology illustration follows:
32
Trang 33Building a Wireless Network Topology
For enabling or disabling logging components
and for changing the number of devices created
33
Trang 34Building a Wireless Network Topology
Part of the Wifi network
Configure the PHY and channel helpers
Yet Another Network Simulator
M Lacage and T R Henderson, “Yet Another Network Simulator,” WNS2 ns-2: The IP Network Simulator, Italy, 2006.
http://cutebugs.net/files/wns2-yans.pdf
34
Trang 35Building a Wireless Network Topology
Create a channel object and associate it to our
PHY layer object manager
NqosWifiMacHelper object to set MAC parameters
rate control algorithm
AARF (Adaptive Auto-Rate Fallback ) algorithm 35
Trang 36Building a Wireless Network Topology
The SSID of the infrastructure network
Create the wifi devices of these stations
36
Trang 37Building a Wireless Network Topology
Configure the AP (access point) node
Shares the same set of PHY-level Attributes
(and channel) as the stations
37
Trang 38Building a Wireless Network Topology
Set some Attributes controlling the “position
Trang 39Building a Wireless Network Topology
Need to tell them how to move
Trang 40Building a Wireless Network Topology
Want the access point to remain in a fixed
position during the simulation
Protocol stacks
40
Trang 41Building a Wireless Network Topology
assign IP addresses to the device interfaces
41
Trang 42Building a Wireless Network Topology
Enable internetwork routing
Trang 43Building a Wireless Network Topology
Run the simulation, clean up and then exit the program
Output
43
Trang 44Read the pcap files
44
Trang 45Plot figures
45
Trang 46An Example of MANET
• Reference
• hidden-terminal.cc
Trang 47/ns-allinone-3.10/ns-3.10/examples/wireless/wifi-Codes (1/7)
47
Trang 48Codes (2/7)
48
Trang 49Codes (3/7)
49
Trang 50Codes (4/7)
50
Trang 51Codes (5/7)
51
Trang 52Codes (6/7)
52
Trang 53Codes (7/7)
53
Trang 5454
Trang 58Q & A
58