Implement simple ESS and with transmitting nodes in wire-less LAN by simulation and determine the performance with respect to transmission of packets

				
					#set ns simulator

set ns [new Simulator]

#open trace file

set nt [open lab41.tr w]

$ns trace-all $nt

set topo [new Topography]

$topo load_flatgrid  1000  1000


#open nam trace file

set nf [open lab41.nam w]

$ns namtrace-all-wireless $nf  1000  1000


$ns node-config -adhocRouting DSDV \

-llType LL \

-macType Mac/802_11 \

-ifqType Queue/DropTail \

-ifqLen 20 \

-phyType Phy/WirelessPhy \

-channelType Channel/WirelessChannel \

-propType Propagation/TwoRayGround \

-antType Antenna/OmniAntenna \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON

create-god 4
				
			
				
					#create nodes

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]




#label the nodes

$n0 label "tcp0"

$n1 label "sink0"

$n2 label "AP0"

$n3 label "AP1"

$n0 set  X_ 70

$n0 set  Y_ 70

$n0 set  Z_ 0

$n1 set X_ 400

$n1 set  Y_ 400

$n1 set  Z_ 0

$n2 set  X_ 120

$n2 set  Y_ 170

$n2 set  Z_ 0

$n3 set  X_ 250

$n3 set  Y_ 300

$n3 set  Z_ 0

$ns at 0.3 "$n0 setdest 70 70 10"

$ns at 0.3 "$n1 setdest 400 400 20"

$ns at 0.3 "$n2 setdest 120 170 30"

$ns at 0.3 "$n3 setdest 250 300 30"


set tcp0 [new Agent/TCP]

$ns attach-agent $n0 $tcp0


set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0


set sink1 [new Agent/TCPSink]

$ns attach-agent $n1 $sink1


$ns connect $tcp0 $sink1


$ns at 5 "$ftp0 start"$ns at 120 "$n1 setdest  250  250  20"

$ns at 100 "$n0 setdest  60  60  10"

$ns at 125 "$n1 setdest  300  350  20"

$ns at 105 "$n0 setdest  50  50  10"

$ns at 130 "$n1 setdest  390  400  20"

$ns at 110 "$n0 setdest  40  40 10"

$ns at 135 "$n1 setdest  450  450  20"

$ns at 115 "$n0 setdest  30  30  10"
				
			
				
					proc finish { } {

global ns nt nf

$ns flush-trace

exec nam lab41.nam &

close $nt

close $nf

exit 0

}


$ns at 400 "finish"

$ns run
				
			
				
					AWK FILE:

BEGIN{

Ps=0;

Pr=0;

pATr=0;

}

{

if(($1=="s")&&($4=="RTR")&&($7=="tcp"))

                     Patr++;




if(($1=="s")&&($4=="AGT")&&($7=="tcp"))

                     Ps++;

if(($1=="r")&&($4=="AGT")&&($7=="tcp"))

                     Pr++;

}

END{

printf("\n Number of packets sent:"Ps);

printf("\n Number of packets recvd:"Pr);

printf("\n packet delivery ratio:"Pr/Ps*100);

printf("\nRouting load"Patr/Pr);

}
				
			
Steps for execution
 Open gedit editor and type program. Program name should have the extension “ .tcl ”
[root@localhost ~]# gedit lab4.tcl
 Save the program and close the file.
 Open gedit editor and type awk program. Program name should have the extension “.awk ”
[root@localhost ~]# gedit lab4.awk
 Save the program and close the file.
 Run the simulation program
[root@localhost~]# ns lab4.tcl
 Here “ns” indicates network simulator. We get the topology shown in the snapshot.
 Now press the play button in the simulation window and the simulation will begins.
 After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f lab4.awk lab4.tr
 To see the trace file contents open the file as ,
[root@localhost~]# gedit lab4.tr

Leave a Reply