Network simulators are developed to propose a variety of networks and protocols and NS (version 2) is a simulator that works under UNIX. NS2 is an object-oriented network simulator that was developed at UC Berkeley and it simulates variety of IP networks. NS is written in two languages that are C++ and OTcl (Tcl script language) that makes NS2 a more consistent simulator. NS is primarily useful for simulating LANs and WANs.
It implements network protocols such as TCP and UDP and the behavior of traffic source such as FTP, Telnet, Web, CBR and VBR, mechanism for managing router queue such as Drop Tail, RED and CBQ, routing algorithms and more. NS also implements multicasting and some of the MAC layer protocols for LAN simulations.
- 4.2.1NS2 SIMULATOR:
NS2 is an object oriented simulator that is based on two languages, an object-oriented simulator (C++), and OTcl (object-oriented Tcl) interpreter. NS2 simulator has rich library of protocol object and the network. Compiled C++ hierarchy makes the simulation efficient and also execution times are made faster whereas with the help of OTcl script a network topology is simulated and that OTcl script is provided by the user.
Get your grade
or your money back
using our Essay Writing Service!
NS2 uses two languages because simulator has two dissimilar sorts of tasks to perform. Firstly, for comprehensive simulations of protocols, a programming language is required that can efficiently control bytes, packet headers, and implementation of algorithms that can run over huge data sets. Secondly, in network research, to some extent there are varying parameters and quickly various number of situations needs to be explored so iteration time becomes important.
OTcl is a language that is implemented for configuration purpose and setup of the data. C++ can be used when processing control of the flow of each packet is needed. C++ is quicker to run and simulation is also done in a fast way but it is slower in case if we want to make changes in the program. So C++ is appropriate for implementation of detailed protocol. C++ language is used for data and is a foundation of NS2. OTcl (Object Tool Command Language) is quite slower in execution but it can be changed promptly and repeatedly and hence is suitable for simulation configuration and for control purpose. Through tclcl provided by NS2, objects and variables can come into view on both languages. NS2 isolates the data path execution from control path executions to make network more efficient.
C++ and OTcl both languages are intimately related to each other. If we see from the user's viewpoint, there is a direct link between a class in the interpreted language OTcl and the one in the compiled language C++.
- 4.2.2NETWORK COMPONENTS:
An OTcl class hierarchy of NS is shown below that can be helpful in understanding the basic network components of NS.
TclObject class is the root of the hierarchy and is the super class of OTcl library objects that includes scheduler, network components, timers and NAM.
NsObject class is the super class of essential objects of network component that manage packets, which may create network objects such as nodes and links.
The network components are moreover divided into two subclasses, Connector and Classifier that are based on the number of the possible output data paths. The objects with distinct output data path are under the Connector class and Classifier class contains switching objects with multiple output data paths.
Below the classifier class, there come Addrclassifier and Mclassclassifier subclasses that are in actual components of a unicast and multicast nodes respectively. Node is a composite object containing node entry object and classifiers. Unicast nodes are the default nodes in NS but for the creation of Multicast nodes, notification in the input OTcl script is required.
Under the connector class, there comes agent class which has TCP and UDP protocols defined in it. Delay class has the packets that are not in the queue or are rejected by the queue. Trace class has EnqT, DeqT, DrpT and Recv objects. When a packet is received by the trace object then the object without consuming simulation time writes to the particular trace file and the packet is then passed to the next object. Queue class is further classified into RED and DROPTAIL queue that can be utilized according to the concern of the user. Snoopqueue class has In, Out, Drp and Edrp objects. When a packet arrives, a snoop queue object informs the queue monitor object. The queue monitor using this information monitors the queue and the packet is transferred to the required destination.
- 4.2.3EVENT SCHEDULER:
Always on Time
Marked to Standard
In NS2, an event is defined as a packet ID that is unique for each packet with scheduled time. An event scheduler discharge the events in the event queue that is scheduled for the current time and activates the proper network component that perform appropriate action related with packet that is pointed by the event. There is no simulation time consumed by the network components. Event scheduler is used by the network components that need a delay to handle a packet by subjecting an event for the packet and waiting for the event to discharge itself for further action. There are two different types of event schedulers
- Real time scheduler: It is used for emulation which allow the simulator to work together with a real network
- Non-real time scheduler: There are three implementations available for this i.e. Heap, List and Calendar. The default is set as Calendar.
- 4.2.4NAM (THE NETWORK ANIMATOR):
Nam is an animation tool that is based on Tcl/TK. NAM is used to view the traces of network simulation and to read a large number of animation data sets. Large data sets are handled by keeping a small amount of information in the memory that is read whenever it is needed.
To use NAM, a trace file is generated by the NS. The trace file has topology information in it including number of nodes, the link in between them and the traces of packets generated. After the generation of trace file, it is animated by NAM that reads the trace file and creates a topology.
In order to transfer data from one node to another, NS packet is used that contains all the required information. With the formation of simulator object, a packet header format is initialized containing a header stack and data space pointer that optional and is mostly set to NULL. Header stack has defined headers such as common header used by the objects, IP header, TCP header, RTP header that is used by UDP and a trace header. For the communicating the packet from one application to another, a new header is created each time that writes the data that is received from the client application to the server application.
4.4USER VIEW OF NS2:
NS is Object-oriented Tcl interpreter that has:
- Simulation event scheduler
- Object libraries of network component
- Network setup module libraries
To use NS, programming is done in OTcl script language. To establish and execute a simulation network, an OTcl script written by the user activates an event scheduler and sets up the network topology with the help of network objects and the plumbing functions present in the library. The event scheduler tells traffic sources about the start and stop time of transmitting packets.
Plumbing modules are executed as member functions of the base simulator object. Plumbing is used to set up a network as setting up a network means to look at possible data paths among network objects. Making a new network object in NS2 is quite simple as a user can easily make an object either by writing an original object or by creating object from the object library and then examining the data path through the object.
4.5ARCHITECTURE OF NS2:
The architectural view of NS is shown as under:
To understand this figure, a user that is designing and running simulations can be regarded as positioned at the bottom left this figure. Simulations are done in Tcl using the simulator objects in the OTcl library. The event schedulers and most of the network components are executed in C++ and accessible to OTcl through an OTcl linkage that is implemented using tclcl. Tclcl is glue library that makes it easy to share functions, variables, etc. So NS, which is OO extended Tcl interpreter with network simulator libraries is made in this way.
4.6SOME APPLICATIONS OF NS2:
Some applications of NS2 are:
- 4.6.1PARETO ON/OFF TRAFFIC GENERATOR:
With the help of NS2, many traffic generators can be implemented and out of them Pareto On/Off generator is a flourishing implementation on NS2. In this, traffic is generated according to the distribution of On/Off status. Packets are only sent during the On status at a fixed rate. With constant size packets, On and Off periods are taken from the distribution. With the help of these generators traffic with long range dependency can be generated effortlessly.
This Essay is
a Student's Work
This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.Examples of our work
The Pareto On/Off traffic generator can also be used as a Web traffic generator with an assumption that sizes of web objects form a Pareto distribution.
- 4.6.1LAN EXAMPLE IN NS2:
Local area networks are successfully implemented on NS2 although the behavior of the local area networks (LAN) is essentially different from the point-to-point links. A new node type is created in NS2 that is called LanNode that simulates the network having sharing and conflicting properties of a LAN.
- 4.6.2MOBILE NETWORKING IN NS2:
In NS2, mobile networking can effortlessly be done with Mobile Node command that can be helpful in the simulation of ad-hoc networks and wireless LANs etc. With the help of Mobile Node command in NS2, movement within a given topology can easily be achieved and the signals are also transmitted and received from a wireless channel. Periodic updates of the position are an extra advantage that can be achieved by implementing networks on NS2.
- 4.6.3SATELLITE NETWORKING IN NS2:
Networking aspects of the satellite systems are studied with the help of NS2 that involves MAC, link layer, routing, and transport protocols. NS2 simulates the satellite networks such as geostationary satellites having multiple users per uplink/downlink and different links and Low-earth-orbiting satellites.
- 4.6.4RADIO PROPAGATION MODELS IN NS2:
Radio propagation models are also implemented in NS2 that are used to forecast the received signal power of each packet. There is a receiving threshold at the physical layer of each wireless node. If signal power of the received packet is below this threshold, the MAC layer drops that packet. Free space model, two-ray ground reflection model and the shadowing model are the three propagation models that are implemented in NS2 up till now.
- 4.6.5ENERGY MODEL IN NS2:
Energy models that are the attributes of a node are also implemented in NS2 and with the help of it, energy level of the node in a mobile host can be determined at the start of the simulation. The received and transmitted power of every packet can also be known with the help of initialEnergy_ command in NS2.
- 4.6.6IMPLEMENTATION OF XCP(EXPLICIT CONGESTION CONTROL PROTOCOL) IN NS2:
XCP is a feedback-based system and it makes use of a router feedback that helps in controlling blockage and over crowdness in the network hence avoiding congestion. Basically XCP is a protocol that can be applied on the transport layer. This protocol is mostly used in the networks with high delay-bandwidth. It is better as compared with TCP as TCP becomes unstable in the case of packet loss in the network. With the help of feedback, stability and efficiency can be achieved easily.
Directory in NS2 for the execution of this protocol is ~ns/xcp. The protocol is utilized in the both TCP client and server sides with the help of a router.