My Project | Low Rate Wireless Personal Area Networks in NS2

My Final Year Project... Thought of Sharing with others..!

Welcome Friends..

I Just finished my graduation and was idle so.. thought of publishing my final year project and finally i made it.
 My project was "Low Rate Wireless Personal Area Network- LRWPAN (IEEE 802.15.4) implementation in Network Simulator NS2". I have posted all my report. Browse through and if you find any mistakes and doubts please do write comments.
Best of Luck

INTRODUCTION

           The IEEE 802.15.4 has recently been adopted as a communication standard for low data rate, low power consumption and low cost Wireless Personal Area Networks. This protocol is quite flexible for a wide range of applications if appropriate tuning of its parameters is carried out. Importantly, the protocol also provides real-time guarantees by using the Guaranteed Time Slot (GTS) mechanism. Indeed, the GTS mechanism is quite attractive for time-sensitive Wireless Sensor Network (WSN) applications, particularly when supported by cluster-tree network topologies, such as defined in the ZigBee standard... Continue Reading


MOTIVATION

The wireless market has been traditionally dominated by high end technologies, but so far Wireless Personal Area Networking products have not been able to make a significant impact on the market. While some technologies like the Bluetooth have been quite a success story, in the areas like computer peripherals, mobile devices, etc, they couldn’t be expanded to the automation arena. This led to the invention of the wireless low data rate personal area networking technology, Zigbee (IEEE 802.15.4),... Continue Reading


Evolution of zigbee

During the last decade there has been an explosion of devices using sensor technologies for control and monitoring purposes. Wired Sensors are now intended to be replaced with wireless technologies. Corporates have been envisioning of a digital home where every device is connected, and remotely controlled and monitored. Even though a perfect digital home is yet a mirage, we are now able to apply several technologies to suite our home and industrial networking needs. However, this concept of a digitally connected home has received a luke warm response due to lack of viable solutions... Continue Reading


Overview of our project 

The objective of our project is to build a simulation model of LR-WPAN and simulated the model using the Network simulator NS2. The WPAN Low Rate Task Group (TG4) is chartered to investigate a low data rate solution with multi-month to multi-year battery life and very low complexity.  This standard specifies two physical layers: an 868 MHz/915 MHz direct sequence spread spectrum PHY and a 2.4 GHz direct sequence spread spectrum PHY.  The 2.4 GHz PHY supports an over air data rate of 250 kb/s and the 868 MHz/915 MHz PHY supports over the air data rates of 20 kb/s and 40 kb/s.... Continue Reading

 

Applications

There has been tremendous excitement on part of the corporates, the market and the consumers alike because of the wide spectrum of applications that zigbee has to other. It is a revolutionary new technology built to compliment or replace existing not so successful technologies. Automation is the buzz word for zigbee. It stands to automate our household, corporate buildings and industries.... Continue Reading

AN OVERVIEW OF IEEE 802.15.4

Compared with wired networks, wireless networks provide advantages in deployment, cost, size, and distributed intelligence. Wireless technology not only enables users to set up a network quickly, but also enables them to set up a network where it is in-convenient or impossible to wire cables. The “care free” feature and convenience of deployment make a wireless network more cost-efficient than a wired network in general... Continue Reading


Network Topologies

A Low rate WPAN supports three different types of topologies.

  •         Star Topology
  •         Peer-to-Peer Topology
  •         Cluster Tree/Mesh Topology... Continue Reading

Network Formation

Network formation is part of the network layer functionalities. An example run of the various steps involved for a network formation is presented:

Star-Topology

  •          Assume a full function device is switched ON for the first time.
  •         It starts scanning its operating channels for possible beacon transmissions, from other PANs... Continue Reading

Architecture

The LR-WPAN architecture is defined in terms of a number of blocks in order to simplify the standard. These blocks are called layers. Each layer is responsible for one part of the standard and offers services to the higher layers. The layout of the blocks is similar to the structure of the OSI layered architecture. But the IEEE 802.15.4 standard only defines the PHY and the MAC layers. The upper layers of networking and application have been left for the application developers. An LR-WPAN device comprises a PHY, which contains the radio frequency (RF) transceiver along with its low-level control mechanism, and a MAC sub layer that provides access to the physical channel for all types of transfer. The figure 2.3 depicts the layered architecture of IEEE 802.15.4... Continue Reading


Functional Overview

The Superframe structure

The superframe structure (Fig: 2.4) is an optional part of a WPAN. It is the time duration between two consecutive beacons. The structure of the superframe is determined by the coordinator. The coordinator can also switch off the use of a superframe by not transmitting the beacons. The superframe duration is divided into 16 concurrent slots. The beacon is transmitted in the first slot. The remaining part of the superframe duration can be described by the terms, CAP, CFP and Inactive. The superframe is used to provide vital statistics like synchronization, identifying the PAN and the superframe structure, to the devices connected in a Wireless PAN. This information is critical for the operation of the PAN in a Beacon enabled network... Continue Reading


Data Transmission

There can be three different types of data transmission possible. They are

Ø Transmission from a device to the coordinator

Ø Transmission from the coordinator to the device

Ø Transmission between any two devices.

In a star topology only the first two transmission techniques are possible...

IEEE 802.15.4 Service Primitives

The new IEEE standard, 802.15.4, defines the physical layer (PHY) and medium access control sublayer (MAC) specifications for low data rate wireless connectivity among relatively simple devices that consume minimal power and typically operate in the Personal Operating Space (POS) of 10 meters or less. An 802.15.4 network can simply be a one-hop star, or, when lines of communication exceed 10 meters, a self-configuring, multi-hop network. A device in an 802.15.4 network can use either a 64-bit IEEE address or a 16-bit short address assigned during the association procedure, and a single 802.15.4 network can accommodate up to 64k (216 ) devices. Wireless links under 802.15.4 can operate in three license free industrial scientific medical (ISM) frequency bands. These accommodate over air data rates of 250 kb/sec (or expressed in symbols, 62.5 ksym/sec) in the 2.4 GHz band, 40 kb/sec (40 ksym/sec) in the 915 MHz band, and 20 kb/sec (20 ksym/sec) in the 868 MHz. Total 27 channels are allocated in 802.15.4, with 16 channels in the 2.4 GHz band, 10 channels in the 915 MHz band, and 1 channel in the 868 MHz band... Continue Reading


PHY Primitives

The primitives indicate the functions organized by each layer. The PHY layer is responsible for the following tasks:

Ø Activation and deactivation of the radio transceiver

Ø Energy Detection

Ø Link Quality Indication Measurement

Ø Clear Channel Assessment

Ø Data Transmission and Reception 

Data Transmission

When ever there is data to be transmitted, the MAC layer Management Entity calls upon the PHY layer with these primitives to transmit a data frame... Continue Reading


MAC Primitives

Data Transmission

The following primitives are used for data transmission from the next higher layer. The result is indicated with confirm primitive. These responses are prepared with respect to its own requests for data transmission to the PHY layer.

MCPS-DATA.request : Requests the transmission of a data unit from the local SSCS entity. It prepares the corresponding MPDU from the incoming SPDU and this is passed on to the PHY layer for transmission...

Continue Reading

NETWORK SIMULATOR

Purpose

NS (version 2) is an object-oriented, discrete event driven network simulator developed at UC Berkely written in C++ and OTcl. NS is primarily useful for simulating local and wide area networks. Although NS is fairly easy to use once you get to know the simulator, it is quite difficult for a first time user, because there are few user-friendly manuals. Even though there is a lot of documentation written by the developers which has in depth explanation of the simulator, it is written with the depth of a skilled NS user. The purpose of this project is to give a new user some basic idea of how the simulator works, how to setup simulation networks, where to look for further information about network components in simulator codes, how to create new network components, etc., mainly by giving simple examples and brief explanations based on our experiences. Although all the usage of the simulator or possible network simulation setups may not be covered in this project, the project should help a new user to get started quickly.

 

3.1.2 Overview

NS is an event driven network simulator developed at UC Berkeley that simulates variety of IP networks. It implements network protocols such as TCP and UPD, traffic source behavior such as... Continue Reading

 

Simple simulation

This section shows a simple NS simulation script and explains what each line does. An OTcl script that creates the simple network configuration and runs the simulation scenario is shown... Continue Reading


EXPLANATION FOR A SIMPLE PROGRAM

The following is the explanation of the script above. In general, an NS script starts with making a Simulator object instance.

set ns [new Simulator]: generates an NS simulator object instance, and assigns it to variable ns (italics is used for variables and values in this section).

What this line does is the following:

Initialize the packet format (ignore this for now)

Create a scheduler (default is calendar scheduler)

Select the default address format (ignore this for now)

 The "Simulator" object has member functions that do the following:

  Create compound objects such as nodes and links (described later)

Connect network component objects created (ex. attach-agent)

Set network component parameters (mostly for compound objects)

Create connections between agents (ex. make connection between a "tcp" and "sink")

Specify NAM display options

Etc... Continue Reading

 

The Network Animator

The network simulator (ns) comes along with an interesting tool, called the Network Animator (NAM). Nam is a Tcl/TK based animation tool for viewing network simulation traces and real world packet trace data. The design theory behind nam was to create an animator that is able to read large animation data sets and be extensible enough so that it could be used in different network visualization situations... Continue Reading

 SIMULATION SETUP

First the simulation model of star and peer-to-peer technology is designed. The following steps are done to simulate the model,

·        Generate the scripts for node arrangement

·        Creating TCL scripts for both the topologies

·        Running the simulation... Continue Reading


Model of Star topology

The node scenario generation is done using the star.scn file. The Start topology model has the following parameters simulated

  • Simulation Parameters

Simulation is a flexible means for assessment of the performance offered by a telecommunication system. However, identifying the correct simulation parameters is key for a successful and nearly realistic analysis


Model of Peer-to-peer topology

The simulation parameters for peer-to-peer topology are mostly simulated similar to that of star topology but for some parameters. The peer-to-peer topology has main advantage that the node can transmit data to different... Continue Reading

 

Simulation Results

The simulation process is carried out systematically as shown,

·        Running Ns2

·        Path setting for NS2

·        Opening Terminal window

·        Running Star.tcl an d Peer.tcl

·        NAM Analysis

Steps to Simulate our project

Ø Firstly the Terminal window in fedora is opened

Ø The path for the NS is loaded

Ø Run the command ns star.tcl or peer.tcl

Continue Reading


[1] IEEE 802.15.4 Standard-2003, “Part 15.4: Wireless Medium Access Control (MAC) and Physical Layer (PHY) Specifications for Low Rate Wireless Personal Area Networks (LR WPANs)”, IEEE SA Standards Board, 2003.

[2] slides by John Heidemann

[3] Retrieved from ns2 website: http://www.isi.edu/nsnam/ns on 12th of Jan 2008

[6] IEEE computer society, “Wireless MAC and PHY Specifications For LR-WPANS” IEEE,2003.

[7] Jianliang Zheng, and Myung J. Lee, “Will IEEE 802.15.4 Make Ubiquitous Networking a Reality?: A Discussion on a Potential Low Power Low Bit Rate Standard” IEEE Communications magazine, pp. 140-146, June 2004.


LR-WPAN is a promising new wireless short range communications technology. It may not have yet swept the short range communications market but it is surely making its presence felt. An alliance of companies called the Zibgbee alliance, have already joined hands to benefit from this new technology and share information and develop new applications. With its promises of short range communications with very low datarates and ultra low power consumption, it has created a market for itself.
A detailed study of the zigbee technology with its internal architecture, and the layered structure has been conducted. Followed by it is a similar study of the simulator environment (ns-2). A detailed study of the zigbee modules built under ns-2 with reference to its implementation in the standard also has been done. Later a well behaved and near realistic simulation scenario is built in TCL. The zigbee modules have been exclusively tested for the simulator environment and several loopholes have been identified. These loopholes are further investigated to replace them with working modules. Both Star and Peer-to-peer topologies have been studied and finalized that the star topology can be used effectively for short range application whereas the peer-to-peer can be used for large application which involves many number of devices.


The simulation process is carried out systematically as shown,
· Running Ns2
· Path setting for NS2
· Opening Terminal window
· Running Star.tcl an d Peer.tcl
· NAM Analysis
Steps to Simulate our project
Ø Firstly the Terminal window in fedora is opened
Ø The path for the NS is loaded
Ø Run the command ns star.tcl or peer.tcl

Fig. 4.2 Simulation terminal for star


The output terminal window appears as shown. In the terminal window the nodes synchronization is stated.
The output Nam appears after the project is executed.
The NAM window shows the animation of the entire process that takes the simulation to complete.

Fig. 4.3 NAM snapshot of Star topology


The peer-to-peer topology is simulated by typing the command
$ ns peer.tcl
The following window shows the simulation in terminal window
Fig. 4.4 simulation terminal for peer-to-peer topology


The following Output Nam will be automatically created and shown as







Fig. 4.5 NAM snapshot of peer-to-topology

Ø The trace files will be generated for both the files,
Ø Star.tr and peer.tr can be viewed for more analysis
Ø The trace files will give a complete scenario of what is been simulated for every micro seconds.

The simulation parameters for peer-to-peer topology are mostly simulated similar to that of star topology but for some parameters. The peer-to-peer topology has main advantage that the node can transmit data to different nodes, that is the communication is possible between the nodes.

Parameter
Value
Traffic Type
FTP
Number of nodes
11
Number of coordinator
1
Traffic direction
Node à node
Simulation time
100 seconds
Figure 4.2 Peer topology parameters

The node scenario generation is done using the star.scn file. The Start topology model has the following parameters simulated
4.1.1 Simulation Parameters
Simulation is a flexible means for assessment of the performance offered by a telecommunication system. However, identifying the correct simulation parameters is key for a successful and nearly realistic analysis
of any study. The following discussion focuses on the task of identifying the correct parameters to generate a realistic network scenario, while explaining their meaning and their reason of choice (if any) in detail. General parameters for basic simulations are described here. However, the parameters that impact the network performance are discussed in the next chapter where we introduce the performance analysis of the system.


Traffic Parameters
Traffic Type
This project report is based on results simulated with a FTP application, based on the internet protocol, UDP (User Datagram Protocol). Its primary features are:
. Single Way Transmission (No Acknowledgements)
. Defined Packet size
. Defined Packet Interval
. Unreliable Data Transmission
FTP traffic with a TCP connection is done due to its advanced features like congestion control, requiring dynamic adjustment of the transmission rate based on the traffic conditions; it is hard to implement simplistic and power efficient devices, for menial applications.
Packet Size
The packet size is assumed be to 70bytes. This is exclusive of the RTR, MAC and PHY layer headers.
Traffic Direction
The traffic flows are all one way, with the communication directed to the coordinator. The study is being investigated with particular focus on low datarate wireless sensors communicating with a central node updating it with the application information.
Number of Nodes
The simulation is carried out with 7 active nodes. One of them being the coordinator.
Coordinators
Since a simple star network topology is being simulated, only a single coordinator is present.
Node Movement
The nodes remain stationary.
Node Position
The nodes are placed along an imaginary circle around the coordinator, with radius equal to the personal operating space of the nodes.
The trace and node parameters are summarized in the following table.



Figure 4.1 Star topology parameters

scen_gen
. Parameters: It accepts the following command line parameters
– scen_gen [number-of-nodes] [X-Pos-of-coord] [Y-Pos-of-coord] [Personal-Operating-Space]
Number-of-nodes: Number of nodes to be placed around the coordinator.
X-Pos-of-coord: X position of the coordinator, with respect to the area of the network dimensions.
Y-Pos-of-coord: Y position of the coordinator, with respect to the area of operation of the network.
Personal-Operating-Space: The operating space or the reachabilitiy of the coordinator. The nodes are required to be placed equidistantly around the coordinator, for the test scenarios in this report, within the operating space of the coordinator, this parameter is utilized to arrange the nodes along an imaginary circle drawn around the coordinator with this value
as radius.
Example: scen gen 11 25 25 10
. Functionality: This utility would automatically generate the coordinates of the nodes to place them around the coordinator, along an imaginary circle drawn with a radius equal to the Personal Operating Space. The node position file, holding the positions of all the nodes around the coordinator is generated from star.scn. Currently this file is being generated with the utility, scen gen. However, it is a simple text file, which can be easily edited to place the nodes at desired positions. Note that the positions of the nodes should respect the boundaries of the network mentioned in the source file, star.tcl
Working: Running the utility would create a file, star.scn, to be used by the source scenario file, star.tcl.
The scn file for star.tcl
$node_(0) set X_ 25
$node_(0) set Y_ 25
$node_(0) set Z_ 0
$node_(1) set X_ 20
$node_(1) set Y_ 16.34
$node_(1) set Z_ 0
$node_(2) set X_ 15
$node_(2) set Y_ 25
$node_(2) set Z_ 0
$node_(3) set X_ 20
$node_(3) set Y_ 33.66
$node_(3) set Z_ 0
$node_(4) set X_ 30
$node_(4) set Y_ 33.66
$node_(4) set Z_ 0
$node_(5) set X_ 35
$node_(5) set Y_ 25
$node_(5) set Z_ 0
$node_(6) set X_ 30
$node_(6) set Y_ 16.34
$node_(6) set Z_ 0

The resultant position file for the nodes would like some think like this:
Figure 4.1 Node arrangement

SIMULATION MODEL
First the simulation model of star and peer-to-peer technology is designed. The following steps are done to simulate the model,
· Generate the scripts for node arrangement
· Creating TCL scripts for both the topologies
· Running the simulation in network simulator
· Analyzing using network simulator
System Requirements
· Operating system – Linux fedora 7
· Package – Ns allinone 2.30
· Scripts – TCL, C++


The network simulator (ns) comes along with an interesting tool, called the Network Animator (NAM). Nam is a Tcl/TK based animation tool for viewing network simulation traces and real world packet trace data. The design theory behind nam was to create an animator that is able to read large animation data sets and be extensible enough so that it could be used in different network visualization situations.Under this constraint nam was designed to read simple animation event commands from a large trace file. In order to handle large animation data sets a minimum amount of information is kept in memory. Event commands are kept in the file and are read from the file whenever necessary. A snapshot of NAM in action is presented
These are the features that can be done using NS-2
• Simulate different scenarios with existing protocols (TCP/UDP)
• Wired Routing protocols - Distance Vector and Link State (with the link state patch)
• Ad-Hoc Routing protocols - DSR, AODV, TORA
• MAC protocols - 802.3, 802.11 (Wireless MAC)
• Scheduling disciplines - DropTail, RED, WFQ, DRR, LQD etc.
• Different traffic characterizations - Poisson, Exponential, Pareto etc.
• Modify NS-2 to implement your own versions of the above protocols or even code totally new protocols
• Measurement of Statistics:
• Throughput, Delay, Jitter etc.
• Queue Monitoring, Drops at Queues.
• Literally all that you will need to know with your simulations.
Graphic visualization - using “nam” (Network Animator)

The following is the explanation of the script above. In general, an NS script starts with making a Simulator object instance.
set ns [new Simulator]: generates an NS simulator object instance, and assigns it to variable ns (italics is used for variables and values in this section).
What this line does is the following:
Initialize the packet format (ignore this for now)
Create a scheduler (default is calendar scheduler)
Select the default address format (ignore this for now)
The "Simulator" object has member functions that do the following:
Create compound objects such as nodes and links (described later)
Connect network component objects created (ex. attach-agent)
Set network component parameters (mostly for compound objects)
Create connections between agents (ex. make connection between a "tcp" and "sink")
Specify NAM display options
Etc.
Most of member functions are for simulation setup (referred to as plumbing functions in the Overview section) and scheduling, however some of them are for the NAM display. The "Simulator" object member function implementations are located in the "ns-2/tcl/lib/ns-lib.tcl" file.
$ns color fid color: is to set color of the packets for a flow specified by the flow id (fid). This member function of "Simulator" object is for the NAM display, and has no effect on the actual simulation.

$ns namtrace-all file-descriptor: This member function tells the simulator to record simulation traces in NAM input format. It also gives the file name that the trace will be written to later by the command $ns flush-trace. Similarly, the member function trace-all is for recording the simulation trace in a general format.
proc finish {}: is called after this simulation is over by the command $ns at 5.0 "finish". In this function, post-simulation processes are specified.
set n0 [$ns node]: The member function node creates a node. A node in NS is compound object made of address and port classifiers (described in a later section). Users can create a node by separately creating an address and a port classifier objects and connecting them together. However, this member function of Simulator object makes the job easier.
$ns duplex-link node1 node2 bandwidth delay queue-type: creates two simplex links of specified bandwidth and delay, and connects the two specified nodes. In NS, the output queue of a node is implemented as a part of a link, therefore users should specify the queue-type when creating links. In the above simulation script, DropTail queue is used. If the reader wants to use a RED queue, simply replace the word DropTail with RED. The NS implementation of a link is shown in a later section. Like a node, a link is a compound object, and users can create its sub-objects and connect them and the nodes.
$ns queue-limit node1 node2 number: This line sets the queue limit of the two simplex links that connect node1 and node2 to the number specified. At this point, the authors do not know how many of these kinds of member functions of Simulator objects are available and what they are.



$ns duplex-link-op node1 node2 : The next couple of lines are used for the NAM display. To see the effects of these lines, users can comment these lines out and try the simulation.
Now that the basic network setup is done, the next thing to do is to setup traffic agents such as TCP and UDP, traffic sources such as FTP and CBR, and attach them to nodes and agents respectively.
set tcp [new Agent/TCP]: This line shows how to create a TCP agent. But in general, users can create any agent or traffic sources in this way. Agents and traffic sources are in fact basic objects (not compound objects), mostly implemented in C++ and linked to OTcl. Therefore, there are no specific Simulator object member functions that create these object instances. To create agents or traffic sources, a user should know the class names these objects (Agent/TCP, Agnet/TCPSink, Application/FTP and so on). This information can be found in the NS documentation or partly in this documentation. But one shortcut is to look at the "ns-2/tcl/libs/ns-default.tcl" file. This file contains the default configurable parameter value settings for available network objects. Therefore, it works as a good indicator of what kind of network objects is available in NS and what are the configurable parameters.
$ns attach-agent node agent: The attach-agent member function attaches an agent object created to a node object. Actually, what this function does is call the attach member function of specified node, which attaches the given agent to itself. Therefore, a user can do the same thing by, for example, $n0 attach $tcp. Similarly, each agent object has a member function attach-agent that attaches a traffic source object to itself.

$ns connect agent1 agent2: After two agents that will communicate with each other are created, the next thing is to establish a logical network connection between them. This line establishes a network connection by setting the destination address to each others' network and port address pair.
Assuming that all the network configuration is done, the next thing to do is write a simulation scenario (i.e. simulation scheduling). The Simulator object has many scheduling member functions. However, the one that is mostly used is the following:
$ns at time "string": This member function of a Simulator object makes the scheduler (scheduler_ is the variable that points the scheduler object created by [new Scheduler] command at the beginning of the script) to schedule the execution of the specified string at given simulation time. For example, $ns at 0.1 "$cbr start" will make the scheduler call a start member function of the CBR traffic source object, which starts the CBR to transmit data. In NS, usually a traffic source does not transmit actual data, but it notifies the underlying agent that it has some amount of data to transmit, and the agent, just knowing how much of the data to transfer, creates packets and sends them.
After all network configurations, scheduling and post-simulation procedure specifications are done, the only thing left is to run the simulation. This is done by $ns run.

This section shows a simple NS simulation script and explains what each line does. An OTcl script that creates the simple network configuration and runs the simulation scenario is shown.

A Simple Network Topology and Simulation Scenario

This network consists of 4 nodes (n0, n1, n2, n3) as shown in above figure. The duplex links between n0 and n2, and n1 and n2 have 2 Mbps of bandwidth and 10 ms of delay. The duplex link between n2 and n3 has 1.7 Mbps of bandwidth and 20 ms of delay. Each node uses a DropTail queue, of which the maximum size is 10. A "tcp" agent is attached to n0, and a connection is established to a tcp "sink" agent attached to n3. As default, the maximum size of a packet that a "tcp" agent can generate is 1KByte. A tcp "sink" agent generates and sends ACK packets to the sender (tcp agent) and frees the received packets. A "udp" agent that is attached to n1 is connected to a "null" agent attached to n3. A "null" agent just frees the packets received. A "ftp" and a "cbr" traffic generator are attached to "tcp" and "udp" agents respectively, and the "cbr" is configured to generate 1 KByte packets at the rate of 1 Mbps. The "cbr" is set to start at 0.1 sec and stop at 4.5 sec, and "ftp" is set to start at 1.0 sec and stop at 4.0 sec.
A Simple NS Simulation Script is shown below
set ns [new Simulator]
$ns color 0 blue
$ns color 1 red
$ns color 2 white

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf

$ns duplex-link $n0 $n2 5Mb 2ms DropTail
$ns duplex-link $n1 $n2 5Mb 2ms DropTail
$ns duplex-link $n2 $n3 1.5Mb 10ms DropTail

$ns duplex-link-op $n0 $n2 orient right-up
$ns duplex-link-op $n1 $n2 orient right-down
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n2 $n3 queuePos 0.5
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
set udp1 [new Agent/UDP]
$ns attach-agent $n3 $udp1
$udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
Set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
set null1 [new Agent/Null]
$ns attach-agent $n1 $null1
$ns connect $udp0 $null0
$ns connect $udp1 $null1
$ns at 1.0 "$cbr0 start"
$ns at 1.1 "$cbr1 start"
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $n0 $tcp
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1.2 "$ftp start"
$ns at 1.35 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"
puts [$cbr0 set packetSize_]
puts [$cbr0 set interval_]
$ns at 3.0 "finish"
proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf
puts "running nam..."
exec nam out.nam &
exit 0
}
$ns run

Purpose
NS (version 2) is an object-oriented, discrete event driven network simulator developed at UC Berkely written in C++ and OTcl. NS is primarily useful for simulating local and wide area networks. Although NS is fairly easy to use once you get to know the simulator, it is quite difficult for a first time user, because there are few user-friendly manuals. Even though there is a lot of documentation written by the developers which has in depth explanation of the simulator, it is written with the depth of a skilled NS user. The purpose of this project is to give a new user some basic idea of how the simulator works, how to setup simulation networks, where to look for further information about network components in simulator codes, how to create new network components, etc., mainly by giving simple examples and brief explanations based on our experiences. Although all the usage of the simulator or possible network simulation setups may not be covered in this project, the project should help a new user to get started quickly.

3.1.2 Overview
NS is an event driven network simulator developed at UC Berkeley that simulates variety of IP networks. It implements network protocols such as TCP and UPD, traffic source behavior such as FTP, Telnet, Web, CBR and VBR, router queue management mechanism such as Drop Tail, RED and CBQ, routing algorithms such as Dijkstra, and more. NS also implements multicasting and some of the MAC layer protocols for LAN simulations. The NS project is now a part of the VINT project that develops tools for simulation results display, analysis and converters that convert network topologies generated by well-known generators to NS formats. Currently, NS (version 2) written in C++ and OTcl (Tcl script language with Object-oriented extensions developed at MIT) is available. This document talks briefly about the basic structure of NS, and explains in detail how to use NS mostly by giving examples. Most of the figures that are used in describing the NS basic structure and network components are from the 5th VINT/NS Simulator Tutorial/Workshop slides and the NS Manual (formerly called "NS Notes and Documentation"), modified little bit as needed. For more information about NS and the related tools, visit the VINT project home page.

Figure 3.1. Simplified User's View of NS

As shown in Figure 3.1, in a simplified user's view, NS is Object-oriented Tcl (OTcl) script interpreter that has a simulation event scheduler and network component object libraries, and network setup (plumbing) module libraries (actually, plumbing modules are implemented as member functions of the base simulator object). In other words, to use NS, you program in OTcl script language. To setup and run a simulation network, a user should write an OTcl script that initiates an event scheduler, sets up the network topology using the network objects and the plumbing functions in the library, and tells traffic sources when to start and stop transmitting packets through the event scheduler. The term "plumbing" is used for a network setup, because setting up a network is plumbing possible data paths among network objects by setting the "neighbor" pointer of an object to the address of an appropriate object. When a user wants to make a new network object, he or she can easily make an object either by writing a new object or by making a compound object from the object library, and plumb the data path through the object. This may sound like complicated job, but the plumbing OTcl modules actually make the job very easy. The power of NS comes from this plumbing.
NS is written not only in OTcl but in C++ also. For efficiency reason, NS separates the data path implementation from control path implementations. In order to reduce packet and event processing time (not simulation time), the event scheduler and the basic network component objects in the data path are written and compiled using C++. These compiled objects are made available to the OTcl interpreter through an OTcl linkage that creates a matching OTcl object for each of the C++ objects and makes the control functions and the configurable variables specified by the C++ object act as member functions and member variables of the corresponding OTcl object. In this way, the controls of the C++ objects are given to OTcl. It is also possible to add member functions and variables to a C++ linked OTcl object. The objects in C++ that do not need to be controlled in a simulation or internally used by another object do not need to be linked to OTcl. Likewise, an object (not in the data path) can be entirely implemented in OTcl. Figure 3.2 shows an object hierarchy example in C++ and OTcl. One thing to note in the figure is that for C++ objects that have an OTcl linkage forming a hierarchy, there is a matching OTcl object hierarchy very similar to that of C++.
Figure 3.2. C++ and OTcl: The Duality

Data Transmission
The following primitives are used for data transmission from the next higher layer. The result is indicated with confirm primitive. These responses are prepared with respect to its own requests for data transmission to the PHY layer.
MCPS-DATA.request : Requests the transmission of a data unit from the local SSCS entity. It prepares the corresponding MPDU from the incoming SPDU and this is passed on to the PHY layer for transmission.
MCPS-DATA.confirm : Reports the result of the request for the transmission of an SPDU over to a single peer SSCS entity.
2.6.2.2 Data Reception
The following primitives are used for data reception from the next lower layer(PHY). The PHY layer upon receiving a data packet informs the upper layer, with an indication about the received packet. And the MAC layer, after analyzing the indication primitive fields, informs the local SSCS entity of an incoming packet data frame, unless it is intended for itself.
MCPS-DATA.indication : The MCPS-DATA.indication primitive indicates the transfer of a data SPDU (i.e., MSDU) from the MAC sublayer to the local SSCS entity. This indicates the arrival of data from the peer SSCS to the local SSCS entity.
2.6.2.3 Association
The primitives that are used to associate a network node or to provide association services, as applicable to a coordinator, are presented here.
MLME-ASSOCIATE.request: The MLME-ASSOCIATE.request primitive allows a device to request an association with a coordinator. The association request is generated at the next higher layer, (generally the routing layer), however it is not part of this study. The conditions that determine the invoking of the association phase is not defined.
MLME-ASSOCIATE.indication: Indicates the reception of an association request command.
MLME-ASSOCIATE.response : This primitive is used to initiate a response to an MLMEASSOCIATE.indication primitive.
MLME-ASSOCIATE.confirm: The MLME-ASSOCIATE.confirm primitive is used to inform the next higher layer of the initiating device whether its request to associate was successful or unsuccessful.
2.6.2.4 Disassociation
Similar to the primitives described for the association phase, the following primitives are used for the disassociation. Their functionality is exactly inverse to that of their counterparts for the association.
MLME-DISASSOCIATE.request
MLME-DISASSOCIATE.indication
MLME-DISASSOCIATE.response
MLME-DISASSOCIATE.confirm


2.6.2.5 PAN Information Management
The following primitives are used to request and to reply back with information about a particular MAC PIB Value.
MLME-GET.request: The next higher layer issues this primitive to the MAC layer to request information about a particular, MAC PIB.
MLME-GET.confirm: This primitive is used by the MAC layer to reply back to the MLMEGET.request primitive received to it by the next higher layer.
MLME-SET.request: Request to set the indicated MAC PIB with the passed value.
MLME-SET.confirm: Returns the result of an attempt to set the indicated PIB value.
2.6.2.6 Orphaning
MLME-ORPHAN.indication: A primitive to indicate to the next higher layer of the presence of an orphan device in the network.
MLME-ORPHAN.response: It helps the next higher layer to respond to the MLMEORPHAN.indication message by the MAC layer. It indicates if the node in question is associated to the network.

2.6.2.7 Receiver Maintainence
The following primitives are used to maintain the receiver enable time.
MLME-RX-ENABLE.request : The next higher layer requests the MAC for the Receiver to be enabled for a finite amount of time.
MLME-RX-ENABLE.confirm : It reports the result of an attempt to enable the receiver.


2.6.2.8 Channel Scanning
These primitives are used to scan the communication channels to determine the presence or absence of PANs.

MLME-SCAN.request: The MLME-SCAN.request primitive is used to initiate a channel scan over a given list of channels. A device can use a channel scan to measure the energy on the channel, search for the coordinator with which it is associated, or search for all coordinators transmitting beacon frames within the POS of the scanning device.
MLME-SCAN.confirm: It reports back to the next higher channel of the result of the channel scan.

Primitives are functions offered by each layer. The four generic types of a primitive are Request, Indication, Response, and Confirm. The PHY layer is responsible for tasks like activating/deactivating the transceiver, CCA, ED, LQI management, Data transmission and reception. The primitives responsible for each of the above described mechanisms are presented and are explained in brief. The PHY primitives are followed by the MAC primitives.

The primitives indicate the functions organized by each layer. The PHY layer is responsible for the following tasks:
Ø Activation and deactivation of the radio transceiver
Ø Energy Detection
Ø Link Quality Indication Measurement
Ø Clear Channel Assessment
Ø Data Transmission and Reception

2.6.1.1 Data Transmission
When ever there is data to be transmitted, the MAC layer Management Entity calls upon the PHY layer with these primitives to transmit a data frame.
PD-DATA.request: The PD-DATA.request primitive is generated by a local MAC sublayer entity and issued to its PHY entity to request the transmission of an MPDU. Upon receiving the PDDATA.request primitive, the PHY first constructs a PPDU with the supplied PSDU.
PD-DATA.confirm : The PD-DATA.confirm primitive is generated by the PHY entity and issued to its MAC sublayer entity in response to a PD-DATA.request primitive. The PD-DATA.confirm primitive will return a status of either SUCCESS, indicating that the request to transmit was successful, or an error code of RX ON or TRX OFF, indicating that the transceiver is working in the Receiver mode or the transceiver is switched off.
2.6.1.2 Data Reception
This primitive is used by the PHY layer to notify the MAC layer of the reception of a data packet.


PD-DATA.indication : The PD-DATA.indication primitive is generated by the PHY entity and issued to its MAC sublayer entity to transfer a received PSDU. This primitive will not be generated if the received PSDU Length field is zero or greater than aMaxPHYPacketSize.
2.6.1.3 Clear Channel Assessment
The following primitives implement the Clear Channel Assessment logic. When ever there is data to be transmitted and the node need to compete with its peers using CSMA-CA, it must go through the CCA phase to ascertain if the channel is free/busy. This function is called upon by the MAC Layer Management Entity.
PLME-CCA.request : The PLME-CCA.request primitive is generated by the MLME and issued to its PLME whenever the CSMA-CA algorithm requires an assessment of the channel.
PLME-CCA.confirm : The PLME-CCA.confirm primitive reports the results of a CCA analysis.
2.6.1.4 Energy Detection
The following primitives are responsible for implementing energy detection of the channel. The MAC layer request for such a service and the PHY layer performs the Energy Detection and replies back with the result of the operation.
PLME-ED.request : The PLME-ED.request primitive requests that the PLME perform an ED(Energy Detection) measurement.
PLME-ED.confirm : The PLME-ED.confirm primitive reports back the results of the ED measurement to the MLME.



2.6.1.5 PAN Information Management
The following primitives are subsequently used by the MAC and the PHY layer entities to access a particular PIB value, or either to set a value for a PIB property.
PLME-GET.request: The PLME-GET.request primitive requests information about a given PHY PIB attribute.
PLME-GET.confirm : The PLME-GET.confirm primitive reports the results of an information request from the PHY PIB.
PLME-SET.request : The PLME-SET.request primitive attempts to set the indicated PHY PIB attribute to the given value.
PLME-SET.confirm : The PLME-SET.confirm primitive reports the results of the attempt to set a PIB attribute.

2.6.1.6 Activate/Deactivate Radio Transceiver
The following two primitives are responsible for implementing the function of activating and deactivatingthe transceiver.
PLME-SET-TRX-STATE.request: The PLME-SET-TRX-STATE.request primitive requests that the PHY entity change the internal operating state of the transceiver. The transceiver will have three main states:
Ø Transceiver disabled (TRX OFF)
Ø Transmitter enabled (TX ON)
Ø Receiver enabled (RX ON)

PLME-SET-TRX-STATE.confirm:
The PLME-SET-TRX-STATE.confirm primitive reports the result
of a request to change the internal operating state of the transceiver.

Not all blocks in Figure 2. Logical blocks in the transceiver PHY layer are required to implement a communications system. However, if the functionality is used (even optionally) in the specification, then the cost for implementing the functionality must be included in the cost estimate. The blocks may occur in different orders in the chain, for example, the frequency spreading may be a part of the modulate/demodulate portion or the encryption may precede the source encoding and the decryption follow the source decoding.












Figure 2.11 Logical blocks in the transceiver PHY layer

· Source Encode/Decode – packet formation including headers, data interleaving, error correction/detection (FEC, CRC, etc), compression/decompression. This function is optional, include if it applies to the proposed system.
· Encrypt/Decrypt – bit level operations to protect data. This function is optional, include if it applies to the proposed system.
· Channel encode/decode – bias suppression, symbol spreading/de-spreading (e.g. DSSS), data whitening/de-whitening (or scrambling). This function is optional, include if it applies to the proposed system.
· Modulate/Demodulate – convert digital data to analog format, can include symbol filtering, frequency conversion, frequency filtering.
· Frequency Spreading/De-spreading – can include frequency hopping or other techniques to decrease or increase, respectively, the bits/Hz of the analog signal in the channel. This function is optional, include if it applies to the proposed system.
· Transmit/Receive – transition the signal to/from the channel.

The new IEEE standard, 802.15.4, defines the physical layer (PHY) and medium access control sublayer (MAC) specifications for low data rate wireless connectivity among relatively simple devices that consume minimal power and typically operate in the Personal Operating Space (POS) of 10 meters or less. An 802.15.4 network can simply be a one-hop star, or, when lines of communication exceed 10 meters, a self-configuring, multi-hop network. A device in an 802.15.4 network can use either a 64-bit IEEE address or a 16-bit short address assigned during the association procedure, and a single 802.15.4 network can accommodate up to 64k (216 ) devices. Wireless links under 802.15.4 can operate in three license free industrial scientific medical (ISM) frequency bands. These accommodate over air data rates of 250 kb/sec (or expressed in symbols, 62.5 ksym/sec) in the 2.4 GHz band, 40 kb/sec (40 ksym/sec) in the 915 MHz band, and 20 kb/sec (20 ksym/sec) in the 868 MHz. Total 27 channels are allocated in 802.15.4, with 16 channels in the 2.4 GHz band, 10 channels in the 915 MHz band, and 1 channel in the 868 MHz band.
Wireless communications are inherently susceptible to interception and interference. Some security research has been done for WLANs and wireless sensor networks, but pursuing security in wireless networks remains a challenging task. 802.15.4 employs a fully handshaked protocol for data transfer reliability and embeds the Advanced Encryption Standard (AES) for secure data transfer.
In the following subsections, we give a brief overview of the PHY layer, MAC sublayer and some general functions of 802.15.4. The services of a layer are the capabilities it offers to the user in the next higher layer or sublayer by building its functions on the services of the next lower layer. This concept is illustrated in 3.1, showing the service hierarchy and the relationship of the two correspondent N-users and their associated N-layer (Or sublayer) peer protocol entities.
The services are specified by describing the information flow between the N-user and the N-layer. This information flow is modeled by discrete, instantaneous events, which characterize the provision of a service. Each event consists of passing a service primitive from one layer to the other through a layer SAP associated with an N-user. Service primitives convey the required information by providing a particular service. These service primitives are an abstraction because they specify only the provided service rather than the means by which it is provided. This definition is independent of any other interface implementation.
Services are specified by describing the service primitives and parameters that characterize it. A service may have one or more related primitives that constitute the activity that is related to that particular service. Each service primitive may have zero or more parameters that convey the information required to provide the service.









Figure 2.10: Service Primitive


A primitive can be one of four generic types:
Ø Request: The request primitive is passed from the N-user to the N-layer to request that a service is initiated.
Ø Indication: The indication primitive is passed from the N-layer to the N-user to indicate an internal N-layer event that is significant to the N-user. This event may be logically related to a remote service request, or it may be caused by an N-layer internal event.
Ø Response: The response primitive is passed from the N-user to the N-layer to complete a procedure previously invoked by an indication primitive.
Ø Confirm: The confirm primitive is passed from the N-layer to the N-user to convey the results of one or more associated previous service requests.

The IEEE 802.15.4 standard describes 14 PHY and 35 MAC primitives. The IEEE 802.15.4, WPAN supports two types of devices, The FFD and the RFD. The FFD is a full function devices supporting all the defined primitives of the standard. While, the RFD, is a reduced function device, degraded in terms of functionality. It supports a subset of these primitives. A total of 38 primitives are supported by RFDs. A few of those primitives are described here which are quite frequently used and are implemented in the zigbee modules.


There can be three different types of data transmission possible. They are
Ø Transmission from a device to the coordinator
Ø Transmission from the coordinator to the device
Ø Transmission between any two devices.
In a star topology only the first two transmission techniques are possible. Transmission between any two devices is not supported, where as in a peer to peer network all the three types of transmissions are possible. The transmissions can be carried out again in either of two ways, depending on if the beacon transmissions are allowed or not. The current study is focused on a beacon enabled network. Hence the following paragraphs will find no reference of a non-beacon enabled transmission techniques.
The following subsections will go through the steps followed by each mode of transmission.

Transmission from a Coordinator to a Device (Fig: 2.8)
Ø The coordinator has data to be transmitted to the device.
Ø It indicates this in the pending address fields of its beacon.
Ø Devices tracking the beacons, decode the pending address fields.
Ø If a device finds its address listed among the pending address fields, it realizes it has data to be received from the coordinator.
Ø It issues a Data-Request Command to the coordinator.
Ø The coordinator replies with an acknowledgement.
Ø If there is data to be sent to the device, it would transmit the data.
Ø If acknowledgements are not optional, the device would respond with an acknowledgement.











Figure 2.8: Coordinator to Device Transmission




Transmission from a device to a coordinator (Fig: 2.9)
Ø The device first listens to the beacon.
Ø On finding the beacon, it synchronizes first to the superframe structure. This process lets it know the start and end time of the Contention access period.
Ø The device will now compete with its peers for a share of the channel.
Ø On its turn, it will transmit the data to the coordinator.
Ø The coordinator may reply back with an acknowledgement, if it is not optional.









Figure 2.9: Device to Coordinator Transmission
Transmission between two devices
There is no predefined manner in which there can be a direct communication between two devices in the network. However, the suitable methods of transmission can be by mutual synchronization techniques, or direct transmission using unslotted CSMA-CA. But either technique has their downsides. The synchronization technique, even though look simpler, is harder to implement. Similarly, direct transmission might degrade the throughput performance of the PAN.

The Superframe structure
The superframe structure (Fig: 2.4) is an optional part of a WPAN. It is the time duration between two consecutive beacons. The structure of the superframe is determined by the coordinator. The coordinator can also switch off the use of a superframe by not transmitting the beacons. The superframe duration is divided into 16 concurrent slots. The beacon is transmitted in the first slot. The remaining part of the superframe duration can be described by the terms, CAP, CFP and Inactive. The superframe is used to provide vital statistics like synchronization, identifying the PAN and the superframe structure, to the devices connected in a Wireless PAN. This information is critical for the operation of the PAN in a Beacon enabled network.
Figure 2.4: The SuperFrame Structure

Contention Access Period: It is the time duration in symbols during which the devices can compete with each other to access the channel using CSMA-CA and transmit the data.
Contention Free Period/Guaranteed Time Slots: It is the time duration for which certain low-latency application devices are given exclusive rights over the channel and the devices can directly start transmitting the data. There can as many as 7 slots assigned for GTS transmissions. These transmissions start immediately after the contention access period.
Inactive Period: It is the time period during which the coordinator goes to a power save mode and it would not interact with the PAN. Therefore, during this time, there will be no beacon transmissions. This implies that the devices also go to sleep mode for this duration.
Superframe Duration: The total time duration of the CAP, CFP (GTS) and a Beacon. The Superframe duration doesn’t include the inactive period.
Beacon Interval: It is the time duration between two successive beacons.

Synchronization is key for better throughput in the network. Every device in the network when ready to transmit data should compete for the channel. But to compete for the channel, they should know when the contention access periods start. And this is what the superframe structure or truly, the beacon transmission does. This information is embedded into the beacon, and the device receiving the beacon can extract this information and get ready to compete for the channel. Similarly is the case when a device wants to exclusively transmit in the GTS mode. It is the coordinator that would assign a device access to the GTS.
The structure of the superframe structure is determined by two parameters. The Superframe Order (SO) and the Beacon Order (BO). The superframe order is the variable which is used to determine the length of the superframe duration. Similarly the Beacon Interval is determined by the variable BO.
For BO=15 shall indicate that there are no beacon transmissions. Also for SO = BO (Fig: 2.5), the beacon interval is same as the superframe duration indicating there is no inactive portion. Similarly, when BO is greater than SO (Fig: 2.6), indicates there is an inactive portion present in the superframe.


BO = SO





BO > SO

The beacon interval and the active and inactive part of the superframe are calculated, in the following computation.
Beacon Interval
aBaseSuperFrameDuration = aBaseSlotDuration×aNumSuperframeSlots
aBaseSlotDuration = 60symbols
aNumSuperFrameSlots = 16
aBaseSuperFrameDuration = 60 × 16symbols = 960symbols
Lets calculate the beacon interval with BO=8 and SO=7.
Similarly the Superframe duration can be calculated using the superframe order as follows
And finally the inactive portion of the superframe can be calculated as,
The figure indicates all the time periods for a superframe with BO=8 and SO=7.

The LR-WPAN architecture is defined in terms of a number of blocks in order to simplify the standard. These blocks are called layers. Each layer is responsible for one part of the standard and offers services to the higher layers. The layout of the blocks is similar to the structure of the OSI layered architecture. But the IEEE 802.15.4 standard only defines the PHY and the MAC layers. The upper layers of networking and application have been left for the application developers. An LR-WPAN device comprises a PHY, which contains the radio frequency (RF) transceiver along with its low-level control mechanism, and a MAC sub layer that provides access to the physical channel for all types of transfer. The figure 2.3 depicts the layered architecture of IEEE 802.15.4.
The features of the PHY layer activation and deactivation of the radio transceiver, ED, LQI, channel selection, clear channel assessment (CCA), and transmitting as well as receiving packets across the physical medium. Similarly, the MAC layer is responsible for beacon management, channel access, GTS management, frame validation, acknowledged frame delivery, association, and disassociation.

Network formation is part of the network layer functionalities. An example run of the various steps involved for a network formation is presented:
Star-Topology
Ø Assume a full function device is switched ON for the first time.
Ø It starts scanning its operating channels for possible beacon transmissions, from other PANs.
Ø If it finds a beacon, it can try to associate with the PAN or it can choose to form its own PAN.
Ø assuming it chooses to form a new PAN, It chooses a PAN ID unique within its operating space.
Ø Now it allows other devices to be associated to it. This ends the Star network formation phase, as initiated by the PAN-Coordinator.
Peer-to-Peer Topology
Ø Assume a full function device is switched ON for the first time.
Ø It starts scanning its operating channels for possible beacon transmissions, from other PANs.
Ø If it finds a beacon, it can try to associate with the PAN or it can choose to form its own PAN.
Ø Assuming it chooses to form a new PAN, It assumes the role of a PAN Coordinator and assigns a Cluster ID (CID) of 0 to itself.
Ø Now it allows other devices to be associated to it.
Ø Other devices which intend to join a PAN, look for the beacon transmissions and upon receiving the beacon transmissions from the coordinator, would request association to the network.

Ø The coordinator shall decide if it would like to add the device into the network.
Ø If it wants to add the device, it will assign a CID value to it. The new device shall add the coordinator as its neighbor, while the coordinator will add it as its child.
Ø And this new device can now act as a cluster head and transmit beacons.
Ø Other devices can now join the network at this node.


A Low rate WPAN supports three different types of topologies.
. Star Topology
. Peer-to-Peer Topology
. Cluster Tree/Mesh Topology
Star Topology
The star topology (Fig: 2.1) is one of the most common forms of network formation. This type of topology can be used in monitoring applications where several devices monitor their applications and report to the coordinator. And the coordinator, a highly capable FFD, reacts to the situation at hand. In this type of network formation the communication between any two devices is forbidden. All devices can only communicate with the coordinator irrespective of their device type. Thus, a device can communicate with the coordinator and vice versa. No routing of information is possible. Given this reduced functionality of the system, routing functionalities like Address Resolution, and Routing finding to certain extent can be disabled.
Peer-to-Peer Topology
The Peer-to-Peer topology (Fig: 2.2) is a mode of communication where routing of data among devices is possible, as long as they are with in the operating space of each other. Complicated applications where devices need sharing of information are intended targets for the implementation of a peer-to-peer topology. Thus possible communication scenarios are between node-to-node, node-to-coordinator, and coordinator-to-node. As is evident if two devices need to transfer data, both have to be full function devices. Applications such as industrial control and monitoring, wireless sensor networks, asset and inventory tracking, intelligent agriculture, and security would benefit from such a network topology. A peer-to-peer network can be ad hoc, self-organizing and self-healing.

Cluster-Tree Topology
The cluster tree topology can in a way be considered as a derivative of the peer-to-peer topology. Several small clusters, each being able to communicate peer-to-peer, can be controlled with a PAN coordinator. And each cluster can have its own coordinator. And the coordinators are answerable to the PAN Coordinator. Among several existing clusters, the coordinators can compete with each other to choose a PAN coordinator.

Compared with wired networks, wireless networks provide advantages in deployment, cost, size, and distributed intelligence. Wireless technology not only enables users to set up a network quickly, but also enables them to set up a network where it is in-convenient or impossible to wire cables. The “care free” feature and convenience of deployment make a wireless network more cost-efficient than a wired network in general.
The release of IEEE 802.15.4 (referred to as 802.15.4 hereinafter), "Wireless Medium Access Control (MAC) and Physical Layer (PHY) Specifications for Low Rate Wireless Personal Area Networks (LR-WPANs)”, represents a milestone in wireless personal area networks and wireless sensor networks.
AW ireless personal area network conforming to the IEEE 802.15.4 standard is composed of several devices and its functionality and features can be illustrated by several terms. Some of them are listed here.
Co-ordinator: It is a device which is authorized to provide synchronization services in an established network. There can be two different kinds of co-ordinators based on their operation scope. First is the PAN-Coordinator, which acts as a coordinator for the entire PAN. Where as an ordinary co-ordinator can only function within the scope of a cluster.
Cluster: A cluster is a small section of a bigger network, which has its own co-ordinator. Groups of clusters communicate with a central PAN-Coordinator to form the PAN in a mesh topology.
Device/End Node: A device is either a reduced/full function device that can be visualized as a leaf of a tree structure. Any device that is not a co-ordinator is an end node (device).
Personal Operating Space (POS): It is the operating range of a node in all directions, and is a constant irrespective of being in motion or stationary.
There are 14 PHY and 35 MAC Primitives defined by the IEEE 802.15.4 standard. The LR-WPAN supports two types of devices called the Full Function Device and the Reduced Function Device.
Full Function Device It is a device which supports all the 49 primitives supported by the technology. It is a fully functional device which is capable of assuming the role of either a PAN Coordinator, a Coordinator, or just as an end node (device). Also an FFD can function as a routing device in certain network topologies where data transfer among FFD is allowed (EX: peer-to-peer communication).
Reduced Function Device It is a device with reduced functionality which can only function as an end device or node. It cannot communicate with any other device other than the coordinator. Given their extremely low functionality, these devices are normally intended for simple applications like a light switch, etc. They merely send information to the coordinator at regular intervals about the status of the device it is monitoring. It can only support a maximum of 38 primitives.
A basic LR-WPAN comprises of a mixture of these devices, an FFD being the most common device used in a PAN. But any PAN network should have at least one FFD, to act as the PAN-Coordinator. However, depending on the application when a RFD is not feasible, to fulfill the needs of the application, an FFD can be applied. The devices of a network monitor the applications and reply back to the coordinator. The devices within the pan should be around the operating space of the coordinator. But given the dynamic propagation characteristics of the channel a definite operating space for each device cannot be defined.

Operating Frequencies and Datarates
Any technology cannot achieve wide ranging popularity if it not flexible enough to be used worldwide. This is also one of the primary reasons for the failure of several proprietary technologies. However, IEEE 802.15.4 has been designed to be applied worldwide. This allows manufactures to concentrate on devices that can work in any of the available channels based on channel characteristics, bandwidth requirements, local regulations, etc. It supports three different operating frequency bands, with different number of supporting channels and datarates.

There has been tremendous excitement on part of the corporates, the market and the consumers alike because of the wide spectrum of applications that zigbee has to other. It is a revolutionary new technology built to compliment or replace existing not so successful technologies. Automation is the buzz word for zigbee. It stands to automate our household, corporate buildings and industries. Its control and monitoring capabilities offer an excellent platform for automation. A host of application categories/scenarios are presented here:
· Monitoring: Surveillance systems, Fire alarms, Pressure sensors, Meter reading monitors, Health and Environment monitors.
· Control: Health, Environment, Sensors, Home, Building and Industry Automation
· Efficiency
· Conservation
Theoretically there can be innumerable number of applications. It only depends on how better we tend to harness the flexibility and services offered by zigbee. As already stated, these are merely applications that are intended or desired and there may be scenarios where this technology cannot be successfully applied. Firstly, these application scenarios can be applied broadly into three application spheres, based on the complexity, feasibility and requirements posed by each sphere of application.
. Home
. Building
. Industrial

The objective of our project is to build a simulation model of LR-WPAN and simulated the model using the Network simulator NS2. The WPAN Low Rate Task Group (TG4) is chartered to investigate a low data rate solution with multi-month to multi-year battery life and very low complexity. This standard specifies two physical layers: an 868 MHz/915 MHz direct sequence spread spectrum PHY and a 2.4 GHz direct sequence spread spectrum PHY. The 2.4 GHz PHY supports an over air data rate of 250 kb/s and the 868 MHz/915 MHz PHY supports over the air data rates of 20 kb/s and 40 kb/s. We simulated models for 2.4 GHz band. The low rate WPAN supports two types of topologies. They can form a star topology where the nodes can only talk to the coordinator and also as in a peer-to-peer topology where capable network nodes can route data. Several peer-to-peer topologies

Network can work together to form a mesh/cluster tree topologies. Two models of different topology namely Star and Peer-to-peer topology is created and then simulated. The code for the simulations is written using C++ and Tool command language. The simulation for both the models runs for up to 100 seconds.

The Simulated model can be analyzed as an animation for the process using the tool network animator. The main advantage of simulating using NS2 is that overall performance of each packet can be studied. The trace files are generated which shows the complete performance of the model simulated.



During the last decade there has been an explosion of devices using sensor technologies for control and monitoring purposes. Wired Sensors are now intended to be replaced with wireless technologies. Corporates have been envisioning of a digital home where every device is connected, and remotely controlled and monitored. Even though a perfect digital home is yet a mirage, we are now able to apply several technologies to suite our home and industrial networking needs. However, this concept of a digitally connected home has received a luke warm response due to lack of viable solutions. Over the years, several possible contenders have been identified. But none match the robustness and reliability required for the automation applications. Robustness when it comes to critical application scenarios as applicable to industrial needs and reliability when it comes to power usage and prompt response. The figure 1.1 illustrates the data rate and the operating range of zigbee in comparison to the other famous wireless technologies.

The wireless market has been traditionally dominated by high end technologies, but so far Wireless Personal Area Networking products have not been able to make a significant impact on the market. While some technologies like the Bluetooth have been quite a success story, in the areas like computer peripherals, mobile devices, etc, they couldn’t be expanded to the automation arena. This led to the invention of the wireless low data rate personal area networking technology, Zigbee (IEEE 802.15.4), for the home/Industrial automation. It has received a tremendous boosting among the industry leaders and critics have been quick enough to indicate that no less than 80 million zigbee products will be shipped by the end of 2006[8]. A group of companies, called the Zigbee Alliance, have been working together to enable reliable, cost-effective, low-power, wirelessly networked monitoring and control products, based on 802.15.4. The alliance has been putting considerable weight on the possible success of this technology. Industry leaders like Ember, FreeScale, HoneyWell, Phillips, Motorola, Samsung, ZMD, and a hundred such companies are backing it. Also the alliance is striving to make this technology applicable worldwide by involving corporates around the globe. Currently the alliance is worth over a hundred other companies and is continually growing. The size of this alliance cannot ensure its popularity and widespread use; however, it does indicate a commitment of the industry to focus on one technology rather than going haphazardly in designing their automation products based on self-developed technologies.

INTRODUCTION

The IEEE 802.15.4 has recently been adopted as a communication standard for low data rate, low power consumption and low cost Wireless Personal Area Networks. This protocol is quite flexible for a wide range of applications if appropriate tuning of its parameters is carried out. Importantly, the protocol also provides real-time guarantees by using the Guaranteed Time Slot (GTS) mechanism. Indeed, the GTS mechanism is quite attractive for time-sensitive Wireless Sensor Network (WSN) applications, particularly when supported by cluster-tree network topologies, such as defined in the ZigBee standard. It is primarily designed for the wide ranging automation applications and to replace the existing non-standard technologies. It currently operates in the 868MHz band at a data rate of 20Kbps in Europe, 914MHz band at 40Kbps in the USA, and the 2.4GHz ISM bands Worldwide at a maximum data-rate of 250Kbps.

Some of its primary features being:
• Standards–based wireless technology
• Interoperability and worldwide usability
• Low data–rates
• Ultra low power consumption
• Very small protocol stack
• Support for small to excessively large networks
• Simple design
• Security, and
• Reliability

1 INTRODUCTION
1.1 Motivation

1.2 Evolution of ZigBee
1.3 Overview of our project
1.4 Applications

2 overview of ieee 802.15.4
2.1 Operating Frequencies and Datarates
2.2 Network topology
2.2.1 Star topology
2.2.2 Peer-to-peer topology
2.2.3 Cluster tree topology
2.3 Network formation
2.3.1 Star topology
2.3.2 Peer-to-peer topology
2.4 Architecture
2.5Functional overview
2.5.1 The Superframe structure
2.5.2 Data Transmission
2.6IEEE 802.15.4 Service Primitives
2.6.1 PHY Primitives
2.6.1.1 Data Transmission
2.6.1.2 Data Reception
2.6.1.3 Clear Channel Assessment
2.6.1.4 Energy Detection
2.6.1.5 PAN Inftn Management

2.6.1.6 Radio Transceiver
2.6.2 MAC Primitives
2.6.2.1 Data Transmission
2.6.2.2 Data Reception
2.6.2.3 Association
2.6.2.4 Disassociation
2.6.2.5 PAN Inftn Management
2.6.2.6 Orphaning
2.6.2.7 Receiver Maintenance
2.6.2.8 Channel Scanning
3.The Simulation Environment
3.1Network Simulator NS2
3.1.1 Purpose
3.1.2 Overview
3.2Simple simulation
3.3The Network Animator
4.SIMULATION SETUP AND RESULT
4.1Simulation Model
4.1.1 Simulation Parameters
4.1.2 Traffic parameters
4.2Model of Star topology
4.3Model of Peer-to-peer topology
4.4Simulation Results
4.1 Simulation Windows
5Conclusions
6.REFERENCES

ABSTRACT

IEEE 802.15.4 is a standard uniquely designed for low rate wireless personal area networks (LR- WPANs). It targets low data rate, low power consumption and low cost wireless networking, and offers device level wireless connectivity. The IEEE 802.15.4 is designed for applications like wireless monitoring and control of lights, security alarms, motion sensors, thermostats and smoke detectors. IEEE 802.15.4 specifies physical and media access control layers that have been optimized to ensure low-power consumption. The MAC layer defines different network topologies, including a star topology (with one node working as a network coordinator, like an access point in IEEE 802.11), tree topology (where some nodes communicate through other nodes to send data to the network coordinator), and mesh topology (where routing responsibilities are distributed between nodes and master coordinator is not needed).

We have developed an NS2 simulator for IEEE 802.15.4 and conduct several sets of experiments to study its various features. In this project a star network topology and peer to peer network topology according to the 802.15.4 standard has been simulated with the simulator ns-2. The goals of this paper are to build a simulation model and to investigate different functional modes of IEEE 802.15.4 and their impact on energy consumption and network performance.


Your Ad Here