Simulation Simulation and Analysis of SMAC Protocol using NS-2
Guided By: Prof. Sachin Gajjar
Prepared By: Pravin Gareta (08BEC156) Malav Malav Mehta Mehta (08BEC1 (08BEC159) 59)
Outlines
Introduction of our project NAM
AWK
Gnuplot
S-MAC
S-MAC implementation in NS-2
Changes made in TCL scripts
Conclusion
References
Introduction
of Project
For our project we need three things : 1. NS-2
2. Know Knowle ledg dgee of AWK prog progra ramm mmin ing g 3. Gnuplot
NS stands for Network Simulator and it extensively used by network netw ork research research community. community. composed Users can define arbitrary network topologies composed of nodes, routers, links and shared medium. A rich set of protocol objects can then be attached to nodes, usually as agents. Ns-2 is is written written in C++, C++, with an Otcl Otcl interpreter interpreter as a
Ns-2 is open-source software and free to use for all users. Due to its open source nature, a user can modify parameters at different layers, create his or her own appl applic icat atio ion ns, and and deve develo lop p new new prot protoc ocol ol..
AWK prog progra ram mming ing like like the c+ c++ + lang langu uage age.
After running the TCL script in the NS-2 we get output in two forms :
1. We can visualize output in NAM editor. 2. We can analyze output using trace file
For trace file analysis we need a awk programming support
NAM : Network Animator
AWK example
BEGIN { clear; rec = 0; 0; send = 0; }{ if ( $1 == "+" && $5==cbr" && $3=="0") { send = send +$6; } if ( $1 == "r" && $5==cbr" && $4=="3" ) { rec = rec rec + $6; $6; } } END{ printf("\n packet Send %d", send) >>"thr.log"; >>"thr.log"; printf("\n packet Recv %d", rec) >> "thr.log"; "thr.log"; printf("\n packet Drop %d", send -rec) >> "thr.log"; "thr.log"; printf("\n packet efficiency %f", (send/rec)*100) (send /rec)*100) >> "thr.log"; "thr.log";
GNUPLOT 0.2 86.67 0.4 96.36 0.5 96.49
1.0 99.300 1.5 100.00 2.0 100.00 2.5 100 00
(This is a data of Link BW and Efficiency)
Gnu nupl plot ot
Scri Scrip pt
set title "Link BW and Rate" set xlabel xlabel "Link "Link BW" BW" set ylabel ylabel "Rate" "Rate" set set xra xrang ngee [0:3] set set yra yrang ngee [70:11 :110] set xtics 0.5 set set yti ytics cs 5 plot "thr7.log" using 1:2 title "packet" with linespoints pause -1 "Hit return to continue"
S-MAC S-MAC stands for
Sensor Medium Access Access Channel.
In a WSN: ³energy conservation conservation and self-configuration self-configuration are primary goals...´ sources of Energy waste: wa ste: Major sources Collision: corrupted packets must be retransmitted re transmitted and it increases energy consumption. Overhearing: picking picking up packets that are destined to other nodes. Idle Listening : Listening to receive possible traffic traffic that is not sent
Basic
Features of S-MAC
Listen and Sleep Periodically according to the
schedule. Both Physical and Virtual Carrier Sense Overhearing Overhea ring Avoidance Avoidance RTS/CTS Mechanism Mec hanism Synchronization Synchronizati on Algorithm Neighbor discovery
Simulating S-MAC with NS-2 Changes
made in NS-2 : If your NS release is 2.30 and above then it is not problem for running the s-mac -mac program. If
your ns version is 2.29 and below then you have to download a cmu-trace.c e.cc file from the site listed below:
http://www.isi.edu/ilense/software/smac/cmu-trace.cc
Put thi this file ile into nto these hese path path : ns-2 ns-2/t /tra race ce//cmu-tra -tracce.cc .cc These file is for the detailed trace analysis of the program
S-MAC Parameter Parameter Settings Settings
In TCL script: Mac/SMAC set sync Flag_ 1 Mac/SMAC set dutyCycle_ 1 0
Common Settings For Simulation Topology
: In this simulation we have used a 2 node topology one is source and another is sink. Traffic
pattern: We attached the UDP agent and CBR Traffic source to the source node. AIM:
In this simulation we have compare the IEEE 802.1 2.11 and and S-MAC -MAC prot protoc ocol ol.. Both are same except S-MAC having the some dif differen erence cess from rom 802.11.
S-MAC Trace Format
First field indicate event type :
Send(s)
Receive(r)
Drop(d)
Forward(f)
Time Event
Id
of the node on which event takes place
Layer where
these event happen
AGT(Agent)
RTR(Router)
IFQ(Interface Queue)
MAC(mac)
Fifth 6th 7th
field is reserved for special event
fiel ield indi indica catte glob global al seque equen nce num number ber for pack packet et represented by packet type Here CBR represents
The
ninth field including three numbers in brackets
concern erns MAC layer information. Originally, there ere will be four numbers in the brackets. But S-MAC revises this format. The first number is the duration field of this packet. In Fig. the duration field of this RTS packet is 0.11 s, which is the remaining time reserved for the coming transmission. The second number stands for the MAC address of the receiver of this packet, and the third number for the sender. er.
Measurement of Energy Consumption We
run the TCL script and get the trace file.
Form
the trace file we compare the ideal energy of both
S-MAC and IEEE 802.11 Because
for s-mac periodic sleep and listen is employed
so, obviously energy consumption of s-mac is low compared to the 802.11 These is
shown in the Gnuplot also :
Measurement of delay vs. energy consumption Here
we change the duty cycle of s-mac in the TCL file.
We
take first duty cycle 10%
For
the second case we have taken it 20%
So,
basically we changed the listen period of the program
by changing the dutycycle. We get the result that as a listen time is small energy consumption is less and delay is more. So,
S-MAC is trade off between delay and energy and it
is shown in the Gnuplot.
Traffic For
Variation Variation vs. energy consumption consumption
the traffic variation we change the CBR traffic
interva rval from 0.001 to 10s. And
note that 0.001s is high traffic case and 10s is the
low lo w tra traff ffic ic case. ase. We
see that for s-mac there is no such variation for high
or low traffic means s-mac will adjust its sleep period acc accordi ording ng to the the situ situa ati tion on.. Whi hille for 802.11
ene en ergy cons onsump umption is large.
Energy consumption at Intermediate node Here 1
we design a 3 node topology
node are sender and 1 node are sink and 1 is router.
Here
we compare the ideal energy state of the
interm intermedi ediat atee node. node. For
s-mac variation of energy consumption at an
intermediate node is very less while for 802.11 it is large variation. These is
shown in the graph.
Changes made in TCL script
Conclusion During the project work, we have done the following two main ain task tasks. s. 1. We learn NS-2 then simulate S-MAC in ns-2.34 and found out how S-MAC works. 2. We have compare the s-mac protocol with the IEEE 802.11. Through analyzing the simulation results, we have the following following conclusion conclusions: s:
S-MAC with periodic sleep efficiently reduces the energy consumptions due to idle listening. However, periodic sleeping increases latency and reduces throughput. So, s-mac is a trade off between energy and and dela delay y.
References
[1] W. W. Ye, Ye, J. Heidemann, and D. Estrin. An energye nergyefficient efficient MAC protocol for wireless sensor networks.
G reis. Tutorial Tutorial for the network n etwork simulator ns. [2] M. Greis. http://www.isi.edu/nsnam/ns/tutorial/index.html Simulator: Building Ns web page. [3] The Network Simulator:
http://www.isi.edu/nsnam/ns/ns-build.html NsNam Site Site Search Search web page. [4] NsNam
http://www.isi.edu/nsnam/htdig/search.html [5] J. Chung and M. Claypool. NS by example
Smac-users --- Discussions Discussions by by users of S-MAC S-MAC web [6] Smac-users
page. http://mailman.isi.edu/mailman/listinfo/smac-
??
THANK YOU !!