SlideShare a Scribd company logo
Ground to ns3
and
Implementing wireless topology
(Power Adaption) in ns3 plus
visualization in Network Animator
JAWAD ALI
UNIVERSITY OF ENGINEERING AND TECHNOLOGY PESHAWAR
Topics Covered
 Introduction to ns3 and its comparison with ns2
 Finding required modules for coding
 Finding sample code
 Understanding the code
 Checking ns3 core-module.h
 Adding animation interface to the code
 Compiling and running simulation using NetAnim
 Understanding the results from trace file
Introduction to ns3 and its comparison
with ns2
 Ns3 is just like traditional network simulators and optimization softwares besides its ready to
modify codes and open source licensing
 The drawback of ns3 as well as ns2 is that we can’t see the Graphical User Interface (GUI) while
building a project. All we can do is comment the c++ and otcl codes for its understanding. The
topology is defined in c++ in ns3
 Ns2 uses traditional otcl and c++ language for its coding on the other hand ns3 uses object
oriented c++, gcc and python. Ns2 always needs otcl for its scripting and c++ for its core
 In ns3, everything is c++. You should find it easy if you are good at OOP and c++
 Ns2 only supports nam while ns3 supports both nam and PyViz for visualization
 Overhead of connecting otcl with c++ in ns2 is removed in ns3, increasing simulation speed
 Packet consists of a single portion in ns3 with metadata attached. Payload portion on the ns2
packet is this removed by defining packet as a single object.
Finding required modules for coding
 Networking follows standards and these standards are kept in certain header files called modules
in ns3
 For example, if want to initialize a node. You must initialize it as an object of the class called
nodecontainer that is defined in the network-module.h of ns3.
 The same network module is responsible for addressing such as ipv4 addressing scheme.
 The internet-module.h knows upd and tcp protocol schemes and one should use it in any
TCP/UDP based communication network.
 Assigning applications to a node is done by referring to applicationcontainer, defined in
applications-module.h
 Visualization needs network animator module and node topology formation needs a topology
module (e.g. point-to-point.h)
 All of the above modules combined by core-module.h library that is responsible for the core work.
Finding sample code
 For a pro in ns3, it is easy to figure out which module he/she is going to need if the scenario is
drawn on a rough page.
 For example: Communication of a node with another node will require a topology defining
module, node formatter module, payload calculation module, application, visualization module
and core module.
 For novice, it should be even a big deal to find a library. Though a library has to be known for its
classes and functions which is even a higher difficulty.
 Therefore, it is a good programming practice to use already implemented codes and modify
according to our needs
 Ns2 has a lot of online libraries as compared to ns3 but you need to understand otcl before any
modification in those ns2 based codes
 Ns3 has a variety of user manuals and implemented codes given in ~/source/ns-3-dev/examples/
that are ready to use and to modify. One can easily find the desired sample code by roaming
through those examples
Understanding the code
 After finding the closest sample code in the library, one needs to understand it.
 Online help and documentation of each example is available so we should be
using that.
 It is a good practice that one should first know about the scenario implemented in
the example code before roaming through the defined classes and objects called
by the developer of the code
Checking the ns3 core-module.h
Create a simple text file naming test1 in scratch directory of ns-3-dev with suffix .cc and
write the following code in it
#include <core-module.h>
using namespace std;
Int main (arg, arg )
{
cout<<“testing ns3 in terminal”;
Return 0;
}
Open terminal and type: cd source/ns-3-dev followed by ./waf –run test1
If you get the statement after you have written in console out. This most likely mean that
your core-module is working fine.
Adding Animation Interface to the code
#include "ns3/netanim-module.h“ header has to be included for enabling animation
generation in the compiling code
Also, before
Simulation::Run();
include
AnimationInterface anim ("animation.xml"); //or any other distinct fie name
Power Adaption (Compiling and running simulation
using NetAnim)
 The simulation consists of 4 Nodes. Of which, 2 nodes are mobile access points
while 2 are Stations (STA#)
• The APs generates UDP traffic with a CBR of 54 Mbps to the STAs.
• The APs use any power and rate control mechanism, and the STAs use only * Minstrel
rate control.
• The STAs can be configured to be at any distance from the APs.
# A station in networking is a device that follows 802.11 protocol
Code to run in the terminal
./waf --run "power-adaptation-interference --manager=ns3::AparfWifiManager --
outputFileName=aparf”
Changing STAs position
./waf --run "power-adaptation-interference --manager=ns3::AparfWifiManager --
outputFileName=aparf --STA1_x=5 --STA2_x=205“
To enable the log of rate and power changes
export NS_LOG=PowerAdaptationInterference=level_info
Animation Interface in NetAnim
 Type ./NetAnim after exploring netanim directory in the terminal
 Open the directory from where you have run the ./waf commands
 Locate animation stored as .xml file
 Open and run
 Animation Interface consists of 3 tabs
 Animator
 Stat
 Packet
1- Animator (cont.)
2- Stat (cont.)
3- Packet (cont.)
Analysis and Results (Understanding the results from
trace file)
The Following 6 quantities have been analyzed by the proposed Topology for APs
 Throughput (Mbps)
 AP idleTime (%age of second)
 AP busyTime (%age of second)
 Power Dissipation (mW)
 AP as Receiver (%age up time per second)
 AP as Transmitter (%age up time per second)
Time Instant Tx-aparf1 Tx-apart0 throughput1 throughput0 idle1 idle0 busy1 busy0 rx1 rx0 Power1 Power0
0 0 0 0 0 0 0 0 0 0 0 0 0
1 52.9808 45.4784 10.3603 10.5875 33.8566 35.1448 5.76876 7.79013 11.5843 7.3916 4.9284 0.659472
2 59.1136 56.0248 20.7206 21.5045 33.4268 36.4201 2.35267 0.748263 6.8124 5.1072 5.7252 0.531744
3 59.1136 55.488 20.8683 21.175 33.412 36.7731 2.30563 0.967239 6.7816 5.1436 5.7252 0.52664
4 58.8356 55.8052 20.7661 21.3227 33.743 36.6801 2.32732 0.799531 6.7172 5.1184 5.6992 0.529656
5 59.1404 55.7464 20.9138 21.425 33.4288 36.6905 2.28001 0.763888 6.7872 5.152 5.7278 0.535456
6 59.3548 55.732 20.9138 21.3568 33.132 36.5629 2.35578 0.862673 6.8376 5.1576 5.7486 0.535224
7 59.2644 55.9516 20.857 21.5954 33.3701 36.2275 2.2207 0.930718 6.8936 5.1408 5.7408 0.531048
8 58.5776 55.4392 20.4707 21.2091 33.968 37.0851 2.40021 0.672226 6.8068 5.0456 5.6732 0.526176
9 58.9796 55.5756 20.6866 21.2659 33.5553 36.7735 2.40223 0.817604 6.8404 5.0988 5.7122 0.550536
10 59.2376 55.8784 20.8115 21.3568 33.3806 36.6025 2.24398 0.716138 6.7844 5.1296 5.7382 0.530352
11 59.0332 55.8052 20.6298 21.3682 33.5933 36.637 2.28056 0.725678 6.8432 5.0848 5.7174 0.529656
12 59.194 55.5124 20.857 21.1864 33.427 36.9562 2.24389 0.761389 6.7872 5.1408 5.733 0.543576
13 59.184 55.6 20.8229 21.2432 33.3479 36.7179 2.32471 0.838697 6.8208 5.1324 5.733 0.5278
14 58.9796 55.6344 20.7661 21.3227 33.5214 36.6934 2.36825 0.795034 6.8656 5.1184 5.7122 0.528032
15 59.0332 55.7564 20.6866 21.4931 33.4809 36.6129 2.3799 0.800512 6.8572 5.0988 5.7174 0.547984
16 59.0768 55.4392 20.8115 21.1182 33.5986 37.0223 2.20354 0.709053 6.8236 5.1296 5.7226 0.526176
17 59.0064 55.5856 20.5957 21.2886 33.6015 36.7763 2.32926 0.853598 6.7928 5.0736 5.7148 0.527568
18 59.1404 55.4536 20.857 21.141 33.4281 36.8947 2.29049 0.838499 6.8012 5.1408 5.7278 0.526408
19 59.5324 55.6344 20.9251 21.2773 33.04 36.7367 2.28328 0.822367 6.818 5.1604 5.7668 0.528032
20 59.1672 56.2688 20.8229 21.7544 33.4277 36.1623 2.25863 0.768667 6.7816 5.1296 5.7304 0.534064
21 58.8188 55.5124 20.5389 21.1296 33.7787 37.1394 2.32681 0.596125 6.7452 5.0652 5.6966 0.526872
22 59.1572 55.9172 20.8229 21.425 33.3905 36.4438 2.34007 0.850693 6.7872 5.1324 5.7304 0.530816
23 58.4436 55.9028 20.3571 21.425 34.1779 36.6213 2.35477 0.732859 6.7648 5.0148 5.6602 0.530584
24 59.1404 55.2928 20.9024 21.1069 33.4001 37.2434 2.30798 0.676535 6.7732 5.1548 5.7278 0.524784
25 58.9428 55.3904 20.5389 21.1864 33.7325 36.9376 2.2517 0.845144 6.818 5.0624 5.7096 0.525712
26 59.2476 55.4292 20.7661 21.1637 33.3454 36.7894 2.31043 0.972126 6.8292 5.1184 5.7382 0.526176
27 59.06 55.6588 20.732 21.2205 33.4471 36.5981 2.37458 0.987638 6.7564 5.11 5.72 0.528264
28 59.2376 55.9028 20.891 21.5045 33.2947 36.4655 2.31681 0.770172 6.8684 5.1492 5.7382 0.530584
29 59.2476 55.732 20.8115 21.3454 33.334 36.7945 2.30442 0.671414 6.8012 5.1296 5.7382 0.52896
30 58.9528 55.6244 20.7888 21.2659 33.5567 36.8707 2.35888 0.673383 6.8292 5.124 5.7096 0.528032
31 58.6212 55.6588 20.5275 21.5272 33.9244 36.4521 2.40434 0.986992 6.8768 5.0596 5.6784 0.528264
32 59.06 55.854 20.7774 21.2886 33.4483 36.4513 2.32715 0.902484 6.8124 5.1212 5.72 0.536384
33 59.3012 55.4636 20.891 21.3114 33.3374 36.7813 2.22513 0.862616 6.8964 5.1492 5.7434 0.526408
34 58.8892 55.6832 20.5843 21.1637 33.6811 36.7574 2.36983 0.790068 6.7564 5.0736 5.7044 0.528496
35 59.6228 55.5756 21.0046 21.2318 33.0258 36.9463 2.17898 0.71646 6.7788 5.1772 5.7746 0.527568
36 59.2208 55.732 20.9592 21.3114 33.3157 36.5427 2.28811 0.884075 6.8488 5.166 5.7356 0.535224
37 59.4252 55.488 20.9024 21.1864 33.1864 36.8179 2.23405 0.814049 6.8544 5.152 5.7564 0.52664
38 59.5692 55.6588 20.857 21.3454 33.0376 36.5892 2.24727 0.945771 6.8236 5.1408 5.7694 0.528264
39 59.1672 55.6732 20.8115 21.2886 33.4333 36.6959 2.28041 0.788958 6.8488 5.1296 5.7304 0.528496
40 58.9428 55.9272 20.7888 21.3795 33.5342 36.5589 2.39844 0.668549 6.846 5.124 5.7096 0.53708
41 59.1404 55.7076 20.8002 21.3795 33.4625 36.6803 2.28589 0.775535 6.8096 5.1268 5.7278 0.528728
42 59.4352 55.9272 21.0274 21.3568 33.0607 36.6997 2.31616 0.700598 6.6864 5.1828 5.7564 0.530816
43 59.184 55.478 20.7888 21.1296 33.2908 37.0138 2.40762 0.708388 6.7788 5.124 5.733 0.52664
44 59.1136 55.2684 20.6525 21.2546 33.5426 36.9864 2.23338 0.842062 6.8768 5.0904 5.7252 0.524552
45 58.6044 55.732 20.3003 21.3114 34.1527 36.7433 2.25213 0.833982 6.7396 5.0036 5.6758 0.52896
46 58.9428 55.9028 20.6752 21.2773 33.6867 36.5856 2.28466 0.716905 6.7928 5.096 5.7096 0.530584
47 59.4888 55.6732 20.8683 21.3341 33.0399 36.7179 2.30612 0.845639 6.7648 5.1436 5.7616 0.528496
48 59.328 55.732 20.8115 21.2318 33.2596 36.8115 2.29437 0.676848 6.7788 5.1296 5.746 0.52896
49 59.2376 55.3416 20.7774 21.0728 33.2981 37.1807 2.347 0.644276 6.8376 5.1212 5.7382 0.525248
50 58.8188 55.6832 20.6866 21.2886 33.7912 36.7413 2.26438 0.721833 6.832 5.0988 5.6966 0.528496
51 59.328 55.2928 20.9706 21.1978 33.2829 37.1029 2.22112 0.784702 6.818 5.1688 5.746 0.531048
52 59.4252 56.1612 21.0955 21.6181 33.1387 36.3473 2.24291 0.668373 6.8292 5.1996 5.7564 0.533136
53 59.2744 55.976 20.8456 21.5386 33.2744 36.0766 2.31788 1.06793 6.888 5.138 5.7408 0.53128
54 58.8992 55.5856 20.5843 21.3227 33.787 36.7842 2.24424 0.806244 6.8152 5.0736 5.7044 0.533832
55 59.452 55.9272 21.0046 21.4022 33.1611 36.6106 2.21723 0.724072 6.7172 5.1772 5.759 0.530816
56 58.8724 55.722 20.5843 21.2432 33.806 36.7762 2.22969 0.758868 6.762 5.0736 5.7018 0.52896
57 58.658 55.9516 20.7434 21.4818 33.832 36.3712 2.41826 0.851094 6.8348 5.1128 5.681 0.537312
58 59.05 55.7564 20.7547 21.3 33.5144 36.6848 2.3268 0.730969 6.8236 5.1156 5.72 0.529192
59 59.0332 56.3176 20.8229 21.7544 33.3307 35.9013 2.47698 0.811473 6.9664 5.1324 5.7174 0.534528
60 58.7116 55.722 20.5048 21.3454 33.8873 36.7914 2.35031 0.715868 6.776 5.054 5.6862 0.52896
61 59.318 55.7076 20.891 21.4818 33.2303 36.5811 2.30487 0.854187 6.8628 5.1492 5.746 0.528728
62 58.8456 55.854 20.7661 21.3909 33.6903 36.567 2.36913 0.755179 6.8292 5.1184 5.6992 0.536384
63 59.3816 55.4636 20.857 21.3454 33.1012 36.9341 2.35365 0.808522 6.7872 5.138 5.7512 0.526408
1 5 9
1
3
0
5
10
15
20
25
30
35
40
1 5 9
1
3
1
7
2
1
0
1
2
3
4
5
6
7
8
9
1 5 9
1
3
1
7
2
1
2
5
0
1
2
3
4
5
6
7
Throughput (Mbps)
AP idleTime (%age of second)
AP busyTime (%age of second)
Power Dissipation (mW)
AP as Receiver (%age up time per second)
AP as Transmitter (%age up time per second)
End

More Related Content

PDF
Ns3 implementation wifi
PDF
Building Complex Topology using NS3
PDF
NS3 Overview
PDF
Tutorial ns 3-tutorial-slides
PDF
1 session installation
PDF
ns-3 Tutorial
PPTX
Network Virtualization Architectural & Technological aspects
PDF
Building Topology in NS3
Ns3 implementation wifi
Building Complex Topology using NS3
NS3 Overview
Tutorial ns 3-tutorial-slides
1 session installation
ns-3 Tutorial
Network Virtualization Architectural & Technological aspects
Building Topology in NS3

What's hot (20)

PDF
Traffic Control with Envoy Proxy
PPTX
Network Virtualization
PPTX
Trace route
PPT
The 3 aspects of network performance management
PDF
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
PDF
VPNaaS in Neutron
PPTX
Web Servers(IIS, NGINX, APACHE)
PPTX
Content Delivery Network - CDN
PDF
macvlan and ipvlan
PDF
Network LACP/Bonding/Teaming with Mikrotik
PPTX
OpenStack Cinder
PDF
Using mikrotik with radius
PPTX
NGINX: Basics and Best Practices
PPTX
NGINX: Basics & Best Practices - EMEA Broadcast
PPTX
Tutorial: Using GoBGP as an IXP connecting router
PDF
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
PDF
Managing Terraform Module Versioning and Dependencies
PPTX
Rabbit MQ introduction
PDF
VLAN vs VXLAN
PDF
Deploying CloudStack and Ceph with flexible VXLAN and BGP networking
Traffic Control with Envoy Proxy
Network Virtualization
Trace route
The 3 aspects of network performance management
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
VPNaaS in Neutron
Web Servers(IIS, NGINX, APACHE)
Content Delivery Network - CDN
macvlan and ipvlan
Network LACP/Bonding/Teaming with Mikrotik
OpenStack Cinder
Using mikrotik with radius
NGINX: Basics and Best Practices
NGINX: Basics & Best Practices - EMEA Broadcast
Tutorial: Using GoBGP as an IXP connecting router
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
Managing Terraform Module Versioning and Dependencies
Rabbit MQ introduction
VLAN vs VXLAN
Deploying CloudStack and Ceph with flexible VXLAN and BGP networking
Ad

Similar to Ground to ns3 - Basic wireless topology implementation (20)

PPTX
Spring sim 2010-riley
PPTX
ACMSE2022-Tutorial-Slides.pptx
PDF
Software size distribution - Why we always underestimate software cost
PDF
WiMAX implementation in ns3
PDF
PDF
Paper9250 implementation of an i pv6 stack for ns-3
PDF
Performance comparision 1307.4129
PDF
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
PPTX
Plenzogan technology
PPTX
June 28 Presentation
PDF
Sample thesis
PPTX
Graph Neural Networks (GNN) for Large-Scale Network Performance Evaluation.pptx
PDF
Network Algorithmics 2nd Edition Varghese
PDF
Virtual lab - Routing in Mobile Adhoc Networks
PDF
A New Programming Model to Simulate Wireless Sensor Networks : Finding The Be...
PPTX
A personal journey towards more reproducible networking research
PDF
Solution(1)
PDF
Network Algorithmics 2nd Edition Varghese
Spring sim 2010-riley
ACMSE2022-Tutorial-Slides.pptx
Software size distribution - Why we always underestimate software cost
WiMAX implementation in ns3
Paper9250 implementation of an i pv6 stack for ns-3
Performance comparision 1307.4129
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
Plenzogan technology
June 28 Presentation
Sample thesis
Graph Neural Networks (GNN) for Large-Scale Network Performance Evaluation.pptx
Network Algorithmics 2nd Edition Varghese
Virtual lab - Routing in Mobile Adhoc Networks
A New Programming Model to Simulate Wireless Sensor Networks : Finding The Be...
A personal journey towards more reproducible networking research
Solution(1)
Network Algorithmics 2nd Edition Varghese
Ad

More from Jawad Khan (20)

PPTX
2.1 input and output in c
PPTX
2.2 variable arithmetics and logics
PPTX
1.2 programming fundamentals
PPTX
1.1 programming fundamentals
PPTX
7 8. emi - analog instruments and digital instruments
PPTX
6. emi instrument transformers (with marking)
PPTX
5 emi ac bridges (with marking)
PPTX
4. emi potentiometer and ac bridges
PPTX
3 .emi wattmeter and energy meter
PPTX
2. emi analog electromechanical instruments
PPTX
1. emi concept of measurement system
PPTX
Varibale frequency response lecturer 2 - audio+
PPTX
Variable frequency response lecture 3 - audio
PPTX
Varibale frequency response lecturer 1 - audio
PPTX
Two port network - part 3
PPTX
Two port network - part 2
PPTX
Two port network - part 1
PPTX
4. ideal transformer and load conversion
PPTX
3. magnetic coupled circuits examples
PPTX
2. magnetic coupled circuits
2.1 input and output in c
2.2 variable arithmetics and logics
1.2 programming fundamentals
1.1 programming fundamentals
7 8. emi - analog instruments and digital instruments
6. emi instrument transformers (with marking)
5 emi ac bridges (with marking)
4. emi potentiometer and ac bridges
3 .emi wattmeter and energy meter
2. emi analog electromechanical instruments
1. emi concept of measurement system
Varibale frequency response lecturer 2 - audio+
Variable frequency response lecture 3 - audio
Varibale frequency response lecturer 1 - audio
Two port network - part 3
Two port network - part 2
Two port network - part 1
4. ideal transformer and load conversion
3. magnetic coupled circuits examples
2. magnetic coupled circuits

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
A Presentation on Artificial Intelligence
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
MYSQL Presentation for SQL database connectivity
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
A Presentation on Artificial Intelligence
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Monthly Chronicles - July 2025
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
MYSQL Presentation for SQL database connectivity

Ground to ns3 - Basic wireless topology implementation

  • 1. Ground to ns3 and Implementing wireless topology (Power Adaption) in ns3 plus visualization in Network Animator JAWAD ALI UNIVERSITY OF ENGINEERING AND TECHNOLOGY PESHAWAR
  • 2. Topics Covered  Introduction to ns3 and its comparison with ns2  Finding required modules for coding  Finding sample code  Understanding the code  Checking ns3 core-module.h  Adding animation interface to the code  Compiling and running simulation using NetAnim  Understanding the results from trace file
  • 3. Introduction to ns3 and its comparison with ns2  Ns3 is just like traditional network simulators and optimization softwares besides its ready to modify codes and open source licensing  The drawback of ns3 as well as ns2 is that we can’t see the Graphical User Interface (GUI) while building a project. All we can do is comment the c++ and otcl codes for its understanding. The topology is defined in c++ in ns3  Ns2 uses traditional otcl and c++ language for its coding on the other hand ns3 uses object oriented c++, gcc and python. Ns2 always needs otcl for its scripting and c++ for its core  In ns3, everything is c++. You should find it easy if you are good at OOP and c++  Ns2 only supports nam while ns3 supports both nam and PyViz for visualization  Overhead of connecting otcl with c++ in ns2 is removed in ns3, increasing simulation speed  Packet consists of a single portion in ns3 with metadata attached. Payload portion on the ns2 packet is this removed by defining packet as a single object.
  • 4. Finding required modules for coding  Networking follows standards and these standards are kept in certain header files called modules in ns3  For example, if want to initialize a node. You must initialize it as an object of the class called nodecontainer that is defined in the network-module.h of ns3.  The same network module is responsible for addressing such as ipv4 addressing scheme.  The internet-module.h knows upd and tcp protocol schemes and one should use it in any TCP/UDP based communication network.  Assigning applications to a node is done by referring to applicationcontainer, defined in applications-module.h  Visualization needs network animator module and node topology formation needs a topology module (e.g. point-to-point.h)  All of the above modules combined by core-module.h library that is responsible for the core work.
  • 5. Finding sample code  For a pro in ns3, it is easy to figure out which module he/she is going to need if the scenario is drawn on a rough page.  For example: Communication of a node with another node will require a topology defining module, node formatter module, payload calculation module, application, visualization module and core module.  For novice, it should be even a big deal to find a library. Though a library has to be known for its classes and functions which is even a higher difficulty.  Therefore, it is a good programming practice to use already implemented codes and modify according to our needs  Ns2 has a lot of online libraries as compared to ns3 but you need to understand otcl before any modification in those ns2 based codes  Ns3 has a variety of user manuals and implemented codes given in ~/source/ns-3-dev/examples/ that are ready to use and to modify. One can easily find the desired sample code by roaming through those examples
  • 6. Understanding the code  After finding the closest sample code in the library, one needs to understand it.  Online help and documentation of each example is available so we should be using that.  It is a good practice that one should first know about the scenario implemented in the example code before roaming through the defined classes and objects called by the developer of the code
  • 7. Checking the ns3 core-module.h Create a simple text file naming test1 in scratch directory of ns-3-dev with suffix .cc and write the following code in it #include <core-module.h> using namespace std; Int main (arg, arg ) { cout<<“testing ns3 in terminal”; Return 0; } Open terminal and type: cd source/ns-3-dev followed by ./waf –run test1 If you get the statement after you have written in console out. This most likely mean that your core-module is working fine.
  • 8. Adding Animation Interface to the code #include "ns3/netanim-module.h“ header has to be included for enabling animation generation in the compiling code Also, before Simulation::Run(); include AnimationInterface anim ("animation.xml"); //or any other distinct fie name
  • 9. Power Adaption (Compiling and running simulation using NetAnim)  The simulation consists of 4 Nodes. Of which, 2 nodes are mobile access points while 2 are Stations (STA#) • The APs generates UDP traffic with a CBR of 54 Mbps to the STAs. • The APs use any power and rate control mechanism, and the STAs use only * Minstrel rate control. • The STAs can be configured to be at any distance from the APs. # A station in networking is a device that follows 802.11 protocol
  • 10. Code to run in the terminal ./waf --run "power-adaptation-interference --manager=ns3::AparfWifiManager -- outputFileName=aparf” Changing STAs position ./waf --run "power-adaptation-interference --manager=ns3::AparfWifiManager -- outputFileName=aparf --STA1_x=5 --STA2_x=205“ To enable the log of rate and power changes export NS_LOG=PowerAdaptationInterference=level_info
  • 11. Animation Interface in NetAnim  Type ./NetAnim after exploring netanim directory in the terminal  Open the directory from where you have run the ./waf commands  Locate animation stored as .xml file  Open and run  Animation Interface consists of 3 tabs  Animator  Stat  Packet
  • 15. Analysis and Results (Understanding the results from trace file) The Following 6 quantities have been analyzed by the proposed Topology for APs  Throughput (Mbps)  AP idleTime (%age of second)  AP busyTime (%age of second)  Power Dissipation (mW)  AP as Receiver (%age up time per second)  AP as Transmitter (%age up time per second) Time Instant Tx-aparf1 Tx-apart0 throughput1 throughput0 idle1 idle0 busy1 busy0 rx1 rx0 Power1 Power0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 52.9808 45.4784 10.3603 10.5875 33.8566 35.1448 5.76876 7.79013 11.5843 7.3916 4.9284 0.659472 2 59.1136 56.0248 20.7206 21.5045 33.4268 36.4201 2.35267 0.748263 6.8124 5.1072 5.7252 0.531744 3 59.1136 55.488 20.8683 21.175 33.412 36.7731 2.30563 0.967239 6.7816 5.1436 5.7252 0.52664 4 58.8356 55.8052 20.7661 21.3227 33.743 36.6801 2.32732 0.799531 6.7172 5.1184 5.6992 0.529656 5 59.1404 55.7464 20.9138 21.425 33.4288 36.6905 2.28001 0.763888 6.7872 5.152 5.7278 0.535456 6 59.3548 55.732 20.9138 21.3568 33.132 36.5629 2.35578 0.862673 6.8376 5.1576 5.7486 0.535224 7 59.2644 55.9516 20.857 21.5954 33.3701 36.2275 2.2207 0.930718 6.8936 5.1408 5.7408 0.531048 8 58.5776 55.4392 20.4707 21.2091 33.968 37.0851 2.40021 0.672226 6.8068 5.0456 5.6732 0.526176 9 58.9796 55.5756 20.6866 21.2659 33.5553 36.7735 2.40223 0.817604 6.8404 5.0988 5.7122 0.550536 10 59.2376 55.8784 20.8115 21.3568 33.3806 36.6025 2.24398 0.716138 6.7844 5.1296 5.7382 0.530352 11 59.0332 55.8052 20.6298 21.3682 33.5933 36.637 2.28056 0.725678 6.8432 5.0848 5.7174 0.529656 12 59.194 55.5124 20.857 21.1864 33.427 36.9562 2.24389 0.761389 6.7872 5.1408 5.733 0.543576 13 59.184 55.6 20.8229 21.2432 33.3479 36.7179 2.32471 0.838697 6.8208 5.1324 5.733 0.5278 14 58.9796 55.6344 20.7661 21.3227 33.5214 36.6934 2.36825 0.795034 6.8656 5.1184 5.7122 0.528032 15 59.0332 55.7564 20.6866 21.4931 33.4809 36.6129 2.3799 0.800512 6.8572 5.0988 5.7174 0.547984 16 59.0768 55.4392 20.8115 21.1182 33.5986 37.0223 2.20354 0.709053 6.8236 5.1296 5.7226 0.526176 17 59.0064 55.5856 20.5957 21.2886 33.6015 36.7763 2.32926 0.853598 6.7928 5.0736 5.7148 0.527568 18 59.1404 55.4536 20.857 21.141 33.4281 36.8947 2.29049 0.838499 6.8012 5.1408 5.7278 0.526408 19 59.5324 55.6344 20.9251 21.2773 33.04 36.7367 2.28328 0.822367 6.818 5.1604 5.7668 0.528032 20 59.1672 56.2688 20.8229 21.7544 33.4277 36.1623 2.25863 0.768667 6.7816 5.1296 5.7304 0.534064 21 58.8188 55.5124 20.5389 21.1296 33.7787 37.1394 2.32681 0.596125 6.7452 5.0652 5.6966 0.526872 22 59.1572 55.9172 20.8229 21.425 33.3905 36.4438 2.34007 0.850693 6.7872 5.1324 5.7304 0.530816 23 58.4436 55.9028 20.3571 21.425 34.1779 36.6213 2.35477 0.732859 6.7648 5.0148 5.6602 0.530584 24 59.1404 55.2928 20.9024 21.1069 33.4001 37.2434 2.30798 0.676535 6.7732 5.1548 5.7278 0.524784 25 58.9428 55.3904 20.5389 21.1864 33.7325 36.9376 2.2517 0.845144 6.818 5.0624 5.7096 0.525712 26 59.2476 55.4292 20.7661 21.1637 33.3454 36.7894 2.31043 0.972126 6.8292 5.1184 5.7382 0.526176 27 59.06 55.6588 20.732 21.2205 33.4471 36.5981 2.37458 0.987638 6.7564 5.11 5.72 0.528264 28 59.2376 55.9028 20.891 21.5045 33.2947 36.4655 2.31681 0.770172 6.8684 5.1492 5.7382 0.530584 29 59.2476 55.732 20.8115 21.3454 33.334 36.7945 2.30442 0.671414 6.8012 5.1296 5.7382 0.52896 30 58.9528 55.6244 20.7888 21.2659 33.5567 36.8707 2.35888 0.673383 6.8292 5.124 5.7096 0.528032 31 58.6212 55.6588 20.5275 21.5272 33.9244 36.4521 2.40434 0.986992 6.8768 5.0596 5.6784 0.528264 32 59.06 55.854 20.7774 21.2886 33.4483 36.4513 2.32715 0.902484 6.8124 5.1212 5.72 0.536384 33 59.3012 55.4636 20.891 21.3114 33.3374 36.7813 2.22513 0.862616 6.8964 5.1492 5.7434 0.526408 34 58.8892 55.6832 20.5843 21.1637 33.6811 36.7574 2.36983 0.790068 6.7564 5.0736 5.7044 0.528496 35 59.6228 55.5756 21.0046 21.2318 33.0258 36.9463 2.17898 0.71646 6.7788 5.1772 5.7746 0.527568 36 59.2208 55.732 20.9592 21.3114 33.3157 36.5427 2.28811 0.884075 6.8488 5.166 5.7356 0.535224 37 59.4252 55.488 20.9024 21.1864 33.1864 36.8179 2.23405 0.814049 6.8544 5.152 5.7564 0.52664 38 59.5692 55.6588 20.857 21.3454 33.0376 36.5892 2.24727 0.945771 6.8236 5.1408 5.7694 0.528264 39 59.1672 55.6732 20.8115 21.2886 33.4333 36.6959 2.28041 0.788958 6.8488 5.1296 5.7304 0.528496 40 58.9428 55.9272 20.7888 21.3795 33.5342 36.5589 2.39844 0.668549 6.846 5.124 5.7096 0.53708 41 59.1404 55.7076 20.8002 21.3795 33.4625 36.6803 2.28589 0.775535 6.8096 5.1268 5.7278 0.528728 42 59.4352 55.9272 21.0274 21.3568 33.0607 36.6997 2.31616 0.700598 6.6864 5.1828 5.7564 0.530816 43 59.184 55.478 20.7888 21.1296 33.2908 37.0138 2.40762 0.708388 6.7788 5.124 5.733 0.52664 44 59.1136 55.2684 20.6525 21.2546 33.5426 36.9864 2.23338 0.842062 6.8768 5.0904 5.7252 0.524552 45 58.6044 55.732 20.3003 21.3114 34.1527 36.7433 2.25213 0.833982 6.7396 5.0036 5.6758 0.52896 46 58.9428 55.9028 20.6752 21.2773 33.6867 36.5856 2.28466 0.716905 6.7928 5.096 5.7096 0.530584 47 59.4888 55.6732 20.8683 21.3341 33.0399 36.7179 2.30612 0.845639 6.7648 5.1436 5.7616 0.528496 48 59.328 55.732 20.8115 21.2318 33.2596 36.8115 2.29437 0.676848 6.7788 5.1296 5.746 0.52896 49 59.2376 55.3416 20.7774 21.0728 33.2981 37.1807 2.347 0.644276 6.8376 5.1212 5.7382 0.525248 50 58.8188 55.6832 20.6866 21.2886 33.7912 36.7413 2.26438 0.721833 6.832 5.0988 5.6966 0.528496 51 59.328 55.2928 20.9706 21.1978 33.2829 37.1029 2.22112 0.784702 6.818 5.1688 5.746 0.531048 52 59.4252 56.1612 21.0955 21.6181 33.1387 36.3473 2.24291 0.668373 6.8292 5.1996 5.7564 0.533136 53 59.2744 55.976 20.8456 21.5386 33.2744 36.0766 2.31788 1.06793 6.888 5.138 5.7408 0.53128 54 58.8992 55.5856 20.5843 21.3227 33.787 36.7842 2.24424 0.806244 6.8152 5.0736 5.7044 0.533832 55 59.452 55.9272 21.0046 21.4022 33.1611 36.6106 2.21723 0.724072 6.7172 5.1772 5.759 0.530816 56 58.8724 55.722 20.5843 21.2432 33.806 36.7762 2.22969 0.758868 6.762 5.0736 5.7018 0.52896 57 58.658 55.9516 20.7434 21.4818 33.832 36.3712 2.41826 0.851094 6.8348 5.1128 5.681 0.537312 58 59.05 55.7564 20.7547 21.3 33.5144 36.6848 2.3268 0.730969 6.8236 5.1156 5.72 0.529192 59 59.0332 56.3176 20.8229 21.7544 33.3307 35.9013 2.47698 0.811473 6.9664 5.1324 5.7174 0.534528 60 58.7116 55.722 20.5048 21.3454 33.8873 36.7914 2.35031 0.715868 6.776 5.054 5.6862 0.52896 61 59.318 55.7076 20.891 21.4818 33.2303 36.5811 2.30487 0.854187 6.8628 5.1492 5.746 0.528728 62 58.8456 55.854 20.7661 21.3909 33.6903 36.567 2.36913 0.755179 6.8292 5.1184 5.6992 0.536384 63 59.3816 55.4636 20.857 21.3454 33.1012 36.9341 2.35365 0.808522 6.7872 5.138 5.7512 0.526408 1 5 9 1 3 0 5 10 15 20 25 30 35 40 1 5 9 1 3 1 7 2 1 0 1 2 3 4 5 6 7 8 9 1 5 9 1 3 1 7 2 1 2 5 0 1 2 3 4 5 6 7
  • 17. AP idleTime (%age of second)
  • 18. AP busyTime (%age of second)
  • 20. AP as Receiver (%age up time per second)
  • 21. AP as Transmitter (%age up time per second)
  • 22. End