0% found this document useful (0 votes)
27 views

Tmac

The document defines options and parameters for configuring a network simulation involving wireless nodes. It sets up the network topology, node and agent definitions, application definitions, and runs the simulation until a specified time.

Uploaded by

K Akshay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Tmac

The document defines options and parameters for configuring a network simulation involving wireless nodes. It sets up the network topology, node and agent definitions, application definitions, and runs the simulation until a specified time.

Uploaded by

K Akshay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

set opt(chan) Channel/WirelessChannel

set opt(prop) Propagation/TwoRayGround


set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/TMac
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(energy) EnergyModel
set opt(txpower) 1.0
set opt(rxpower) 0.0
set opt(initialenergy) 1000
set opt(idlepower) 0.0
set opt(ant) Antenna/OmniAntenna ;#we don't use it in underwater
set opt(filters) GradientFilter ;# options can be one or more of
;# TPP/OPP/Gear/Rmst/SourceRoute/Log/TagFilter

set opt(bit_rate) 1.0e4


set opt(encoding_efficiency) 1
set opt(ND_window) 1
set opt(ACKND_window) 1
set opt(PhaseOne_window) 3
set opt(PhaseTwo_window) 1
set opt(PhaseTwo_interval) 0.5
set opt(IntervalPhase2Phase3) 1
set opt(duration) 0.1
set opt(PhyOverhead) 8
set opt(large_packet_size) 480 ;# 60 bytes
set opt(short_packet_size) 40 ;# 5 bytes
set opt(PhaseOne_cycle) 4 ;
set opt(PhaseTwo_cycle) 2 ;
set opt(PeriodInterval) 1
set opt(transmission_time_error) 0.0001;
set opt(ContentionWindow) 0.1;

set opt(dz) 10
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 10 ;# number of nodes in each layer
set opt(layers) 1
set opt(x) 100 ;# X dimension of the topography
set opt(y) 100 ;# Y dimension of the topography
set opt(z) 0
set opt(seed) 55
set opt(stop) 100 ;# simulation time
set opt(prestop) 60 ;# time to prepare to stop
set opt(tr) "out.tr" ;# trace file
set opt(nam) "out.nam" ;# nam file
set opt(rp) DumbAgent ;# routing protocol
set opt(width) 20
set opt(adj) 10
set opt(interval) 0.001

# ==================================================================

LL set mindelay_ 50us


LL set delay_ 25us
LL set bandwidth_ 0 ;# not used
Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1

# unity gain, omni-directional antennas


# set up the antennas to be centered in the node and 1.5 meters above it
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Z_ 0.05
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0

# ==================================================================
# Main Program
# =================================================================

#
# Initialize Global Variables
#
#set sink_ 1
set ns_ [new Simulator]
set topo [new Topography]

$topo load_flatgrid $opt(x) $opt(y)


$ns_ use-newtrace
set tracefd [open $opt(tr) w]
$ns_ trace-all $tracefd

set namfile [open out.nam w]


$ns_ namtrace-all $namfile
$ns_ namtrace-all-wireless $namfile $opt(x) $opt(y)

set total_number [expr $opt(nn)-1]


set god_ [create-god $opt(nn)]

set chan_1_ [new $opt(chan)]

$ns_ node-config -adhocRouting $opt(rp) \


-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF\
-topoInstance $topo\
-energyModel $opt(energy)\
-txpower $opt(txpower)\
-rxpower $opt(rxpower)\
-initialEnergy $opt(initialenergy)\
-idlePower $opt(idlepower)\
-channel $chan_1_

#===================================
# Nodes Definition
#===================================
#Create 5 nodes
for {set i 0} {$i < $opt(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
$ns_ initial_node_pos $node_($i) 20 ;#size of the node
}

#create movement in nodes


$ns_ at 5.0 "$node_(0) setdest 99.0 90.0 10.0"
$ns_ at 10.0 "$node_(1) setdest 25.0 50.0 25.0"
$ns_ at 10.0 "$node_(2) setdest 75.0 20.0 30.0"
$ns_ at 10.0 "$node_(3) setdest 25.0 20.0 20.0"
$ns_ at 10.0 "$node_(4) setdest 80.0 10.0 50.0"
$ns_ at 10.0 "$node_(5) setdest 90.0 90.0 20.0"
$ns_ at 20.0 "$node_(6) setdest 55.0 30.0 30.0"
$ns_ at 10.0 "$node_(7) setdest 65.0 20.0 15.0"
$ns_ at 10.0 "$node_(8) setdest 25.0 20.0 20.0"
$ns_ at 90.0 "$node_(9) setdest 48.0 60.0 75.0"

#for {set i 0} {$i < $val(nn) } {incr i} {


#set n+$i [$ns_ node]
#$ns_ initial_node_pos n+"$i" 20
#}

#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp0
set null1 [new Agent/Null]
$ns_ attach-agent $node_(9) $null1
$ns_ connect $udp0 $null1
$udp0 set packetSize_ 512

#Setup a UDP connection


set udp1 [new Agent/UDP]
$ns_ attach-agent $node_(1) $udp1
set null6 [new Agent/Null]
$ns_ attach-agent $node_(8) $null6
$ns_ connect $udp1 $null6
$udp1 set packetSize_ 512

#Setup a UDP connection


set udp2 [new Agent/UDP]
$ns_ attach-agent $node_(2) $udp2
set null7 [new Agent/Null]
$ns_ attach-agent $node_(7) $null7
$ns_ connect $udp2 $null7
$udp2 set packetSize_ 512
#Setup a UDP connection
set udp3 [new Agent/UDP]
$ns_ attach-agent $node_(3) $udp3
set null8 [new Agent/Null]
$ns_ attach-agent $node_(6) $null8
$ns_ connect $udp3 $null8
$udp3 set packetSize_ 512

#Setup a UDP connection


set udp4 [new Agent/UDP]
$ns_ attach-agent $node_(4) $udp4
set null9 [new Agent/Null]
$ns_ attach-agent $node_(5) $null9
$ns_ connect $udp4 $null9
$udp4 set packetSize_ 512

#Setup a UDP connection


set udp10 [new Agent/UDP]
$ns_ attach-agent $node_(1) $udp10
set null11 [new Agent/Null]
$ns_ attach-agent $node_(7) $null11
$ns_ connect $udp10 $null11
$udp10 set packetSize_ 512

#===================================
# Applications Definition
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 512
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns_ at 1.0 "$cbr0 start"
$ns_ at 2.0 "$cbr0 stop"

#Setup a CBR Application over UDP connection


set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 512
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns_ at 1.0 "$cbr1 start"
$ns_ at 2.0 "$cbr1 stop"

#Setup a CBR Application over UDP connection


set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
$cbr2 set packetSize_ 512
$cbr2 set rate_ 1.0Mb
$cbr2 set random_ null
$ns_ at 1.0 "$cbr2 start"
$ns_ at 2.0 "$cbr2 stop"

#Setup a CBR Application over UDP connection


set cbr3 [new Application/Traffic/CBR]
$cbr3 attach-agent $udp3
$cbr3 set packetSize_ 512
$cbr3 set rate_ 1.0Mb
$cbr3 set random_ null
$ns_ at 1.0 "$cbr3 start"
$ns_ at 2.0 "$cbr3 stop"

#Setup a CBR Application over UDP connection


set cbr4 [new Application/Traffic/CBR]
$cbr4 attach-agent $udp4
$cbr4 set packetSize_ 512
$cbr4 set rate_ 1.0Mb
$cbr4 set random_ null
$ns_ at 1.0 "$cbr4 start"
$ns_ at 2.0 "$cbr4 stop"

#Setup a CBR Application over UDP connection


set cbr5 [new Application/Traffic/CBR]
$cbr5 attach-agent $udp10
$cbr5 set packetSize_ 512
$cbr5 set rate_ 1.0Mb
$cbr5 set random_ null
$ns_ at 1.0 "$cbr5 start"
$ns_ at 2.0 "$cbr5 stop"

#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns_ flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns_ at $val(stop) "\$node_($i) reset"
}
$ns_ at $val(stop) "$ns_ nam-end-wireless $val(stop)"
$ns_ at $val(stop) "finish"
$ns_ at $val(stop) "puts \"done\" ; $ns_ halt"
$ns_ run

You might also like