Carrier Sense
Carrier Sense
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation
model
set val(netif) Phy/WirelessPhy ;# network interface
type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue
type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 4 ;# number of
mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 1000.0 ;
set val(y) 1000.0 ;
set val(simtime) 10.0 ; #sim time
set val(drate) 2.0e6 ; #default datarate
set val(dist) 100.0 ;
# ======================================================================
# Main Program
# ======================================================================
if { $argc != 6} {
puts "Wrong no. of cmdline args."
puts "Usage: ns csense.tcl -RTSthresh <RTS_Threshold> -CSthresh
<carrier-sense threshold> -dist <x>"
exit 0
}
#
# Initialize Global Variables
#
set ns_ [new Simulator]
set tracefd [open csense.tr w]
$ns_ trace-all $tracefd
#
# Create God
#
#
# Create the specified number of mobilenodes [$val(nn)] and "attach"
them
# to the channel.
# configure node
#
# Provide initial (X,Y, Z=0) co-ordinates for mobilenodes
#
#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(simtime) "$node_($i) reset";
}
$ns_ at $val(simtime) "stop"
$ns_ at $val(simtime).01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
Fairsim:
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation
model
set val(netif) Phy/WirelessPhy ;# network interface
type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue
type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 4 ;# number of
mobilenodes
set val(rp) AODV ;# routing protocol
set val(sc) "./scenario" ;# scenario file
set val(x) 3000.0 ;
set val(y) 400.0 ;
set val(simtime) 10.0 ; #sim time
set val(drate) 2.0e6 ; #default datarate
set val(dist) 150.0 ; #default datarate
# ======================================================================
if { $argc < 2} {
puts "Wrong no. of cmdline args."
puts "Usage: ns sim.tcl -dist <dist>"
exit 0
}
}
# Main Program
# ======================================================================
#
# Initialize Global Variables
#
set ns_ [new Simulator]
set tracefd [open fairsim.tr w]
$ns_ trace-all $tracefd
set namtrace [open fairsim.nam w] ;# for nam tracing
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
$ns_ use-newtrace
#
# Create God
#
#
# Create the specified number of mobilenodes [$val(nn)] and "attach"
them
# to the channel.
# configure node
#
# Provide initial (X,Y, Z=0) co-ordinates for mobilenodes
#
#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(simtime) "$node_($i) reset";
}
$ns_ at $val(simtime) "stop"
$ns_ at $val(simtime).01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
Aodv:
set val(chan) Channel/WirelessChannel ;
set val(prop) Propagation/TwoRayGround ;
set val(netif) Phy/WirelessPhy ;
set val(mac) Mac/802_11 ;
set val(ifq) Queue/DropTail/PriQueue ;
set val(ll) LL ;
set val(ant) Antenna/OmniAntenna ;
set val(ifqlen) 50 ;
set val(nn) 3 ;
set val(rp) AODV ;
set val(x) 500 ;
set val(y) 400 ;
set val(stop) 150 ;
create-god $val(nn)
Sim:
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/Shadowing ;# radio-propagation
model
set val(netif) Phy/WirelessPhy ;# network interface
type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue
type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 2 ;# number of
mobilenodes
set val(rp) AODV ;# routing protocol
set val(sc) "./scenario" ;# scenario file
set val(x) 3000.0 ;
set val(y) 400.0 ;
set val(simtime) 10.0 ; #sim time
set val(drate) 2.0e6 ; #default datarate
set val(dist) 100 ;
# ======================================================================
# Main Program
# ======================================================================
if { $argc != 2} {
puts "Wrong no. of cmdline args."
puts "Usage: ns sim.tcl -dist <x>"
exit 0
}
#
# Initialize Global Variables
#
set ns_ [new Simulator]
set tracefd [open sim.tr w]
$ns_ trace-all $tracefd
$ns_ use-newtrace
#
# Create God
#
#
# Create the specified number of mobilenodes [$val(nn)] and "attach"
them
# to the channel.
# configure node
#
# Provide initial (X,Y, Z=0) co-ordinates for mobilenodes
#
#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(simtime) "$node_($i) reset";
}
$ns_ at $val(simtime) "stop"
$ns_ at $val(simtime).01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
Rcs_sim:
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-
propagation model
set val(netif) Phy/WirelessPhy ;# network interface
type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue
type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 100 ;# default number of
mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 1500.0 ;
set val(y) 1500.0 ;
set val(simtime) 10.0 ; #sim time
set val(rlen) 10 ;
# ======================================================================
# Main Program
# ======================================================================
if { $argc != 8 } {
puts "Wrong no. of cmdline args."
puts "Usage: ns multi-hop.tcl -rate <rate (Mbps)> -rxthresh
<rcv_threshold> -cpthresh <capture-threshold> -csthresh <carrier-sense
threshold (W)>"
exit 0
}
#
# Create God
#
#
# Create the specified number of mobilenodes [$val(nn)] and "attach"
them
# to the channel.
# configure node
#
# Provide initial (X,Y, Z=0) co-ordinates for mobilenodes
#
#
# Tell nodes when the simulation ends
#
expr srand(19987)
Single hop:
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation
model
set val(netif) Phy/WirelessPhy ;# network interface
type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue
type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 2 ;# number of
mobilenodes
set val(rp) AODV ;# routing protocol
set val(sc) "./scenario" ;# scenario file
set val(x) 3000.0 ;
set val(y) 400.0 ;
set val(simtime) 10.0 ; #sim time
set val(drate) 2.0e6 ; #default datarate
# ======================================================================
# Main Program
# ======================================================================
if { $argc != 2} {
puts "Wrong no. of cmdline args."
puts "Usage: ns single-hop.tcl -drate <dataRate>"
exit 0
}
#
# Initialize Global Variables
#
set ns_ [new Simulator]
set tracefd [open single-hop.tr w]
$ns_ trace-all $tracefd
#
# Create God
#
#
# Create the specified number of mobilenodes [$val(nn)] and "attach"
them
# to the channel.
# configure node
#
# Provide initial (X,Y, Z=0) co-ordinates for mobilenodes
#
#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(simtime) "$node_($i) reset";
}
$ns_ at $val(simtime) "stop"
$ns_ at $val(simtime).01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}