I am doing my final year undergraduate project in Network Simulator. Our project is study and simulation of S-MAC protocol. At the very first stage, we created a wireless scenario, of 10 linear nodes as shown below:
figure1: 10 linear nodes
The each nodes are separated by 200 m distance. The maximum range of hearing of each node is 250 m. So a node can only hear its neighboring node. For example, node 2 can hear only node 1 and node 3. In the simulation, node 0 creates CBR (Constant Bit Rate) traffic packets and transmits it. Node 9 is sink node and receives the incoming traffic packets. After simulation i got my trace file "filename.tr".
At first i was interested to calculate Average throughput. I used perl script to calculate throughput form this trace file (filename.tr). This script is as below:
# ==============================================================
#THROUGHPUT FOR NEW WIRELESS TRACE
# ==============================================================
# Usage:
# perl throughput.pl filename.tr
# ==============================================================
# perl throughput.pl filename.tr
# ==============================================================
#Get input file (first arg)
$infile=$ARGV[0];
# new wireless trace format is used. For example:
# s -t 147.236000000 -Hs 9 -Hd -2 -Ni 9 -Nx 0.00 -Ny 0.00 -Nz 0.00 -Ne 905.466702 -Nl MAC -Nw ---[0.06 0 9]
# new wireless trace format is used. For example:
# s -t 147.236000000 -Hs 9 -Hd -2 -Ni 9 -Nx 0.00 -Ny 0.00 -Nz 0.00 -Ne 905.466702 -Nl MAC -Nw ---[0.06 0 9]
# start some initial values
$flag = 0;
$grantsum = 0;
# Open input file
open (DATA,"<$infile") || die "Can't open $infile $!";
while (<DATA>)
{
# Tokenize line using space as separator
@x = split(' ');
# check if column 0 is for send, column 1 is field for time, column 8 is node 0, packet is cbr
$flag = 0;
$grantsum = 0;
# Open input file
open (DATA,"<$infile") || die "Can't open $infile $!";
while (<DATA>)
{
# Tokenize line using space as separator
@x = split(' ');
# check if column 0 is for send, column 1 is field for time, column 8 is node 0, packet is cbr
# $clk_fst stores time of first packet send. Time is column 2. Node id is column 8.
if (($x[0] eq 's')&&($x[1] eq '-t')&&($x[8] eq '0')&&($x[39] eq 'cbr')&&($flag eq 0))
{
$clock_fst=$x[2];
$flag = 1;
}
if (($x[0] eq 's')&&($x[1] eq '-t')&&($x[8] eq '0')&&($x[39] eq 'cbr')&&($flag eq 0))
{
$clock_fst=$x[2];
$flag = 1;
}
# $clk_lst stores time of last packet received. Time is column 2.
# $grantsum stores total packet received in byte.
if (($x[0] eq 'r')&&($x[1] eq '-t')&&($x[4] eq '9')&&($x[39] eq 'cbr'))
{
$grantsum=$grantsum+$x[31];
$clock_lst=$x[2];
}
}
if (($x[0] eq 'r')&&($x[1] eq '-t')&&($x[4] eq '9')&&($x[39] eq 'cbr'))
{
$grantsum=$grantsum+$x[31];
$clock_lst=$x[2];
}
}
# find total time between first packet send and last packet received
$clock=$clock_lst-$clock_fst;
$clock=$clock_lst-$clock_fst;
# print throughput
print "End to end throughput:\t ", $grantsum/($clock), "\t(Bytes/sec)\n";
close DATA;
exit(0);
#==============================================================
print "End to end throughput:\t ", $grantsum/($clock), "\t(Bytes/sec)\n";
close DATA;
exit(0);
#==============================================================
So our throughput is the total packet received in receiver node (In this case: node 9) divided by time between first packet send and last packet received.
We (me & Gaurav ) have calculated throughput using this perl script for different duty cycle of S-MAC varying packet inter-sending time of transmitter node (increasing and decreasing traffic). A typical result is as shown in graph plotted in 'gnuplot'.
figure 2: Average throughput vs Packet inter-sending time of tx
Increasing packet inter sending time is actually decreasing traffic load. So there is maximum traffic load when x axis has value 1 and minimum traffic load when x axis has value 10. When the traffic load is very light, the five curves nearly overlap, because the five S-MAC modes spend almost the same time to send a fixed number of packets from the source to the sink. So performance is satisfactory. As the traffic load increases, the throughput of all three modes increases with different rate. No periodic sleep has high throughput at high load because it is always on (spends must of the time to send packet) and chance of packet loss is low. But duty cycle of 5% has poor throughput at high load because it is only 5% on (spends less time to send packet) in a cycle and chance of packet loss is high. So performance with sleep listen is poor.
As i am doing project on analysis of S-MAC protocol, suggestions are hearty welcomed. You can mail me at shrestha.sp11 at gmail dot com.
Illegal division by zero at throughput.pl line 38, line 457903
ReplyDeleteI get this error while executing the code. Please advice, thnx