Skip to main content

PyTorch Code for Simple Neural Networks for MNIST Dataset

Introduction to NS2 - NS2 Tutorial 1

Introduction to Network Simulations

In this post, you can learn

  • Introduction to Network Simulator 2 and its architecture
  • Installation of Network Simulator 2 in various Operating Systems
  • How to simulate a given network with available libraries of NS2

A simulator is of extensive use to engineers and researchers as it provides them a simple and inexpensive way to test the real world scenarios without facing the problems of actual implementation, though getting the same results. Similarly, a network simulator is software which models the behavior of the network given to it as an input, under real network characteristics without the actual network being present. To generalize, we can say that a simple network simulator must provide the user the capability to create nodes, the links between them and the traffic between the nodes. Additionally, an advanced network simulator may provide options for specifying every detail about the protocol used in handling network traffic.

Simulation is the modelling of an environment which is exactly similar to the underlying state of the target. The main goal of building a simulator is that, the internal state transitions and responsiveness of the system must exactly match the actual target environment it’s trying to mimic. Simulators are often used in order to give the user an initial experience of the real environment, since it may not be feasible for the user or the corporation to let the trainee use the actual environment due to monetary or safety reasons. The best example of a simulator is the flight simulator. The pilot trainee is never allowed to board the actual cockpit until he is able to get through the flight simulator environment. The flight simulator has the exact controls which is present in the cockpit and creates a virtual environment similar to that of the actual cockpit. It is capable of taking into consideration a number of factors like G-Forces, turbulence etc. It’s mandatory that these effects are very accurate so that the pilot doesn’t make any errors during the actual flight. Like wise, network simulators are useful in analysing, testing and design of various methods of computer networks. The emergence of wireless networks forced network simulations to be more accurate and appropriate due to its dynamic nature while deploying such networks.

1.1  Need for Simulation

Most of the pilot projects are using simulators rather than the real network deployments because of various factors like cost, implementation difficulties, customization, new technology adaptation, etc.

However there are situations where the real networks deployment are at upper hand for accurate results and it is the actual thing happening. Here is a simple comparison between the real model and the simulated model.

Real Network

Simulated Model

The cost of all the network components have to be procured

Most of the simulators are open source and free and cost is zero. (Example, NS2, OMNeT++, etc)

Time to set the things is really a painful task. (For Example, configuring a switch, hub or a router involves a skilled worker)

Learn a programming tool to model the devices once. Once learned, setting a network is a very simple task

Altering a given component may incur additional devices to setup or malfunction the entire network setup.

There is no risk while changing or altering the pre existing network.

This is the actual thing happening and whatever results you get the results are real and accurate.

Here also one may get accurate results until the system is bug free. If there are bugs in the system, the results may be unreliable or inaccurate.

Overall: Cost is high and exact results.

Overall: Cheaper and easier to deploy and development

So once the network project is decided, it is advisable to look for a simulator rather than option for a real network deployment as the initial cost should in any case be minimal.

1.2  List of Network Simulators

There are various simulators available for simulations each with their own purpose. However there are limited simulators that support wide range of protocols, routing metrics, etc. Here is the list of simulators that support huge number of protocols and network entities.

Network Simulator 2 [NS2]

Network simulator 2[3] is one of the oldest simulator available for simulation of wired, wireless, satellite networks, etc. For more than a decade, it satisfies most of the researchers/students across the globe in simulating the networks. It has a strong community that helps developers, researchers across the internet.  NS2 was criticized because of the complex architecture it has (OTcl and C++), but it supports the oldest to latest the protocol that were available for the wired or wireless networks.  NS2 is completely open source and free.

Network Simulator 3 [NS3]

NS3 [14] is another simulator available for less than a decade and it supports network components of recent developments, unlike NS2, the architecture of ns3 is simpler and one can simulate a network using either C++ or python scripts. NS3 is evolving these days to a greater extent and will come with new protocols, new networks, etc in each of their releases. NS3 is completely open source and free.

OMNeT++

OMNeT++[15] another tool that supports many protocols, network entities using the framework INET which is coming as a third party interface. OMNeT++ is built on the eclipse framework and the development and deployment is very easy as it as a richer GUI that supports the developers to form a network very easy.  It is built over C++ and most of the developmental modules are developed in C++ and there is a configuration file (omnetpp.ini) which solves the purpose of forming a network either in a text mode or in a graphical mode.  All these things available at a free cost. OMNEST is the commercial version.

OPNET

This is expensive commercial software available for network simulation and is available with source codes for unrestricted protocols. Trial version is available on request. It contains excellent manual. It has a full-fledged GUI with XML based support for scenario generation. Because of its heavy weight components, this is a slow simulator.

There are various other simulators too in the market that solves the purpose of narrow network research. So, the developers once identified a network, there are choices available for them to select the perfect simulator for their research. The following table will list some of the key comparisons between the simulators

Name

OPNET

NS2

NS3

OMNeT++

Cost

Highly expensive.

Free and Open Source

Free and Open Source

Academic Version is Free

Support

Good manual with source codes

Proper documentation

Proper documentation

Documentation is available

Topology/Scenario

GUI

OTcl

C++ or Python

GUI with omnetpp.ini

Languages/scripts used

C++

OTcl and C++

C++ and Python

C++

Forum /Community Help

Less

Best

Good

Good

Overall Rating

Expensive and highly commercial, simulation is also slow, suited best for the industries

Best for latest and faster simulations

Best for latest and faster simulations

Need for a third party framework for a given network. Also issue with version compatibility

1.3 Time driven and Event Driven Simulations

Usually network simulations carried out either in time driven or event driven. Each of them have their own pros and cons. This topic will show you the difference between these simulations.

Time driven Simulation

Time driven simulation is also called as discrete time simulation. The simulation is carried out on a fixed time interval. The time interval in which a task is running is assumed to be running before the end of the interval though the task would have arrived at the beginning of the interval.

For example:

Assume ∆t is the interval in which the task is running (Assuming a packet arrives in ∆t)

∆t = t2- t1.

Suppose if the packet arrives t1+0.001 and it may be running before the time t2. So sometimes, the packet may have to wait for a shorter duration of time because of this kind of simulation.

A simple pseudo code shows

For t = 1 to time

{

If (packet arrival)

Buffer ++;

Else (packet departure)

Buffer—

Print (Buffer);

}

This shows the time driven simulation has some limitations in networks.

Event driven Simulation

Event driven simulation as the name says, it handles some set of events using a scheduler or a handler.  Here are some of the key features of event driven simulation

  • Discrete set of events can be handled by a scheduler
  • One event upon completes triggers the next events
  • The events are fired as random intervals and are scheduled by the handler
  • The simulation may be stopped once all the events are executed or at a predefined time (where we want to end the simulation). In short, the stopping occurs when the system reaches a particular state or particular time.

Here is the pseudo code for Event driven simulation

Initialize the system

Initialize the events

While (true)

     Collect information from the current event.

     Remove first event from the list and handle it.

     Set time to the event

When compared event driven simulation has upper hand over the time driven simulation as in the latter case, the time is wasted in difference of timing. But selecting a small ∆t does not solve the purpose as the computational complexity of handling the network dynamics may not suite.

This book is demonstrates the Network Simulator 2 (NS2) which is a discrete event simulator that handles the network dynamics using discrete number of events that are handled by a scheduler. Also ns2 supports four different types of scheduler namely calendar (Default), heap, simple linked list and real time scheduler.  

1.4 Modeling for Network Simulation

The most difficult part in simulation of network is the selection of a Model. Selecting a model needs the thorough knowledge of network elements, problem specification and the deep knowledge of the system under study. So, to analyse a given network under study, here are steps that can be used for performance analysis [16]

  • Problem formulation and system model definition
  • Performance Metrics definitions
  • Various levels under study
  • Data collection
  • Selection of simulation environment
  • Verification and validation
  • Experimentation and analysis

1.5 Conclusion

This chapter deals with the elements of network simulation that compared time driven and event driven simulation. Also this chapter tells the list of network simulators that are available for research and development. This chapter compares various simulators based on their usage and features.                                   

Comments

Popular posts from this blog

Installing ns3 in Ubuntu 22.04 | Complete Instructions

In this post, we are going to see how to install ns-3.36.1 in Ubuntu 22.04. You can follow the video for complete details Tools used in this simulation: NS3 version ns-3.36.1  OS Used: Ubuntu 22.04 LTS Installation of NS3 (ns-3.36.1) There are some changes in the ns3 installation procedure and the dependencies. So open a terminal and issue the following commands Step 1:  Prerequisites $ sudo apt update In the following packages, all the required dependencies are taken care and you can install all these packages for the complete use of ns3. $ sudo apt install g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libclang-dev llvm-

Installation of NS2 (ns-2.35) in Ubuntu 20.04

Installation of NS2 (ns-2.35) in Ubuntu 20.04 LTS Step 1: Install the basic libraries like      $] sudo apt install build-essential autoconf automake libxmu-dev Step 2: install gcc-4.8 and g++-4.8 open the file using sudo mode $] sudo nano /etc/apt/sources.list Include the following line deb http://in.archive.ubuntu.com/ubuntu bionic main universe $] sudo apt update $] sudo apt install gcc-4.8 g++-4.8 Step 3:  Unzip the ns2 packages to home folder $] tar zxvf ns-allinone-2.35.tar.gz $] cd ns-allinone-2.35/ns-2.35 Modify the following make files. ~ns-2.35/Makefile.in Change @CC@ to gcc-4.8 change @CXX@ to g++-4.8 ~nam-1.15/Makefile.in ~xgraph-12.2/Makefile.in ~otcl-1.14/Makefile.in Change in all places  @CC@ to gcc-4.8 @CPP@ or @CXX@ to g++-4.8 open the file: ~ns-2.35/linkstate/ls.h Change at the Line no 137  void eraseAll() { erase(baseMap::begin(), baseMap::end()); } to This void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); } All changes made Step 4: Open a new termi

Installation of NS2 in Ubuntu 22.04 | NS2 Tutorial 2

NS-2.35 installation in Ubuntu 22.04 This post shows how to install ns-2.35 in Ubuntu 22.04 Operating System Since ns-2.35 is too old, it needs the following packages gcc-4.8 g++-4.8 gawk and some more libraries Follow the video for more instructions So, here are the steps to install this software: To download and extract the ns2 software Download the software from the following link http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download Extract it to home folder and in my case its /home/pradeepkumar (I recommend to install it under your home folder) $ tar zxvf ns-allinone-2.35.tar.gz or Right click over the file and click extract here and select the home folder. $ sudo apt update $ sudo apt install build-essential autoconf automake libxmu-dev gawk To install gcc-4.8 and g++-4.8 $ sudo gedit /etc/apt/sources.list make an entry in the above file deb http://in.archive.ubuntu.com/ubuntu/ bionic main universe $ sudo apt update Since, it&#