Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Advanced Network Simulations Simplified

You're reading from   Advanced Network Simulations Simplified Practical guide for wired, Wi-Fi (802.11n/ac/ax), and LTE networks using ns-3

Arrow left icon
Product type Paperback
Published in Apr 2023
Publisher Packt
ISBN-13 9781804614457
Length 360 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Anil Kumar Rangisetti Anil Kumar Rangisetti
Author Profile Icon Anil Kumar Rangisetti
Anil Kumar Rangisetti
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Part 1: Exploring Network Simulator-3 (ns-3) Thoroughly and Quickly
2. Chapter 1: Getting Started with Network Simulator-3 (ns-3) FREE CHAPTER 3. Chapter 2: Monitoring, Debugging, Tracing, and Evaluating Network Topologies in ns-3 4. Chapter 3: ns-3 Key Building Blocks for Simulations 5. Part 2: Learn, Set Up, and Evaluate Wired and Wi-Fi (802.11a/b/g/n/ac/ax) Networks
6. Chapter 4: Setting Up and Evaluating CSMA/P2P LANs, Wi-Fi LANs, and the Internet 7. Chapter 5: Exploring Basic Wi-Fi Technologies and Setting Up and Evaluating Wireless Ad Hoc Networks 8. Chapter 6: Researching Advanced Wi-Fi Technologies – 802.11n, ac, and ax in ns-3 9. Part 3: Learn, Set Up, and Evaluate 4G Long-Term Evolution (LTE) Networks
10. Chapter 7: Getting Started with LTE Network Simulations Using ns-3 11. Chapter 8: Researching LTE Network Radio Resource Management and Mobility Management Using ns-3 12. Chapter 9: Researching LTE Advanced Networks: LTE HetNets and Interference Management Using ns-3 13. Index 14. Other Books You May Enjoy

Understanding an ns-3 program’s structure

Before writing any simulation program, it is important to understand the ns-3 simulation program structure. By doing so, it is possible to avoid common mistakes and save a lot of time in debugging your simulation issues. Here, we describe how to create the basic and advanced ns-3 simulation program structures, as follows:

  1. Import all necessary ns-3 packages.
  2. Define the logging component for your program. Your simulation program allows you to include necessary log statements, such as information, warnings, errors, exceptions, assertions, and debug details. While running a simulation, you can enable or disable any of the log statements.
  3. Set up a simulation topology and configure it. Before writing your simulation program, it is recommended to draw your simulation network topology:
    1. Create nodes using the ns-3 NodeContainer class. In ns-3, hosts and other network equipment are referred to as nodes, and users can install the necessary protocols to configure them as a specific piece of networking equipment. Identify the type of nodes, such as hosts, routers, switches, access points (APs), and BSs, involved in your topology and create the necessary number of nodes for each type using the ns-3 NodeContainer class.
    2. Connect nodes using suitable communication channels and install the necessary communication protocols to get the NetDevices (network interface cards (NIC)) associated with the nodes. For example, you'll need to collect the necessary wired or wireless/mobile network devices using the ns-3 NetDeviceContainer class.
    3. Install the Transmission Control Protocol (TCP)/Internet Protocol (IP) on nodes using the ns-3 InternetStackHelper class. Hence, we can assign IP addresses and install routing protocols.
    4. Configure IP addresses. We need to identify and create types of network addresses as required by setting suitable network IDs and subnet masks. Then, we can configure the respective IP address to respective NetDevices using the ns-3 NetDeviceContainer class.
    5. Configure routing protocols to interconnect different networks involved in your topology.
  4. Next, identify the necessary network applications to install and run on various nodes:
    1. Identify on which nodes you need to install your client or server applications, then configure suitable IP addresses and port numbers for those client and server applications.
    2. Configure client and server application traffic flow characteristics, such as packet size, packet interval, and number of packets.
    3. Install the network applications on the selected nodes.
    4. Configure the start and stop timings of your applications.
  5. Install FlowMonitor (an ns-3 class) on all nodes to collect all flow statistics. Although it is not necessary to install a FlowMonitor application on nodes, it is important to analyze your network application’s performance on the simulation topology in terms of flow level throughput, delay, packet loss, and jitter metrics.
  6. Configure packet capturing and traces on nodes (this is optional). This helps you to collect a variety of packets exchanged across your simulation topology and possibly to inspect packet details using the wireshark or tcpdump packet analysis tools.
  7. Configure the Animation Interface (this is optional). It helps you to view the following simulation execution and results using the NetAnim visualization tool:
    1. Enable various packets exchange among nodes tracking feature.
    2. Enable the routing tables tracking feature.
    3. Enable the counter tables tracking feature.
    4. Enable flow monitor statistics capturing.
  8. Configure the stopping time of your simulation using Simulator::Stop(). It is necessary to stop the simulation when you use a flow monitor; otherwise, your simulation never ends.
  9. Start running your simulation using Simulator::Run(). This statement starts your simulation execution.
  10. Convert the flow monitor results into an XML file to visualize using NetAnim.
  11. Clean up your simulation resources using Simulator::Destroy(). It is important to clean up your simulation resources such as memory, devices, and files.

We now understand a typical ns-3 simulation program structure. This common structure is suitable for writing any wired, wireless, or mobile networking topology simulation. With this knowledge, in the next section, we will start writing our first simulation program (pkt_first.cc) by referring to the existing tutorial/first.cc simulation program.

You have been reading a chapter from
Advanced Network Simulations Simplified
Published in: Apr 2023
Publisher: Packt
ISBN-13: 9781804614457
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime