LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-20-2017, 05:44 AM   #1
deepadurai
LQ Newbie
 
Registered: Mar 2017
Posts: 2

Rep: Reputation: Disabled
created tcl file and executed got .nam and .tr file..now how to proceed using awk


i created a tcl file and executed . I got the nam and trace files.
now how to proceed execute the awk file.
 
Old 03-20-2017, 06:38 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 6,620
Blog Entries: 12

Rep: Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298Reputation: 2298
Hi and welcome to LQ.

You'll have to update with a lot more information to allow people to be able to help you. How did you run this tcl file, did you use tclsh?

Perhaps you can post this awk file which you are asking about as well as the tcl file. Please use [code][/code] tags to enclose your code clips to retain formatting and make it easier to read.

You should also post what Linux distribution you are using, what version of tclsh or other tcl tools you have.

Please understand that people on this forum are volunteers, they are also not mind readers, and thus they cannot understand details when there aren't many details.

Best Regards, and once again welcome. We hope that you can provide updates to allow members to aid you better and more clearly.
 
Old 03-21-2017, 08:33 AM   #3
deepadurai
LQ Newbie
 
Registered: Mar 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
i work in windows 7 using ns2.35 with aid of cygwin.


my tcl file.
Code:
# THIS PROGRAM CODE CONTAINS CODING TO GENERATE 
#SIMULATOR
#TRACE FILE NAMTRACE FILE (OPEN CLOSE AND RUN)
#DEFINE MANY NODES- CONFIGURE THEM- CREATE NODES  USING FOR LOOP
# PROVIDE INITIAL POSITION  - SET DESTINATION AND MAKE THEM MOVE 
#PROVIDE NODE NAME (HEADING FOR EACH NODE)
#ATTACH THE SOURCE & SINK AGENTS TO APPROPRIATE NODE & CONNECT BOTH
#AGENTS - UDP  & UDP NULL
#ATTACH CBR TRAFFIC PROVIDER APPLICATION TO THE SOURCE NODE
#RUN SIMULATION


# Define options
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)     20   ;# number of mobilenodes
set val(rp)     AODV ;# routing protocol
set val(x)      1000 ;# X dimension of topography
set val(y)      1000 ;# Y dimension of topography
set val(stop)   50  ;# time of simulation end

set ns [new Simulator]

set tracefd [open thesis4.tr w]
set namtrace [open thesis4.nam w]

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


# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)


#configure the nodes
set chan1 [new $val(chan)]
$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) \
-channel $chan1 \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON

for {set i 0} {$i < $val(nn) } { incr i } {
set n($i) [$ns node]
#$ns at 0.1 "$n($i) color blue"
}


# Provide initial location of mobilenodes

$n(0) set X_ 105.0
$n(0) set Y_ 206.0
$n(0) set Z_ 0.0

$n(1) set X_ 805.0
$n(1) set Y_ 742.0
$n(1) set Z_ 0.0

$n(2) set X_ 515.0
$n(2) set Y_ 606.0
$n(2) set Z_ 0.0

$n(3) set X_ 405.0
$n(3) set Y_ 342.0
$n(3) set Z_ 0.0

$n(4) set X_ 675.0
$n(4) set Y_ 156.0
$n(4) set Z_ 0.0

$n(5) set X_ 905.0
$n(5) set Y_ 549.0
$n(5) set Z_ 0.0

$n(6) set X_ 675.0
$n(6) set Y_ 336.0
$n(6) set Z_ 0.0

$n(7) set X_ 555.0
$n(7) set Y_ 762.0
$n(7) set Z_ 0.0

$n(8) set X_ 258.0
$n(8) set Y_ 646.0
$n(8) set Z_ 0.0

$n(9) set X_ 645.0
$n(9) set Y_ 522.0
$n(9) set Z_ 0.0

$n(10) set X_ 265.0
$n(10) set Y_ 376.0
$n(10) set Z_ 0.0

$n(11) set X_ 495.0
$n(11) set Y_ 502.0
$n(11) set Z_ 0.0

$n(12) set X_ 75.0
$n(12) set Y_ 426.0
$n(12) set Z_ 0.0

$n(13) set X_ 145.0
$n(13) set Y_ 119.0
$n(13) set Z_ 0.0

$n(14) set X_ 85.0
$n(14) set Y_ 702.0
$n(14) set Z_ 0.0

$n(15) set X_ 340.0
$n(15) set Y_ 36.0
$n(15) set Z_ 0.0

$n(16) set X_ 758.0
$n(16) set Y_ 602.0
$n(16) set Z_ 0.0

$n(17) set X_ 435.0
$n(17) set Y_ 186.0
$n(17) set Z_ 0.0

$n(18) set X_ 5.0
$n(18) set Y_ 2.0
$n(18) set Z_ 0.0

$n(19) set X_ 515.0
$n(19) set Y_ 366.0
$n(19) set Z_ 0.0


# Set a TCP connection between n(1) and n(13)
set udp [new Agent/UDP]    ;#use UDP to connect to sender node1
#$tcp set class_ 2
set null [new Agent/Null]  ;#use NULL to attach to reciever node2
$ns attach-agent $n(1) $udp
$ns attach-agent $n(13) $null
$ns connect $udp $null     ;#connect UDP AND NULL

set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 200kb
$cbr1 set interval_ 0.02
$cbr1 attach-agent $udp   ;#cbr object attached to udp


$ns at 2.0 "$cbr1 start"



#defining heads
$ns at 0.0 "$n(0) label CH"
$ns at 0.0 "$n(1) label Source"
$ns at 0.0 "$n(13) label Destination"
$ns at 0.0 "$n(2) label N2"



#new location after move
$ns at 0.0 "$n(0) setdest 130.0 208.0 5.0"
$ns at 0.0 "$n(1) setdest 485.0 128.0 5.0"
$ns at 1.0 "$n(2) setdest 615.0 340.0 5.0"
$ns at 1.0 "$n(3) setdest 680.0 458.0 5.0"
$ns at 3.0 "$n(4) setdest 580.0 368.0 5.0"
$ns at 3.0 "$n(5) setdest 785.0 228.0 5.0"
$ns at 2.0 "$n(6) setdest 750.0 638.0 5.0"
$ns at 1.0 "$n(7) setdest 185.0 120.0 5.0"
$ns at 0.0 "$n(8) setdest 335.0 700.0 5.0"
$ns at 2.0 "$n(9) setdest 425.0 590.0 5.0"
$ns at 2.0 "$n(10) setdest 105.0 620.0 5.0"
$ns at 0.0 "$n(11) setdest 565.0 420.0 5.0"
$ns at 1.0 "$n(12) setdest 700.0 20.0 5.0"
$ns at 1.0 "$n(13) setdest 115.0 85.0 5.0"
$ns at 1.0 "$n(14) setdest 195.0 185.0 5.0"
$ns at 1.0 "$n(15) setdest 387.0 590.0 5.0"
$ns at 2.0 "$n(16) setdest 165.0 620.0 5.0"
$ns at 0.0 "$n(17) setdest 765.0 320.0 5.0"
$ns at 1.0 "$n(18) setdest 109.0 20.0 5.0"
$ns at 1.0 "$n(19) setdest 175.0 185.0 5.0"


# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
#80 defines the node size for nam
$ns initial_node_pos $n($i) 80
}




# ending nam and the simulation
$ns at 40 "$cbr1 stop"
#$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 50.01 "puts \"end simulation\" ; #$ns halt"



proc stop {} {
global ns tracefd namtrace 
$ns flush-trace
close $tracefd
close $namtrace

                           
exec nam thesis4.nam &
puts "nam" 


#exec Xgraph thesis4.tr &
exit 0
}


$ns run

used command to run : ns thesis4.tcl
o/p got .nam & .tr files
1.now i want to find the throughput ,packet delivery ratio, control overhead and end to end delay


sample code to find throughput:
Code:
BEGIN {
        recvdSize = 0
        startTime = 400
        stopTime = 0
   }
    
   {
              event = $1
              time = $2
              node_id = $3
              pkt_size = $8
              level = $4
    
   # Store start time
   if (level == "AGT" && event == "s" && pkt_size >= 512) {
     if (time < startTime) {
              startTime = time
              }
        }
    
   # Update total received packets' size and store packets arrival time
   if (level == "AGT" && event == "r" && pkt_size >= 512) {
        if (time > stopTime) {
              stopTime = time
              }
        # Rip off the header
        hdr_size = pkt_size % 512
        pkt_size -= hdr_size
        # Store received packet's size
        recvdSize += pkt_size
        }
   }
    
   END {
        printf("Average Throughput[kbps] = %.2f\t\t StartTime=%.2f\tStopTime=%.2f\n",(recvdSize/(stopTime-startTime))*(8/1000),startTime,stopTime)
   }

commmand used 0t runto run:

awk -f filename.awk
filename .tr
 
Old 03-22-2017, 01:30 PM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2017 CentOS6.9 CentOS7.4 + 50+ other Linux OS, for test only.
Posts: 17,028

Rep: Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444Reputation: 3444
Awk scripts for analyzing throughput, packet delivery ratio, end to end delay :

Included in the ns2 scripts collection, awk#perl#python__scripts-1-2017.tar.gz
https://drive.google.com/file/d/0B7S...ew?usp=sharing

"control overhead" : If you don't find a script, I guess you will have to write the code yourself.

About the scripts awk#perl#python__scripts-1-2017 :
Only one or two of the multiple scripts in each category may work with your specific trace file.
Please try out them all :
Code:
$ awk -f filename.awk trace.tr
-

Last edited by knudfl; 03-23-2017 at 10:27 AM.
 
  


Reply


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
awk file for mannasim generated leach.tcl amita_s12 Linux - Software 3 06-08-2015 12:38 PM
fail to ns lte.tcl,I can't find the out.nam file ladyelaine Ubuntu 4 04-09-2015 11:55 PM
running nam file in ns2 it gives warning as trace file events are not sorted by time s20 Linux - Software 0 07-19-2013 09:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:17 PM.

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