Hello ns-users

I want to analyse an energy related trace file and i work with AWK.
but it doesn't deal with energy. I have a tcl file which i want to
caculate the "end
to end delay" and "throughput" and "energy consumption" through it.
when i set the mac type as 802.11 it works with AWK and give me the
"end to end delay"and "thorughput". but when i change the mac type to
smac it doesn't work even on calculating "end to end delay"and
"throughput". I use the following tcl file.

Thanks in advance
Samira Niafar

####################

 # run SMAC in a 5-nodes multihop network with DSR routing

set opt(chan)           Channel/WirelessChannel
set opt(prop)           Propagation/TwoRayGround
set opt(netif)          Phy/WirelessPhy
set opt(mac)            Mac/802_11                 ;# MAC type
#set opt(mac)            Mac/SMAC
set opt(ifq)            Queue/DropTail/PriQueue
set opt(ifq)            CMUPriQueue
set opt(ll)             LL
set opt(ant)            Antenna/OmniAntenna
set opt(x)              600              ;# X dimension of the topography
set opt(y)              600               ;# Y dimension of the topography
set opt(ifqlen)         50                ;# max packet in ifq
set opt(seed)           0.0
set opt(tr)             smac2.tr       ;# trace file
set opt(rp)             DSR
set opt(filters)        GradientFilter
set opt(nn)             14                ;# how many nodes are simulated
set opt(stop)           300.0            ;# simulation time
set opt(syncFlag)       1                 ;# is set to 1 when SMAC
uses sleep-wakeup cycle
set opt(selfConfigFlag) 1      ;# is set to 0 when SMAC uses user
configurable schedule start time
set opt(initialenergy)  1000
set opt(energymodel)    EnergyModel     ;
set opt(radiomodel)     RadioModel        ;
set opt(receivepower)   0.281838               ;# Receiving Power
set opt(transmitpower)  0.281838                ;# Transmitting Power
set opt(idlepower)      0.281838               ;# Idle Power
set opt(sleeppower)     2.81838e-4                  ;# sleep power
set opt(transitionpower)  0.0563676                ;# transition power
set opt(transitiontime)   0.005                ;# transition time


#set interval            1.0
#set appTime1             42.0    ;# in seconds
#set appTime2             44.0    ;# in seconds
#set stopTime            100    ;# in seconds




# =====================================================================
# Other default settings


#LL set mindelay_                50us
#LL set delay_                   25us
#LL set bandwidth_               0         ;


Agent/Null set sport_           0
Agent/Null set dport_           0


Agent/CBR set sport_            0
Agent/CBR set dport_            0


Agent/TCPSink set sport_        0
Agent/TCPSink set dport_        0


Agent/TCP set sport_            0
Agent/TCP set dport_            0
Agent/TCP set packetSize_       512

#
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 Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0


# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface


Phy/WirelessPhy set CPThresh_ 10.0
#Phy/WirelessPhy set CSThresh_ 1.50990e-07
#Phy/WirelessPhy set RXThresh_ 4.80696e-07
Phy/WirelessPhy set CSThresh_ 1.559e-10
Phy/WirelessPhy set RXThresh_ 3.652e-10 ;# Receiving Threshold
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0



# SMAC settings
Mac/SMAC set syncFlag_ 1        ; # sleep wakeup cycles
#Mac/SMAC set SMAC_DUTY_CYCLE 50
Mac/SMAC set dutyCycle_ 90

#ErrorModel set rate_ 0.1


#proc UniformError {} {
 #   global
#opt

 #   set errObj [new ErrorModel]
  #  $errObj unit packet
   # return $errObj
#}





# create simulator instance
set ns_    [new Simulator]
set tracefd [open $opt(tr) w]
$ns_ use-newtrace
$ns_ trace-all $tracefd
set nf [open out03.nam w]
$ns_ namtrace-all-wireless $nf 600 600

set f0 [open out03.tr w]

set wtopo [new Topography]
$wtopo load_flatgrid $opt(x) $opt(y)

# $ns_ set WirelessNewTrace_ ON
create-god $opt(nn)

# define topology



#
# Create God
#



#
# define how node should be created
#


# node setting



   $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) \
                         -channelType $opt(chan) \
                         -topoInstance $wtopo \
                         -agentTrace ON \
                         -routerTrace ON \
                         -macTrace ON \
                         -movementTrace ON \
                    -diffusionFilter $opt(filters) \
                 -energyModel EnergyModel \
                 -idlePower 0.281838 \
                 -rxPower 0.281838 \
                 -txPower 0.281838 \
                 -sleepPower 2.81838e-4 \
                 -transitionPower 0.0563676 \
                 -transitionTime 0.005\
                 -initialEnergy 1000    

#$ns_ node-config -IncomingErrProc UniformError -OutgoingErrProc UniformError
#  Create the specified number of nodes [$opt(nn)] and "attach" them
#  to the channel.


    for {set i 0} {$i < $opt(nn) } {incr i} {
        set node_($i) [$ns_ node $i]
    }

for {set i 0} {$i < $opt(nn)} {incr i} {
    $ns_ initial_node_pos $node_($i) 100
}


    set god_ [create-god $opt(nn)]
#
#  Create DSR Agent
#  rt_rq_max_period indicates maximum time between rt reqs
#  rt_rq_period indicates length of one backoff period
#  send_timeout indicates how long a packet can live in sendbuf


#for {set i 0} {$i < $opt(nn)} {incr i} {
 #   set dsr($i) [new Agent/DSRAgent]
  #  $dsr($i)  node $node_($i)
   # $dsr($i) rt_rq_max_period 100
   # $dsr($i) rt_rq_period 30
   # $dsr($i) send_timeout 300
#}


#
#  Create the topology

$node_(0) set X_ 289.174121233685
$node_(0) set Y_ 532.222630433344
$node_(0) set Z_ 0.000000000000
$node_(1) set X_ 8.376937718690
$node_(1) set Y_ 388.816552300435
$node_(1) set Z_ 0.000000000000
$node_(2) set X_ 144.715541857489
$node_(2) set Y_ 90.031594020913
$node_(2) set Z_ 0.000000000000
$node_(3) set X_ 218.842303966917
$node_(3) set Y_ 441.557378471814
$node_(3) set Z_ 0.000000000000
$node_(4) set X_ 165.461244391263
$node_(4) set Y_ 454.793861414567
$node_(4) set Z_ 0.000000000000
$node_(5) set X_ 369.432790214666
$node_(5) set Y_ 580.361955965703
$node_(5) set Z_ 0.000000000000
$node_(6) set X_ 216.204723150139
$node_(6) set Y_ 592.333071959503
$node_(6) set Z_ 0.000000000000
$node_(7) set X_ 69.169004584465
$node_(7) set Y_ 193.122149810523
$node_(7) set Z_ 0.000000000000
$node_(8) set X_ 193.823789180105
$node_(8) set Y_ 85.517872867109
$node_(8) set Z_ 0.000000000000
$node_(9) set X_ 339.205839753806
$node_(9) set Y_ 189.069852867753
$node_(9) set Z_ 0.000000000000
$node_(10) set X_ 275.292159072303
$node_(10) set Y_ 230.926965417529
$node_(10) set Z_ 0.000000000000
$node_(11) set X_ 84.771837907038
$node_(11) set Y_ 325.588571401877
$node_(11) set Z_ 0.000000000000
$node_(12) set X_ 454.164068788785
$node_(12) set Y_ 467.766484966369
$node_(12) set Z_ 0.000000000000
$node_(13) set X_ 310.283006201234
$node_(13) set Y_ 345.991246068426
$node_(13) set Z_ 0.000000000000
$ns_ at 0.000000000000 "$node_(0) setdest 53.023557278537
86.512188472444 0.000010000000"
$ns_ at 0.000000000000 "$node_(1) setdest 328.951874892691
387.527198578617 0.000010000000"
$ns_ at 0.000000000000 "$node_(2) setdest 344.091691163152
279.980230526041 0.000010000000"
$ns_ at 0.000000000000 "$node_(3) setdest 491.585491516111
328.717712446415 0.000010000000"
$ns_ at 0.000000000000 "$node_(4) setdest 93.936835215162
477.590409279523 0.000010000000"
$ns_ at 0.000000000000 "$node_(5) setdest 308.400181994596
360.036678399804 0.000010000000"
$ns_ at 0.000000000000 "$node_(6) setdest 136.920488597700
491.466570884233 0.000010000000"
$ns_ at 0.000000000000 "$node_(7) setdest 79.119387934178
208.680626937554 0.000010000000"
$ns_ at 0.000000000000 "$node_(8) setdest 100.850885728603
94.399771242205 0.000010000000"
$ns_ at 0.000000000000 "$node_(9) setdest 529.190354997198
210.847149243627 0.000010000000"
$ns_ at 0.000000000000 "$node_(10) setdest 407.005530609086
343.788999809910 0.000010000000"
$ns_ at 0.000000000000 "$node_(11) setdest 215.868238057148
319.910406726730 0.000010000000"
$ns_ at 0.000000000000 "$node_(12) setdest 584.146157443151
344.793501942663 0.000010000000"
$ns_ at 0.000000000000 "$node_(13) setdest 220.790254167368
195.419207133165 0.000010000000"
$god_ set-dist 0 1 2
$god_ set-dist 0 2 3
$god_ set-dist 0 3 1
$god_ set-dist 0 4 1
$god_ set-dist 0 5 1
$god_ set-dist 0 6 1
$god_ set-dist 0 7 3
$god_ set-dist 0 8 3
$god_ set-dist 0 9 2
$god_ set-dist 0 10 2
$god_ set-dist 0 11 2
$god_ set-dist 0 12 1
$god_ set-dist 0 13 1
$god_ set-dist 1 2 2
$god_ set-dist 1 3 1
$god_ set-dist 1 4 1
$god_ set-dist 1 5 2
$god_ set-dist 1 6 2
$god_ set-dist 1 7 1
$god_ set-dist 1 8 2
$god_ set-dist 1 9 3
$god_ set-dist 1 10 2
$god_ set-dist 1 11 1
$god_ set-dist 1 12 2
$god_ set-dist 1 13 2
$god_ set-dist 2 3 2
$god_ set-dist 2 4 2
$god_ set-dist 2 5 3
$god_ set-dist 2 6 3
$god_ set-dist 2 7 1
$god_ set-dist 2 8 1
$god_ set-dist 2 9 1
$god_ set-dist 2 10 1
$god_ set-dist 2 11 1
$god_ set-dist 2 12 3
$god_ set-dist 2 13 2
$god_ set-dist 3 4 1
$god_ set-dist 3 5 1
$god_ set-dist 3 6 1
$god_ set-dist 3 7 2
$god_ set-dist 3 8 2
$god_ set-dist 3 9 2
$god_ set-dist 3 10 1
$god_ set-dist 3 11 1
$god_ set-dist 3 12 1
$god_ set-dist 3 13 1
$god_ set-dist 4 5 1
$god_ set-dist 4 6 1
$god_ set-dist 4 7 2
$god_ set-dist 4 8 2
$god_ set-dist 4 9 2
$god_ set-dist 4 10 1
$god_ set-dist 4 11 1
$god_ set-dist 4 12 2
$god_ set-dist 4 13 1
$god_ set-dist 5 6 1
$god_ set-dist 5 7 3
$god_ set-dist 5 8 3
$god_ set-dist 5 9 2
$god_ set-dist 5 10 2
$god_ set-dist 5 11 2
$god_ set-dist 5 12 1
$god_ set-dist 5 13 1
$god_ set-dist 6 7 3
$god_ set-dist 6 8 3
$god_ set-dist 6 9 3
$god_ set-dist 6 10 2
$god_ set-dist 6 11 2
$god_ set-dist 6 12 2
$god_ set-dist 6 13 2
$god_ set-dist 7 8 1
$god_ set-dist 7 9 2
$god_ set-dist 7 10 1
$god_ set-dist 7 11 1
$god_ set-dist 7 12 3
$god_ set-dist 7 13 2
$god_ set-dist 8 9 1
$god_ set-dist 8 10 1
$god_ set-dist 8 11 2
$god_ set-dist 8 12 3
$god_ set-dist 8 13 2
$god_ set-dist 9 10 1
$god_ set-dist 9 11 2
$god_ set-dist 9 12 2
$god_ set-dist 9 13 1
$god_ set-dist 10 11 1
$god_ set-dist 10 12 2
$god_ set-dist 10 13 1
$god_ set-dist 11 12 2
$god_ set-dist 11 13 1
$god_ set-dist 12 13 1



set udp0 [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 512
$cbr0 set interval_ 0.03
$cbr0 attach-agent $udp0
set null0 [new Agent/LossMonitor]
$ns_ attach-agent $node_(1) $null0
$ns_ connect $udp0 $null0
$ns_ at 60.0 "$cbr0 start"
$ns_ at 300.0 "$cbr0 stop"

set udp1 [new Agent/UDP]
$ns_ attach-agent $node_(2) $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 512
$cbr1 set interval_ 0.03
$cbr1 attach-agent $udp1
set null1 [new Agent/LossMonitor]
$ns_ attach-agent $node_(3) $null1
$ns_ connect $udp1 $null1
$ns_ at 100.0 "$cbr1 start"
$ns_ at 300.0 "$cbr1 stop"

set udp2 [new Agent/UDP]
$ns_ attach-agent $node_(4) $udp2
set cbr2 [new Application/Traffic/CBR]
$cbr2 set packetSize_ 1023
$cbr2 set interval_ 0.03
$cbr2 attach-agent $udp2
set null2 [new Agent/LossMonitor]
$ns_ attach-agent $node_(5) $null2
$ns_ connect $udp2 $null2
$ns_ at 80.0 "$cbr2 start"
$ns_ at 300.0 "$cbr2 stop"

set udp3 [new Agent/UDP]
$ns_ attach-agent $node_(7) $udp3
set cbr3 [new Application/Traffic/CBR]
$cbr3 set packetSize_ 1023
$cbr3 set interval_ 0.03
$cbr3 attach-agent $udp3
set null3 [new Agent/LossMonitor]
$ns_ attach-agent $node_(8) $null3
$ns_ connect $udp3 $null3
$ns_ at 100.0 "$cbr3 start"
$ns_ at 300.0 "$cbr3 stop"

set udp4 [new Agent/UDP]
$ns_ attach-agent $node_(9) $udp4
set cbr4 [new Application/Traffic/CBR]
$cbr4 set packetSize_ 512
$cbr4 set interval_ 0.03
$cbr4 attach-agent $udp4
set null4 [new Agent/LossMonitor]
$ns_ attach-agent $node_(10) $null4
$ns_ connect $udp4 $null4
$ns_ at 90.0 "$cbr4 start"
$ns_ at 300.0 "$cbr4 stop"

set udp5 [new Agent/UDP]
$ns_ attach-agent $node_(11) $udp5
set cbr5 [new Application/Traffic/CBR]
$cbr5 set packetSize_ 850
$cbr5 set interval_ 0.03
$cbr5 attach-agent $udp5
set null5 [new Agent/LossMonitor]
$ns_ attach-agent $node_(12) $null5
$ns_ connect $udp5 $null5
$ns_ at 120.0 "$cbr5 start"
$ns_ at 300.0 "$cbr5 stop"

#cbrtraffic 0 4 $interval $appTime1
#cbrtraffic 1 3 $interval $appTime2

#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $opt(nn) } {incr i} {
    $ns_ at $opt(stop) "$node_($i) reset";
}


$ns_ at 300.0001 "stop"
$ns_ at 300.0002 "$ns_ halt"

proc stop {} {
    global tracefd nf ns_ f0 np
    $ns_ flush-trace
    close $tracefd
    close $nf
    close $f0
    exec nam out03.nam
    puts "... SASAN"
    exec xgraph out03.tr -geometry 900x900 &
    exit 0
}

proc record {} {
        global null0 f0
        set ns_ [Simulator instance]
        set time 25.0
        set bw0 [$null0 set bytes_]
        set now [$ns_ now]
        puts $f0 "$now [expr $bw0/$time*8/1000000]"
        $null0 set bytes_ 0
        $ns_ at [expr $now+$time] "record"
}

$ns_ at  $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"

puts "Starting Simulation..."
$ns_ at 0.0 "record"
$ns_ at 300.0 "stop"
$ns_ run

Reply via email to