[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

No Subject



Hi all,
  I attach the file I use for the simulation below..
In this file if I use tcp_(0) and ftp_(0) instead of tcp1 and ftp1 as in
the current file, the simulator will not start and complains that tcp_(0)
is not a valid variable..But, with the present script, the simulation runs
and produces the scr1-out.tr file but not the scr1_seq.tr(actually it
produces just a blank file)..I want to get a graph of the seq number sent
by the sender with time..Can someone please help about why the script
gives an error initially and after I change the variable names, it runs,
but does not produce any output for the sequence number traces...

Thanks.
Jeyandran           
ps:The $val(cp) contains a file generated by setdest..

# ======================================================================
# Define options
# ======================================================================

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(x)              1000   ;# X dimension of the topography
set val(y)              1000   ;# Y dimension of the topography
set val(ifqlen)         50            ;# max packet in ifq
set val(seed)           0.0
set val(adhocRouting)   DSR
set val(nn)             50             ;# how many nodes are simulated
set val(cp)             "mov_p1000_50" 
set val(stop)           600.0           ;# simulation time

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

#
# Initialize Global Variables
#

# create simulator instance

set ns_		[new Simulator]

# setup topography object

set topo	[new Topography]

# create trace object for ns and nam

set tracefd	[open scr1-out.tr w]
set namtrace    [open scr1-out.nam w]
set seqtrace     [open scr1_seq.tr w]

$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)

# define topology
$topo load_flatgrid $val(x) $val(y)

#
# Create God
#
set god_ [create-god $val(nn)]

#
# define how node should be created
#

#global node setting

set chan_1_ [new $val(chan)]

$ns_ node-config -adhocRouting $val(adhocRouting) \
                 -llType $val(ll) \
                 -macType $val(mac) \
                 -ifqType $val(ifq) \
                 -ifqLen $val(ifqlen) \
                 -antType $val(ant) \
                 -propType $val(prop) \
                 -phyType $val(netif) \
		 -topoInstance $topo \
		 -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
                 -channel $chan_1_

#
#  Create the specified number of nodes [$val(nn)] and "attach" them
#  to the channel. 

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


# 
# Define node movement model
#
puts "Loading connection pattern..."
source $val(cp)


# 
# Define traffic model
#
# 1 connecting to 50 at time 1.0               
set tcp1 [$ns_ create-connection  TCP $node_(0) TCPSink $node_(49) 0]
$tcp1 set window_ 32
$tcp1 set packetSize_ 512
set ftp1 [$tcp1 attach-source FTP]

$ns_ at 0.0 "record"

$ns_ at 1.0 "$ftp1 start"

# Define node initial position in nam

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

    # 20 defines the node size in nam, must adjust it according to your scenario
    # The function must be called after mobility model is defined
    
    $ns_ initial_node_pos $node_($i) 20
}


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


puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(adhocRouting)"
puts $tracefd "M 0.0 cp $val(cp) seed $val(seed)"
puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)"

$ns_ at $val(stop).1 "finish" 

proc record {} {
       global tcp1 seqtrace
       set ns [Simulator instance]
       set time 1.0
       set curseqno [$tcp1 set maxseq_]
       set now [$ns now]
       puts $seqtrace "$now $curseqno"
       $ns at [expr $now+$time] "record"
}

proc finish {} {
        global ns_ tracefd namtrace seqtrace
        $ns_ flush-trace
        close $namtrace
        close $tracefd
        close $bwtrace 
        exec xgraph scr1_seq.tr -geometry 800x400 &
        exit 0 
}

puts "Starting Simulation..."
$ns_ run