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

[ns] : Example of awk in Wireless2.tcl



After running it i received a message like;
  Invalid commmand BEGIN {
   # simple awk script to generate end-to-end packet
lifetime statistics
  # in a form suitable for plotting with xgrah.
# Lloyd Wood,jul.............
...............................
Can you pls tell me what to do next?
addy.
Note: forwarded message attached.


__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/


Hi,
can someone fidget out where is the problem in this
scripts
Thanks ,

######################################################
# Addy2.tcl
# simulation for a wired-cum-wireless scenario  
# consisting of 2 wired nodes connected toa wireless 
# domain through a base-station node.
#
=====================================================
# Define options
#
=====================================================
set opt(chan)        channel/WirelessChannel   ;#
chann
.....
......
#
=====================================================
check for boundary parameters and random seed
if { $opt(x) == 0 || $opt(y) == 0 } {
        puts "NO X-Y..............
}
if {$opt(seed) > 0} {
        puts "seeding Random number genarator......
        ns-random $opt(seed)
}

# create simulator instance
set ns_   [new Simulator]
....................................
.................................
.........
set tracefd  [open addy2-out.tr w]
set namtrace [open addy2-out.nam w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x)  $opt(y)
$ns_ namtrace-all $namtrace
set f1 [open D_www.tr w]
set f2 [open N_pc.tr w]
set f3 [open D_pc.tr w]
set f4 [open N_i.tr w]
set f5 [open S_iu.tr w]
set f6 [open S_id.tr w]
set f7 [open SS.tr w]
set f8 [open RT.tr w]

# Create topography object
set topo [new Topography]
# define topology
$topo load_flatgrid 4opt(x) $opt(y)
# Create God
......
# Create wired nodes
......................................
....................................
.....................

# configure for base -station node
$ns_ node-config - adhocRouting $opt(......)\
                 - llType $opt(ll)\
                 - macType $opt(mac)\
                 ......................
                 ........................
                  ............
# Create base-station node
 set temp {1.0.0 1.0.1 1.0.2 1.0.3}
 ................................
...................
.................
}
 # create links between wired and BS nodes
 
 $ns_ duplex-link $W(0) $W(1)  5Mb 2ms Droptail
...........................................


# setup TCP connections
 set tcp1 [new Agent/TCP]
 ........................
.........................
..................
..........
set tcp2 [new Agent/TCP]
$tcp2 set class_2
..................
...........
......


.......................................
........................
...............
.................

proc stop {} {
    global ns_ f nf f1 f2 f3 f4 f5 f6 f7 f8
#     $ns_ flush-trace
#    close the trace files.
#    close the namtrace files.
#    close tracefd; close $nf; close $f2; ....close
$f4;|
     close $f5; close $f6;.............close $f8
     exec rm -f PDG.data
     exec touch PDG.data
     exec rm -f RTG.tr
     exec touch RTG.tr
BEGIN {
   # simple awk script to generate end-to-end packet
lifetime statistics
   # in a form suitable for plotting with xgraph.
   # Lloyd Wood, July 1999.
   # http://www.ee.surrey.ac.uk/Personal/L.wood/ns/
             
   highest_packet_id = 0;
}

{
  action = $1;
  time =$2;
  node_1 = $3;
  node_2 = $4;
  src = $5;
  flow_id = $8;
  node_1_address = $9;
  node_2_address = $10;
  seq_no =$11;
  packet_id =$12;

if (packet_id > highest_packet_id ) highest_packet_id
=
 packet_id;
3 getting start time is not a problem,provided you're
not stating
# traffic at 0.0
# could test for sending node_1_address or flow_id
here.
if 9start_time[packet-id] == 0 ) start_time[packet-id]
=time;

# only useful for small unicast where packet_id
doesn't 
wrap.
# checking receive means avoiding recording drops
if (action != "d") {
If (action =="r" ) {
# colud test for receiving node_2_address or flow_id
here.
end_time[packet_id] = time;
}
}else {
end_time[packet_id] = -1
}
}
END {
for (packet_id = 0; packet_id <= highest_packet_id;
packet_id++ ) {
start = start_time[packet_id];
end =end_ time[packet_id];
packet_duration =end - start;

if (start < end ) print ("%d %f\n", start,
packet_duration);
}
}
}

# informative header for CMUTracefile
puts $tracefd "M 0.0nn $opt(nn) x $opt(x) y $opt(y) rp
\ $opt(adhocRouting)"
.....................................................
.....................................................

puts "Starting Simulation......"
$ns_ run





__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/