Presentation is loading. Please wait.

Presentation is loading. Please wait.

ns-3 Training 5/08/2017 Computer and Communication Network Lab

Similar presentations


Presentation on theme: "ns-3 Training 5/08/2017 Computer and Communication Network Lab"— Presentation transcript:

1 ns-3 Training 5/08/2017 Computer and Communication Network Lab
Department of Electrical Engineering National Sun Yat-Sen University 5/08/2017

2 Topics Getting Started ns-3 A First ns-3 Script
What is ns-3? Installation A First ns-3 Script Two tutorial examples A simple example for this project Complete the remaining parts

3 Getting Started ns-3 Please read the following documents ns-3 overview
ns-3 Tutorial ns-3 Manual

4 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

5 Extensible Software Core
Written in C++ with optional Python interface extensively documented API (doxygen):

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

7 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

8 ns-3 Has A New Tracing Model
ns-3 solution: decouple trace sources from trace sinks Benefit: Customizable trace sinks

9 Downloading ns-3 Latest release: ns-3.27

10 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

11 Building ns-3 (1/5) # ./build.py

12 Building ns-3 (2/5) # ./waf -d optimized configure
ns-3 uses the waf build system

13 Building ns-3 (3/5) # ./waf -d debug configure

14 Building ns-3 (4/5) # ./test.py -c core

15 Building ns-3 (5/5)

16 Running a Script ./waf --run hello-simulator

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

18 Building Your Script # ./waf --run scratch/myfirst

19 /ns-allinone-3.10/ns-3.10/examples/tutorial first.cc third.cc
A First ns-3 Script /ns-allinone-3.10/ns-3.10/examples/tutorial first.cc third.cc

20 Boilerplate The first line in the file is an emacs mode line.
The ns-3 simulator is licensed using the GNU General Public License.

21 Module Includes The code proper starts with a number of include statements. ../../build/debug/ns3

22 Ns3 Namespace The next line in the first.cc script is a namespace declaration. Logging NS_LOG_COMPONENT_DEFINE ("FirstScriptExample"); 是指將 first.cc 檔取名為 "FirstScriptExample" ,並利用 LogComponentEnable(參數一, 參數二),開啟 "參數一" 的 log 功能,再利用參數二設定等級,所以LogComponentEnable("FirstScriptExample", LOG_LEVEL_INFO) 設定了 "FirstScriptExample" 的 log 等級為 LOG_LEVEL_INFO。

23 Main Functions The next lines of the script you will find are,
ns3 提供的 log 訊息分成了以下幾個等級: NS_LOG_ERROR — Log error messages; NS_LOG_WARN — Log warning messages; NS_LOG_DEBUG — Log relatively rare, ad-hoc debugging messages; NS_LOG_INFO — Log informational messages about program progress; NS_LOG_FUNCTION — Log a message describing each function called; NS_LOG_LOGIC – Log messages describing logical flow within a function; NS_LOG_ALL — Log everything. NS_LOG_UNCOND – Log the associated message unconditionally.

24 Topology Helpers Create the ns-3 Node objects that will represent the computers in the simulation. We are constructing a point to point link

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

26 Internet Stack Helper Protocol stacks installed on our nodes
TCP, UDP, IP, etc. Ipv4AddressHelper make the association between an IP address and a device

27 Applications Two specializations of the core ns-3 class Application called UdpEchoServerApplication UdpEchoClientApplication UdpEchoServerHelper

28 Applications UdpEchoClientHelper

29 Simulator What we need to do at this point is to actually run the simulation. scheduled events in the simulator at 1.0 seconds, 2.0 seconds and two events at 10.0 seconds

30 Building Your Script Drop your script into the scratch directory
Now build your first example script using waf

31 Building Your Script You can now run the example

32 Building a Wireless Network Topology
Add the Wifi and the mobility modules The network topology illustration follows:

33 Building a Wireless Network Topology
For enabling or disabling logging components and for changing the number of devices created

34 Building 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.

35 Building 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

36 Building a Wireless Network Topology
The SSID of the infrastructure network Create the wifi devices of these stations

37 Building a Wireless Network Topology
Configure the AP (access point) node Shares the same set of PHY-level Attributes (and channel) as the stations

38 Building a Wireless Network Topology
Set some Attributes controlling the “position allocator” functionality The number of objects layed out on a line.

39 Building a Wireless Network Topology
Need to tell them how to move RandomWalk2dMobilityModel random direction random speed Rectangle (double _xMin, double _xMax, double _yMin, double _yMax)

40 Building a Wireless Network Topology
Want the access point to remain in a fixed position during the simulation Protocol stacks

41 Building a Wireless Network Topology
assign IP addresses to the device interfaces

42 Building a Wireless Network Topology
Enable internetwork routing Create just enough tracing to cover all three networks

43 Building a Wireless Network Topology
Run the simulation, clean up and then exit the program Output

44 Read the pcap files

45 Plot figures

46 An Example of MANET Reference
/ns-allinone-3.10/ns-3.10/examples/wireless/wifi-hidden-terminal.cc

47 Codes (1/7)

48 Codes (2/7)

49 Codes (3/7)

50 Codes (4/7)

51 Codes (5/7)

52 Codes (6/7)

53 Codes (7/7)

54 Result

55 Need to do…… (1/3) Transmission range of a node Node moving speed
ns3::RangePropagationLossModel MaxRange Node moving speed ns3::RandomWaypointMobilityModel Speed Pause Node data rate ns3::ConstantRateWifiManager

56 Need to do…… (2/3) RTS retry limit Buffer size AODV hello periods
ns3::UanMacRc RetryRate Buffer size ns3::TcpSocket SndBufSize AODV hello periods ns3::aodv::RoutingProtocol HelloInterval

57 Need to do…… (3/3) Uniform distribution in a square with 500 meters
ns3::RandomRectanglePositionAllocator ns3::UniformVariable

58 Q & A


Download ppt "ns-3 Training 5/08/2017 Computer and Communication Network Lab"

Similar presentations


Ads by Google