LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-09-2014, 07:27 AM   #1
Aska123
Member
 
Registered: Apr 2013
Posts: 197

Rep: Reputation: Disabled
No output in xgraph file


Hello friends

I worked on a file

http://hpds.ee.ncku.edu.tw/~smallko/...less-udp-1.htm

file is as follow
Code:
# Define Node Configuration paramaters
#====================================================================
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)      8                       ;# number of mobilenodes
set val(rp)      DSDV 			;# routing protocol
set val(x) 	500 			;# X dimension of the topography
set val(y) 	500 			;# Y dimension of the topography

Mac/802_11 set RTSThreshold_ 3000
Mac/802_11 set basicRate_ 1Mb 
Mac/802_11 set dataRate_ 2Mb

#=====================================================================
# Initialize trace file desctiptors
#=====================================================================
# *** Throughput Trace ***
set f0 [open out02.tr w]
set f1 [open out12.tr w]
set f2 [open out22.tr w]
set f3 [open out32.tr w]

# *** Packet Loss Trace ***
set f4 [open lost02.tr w]
set f5 [open lost12.tr w]
set f6 [open lost22.tr w]
set f7 [open lost32.tr w]

# *** Packet Delay Trace ***
set f8 [open delay02.tr w]
set f9 [open delay12.tr w]
set f10 [open delay22.tr w]
set f11 [open delay32.tr w]

# *** Initialize Simulator ***
set ns_ [new Simulator]

# *** Initialize Trace file ***
set tracefd [open trace2.tr w]
$ns_ trace-all $tracefd

# *** Initialize Network Animator ***
set namtrace [open sim12.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)

# *** set up topography object ***
set topo [new Topography]
$topo load_flatgrid 500 500

# Create General Operations Director (GOD) object. It is used to store global information about the state of the environment, network, or nodes that an
# omniscent observer would have, but that should not be made known to any participant in the simulation.

create-god $val(nn)

# configure 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 OFF \
-movementTrace OFF 

# Create Nodes

for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node] 
$node_($i) random-motion 0 ;# disable random motion
}

# Initialize Node Coordinates

$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 200.0
$node_(1) set Y_ 5.0
$node_(1) set Z_ 0.0

$node_(2) set X_ 5.0
$node_(2) set Y_ 50.0
$node_(2) set Z_ 0.0

$node_(3) set X_ 200.0
$node_(3) set Y_ 50.0
$node_(3) set Z_ 0.0

$node_(4) set X_ 5.0
$node_(4) set Y_ 100.0
$node_(4) set Z_ 0.0

$node_(5) set X_ 200.0
$node_(5) set Y_ 100.0
$node_(5) set Z_ 0.0

$node_(6) set X_ 2.0
$node_(6) set Y_ 150.0
$node_(6) set Z_ 0.0

$node_(7) set X_ 200.0
$node_(7) set Y_ 150.0
$node_(7) set Z_ 0.0

# Setup traffic flow between nodes
# UDP connections between node_(0) and node_(1)

# Create Constant four Bit Rate Traffic sources

set agent1 [new Agent/UDP] ;# Create UDP Agent
#$agent1 set prio_ 0 ;# Set Its priority to 0

set sink [new Agent/LossMonitor] ;# Create Loss Monitor Sink in order to be able to trace the number of bytes received

$ns_ attach-agent $node_(0) $agent1 ;# Attach Agent to source node
$ns_ attach-agent $node_(1) $sink ;# Attach Agent to sink node
$ns_ connect $agent1 $sink ;# Connect the nodes

set app1 [new Application/Traffic/CBR] ;# Create Constant Bit Rate application
$app1 set packetSize_ 512 ;# Set Packet Size to 512 bytes
$app1 set rate_ 600Kb ;# Set CBR rate to 200 Kbits/sec
$app1 attach-agent $agent1 ;# Attach Application to agent

set agent2 [new Agent/UDP] ;# Create UDP Agent
#$agent2 set prio_ 1 ;# Set Its priority to 1

set sink2 [new Agent/LossMonitor] ;# Create Loss Monitor Sink in order to be able to trace the number obytes received
$ns_ attach-agent $node_(2) $agent2 ;# Attach Agent to source node
$ns_ attach-agent $node_(3) $sink2 ;# Attach Agent to sink node
$ns_ connect $agent2 $sink2 ;# Connect the nodes

set app2 [new Application/Traffic/CBR] ;# Create Constant Bit Rate application
$app2 set packetSize_ 512 ;# Set Packet Size to 512 bytes
$app2 set rate_ 600Kb ;# Set CBR rate to 200 Kbits/sec
$app2 attach-agent $agent2 ;# Attach Application to agent

set agent3 [new Agent/UDP] ;# Create UDP Agent
#$agent3 set prio_ 2 ;# Set Its priority to 2
set sink3 [new Agent/LossMonitor] ;# Create Loss Monitor Sink in order to be able to trace the number obytes received
$ns_ attach-agent $node_(4) $agent3 ;# Attach Agent to source node
$ns_ attach-agent $node_(5) $sink3 ;# Attach Agent to sink node
$ns_ connect $agent3 $sink3 ;# Connect the nodes
set app3 [new Application/Traffic/CBR] ;# Create Constant Bit Rate application
$app3 set packetSize_ 512 ;# Set Packet Size to 512 bytes
$app3 set rate_ 600Kb ;# Set CBR rate to 200 Kbits/sec
$app3 attach-agent $agent3 ;# Attach Application to agent

set agent4 [new Agent/UDP] ;# Create UDP Agent
#$agent4 set prio_ 3 ;# Set Its priority to 3
set sink4 [new Agent/LossMonitor] ;# Create Loss Monitor Sink in order to be able to trace the number obytes received
$ns_ attach-agent $node_(6) $agent4 ;# Attach Agent to source node
$ns_ attach-agent $node_(7) $sink4 ;# Attach Agent to sink node
$ns_ connect $agent4 $sink4 ;# Connect the nodes
set app4 [new Application/Traffic/CBR] ;# Create Constant Bit Rate application
$app4 set packetSize_ 512 ;# Set Packet Size to 512 bytes
$app4 set rate_ 600Kb ;# Set CBR rate to 200 Kbits/sec
$app4 attach-agent $agent4 ;# Attach Application to agent

# defines the node size in Network Animator

for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 20
}

# Initialize Flags
set holdtime 0
set holdseq 0

set holdtime1 0
set holdseq1 0

set holdtime2 0
set holdseq2 0

set holdtime3 0
set holdseq3 0

set holdrate1 0
set holdrate2 0
set holdrate3 0
set holdrate4 0

# Function To record Statistcis (Bit Rate, Delay, Drop)

proc record {} {
global sink sink2 sink3 sink4 f0 f1 f2 f3 f4 f5 f6 f7 holdtime holdseq holdtime1 holdseq1 holdtime2 holdseq2 holdtime3 holdseq3 f8 f9 f10 f11 holdrate1 holdrate2 holdrate3 holdrate4

set ns [Simulator instance]

set time 0.9 ;#Set Sampling Time to 0.9 Sec

set bw0 [$sink set bytes_]
set bw1 [$sink2 set bytes_]
set bw2 [$sink3 set bytes_]
set bw3 [$sink4 set bytes_]

set bw4 [$sink set nlost_]
set bw5 [$sink2 set nlost_]
set bw6 [$sink3 set nlost_]
set bw7 [$sink4 set nlost_]

set bw8 [$sink set lastPktTime_]
set bw9 [$sink set npkts_]

set bw10 [$sink2 set lastPktTime_]
set bw11 [$sink2 set npkts_]

set bw12 [$sink3 set lastPktTime_]
set bw13 [$sink3 set npkts_]

set bw14 [$sink4 set lastPktTime_]
set bw15 [$sink4 set npkts_]

set now [$ns now]

# Record Bit Rate in Trace Files
puts $f0 "$now [expr (($bw0+$holdrate1)*8)/(2*$time*1000000)]"
puts $f1 "$now [expr (($bw1+$holdrate2)*8)/(2*$time*1000000)]"
puts $f2 "$now [expr (($bw2+$holdrate3)*8)/(2*$time*1000000)]"
puts $f3 "$now [expr (($bw3+$holdrate4)*8)/(2*$time*1000000)]"

# Record Packet Loss Rate in File
puts $f4 "$now [expr $bw4/$time]"
puts $f5 "$now [expr $bw5/$time]"
puts $f6 "$now [expr $bw6/$time]"
puts $f7 "$now [expr $bw7/$time]"

# Record Packet Delay in File
if { $bw9 > $holdseq } {
puts $f8 "$now [expr ($bw8 - $holdtime)/($bw9 - $holdseq)]"
} else {
puts $f8 "$now [expr ($bw9 - $holdseq)]"
}

if { $bw11 > $holdseq1 } {
puts $f9 "$now [expr ($bw10 - $holdtime1)/($bw11 - $holdseq1)]"
} else {
puts $f9 "$now [expr ($bw11 - $holdseq1)]"
}

if { $bw13 > $holdseq2 } {
puts $f10 "$now [expr ($bw12 - $holdtime2)/($bw13 - $holdseq2)]"
} else {
puts $f10 "$now [expr ($bw13 - $holdseq2)]"
}

if { $bw15 > $holdseq3 } {
puts $f11 "$now [expr ($bw14 - $holdtime3)/($bw15 - $holdseq3)]"
} else {
puts $f11 "$now [expr ($bw15 - $holdseq3)]"
}

# Reset Variables
$sink set bytes_ 0
$sink2 set bytes_ 0
$sink3 set bytes_ 0
$sink4 set bytes_ 0

$sink set nlost_ 0
$sink2 set nlost_ 0
$sink3 set nlost_ 0
$sink4 set nlost_ 0

set holdtime $bw8
set holdseq $bw9

set holdrate1 $bw0
set holdrate2 $bw1
set holdrate3 $bw2
set holdrate4 $bw3

$ns at [expr $now+$time] "record" ; # Schedule Record after $time interval sec
}

# Start Recording at Time 0
$ns_ at 0.0 "record"

$ns_ at 1.4 "$app1 start" ;# Start transmission at time t = 1.4 Sec

$ns_ at 10.0 "$app2 start" ;# Start transmission at time t = 10 Sec

$ns_ at 20.0 "$app3 start" ;# Start transmission at time t = 20 Sec

$ns_ at 30.0 "$app4 start" ;# Start transmission at time t = 30 Sec

# Stop Simulation at Time 80 sec
$ns_ at 180.0 "stop"

# Reset Nodes at time 80 sec

for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 80.0 "$node_($i) reset";
}

# Exit Simulatoion at Time 80.01 sec
$ns_ at 80.01 "puts \"NS EXITING...\" ; $ns_ halt"

proc stop {} {
global ns_ tracefd f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11

# Close Trace Files
close $f0 
close $f1
close $f2
close $f3

close $f4 
close $f5
close $f6
close $f7

close $f8
close $f9
close $f10
close $f11

# Plot Recorded Statistics
exec xgraph out02.tr out12.tr out22.tr out32.tr -geometry 800x400 &
exec xgraph lost02.tr lost12.tr lost22.tr lost32.tr -geometry 800x400 &
exec xgraph delay02.tr delay12.tr delay22.tr delay32.tr -geometry 800x400 &

# Reset Trace File
$ns_ flush-trace
close $tracefd
exec nam sim12.nam &
exit 0
}

puts "Starting Simulation..."
$ns_ run
site is showing result but when I run it on my terminal there is only straight line in x graph
also there is only data

0.0
0.90000000000000002 0.0
1.8 0.0
2.7000000000000002 0.0
3.6000000000000001 0.0
4.5 0.0
5.4000000000000004 0.0
6.3000000000000007 0.0
7.2000000000000011 0.0
8.1000000000000014 0.0
9.0000000000000018 0.0
9.9000000000000021 0.0
10.800000000000002 0.0
11.700000000000003 0.0
12.600000000000003 0.0
13.500000000000004 0.0
14.400000000000004 0.0
15.300000000000004 0.0
16.200000000000003 0.0
17.100000000000001 0.0
all 0.0

please reply where is the error?

Thanks
 
Old 03-10-2014, 06:39 PM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,325

Rep: Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583
Quote:
.. when I run it on my terminal ..
Please show the command(s) you are using.

No issues here with the original file : $ ns wireless-udp-1.tcl
.. and the usual three Xgraph windows are opened.
( It's a well known tcl file, not the first time it appears at LQ.)

What did you edit ? ? Line numbers, please.
-
Attached Thumbnails
Click image for larger version

Name:	wireless-udp-1.xgraph.jpg
Views:	40
Size:	30.1 KB
ID:	14927  

Last edited by knudfl; 03-10-2014 at 06:48 PM.
 
Old 03-11-2014, 12:31 AM   #3
Aska123
Member
 
Registered: Apr 2013
Posts: 197

Original Poster
Rep: Reputation: Disabled
Thanks for replying.

I have changed nothing . I have copy paste file as it is.

I am again uploading code.

Code:
# ====================================================================
# Define Node Configuration paramaters
#====================================================================
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)             8                          ;# number of mobilenodes
set val(rp)             DSDV                       ;# routing protocol
set val(x)              500                        ;# X dimension of the topography
set val(y)              500                           ;# Y dimension of the topography
 
Mac/802_11 set RTSThreshold_  3000
Mac/802_11 set basicRate_ 1Mb
Mac/802_11 set dataRate_  2Mb
 
#=====================================================================
# Initialize trace file desctiptors
#=====================================================================
# *** Throughput Trace ***
set f0 [open out02.tr w]
set f1 [open out12.tr w]
set f2 [open out22.tr w]
set f3 [open out32.tr w]
 
# *** Packet Loss Trace ***
set f4 [open lost02.tr w]
set f5 [open lost12.tr w]
set f6 [open lost22.tr w]
set f7 [open lost32.tr w]
 
# *** Packet Delay Trace ***
set f8 [open delay02.tr w]
set f9 [open delay12.tr w]
set f10 [open delay22.tr w]
set f11 [open delay32.tr w]


# *** Initialize Simulator ***
set ns_              [new Simulator]
 
# *** Initialize Trace file ***
set tracefd     [open trace2.tr w]
$ns_ trace-all $tracefd
 
# *** Initialize Network Animator ***
set namtrace [open sim12.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
 
# *** set up topography object ***
set topo       [new Topography]
$topo load_flatgrid 500 500
 
# Create  General Operations Director (GOD) object. It is used to store global information about the state of the environment, network, or nodes that an
# omniscent observer would have, but that should not be made known to any participant in the simulation.
 
create-god $val(nn)
 
# configure 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 OFF \
                         -movementTrace OFF                   
 
# Create Nodes
 
        for {set i 0} {$i < $val(nn) } {incr i} {
                set node_($i) [$ns_ node]
                $node_($i) random-motion 0            ;# disable random motion
        }
 
# Initialize Node Coordinates
 
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0
 
$node_(1) set X_ 200.0
$node_(1) set Y_ 5.0
$node_(1) set Z_ 0.0
 
$node_(2) set X_ 5.0
$node_(2) set Y_ 50.0
$node_(2) set Z_ 0.0
 
$node_(3) set X_ 200.0
$node_(3) set Y_ 50.0
$node_(3) set Z_ 0.0
 
$node_(4) set X_ 5.0
$node_(4) set Y_ 100.0
$node_(4) set Z_ 0.0
 
$node_(5) set X_ 200.0
$node_(5) set Y_ 100.0
$node_(5) set Z_ 0.0
 
$node_(6) set X_ 2.0
$node_(6) set Y_ 150.0
$node_(6) set Z_ 0.0
 
$node_(7) set X_ 200.0
$node_(7) set Y_ 150.0
$node_(7) set Z_ 0.0
 
# Setup traffic flow between nodes
# UDP connections between node_(0) and node_(1)
 
# Create Constant four Bit Rate Traffic sources
 
set agent1 [new Agent/UDP]             ;# Create UDP Agent
$agent1 set prio_ 0                   ;# Set Its priority to 0
set sink [new Agent/LossMonitor]  ;# Create Loss Monitor Sink in order to be able to trace the number obytes received
$ns_ attach-agent $node_(0) $agent1     ;# Attach Agent to source node
$ns_ attach-agent $node_(1) $sink ;# Attach Agent to sink node
$ns_ connect $agent1 $sink            ;# Connect the nodes
set app1 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application
$app1 set packetSize_ 512               ;# Set Packet Size to 512 bytes
$app1 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec
$app1 attach-agent $agent1             ;# Attach Application to agent
 
set agent2 [new Agent/UDP]             ;# Create UDP Agent
$agent2 set prio_ 1                   ;# Set Its priority to 1
set sink2 [new Agent/LossMonitor]         ;# Create Loss Monitor Sink in order to be able to trace the number obytes received
$ns_ attach-agent $node_(2) $agent2     ;# Attach Agent to source node
$ns_ attach-agent $node_(3) $sink2        ;# Attach Agent to sink node
$ns_ connect $agent2 $sink2                  ;# Connect the nodes
set app2 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application
$app2 set packetSize_ 512               ;# Set Packet Size to 512 bytes
$app2 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec
$app2 attach-agent $agent2             ;# Attach Application to agent
 
set agent3 [new Agent/UDP]             ;# Create UDP Agent
$agent3 set prio_ 2                   ;# Set Its priority to 2
set sink3 [new Agent/LossMonitor]         ;# Create Loss Monitor Sink in order to be able to trace the number obytes received
$ns_ attach-agent $node_(4) $agent3     ;# Attach Agent to source node
$ns_ attach-agent $node_(5) $sink3        ;# Attach Agent to sink node
$ns_ connect $agent3 $sink3                  ;# Connect the nodes
set app3 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application
$app3 set packetSize_ 512               ;# Set Packet Size to 512 bytes
$app3 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec
$app3 attach-agent $agent3             ;# Attach Application to agent
 
set agent4 [new Agent/UDP]             ;# Create UDP Agent
$agent4 set prio_ 3                   ;# Set Its priority to 3
set sink4 [new Agent/LossMonitor]         ;# Create Loss Monitor Sink in order to be able to trace the number obytes received
$ns_ attach-agent $node_(6) $agent4     ;# Attach Agent to source node
$ns_ attach-agent $node_(7) $sink4        ;# Attach Agent to sink node
$ns_ connect $agent4 $sink4                  ;# Connect the nodes
set app4 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application
$app4 set packetSize_ 512               ;# Set Packet Size to 512 bytes
$app4 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec
$app4 attach-agent $agent4             ;# Attach Application to agent


# defines the node size in Network Animator
 
for {set i 0} {$i < $val(nn)} {incr i} {
    $ns_ initial_node_pos $node_($i) 20
}
 
# Initialize Flags
set holdtime 0
set holdseq 0
 
set holdtime1 0
set holdseq1 0
 
set holdtime2 0
set holdseq2 0
 
set holdtime3 0
set holdseq3 0
 
set holdrate1 0
set holdrate2 0
set holdrate3 0
set holdrate4 0
 
# Function To record Statistcis (Bit Rate, Delay, Drop)
 
proc record {} {
        global sink sink2 sink3 sink4 f0 f1 f2 f3 f4 f5 f6 f7 holdtime holdseq holdtime1 holdseq1 holdtime2 holdseq2 holdtime3 holdseq3 f8 f9 f10 f11 holdrate1 holdrate2 holdrate3 holdrate4
       
        set ns [Simulator instance]
       
    set time 0.9 ;#Set Sampling Time to 0.9 Sec
 
        set bw0 [$sink set bytes_]
        set bw1 [$sink2 set bytes_]
        set bw2 [$sink3 set bytes_]
        set bw3 [$sink4 set bytes_]
 
        set bw4 [$sink set nlost_]
        set bw5 [$sink2 set nlost_]
        set bw6 [$sink3 set nlost_]
        set bw7 [$sink4 set nlost_]
 
        set bw8 [$sink set lastPktTime_]
        set bw9 [$sink set npkts_]
 
        set bw10 [$sink2 set lastPktTime_]
        set bw11 [$sink2 set npkts_]
 
        set bw12 [$sink3 set lastPktTime_]
        set bw13 [$sink3 set npkts_]
 
        set bw14 [$sink4 set lastPktTime_]
        set bw15 [$sink4 set npkts_]
       
    set now [$ns now]
       
        # Record Bit Rate in Trace Files
        puts $f0 "$now [expr (($bw0+$holdrate1)*8)/(2*$time*1000000)]"
        puts $f1 "$now [expr (($bw1+$holdrate2)*8)/(2*$time*1000000)]"
        puts $f2 "$now [expr (($bw2+$holdrate3)*8)/(2*$time*1000000)]"
        puts $f3 "$now [expr (($bw3+$holdrate4)*8)/(2*$time*1000000)]"
 
        # Record Packet Loss Rate in File
        puts $f4 "$now [expr $bw4/$time]"
        puts $f5 "$now [expr $bw5/$time]"
        puts $f6 "$now [expr $bw6/$time]"
        puts $f7 "$now [expr $bw7/$time]"
 
        # Record Packet Delay in File
        if { $bw9 > $holdseq } {
                puts $f8 "$now [expr ($bw8 - $holdtime)/($bw9 - $holdseq)]"
        } else {
                puts $f8 "$now [expr ($bw9 - $holdseq)]"
        }
 
        if { $bw11 > $holdseq1 } {
                puts $f9 "$now [expr ($bw10 - $holdtime1)/($bw11 - $holdseq1)]"
        } else {
                puts $f9 "$now [expr ($bw11 - $holdseq1)]"
        }
 
        if { $bw13 > $holdseq2 } {
                puts $f10 "$now [expr ($bw12 - $holdtime2)/($bw13 - $holdseq2)]"
        } else {
                puts $f10 "$now [expr ($bw13 - $holdseq2)]"
        }
 
        if { $bw15 > $holdseq3 } {
                puts $f11 "$now [expr ($bw14 - $holdtime3)/($bw15 - $holdseq3)]"
        } else {
                puts $f11 "$now [expr ($bw15 - $holdseq3)]"
        }
       
        # Reset Variables
        $sink set bytes_ 0
        $sink2 set bytes_ 0
        $sink3 set bytes_ 0
        $sink4 set bytes_ 0
 
        $sink set nlost_ 0
        $sink2 set nlost_ 0
        $sink3 set nlost_ 0
        $sink4 set nlost_ 0
 
        set holdtime $bw8
        set holdseq $bw9
 
        set  holdrate1 $bw0
        set  holdrate2 $bw1
        set  holdrate3 $bw2
        set  holdrate4 $bw3
 
    $ns at [expr $now+$time] "record"   ;# Schedule Record after $time interval sec
}
 

# Start Recording at Time 0
$ns_ at 0.0 "record"
 
$ns_ at 1.4 "$app1 start"                 ;# Start transmission at time t = 1.4 Sec
 
$ns_ at 10.0 "$app2 start"               ;# Start transmission at time t = 10 Sec
 
$ns_ at 20.0 "$app3 start"               ;# Start transmission at time t = 20 Sec
 
$ns_ at 30.0 "$app4 start"               ;# Start transmission at time t = 30 Sec
 
# Stop Simulation at Time 80 sec
$ns_ at 80.0 "stop"
 
# Reset Nodes at time 80 sec
 
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at 80.0 "$node_($i) reset";
}
 
# Exit Simulatoion at Time 80.01 sec
$ns_ at 80.01 "puts \"NS EXITING...\" ; $ns_ halt"
 
proc stop {} {
        global ns_ tracefd f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11
 
        # Close Trace Files
        close $f0 
        close $f1
        close $f2
        close $f3
 
        close $f4 
        close $f5
        close $f6
        close $f7
 
        close $f8
        close $f9
        close $f10
        close $f11
 
        # Plot Recorded Statistics
        exec xgraph out02.tr out12.tr out22.tr out32.tr -geometry 800x400 &
        exec xgraph lost02.tr lost12.tr lost22.tr lost32.tr -geometry 800x400 &
        exec xgraph delay02.tr delay12.tr delay22.tr delay32.tr -geometry 800x400 &
       
        # Reset Trace File
        $ns_ flush-trace
        close $tracefd
       
        exit 0
}
 
puts "Starting Simulation..."
$ns_ run
I have two ns-2.34 installed on my system. I run this file on both but same output.

Last edited by Aska123; 03-11-2014 at 12:38 AM.
 
Old 03-11-2014, 06:37 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,325

Rep: Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583Reputation: 3583
# 4 .

Your example copy in post #1 does not open 'xgraph', any 'ns-<??>.
Your other copy, post #3 is OK. With the most 'ns-<??>' I think.
But you can probably patch ns2 with something that makes the file not work OK .. →
I have not tested "wireless-udp-1.tcl with all the eighty (80) most used 'ns-<modified>'.
But it will display a straight line with $ ns-leach wireless-udp-1.tcl

-
 
1 members found this post helpful.
Old 03-11-2014, 09:59 AM   #5
Aska123
Member
 
Registered: Apr 2013
Posts: 197

Original Poster
Rep: Reputation: Disabled
Hello Kundfi

I have installed a new ns-allinone-2.34 in a new folder without ant patch.

Now there are graph in xgraph window.

Previously I have mannasim patch and leach patch attached in my ns-2.34.

Thanks one again.

I have also a query on Jitter awk please see that thread also.
 
Old 03-12-2014, 03:07 AM   #6
Aska123
Member
 
Registered: Apr 2013
Posts: 197

Original Poster
Rep: Reputation: Disabled
Hello Kundfi
Today I used the above file for energy model just for four nodes.
Code:
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)              500                        ;# X dimension of the topography
set val(y)              500                           ;# Y dimension of the topography
set opt(energymodel)    EnergyModel 
 
Mac/802_11 set RTSThreshold_  3000
Mac/802_11 set basicRate_ 1Mb
Mac/802_11 set dataRate_  2Mb

#=====================================================================
# Initialize trace file desctiptors
#=====================================================================
# *** Throughput Trace ***
set f0 [open out03.tr w]

 
# *** Packet Loss Trace ***
set f4 [open lost03.tr w]

 
# *** Packet Delay Trace ***
set f8 [open delay03.tr w]

#*** Throughput Trace ***
set f1 [open thro.tr w]

 
# *** Initialize Simulator ***
set ns_              [new Simulator]
 
# *** Initialize Trace file ***
set tracefd     [open trace3.tr w]
$ns_ trace-all $tracefd
 
# *** Initialize Network Animator ***
set namtrace [open sim3.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
 
# *** set up topography object ***
set topo       [new Topography]
$topo load_flatgrid 500 500

create-god $val(nn)
 
# configure 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 OFF \
                         -movementTrace OFF \
			-energyModel $opt(energymodel) \
			 -rxPower 0.3 \
			 -txPower 0.9                   
 
# Create Nodes
 
       # for {set i 0} {$i < $val(nn) } {incr i} {
        #        set node_($i) [$ns_ node]
         #       $node_($i) random-motion 0            ;# disable random motion
        #}
 
# Initialize Node Coordinates

$ns_ node-config -initialEnergy 1
set node_(0) [$ns_ node] 
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0
 
$ns_ node-config -initialEnergy 0.1
set node_(1) [$ns_ node] 
$node_(1) set X_ 200.0
$node_(1) set Y_ 5.0
$node_(1) set Z_ 0.0

$ns_ node-config -initialEnergy 0.1
set node_(2) [$ns_ node]  
$node_(2) set X_ 5.0
$node_(2) set Y_ 50.0
$node_(2) set Z_ 0.0

$ns_ node-config -initialEnergy 0.1
set node_(3) [$ns_ node] 
$node_(3) set X_ 437.0
$node_(3) set Y_ 295.0
$node_(3) set Z_ 0.0

set agent1 [new Agent/UDP]            

$agent1 set prio_ 0                   

set sink [new Agent/LossMonitor]  

$ns_ attach-agent $node_(0) $agent1     ;# Attach Agent to source node

$ns_ attach-agent $node_(1) $sink          ;# Attach Agent to sink node

$ns_ connect $agent1 $sink                   ;# Connect the nodes

set app1 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application
$app1 set packetSize_ 512               ;# Set Packet Size to 512 bytes
$app1 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec
$app1 attach-agent $agent1             ;# Attach Application to agent

set agent2 [new Agent/UDP]             ;# Create UDP Agent
$agent2 set prio_ 1                   ;# Set Its priority to 1


$ns_ attach-agent $node_(2) $agent2

$ns_ connect $agent2 $sink


set app2 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application
$app2 set packetSize_ 512               ;# Set Packet Size to 512 bytes
$app2 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec
$app2 attach-agent $agent2             ;# Attach Application to agent

$ns_ attach-agent $node_(2) $agent2

$ns_ connect $agent2 $sink


set agent3 [new Agent/UDP]             ;# Create UDP Agent
$agent3 set prio_ 1                   ;# Set Its priority to 1


$ns_ attach-agent $node_(3) $agent3

$ns_ connect $agent3 $sink
set app3 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application
$app3 set packetSize_ 512               ;# Set Packet Size to 512 bytes
$app3 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec
$app3 attach-agent $agent3             ;# Attach Application to agent

# defines the node size in Network Animator
 
for {set i 0} {$i < $val(nn)} {incr i} {
    $ns_ initial_node_pos $node_($i) 20
}
 
# Initialize Flags
set holdtime 0
set holdseq 0
 
set holdtime1 0
set holdseq1 0
 
set holdtime2 0
set holdseq2 0

set holdrate1 0
set holdrate2 0
set holdrate3 0


# Function To record Statistcis (Bit Rate, Delay, Drop)
 
proc record {} {
        global sink  f0  f4  f8 holdtime holdseq holdtime1 holdseq1 holdtime2 holdseq2  f8 f9 f10 f11 holdrate1  
       
	set ns [Simulator instance]
        set time 0.9 ;#Set Sampling Time to 0.9 Sec
 
set bw0 [$sink set bytes_]
set bw4 [$sink set nlost_]
set bw8 [$sink set lastPktTime_]
 set bw9 [$sink set npkts_]

 set now [$ns now]
   
   # Record Bit Rate in Trace Files
   puts $f0 "$now [expr (($bw0+$holdrate1)*8)/(2*$time*1000000)]"
     
 # Record Packet Loss Rate in File
        puts $f4 "$now [expr $bw4/$time]"
       
 # Record Packet Delay in File
        if { $bw9 > $holdseq } {
                puts $f8 "$now [expr ($bw8 - $holdtime)/($bw9 - $holdseq)]"
        } else {
                puts $f8 "$now [expr ($bw9 - $holdseq)]"
        }
             
 # Reset Variables
        $sink set bytes_ 0
        $sink set nlost_ 0
        set holdtime $bw8
        set holdseq $bw9
        set  holdrate1 $bw0
        
    $ns at [expr $now+$time] "record"   ;# Schedule Record after $time interval sec
}

# Start Recording at Time 0
$ns_ at 0.0 "record"
$ns_ at 1.4 "$app1 start"                 ;# Start transmission at time t = 1.4 Sec
$ns_ at 10.0 "$app2 start"               ;# Start transmission at time t = 10 Sec


# Stop Simulation at Time 80 sec
$ns_ at 80.0 "stop"
 
# Reset Nodes at time 80 sec
 
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at 80.0 "$node_($i) reset";
}
 
# Exit Simulatoion at Time 80.01 sec
$ns_ at 80.01 "puts \"NS EXITING...\" ; $ns_ halt"
 
proc stop {} {
        global ns_ tracefd f0 f1 f4  f8  namtrace
 
        # Close Trace Files
        close $f0 
        close $f4 
        close $f8
close $f1

 # Plot Recorded Statistics
        exec xgraph out03.tr  -geometry 800x400 &
        exec xgraph lost03.tr  -geometry 800x400 &
        exec xgraph delay03.tr  -geometry 800x400 &

 # Reset Trace File
        $ns_ flush-trace
        close $tracefd
	close $namtrace
	exec nam sim3.nam &
       
        exit 0
}
 
puts "Starting Simulation..."
$ns_ run
when I run this file I have graph in throughput and delay trace but I have no output in lost trace.

If I remove energy opt from node-config.

I have result in lost trace too.

what is the reason?

please reply
 
  


Reply

Tags
ns-2.34, ns2, xgraph


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting error while running" xgraph Error in file `out.tr' at line 23930: " albho Linux - Newbie 2 04-02-2012 01:00 PM
How to save a xgraph file in ns2.34 for later printout !! Shruti Linux - Newbie 6 07-11-2011 11:39 AM
Standard script output to screen & -x option output to file BoBeau236 Programming 6 05-10-2011 08:43 AM
Output Redirection - Trying to output to screen and file? helptonewbie Linux - Newbie 7 03-19-2009 08:05 AM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 08:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration