Hi,
 
I am struggling in getting the idea of transmission range of a WSN node that 
uses 802_11, attached is my code please have a look 
1. nodes 0,1,2,3 are assumed to be source nodes although currently node 0 is 
sending the data.
2. node 4 and 5 are parents to nodes (0&1) and nodes(2&3) respectively.
3. node 6 is parent to nodes 4&5 and node 7 is sink.
I want to keep this hierarchy but what happen right now is node 0 directly 
communicates with sink via node 6.
How I stict the above mentioend hierarchy?
Also I need to set the radius of communication to be around 40 meters what 
shall I do? please list me the commands for that or the values I need to add.
same is true for 802.15.4?
 
---code---
 set val(chan) Channel/WirelessChannel ; # channel type
set val(prop) Propagation/TwoRayGround ; # radio-propagation model
set val(ant) Antenna/OmniAntenna ; # Antenna type
set val(ll) LL ; # Link layer type
#set val(ifq) CMUPriQueue
set val(ifq) Queue/DropTail/PriQueue ;# Interface queue type
set val(ifqlen) 100 ; # max packet in ifq
set val(netif) Phy/WirelessPhy ; # network interface type
set val(mac) Mac/802_11 ; # MAC type
set val(nn) 8 ; # number of mobilenodes
#set val(rp) DSDV ; # routing protocol (Chay duoc)
set val(rp) AODV ; # routing protocol 
set val(x) 1500
set val(y) 500
set val(energymodel) EnergyModel ;# Energy Model
set val(initialenergy) 1000 
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0
 
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 1.559e-11
Phy/WirelessPhy set RXThresh_ 3.652e-10
Phy/WirelessPhy set bandwidth_ 2e6
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0
Phy/WirelessPhy set debug_ false
 
 
set ns [new Simulator]
#ns-random 0
set ftr [open atif3.tr w]
$ns trace-all $ftr
set namtrace [open atif3.nam w]
set runall [open runall.bat w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid 800 800
create-god $val(nn)
# CONFIGURE AND CREATE NODES
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON \
-energyModel $val(energymodel) \
-initialEnergy $val(initialenergy) \
-idlePower 712e-6 \
-rxPower 35.28e-3 \
-txPower 0.28183815 \
-sleepPower 0.001 
#-transitionPower 0.2 \
#-transitionTime 0.005 
proc record {} {
global sink5 
#Get An Instance Of The Simulator
set ns [Simulator instance]
#Set The Time After Which The Procedure Should Be Called Again
set time 0.05
#How Many Bytes Have Been Received By The Traffic Sinks?
#set bw0 [$sink5 set npkts_]
#set bw1 [$sink5 set nlost_]
#set bw2 [$sink2 set npkts_]
#set bw3 [$sink3 set npkts_]
#Get The Current Time
set now [$ns now]
#Re-Schedule The Procedure
$ns at [expr $now+$time] "record"
}
# define color index
$ns color 0 blue
$ns color 1 red
$ns color 2 chocolate
$ns color 3 red
$ns color 4 brown
$ns color 5 tan
$ns color 6 gold
$ns color 7 black
set node_(0) [$ns node]
#$ns at 0.0 "$n(0) color red"
$node_(0) color "0"
$node_(0) shape "circle"
set node_(1) [$ns node]
$node_(1) color "blue"
$node_(1) shape "circle"
set node_(2) [$ns node]
$node_(2) color "tan"
$node_(2) shape "circle"
set node_(3) [$ns node]
$node_(3) color "red"
$node_(3) shape "circle"
set node_(4) [$ns node]
$node_(4) color "tan"
$node_(4) shape "circle"
set node_(5) [$ns node]
$node_(5) color "red"
$node_(5) shape "circle"
set node_(6) [$ns node]
$node_(6) color "red"
$node_(6) shape "circle"
set node_(7) [$ns node]
$node_(7) color "red"
$node_(7) shape "circle"
# Define node initial position in nam
$node_(0) set X_ 0.0
$node_(0) set Y_ 0.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 100.0
$node_(1) set Y_ 0.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 200.0
$node_(2) set Y_ 0.0
$node_(2) set Z_ 0.0
$node_(3) set X_ 300.0
$node_(3) set Y_ 0.0
$node_(3) set Z_ 0.0
$node_(4) set X_ 50.0
$node_(4) set Y_ 100.0
$node_(4) set Z_ 0.0
$node_(5) set X_ 250.0
$node_(5) set Y_ 100.0
$node_(5) set Z_ 0.0
 
$node_(6) set X_ 150.0
$node_(6) set Y_ 200.0
$node_(6) set Z_ 0.0
$node_(7) set X_ 150.0
$node_(7) set Y_ 450.0
$node_(7) set Z_ 0.0
$node_(7) label "Sink"
$node_(0) label "Source"
$node_(1) label "Source"
$node_(2) label "Source"
$node_(3) label "Source"
for {set i 0} {$i < 8 } { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 20
}
 
set tcp0 [new Agent/TCP/Newreno] 
$ns attach-agent $node_(0) $tcp0 
set sink0 [new Agent/TCPSink] 
$ns attach-agent $node_(7) $sink0 
$ns connect $tcp0 $sink0 
set ftp0 [new Application/FTP] 
$ftp0 attach-agent $tcp0 
$tcp0 set fid_ 0 
$ns at 0.0 "record"
$ns at 0.1 "$ftp0 start"
$ns at 2.4 "$ftp0 stop"
$ns at 3.0 "$ns nam-end-wireless 3.0"
proc finish {} {
global ns ftr namtrace
$ns flush-trace
close $namtrace
#exec xgraph packets_received.tr packets_lost.tr
exec nam atif3.nam &
exit 0
}
 
$ns at 3.0 "finish"
$ns run 


      

Reply via email to