AWK help for traces in NS2


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK help for traces in NS2
# 1  
Old 11-03-2008
AWK help for traces in NS2

Hello Everyone,

I'm a very new user to both NS-2 and awk and struggling quite a bit. I have a created a wireless trace in NS2 which is of the format as given below:

s 0.029290548 _1_ RTR --- 0 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
s 1.119926192 _0_ RTR --- 1 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
M 10.00000 0 (5.00, 2.00, 0.00), (20.00, 18.00), 1.00
s 10.000000000 _0_ AGT --- 2 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
r 10.000000000 _0_ RTR --- 2 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
s 12.941172739 _1_ RTR --- 3 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
s 13.242656084 _0_ RTR --- 4 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
s 16.000000000 _0_ AGT --- 5 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
r 16.000000000 _0_ RTR --- 5 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
s 24.799296167 _1_ RTR --- 6 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
s 27.719583723 _0_ RTR --- 7 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
s 28.000000000 _0_ AGT --- 8 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
r 28.000000000 _0_ RTR --- 8 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
s 39.083332528 _1_ RTR --- 9 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
s 40.918940913 _0_ RTR --- 10 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
M 50.00000 1 (390.00, 385.00, 0.00), (25.00, 20.00), 15.00
s 52.000000000 _0_ AGT --- 11 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
r 52.000000000 _0_ RTR --- 11 tcp 40 [0 0 0 0] ------- [0:0 1:0 32 0] [0 0] 0 0
s 53.478111556 _1_ RTR --- 12 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
s 54.709362820 _0_ RTR --- 13 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
s 65.134134662 _1_ RTR --- 14 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
s 69.500212994 _0_ RTR --- 15 message 32 [0 0 0 0] ------- [0:255 -1:255 32 0]
r 69.501265756 _1_ RTR --- 15 message 32 [0 ffffffff 0 800] ------- [0:255 -1:255 32 0]
s 76.429530123 _1_ RTR --- 16 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
r 76.430622539 _0_ RTR --- 16 message 32 [0 ffffffff 1 800] ------- [1:255 -1:255 32 0]
s 76.430622539 _0_ RTR --- 2 tcp 80 [0 0 0 0] ------- [0:0 1:0 32 1] [0 0] 0 0
s 76.430622539 _0_ RTR --- 5 tcp 80 [0 0 0 0] ------- [0:0 1:0 32 1] [0 0] 0 0
D 76.430622539 _0_ IFQ ARP 2 tcp 80 [0 0 0 800] ------- [0:0 1:0 32 1] [0 0] 0 0
s 76.430622539 _0_ RTR --- 8 tcp 80 [0 0 0 0] ------- [0:0 1:0 32 1] [0 0] 0 0
D 76.430622539 _0_ IFQ ARP 5 tcp 80 [0 0 0 800] ------- [0:0 1:0 32 1] [0 0] 0 0
s 76.430622539 _0_ RTR --- 11 tcp 80 [0 0 0 0] ------- [0:0 1:0 32 1] [0 0] 0 0
D 76.430622539 _0_ RTR CBK 8 tcp 80 [0 0 0 800] ------- [0:0 1:0 32 1] [0 0] 0 0
D 76.430622539 _0_ RTR CBK 11 tcp 80 [0 0 0 800] ------- [0:0 1:0 32 1] [0 0] 0 0
s 81.503053035 _1_ RTR --- 17 message 32 [0 0 0 0] ------- [1:255 -1:255 32 0]
r 81.503945197 _0_ RTR --- 17 message 32 [0 ffffffff 1 800] ------- [1:255 -1:255 32 0]
s 83.261238775 _0_ RTR --- 18 message 44 [0 0 0 0] ------- [0:255 -1:255 32 0]
r 83.262226850 _1_ RTR --- 18 message 44 [0 ffffffff 0 800] ------- [0:255 -1:255 32 0]



I'm using an awk file in order to read the traces but I'm getting an error like "FATALSmilieivide by zero attempted"

I typed it in as "awk -f delay.awk simple.tr" ( I dunno if tht is right)

delay.awk
----------
Code:
BEGIN {highest_packet_id = 0;}
{
 action = $1;
 time = $2;
 node =$3;
 tracename = $4;
 type = $7;
 packet_id =$6;
 if (packet_id > highest_packet_id)
   highest_packet_id = packet_id;
 if (action == "s"){
 if (type == "cbr" && tracename == "AGT"){
    send_time[packet_id] = time;}
#else {send_time[packet_id] = 0;}
}
else if (action == "r"){
    if (type == "cbr" && tracename =="AGT"){
       rcv_time[packet_id] = time;
   }
#else{rcv_time[packet_id] = 0;}
 }
}
 END {packet_no = 0; total_delay = 0;
       for (packet_id = 0; packet_id <=highest_packet_id; packet_id++){
            if ((send_time[packet_id]!=0) && (rcv_time[packet_id]!=0)){
                start = send_time[packet_id];
                end = rcv_time[packet_id];
               packet_duration = end-start;}
else
      packet_duration = -1;
if (packet_duration > 0)
{packet_no++;
  total_delay = total_delay + packet_duration; }
}
   printf("%d %f %f\n", packet_no, total_delay, total_delay/packet_no);
}


Again I'm not sure if this is the right file to use, as it was mailed to me saying that I use this for delay. Should I make changes here ?? Should I use some other awk file ??? Should I make any other changes ??? Any help would be most welcome. Thank you so much for your time and help !!

Smilie

Last edited by jim mcnamara; 11-03-2008 at 02:13 PM.. Reason: add code tags
# 2  
Old 11-03-2008
In just trying to edit code tags, you seem to have several syntax errors. But the code is very hard to read. So who knows....

If you carefully describe what you are trying to do, then one of us can probably write simpler code that is readable to get you going. As it is I can't spend the time "decoding" your code.
# 3  
Old 11-03-2008
Thank you so much for the reply Jim. I'm just trying to obtain the delay and overhead for the trace file here. Unfortunately I have no knowledge of how to work with awk, and how to parse the lines in the trace file. I used this awk file, as someone suggested it to me but its not of much help currently. If there's anything that can work better that would be fantastic. Once again, thank you so much for your time and help.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

regarding adding fields to DSR protocol in ns2.34

hi i am student doing project in ns2.34. i hav to add field in route cache and packet of DSR routing protocol. which files hv to be changed...pl help me (1 Reply)
Discussion started by: khubalkar
1 Replies

2. IP Networking

Issue with Ns2.29

Hello, I am a beginner in Ns2 . I'am trying to run the example attached bu I have this errors : Simulation is running ... please wait ... can't read "Node_(7)": no such element in array while executing "return $Node_($id)" (procedure "_o3" line 3) (Simulator get-node-by-id... (0 Replies)
Discussion started by: Yotta15
0 Replies

3. IP Networking

Issue with ns2 - no throughput data

Hello, First time poster here hoping to get some help with ns2. I've recently started using ns2(first time user) but I'm having difficulty getting the results I'm after. I am trying to set up a network with wireless nodes(5-15 nodes) and then use xgraph to display a timing diagram,... (0 Replies)
Discussion started by: UnicksMan
0 Replies

4. IP Networking

OLSR simulation in ns2

# Create the simulator object that we need in order to run NS set ns # Set the parameters that we will use for wireless communications set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set... (0 Replies)
Discussion started by: amithkhandakar
0 Replies

5. UNIX for Advanced & Expert Users

Need help for getting hard-disk traces

When we write a programme,we declare variables and compiler allocates memory to them.I want to get access to the physical block number of hard-disk where actually the data is stored by the programme " Some one help me out... (3 Replies)
Discussion started by: nagraz007
3 Replies

6. Red Hat

Need help for getting hard-disk traces

When we write a programme,we declare variables and compiler allocates memory to them.I want to get access to the physical block number of hard-disk where actually the data is stored by the programme " Some one help me out... (1 Reply)
Discussion started by: nagraz007
1 Replies

7. Shell Programming and Scripting

TCL in NS2

Hi all, I wrote a TCL script in NS2 which involves running multiple Voice and video sessions. Am not able to troubleshoot one error at all. Can anyone please help me please. I am ready to send the documents if possible. please please help me guys !! I am trying to solve the problem since... (0 Replies)
Discussion started by: mehera
0 Replies

8. IP Networking

Installing NS2 On Ubuntu Machine

I have to work with NS2 (Network Simulator)and i have to install it beforeusing it on Manets Simulations. Can some one Help me on this topic? Thank's (1 Reply)
Discussion started by: hakim19
1 Replies

9. Shell Programming and Scripting

tracing ethereal traces

Hi All........ i need a perl script that can trace the traces of the ethereal tool. PLZ help me out...............!!!!!!!!! (1 Reply)
Discussion started by: trupti_rinku
1 Replies
Login or Register to Ask a Question